/* =========================================================================
   AlcashX Admin Console — design system
   Palette: slate neutrals + indigo primary. System fonts only (CSP: self).
   ========================================================================= */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cdd5df;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;

  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;

  --green: #059669;  --green-50: #ecfdf5;
  --amber: #b45309;  --amber-50: #fffbeb;
  --red: #dc2626;    --red-50: #fef2f2;  --red-600: #b91c1c;
  --sky: #0284c7;    --sky-50: #f0f9ff;
  --violet: #7c3aed; --violet-50: #f5f3ff;

  --side-bg: #0f172a;
  --side-text: #cbd5e1;
  --side-muted: #64748b;
  --side-hover: #1e293b;
  --side-active: #312e81;

  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 20px 45px -12px rgba(15, 23, 42, .28);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sidebar-w: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--primary); }
.hidden { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.ta-r { text-align: right; }
.grow { flex: 1; }

.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 14px; height: 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: none; font-weight: 600; font-size: 13.5px;
  white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:focus-visible, .icon-btn:focus-visible, .nav-item:focus-visible, .seg:focus-visible, .stat-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--primary-600); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--red-600); }
.btn-danger-ghost { background: var(--surface); border-color: #f5c2c2; color: var(--red); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--red-50); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12.5px; }
.btn-sm .ico { width: 15px; height: 15px; }
.btn-lg { height: 44px; font-size: 14.5px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm); border: 0; background: none; color: inherit;
}
.icon-btn:hover { background: rgba(100, 116, 139, .12); }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 600; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }

.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.hint { font-weight: 500; color: var(--muted-2); margin-left: 4px; }
.field input, .field textarea, .select {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); transition: border-color .15s, box-shadow .15s; outline: none;
}
.field textarea { height: auto; padding: 10px 12px; resize: vertical; }
.field input:focus, .field textarea:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.field input[readonly] { background: var(--surface-2); color: var(--text-2); }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.input-group { display: flex; align-items: stretch; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; flex: 1; min-width: 0; }
.input-addon {
  display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border: 1px solid var(--border-strong); border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--surface-2); font-size: 12.5px; font-weight: 600; color: var(--text-2); white-space: nowrap;
}
.input-addon:hover { background: #eef2f7; }
.otp-input { font-family: var(--mono); font-size: 20px !important; letter-spacing: .35em; text-align: center; height: 48px !important; }
.otp-inline { max-width: 220px; font-size: 16px !important; height: 40px !important; }
.check-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.check-row input { width: 16px; height: 16px; accent-color: var(--primary); }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; }
.alert-error { background: var(--red-50); color: var(--red-600); border: 1px solid #fecaca; }
.alert-warn { background: var(--amber-50); color: #92400e; border: 1px solid #fde68a; }
.alert .ico { margin-top: 1px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.no-dot::before { display: none; }
.badge-green { background: var(--green-50); color: var(--green); border-color: #a7f3d0; }
.badge-amber { background: var(--amber-50); color: var(--amber); border-color: #fde68a; }
.badge-red { background: var(--red-50); color: var(--red); border-color: #fecaca; }
.badge-indigo { background: var(--primary-50); color: var(--primary); border-color: var(--primary-100); }
.badge-sky { background: var(--sky-50); color: var(--sky); border-color: #bae6fd; }
.badge-violet { background: var(--violet-50); color: var(--violet); border-color: #ddd6fe; }
.badge-gray { background: var(--surface-2); color: var(--muted); }

/* =========================================================================
   Login
   ========================================================================= */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 44%) 1fr; }
.auth-aside {
  background: radial-gradient(1200px 600px at -10% -20%, #4338ca 0%, transparent 55%), linear-gradient(160deg, #0f172a 0%, #1e1b4b 100%);
  color: #e2e8f0; display: flex; align-items: center; padding: 56px;
}
.auth-aside-inner { max-width: 440px; }
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 48px; }
.brand-mark { width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(135deg, #6366f1, #4338ca); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; letter-spacing: .02em; box-shadow: 0 6px 16px -6px rgba(79,70,229,.7); }
.brand-mark.sm { width: 34px; height: 34px; font-size: 12.5px; border-radius: 9px; }
.brand-name { font-weight: 700; font-size: 16px; color: #fff; }
.brand-sub { font-size: 12px; color: #94a3b8; }
.auth-hero { font-size: 30px; line-height: 1.25; font-weight: 700; color: #fff; margin-bottom: 28px; }
.auth-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.auth-points li { display: flex; align-items: center; gap: 12px; color: #cbd5e1; font-size: 14.5px; }
.auth-points .ico { color: #a5b4fc; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card-brand { display: none; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 28px; }
.auth-form { display: flex; flex-direction: column; gap: 18px; }
.auth-head h2 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.auth-head p { color: var(--muted); }
.auth-step-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; }
.auth-step-icon .ico { width: 22px; height: 22px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.auth-note { display: flex; gap: 7px; align-items: center; color: var(--muted); font-size: 12.5px; }
.auth-footer { margin-top: 36px; font-size: 12px; color: var(--muted-2); text-align: center; }
.qr-frame { align-self: center; padding: 10px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.qr-frame img { display: block; width: 200px; height: 200px; }

/* =========================================================================
   App shell
   ========================================================================= */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; z-index: 40; transition: transform .22s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 20px 18px 18px; }
.sidebar-close { display: none; margin-left: auto; color: var(--side-text); }
.nav { flex: 1; overflow-y: auto; padding: 4px 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); padding: 16px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; height: 38px; padding: 0 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--side-text); font-weight: 500; font-size: 13.5px; text-align: left;
}
.nav-item .ico { color: #94a3b8; }
.nav-item:hover { background: var(--side-hover); color: #fff; }
.nav-item.active { background: var(--side-active); color: #fff; }
.nav-item.active .ico { color: #a5b4fc; }
.nav-count { margin-left: auto; font-size: 11px; font-weight: 600; color: #a5b4fc; background: rgba(99,102,241,.18); padding: 1px 7px; border-radius: 999px; }
.nav-count:empty { display: none; }
.sidebar-footer { display: flex; align-items: center; gap: 10px; padding: 14px 14px 16px; border-top: 1px solid #1e293b; }
.sidebar-footer .icon-btn { color: var(--side-text); }
.sidebar-footer .icon-btn:hover { background: var(--side-hover); color: #fff; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #334155; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-name { color: #fff; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { color: var(--side-muted); font-size: 11.5px; text-transform: capitalize; }
.sidebar-backdrop { display: none; }

.main { margin-left: var(--sidebar-w); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 16px 28px; background: rgba(244, 246, 250, .88); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; }
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 20px; font-weight: 700; }
.topbar-title p { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; }
.content { padding: 24px 28px 48px; max-width: 1440px; }
.tab-pane { display: flex; flex-direction: column; gap: 20px; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; }
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.settings-grid > .card { padding-bottom: 18px; }
.settings-grid .form-stack, .settings-grid .kv, .settings-grid > .card > .btn { margin: 0 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.stat-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card {
  display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); text-align: left; min-width: 0;
}
button.stat-card { transition: border-color .15s, box-shadow .15s, transform .15s; }
button.stat-card:hover { border-color: var(--primary-100); box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; color: var(--text); }
.stat-value-sm { font-size: 15px; padding-top: 3px; }
.tone-indigo { background: var(--primary-50); color: var(--primary); }
.tone-green { background: var(--green-50); color: var(--green); }
.tone-sky { background: var(--sky-50); color: var(--sky); }
.tone-amber { background: var(--amber-50); color: var(--amber); }
.tone-red { background: var(--red-50); color: var(--red); }

.hero-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 24px; background: linear-gradient(120deg, #ffffff 0%, #eef2ff 100%); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.eyebrow { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--primary); }
.hero-version { font-size: 30px; font-weight: 800; margin: 2px 0; }

/* ---------- Toolbar / search ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; flex: 1 1 280px; max-width: 420px; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); }
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.search input { flex: 1; border: 0; outline: none; background: none; min-width: 0; color: var(--text); height: 100%; }
.toolbar-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-filters .select { width: auto; height: 38px; min-width: 140px; }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.seg { border: 0; background: none; height: 30px; padding: 0 12px; border-radius: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.seg.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 13.5px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfd; }
.table th.ta-r, .table td.ta-r { text-align: right; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--muted); }
.cell-clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-stack { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px; }
.text-warn { color: var(--amber); font-weight: 600; }
.btn-icon { width: 32px; padding: 0 !important; }
.grid-2 .cell-clip { max-width: 240px; }
.cell-wrap { white-space: pre-wrap; word-break: break-word; max-width: 520px; }
.nowrap { white-space: nowrap; }
.key-cell { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 3px 4px 3px 8px; max-width: 250px; }
.key-cell span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-btn { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 5px; background: none; color: var(--muted); }
.mini-btn:hover { background: var(--primary-50); color: var(--primary); }
.row-actions { display: inline-flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.row-actions .btn-sm { padding: 0 9px; }
.devices-bar { display: inline-flex; align-items: center; gap: 8px; }
.meter { width: 44px; height: 6px; border-radius: 99px; background: var(--border); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--primary); }
.meter.full > span { background: var(--amber); }

.empty { text-align: center; padding: 44px 20px !important; color: var(--muted); }
.empty-icon { width: 44px; height: 44px; border-radius: 12px; margin: 0 auto 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted-2); border: 1px solid var(--border); }
.empty-title { font-weight: 600; color: var(--text-2); margin-bottom: 2px; }
.empty .btn { margin-top: 12px; }
.skeleton { height: 12px; border-radius: 4px; background: linear-gradient(90deg, #eef1f5 25%, #f6f8fa 37%, #eef1f5 63%); background-size: 400% 100%; animation: shimmer 1.2s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12.5px; }
.pager-btns { display: flex; align-items: center; gap: 8px; }
.pager-num { min-width: 28px; text-align: center; font-weight: 600; }

/* ---------- Settings bits ---------- */
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px; border-top: 1px solid var(--border); }
.setting-title { font-weight: 600; }
.setting-desc { color: var(--muted); font-size: 12.5px; margin-top: 2px; max-width: 520px; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch-track { position: absolute; inset: 0; border-radius: 99px; background: var(--border-strong); transition: background .15s; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }
.current-ip { padding: 0 20px 12px; font-size: 12.5px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin-bottom: 16px !important; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-all; }

/* ---------- Modals ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(15, 23, 42, .5); backdrop-filter: blur(2px); animation: fade .15s ease; }
.modal-card { width: 100%; max-width: 560px; max-height: calc(100vh - 40px); overflow-y: auto; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-wide { max-width: 760px; }
.modal-narrow { max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding-top: 6px; flex-wrap: wrap; }
.confirm-body { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.confirm-body .field { width: 100%; text-align: left; }
#confirmMessage { white-space: pre-line; word-break: break-word; }
.confirm-body .modal-foot { width: 100%; justify-content: center; padding-top: 10px; }
.confirm-body .modal-foot .btn { flex: 1; }
.confirm-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--red-50); color: var(--red); }
.confirm-icon.info { background: var(--primary-50); color: var(--primary); }
.confirm-icon .ico { width: 24px; height: 24px; }
.device-summary { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.device-summary code { background: var(--surface-2); border: 1px solid var(--border); padding: 4px 8px; border-radius: 6px; word-break: break-all; }
.backup-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 16px 0; }
.backup-codes code { padding: 10px; text-align: center; font-size: 15px; letter-spacing: .08em; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.step { font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }
.step.done { color: var(--green); background: var(--green-50); border-color: #a7f3d0; }
.step.current { color: var(--primary); background: var(--primary-50); border-color: var(--primary-100); }
.dropzone { display: flex; align-items: center; gap: 12px; padding: 16px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; color: var(--muted); }
.dropzone:hover { border-color: var(--primary); color: var(--primary); }
.dropzone-name { font-weight: 600; color: var(--text-2); word-break: break-all; }
.upload-box { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); }
.upload-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; color: var(--text-2); }
.upload-meta .sha code { word-break: break-all; }
.upload-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.upload-status { font-size: 12.5px; }
.upload-status.err { color: var(--red); }
.progress { height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.current-line { font-size: 12.5px; color: var(--text-2); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 40px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: #0f172a; color: #f1f5f9; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: toastIn .2s ease; }
.toast .ico { margin-top: 1px; }
.toast-success .ico { color: #34d399; }
.toast-error .ico { color: #f87171; }
.toast-info .ico { color: #93c5fd; }
.toast-msg { flex: 1; word-break: break-word; }
.toast-close { border: 0; background: none; color: #94a3b8; padding: 0; line-height: 1; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all .2s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 1280px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .grid-2, .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-card-brand { display: flex; }

  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .app-shell.nav-open .sidebar { transform: none; }
  .app-shell.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(15,23,42,.45); }
  .sidebar-close { display: inline-flex; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 40px; }
}
@media (max-width: 720px) {
  body { font-size: 14px; }
  .hide-sm { display: none; }
  .topbar-title h1 { font-size: 17px; }
  .topbar-title p { display: none; }
  .topbar-actions .btn { padding: 0 11px; }
  .stat-grid, .stat-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-icon { width: 34px; height: 34px; border-radius: 9px; }
  .stat-value { font-size: 20px; }
  .field-row { grid-template-columns: 1fr; }
  .hero-card { flex-direction: column; align-items: flex-start; }
  .hero-card .btn { width: 100%; }
  .toolbar { padding: 12px; }
  .search { max-width: none; flex-basis: 100%; }
  .toolbar-filters { width: 100%; }
  .toolbar-filters .select { flex: 1; min-width: 0; }
  .segmented { width: 100%; }
  .seg { flex: 1; padding: 0 6px; }
  .card-head { padding: 16px 16px 12px; }
  .setting-row { padding: 14px 16px; }
  .settings-grid .form-stack, .settings-grid .kv, .settings-grid > .card > .btn { margin: 0 16px; }

  /* Tables collapse into stacked cards */
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table.responsive tbody tr:last-child { border-bottom: 0; }
  .table.responsive tbody tr:hover td { background: none; }
  .table.responsive td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  .table.responsive td::before { content: attr(data-label); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: left; flex: none; }
  .table.responsive td[data-label=""]::before, .table.responsive td.empty::before { display: none; }
  .table.responsive td.empty { display: block; text-align: center; }
  .table.responsive td.ta-r { justify-content: flex-end; padding-top: 10px; }
  .table.responsive .hide-mobile { display: none; }
  .table.responsive .cell-stack { align-items: flex-end; text-align: right; }
  .ellipsis { max-width: 58vw; }
  .table.responsive .row-actions { flex-wrap: wrap; justify-content: flex-end; }
  .cell-clip, .cell-wrap { max-width: 64vw; }
  .key-cell { max-width: 60vw; }

  .modal { padding: 0; align-items: flex-end; }
  .modal-card { max-height: 92vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-foot .btn { flex: 1; }
  .backup-codes { grid-template-columns: 1fr 1fr; }
  .toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}
