/* =========================================================================
   AlcashMeta Admin Console — clean professional theme
   Slate neutrals · blue primary · dark navy sidebar · responsive (desktop → 360px)
   No inline styles anywhere (strict CSP: style-src 'self').
   ========================================================================= */

:root {
  --bg: #F3F5F9;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #0F172A;
  --text-2: #334155;
  --text-muted: #64748B;
  --text-faint: #94A3B8;

  --nav-bg: #0F172A;
  --nav-bg-2: #1E293B;
  --nav-text: #CBD5E1;
  --nav-muted: #64748B;

  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-soft: #EFF6FF;
  --primary-border: #BFDBFE;

  --success: #15803D;
  --success-soft: #F0FDF4;
  --success-border: #BBF7D0;
  --warning: #B45309;
  --warning-soft: #FFFBEB;
  --warning-border: #FDE68A;
  --danger: #DC2626;
  --danger-dark: #B91C1C;
  --danger-soft: #FEF2F2;
  --danger-border: #FECACA;
  --violet: #6D28D9;
  --violet-soft: #F5F3FF;
  --violet-border: #DDD6FE;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.18);
  --sidebar-w: 248px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
code, .font-mono { font-family: var(--font-mono); font-size: 0.85em; }

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 14px; height: 14px; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.u-mb-md { margin-bottom: 14px; }
.u-mb-lg { margin-bottom: 20px; }
.u-mt-sm { margin-top: 10px; }
.u-fs-sm { font-size: 13px; }
.u-narrow { max-width: 440px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.clipboard-helper { position: fixed; top: -1000px; left: -1000px; opacity: 0; }
.visually-hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; line-height: 1.2;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:focus-visible, .nav-item:focus-visible, .btn-icon:focus-visible, .kpi-card:focus-visible, .link-btn:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ico { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-faint); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-dark); }
.btn-danger-outline { background: var(--surface); color: var(--danger); border-color: var(--danger-border); }
.btn-danger-outline:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-lg { padding: 11px 16px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: inherit; cursor: pointer;
}
.btn-icon:hover { background: rgba(148, 163, 184, .16); }
.link-btn { background: none; border: none; color: var(--primary); font-weight: 600; cursor: pointer; font-size: 13px; padding: 2px 0; }
.link-btn:hover { text-decoration: underline; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer;
}
.icon-btn .ico { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { background: var(--danger-soft); border-color: var(--danger-border); }
.icon-btn.success { color: var(--success); }
.icon-btn.success:hover { background: var(--success-soft); border-color: var(--success-border); }

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

/* ---------- Forms ---------- */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.form-group label .text-muted { font-weight: 400; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 14px; transition: border-color .15s, box-shadow .15s; min-width: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
input[readonly] { background: var(--surface-2); }
.mono-input { font-family: var(--font-mono); font-size: 13px; letter-spacing: .02em; }
.otp-input { font-family: var(--font-mono); font-size: 20px; letter-spacing: .3em; text-align: center; }
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; }
.field-help { font-size: 12px; color: var(--text-muted); line-height: 1.45; }
.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text-2); margin: 4px 0 6px; cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--primary); }
.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px; }
.alert-error { background: var(--danger-soft); border: 1px solid var(--danger-border); color: var(--danger-dark); }

/* Switch */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); cursor: pointer; }
.switch-row > span:first-child { display: flex; flex-direction: column; gap: 2px; }
.switch-row small { font-size: 12.5px; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .15s; pointer-events: none; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }
.current-ip { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--text-2); }
.current-ip .ico { color: var(--text-muted); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; line-height: 1.6;
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.badge-accent { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--primary-border); }
.badge-violet { background: var(--violet-soft); color: var(--violet); border-color: var(--violet-border); }
.badge-neutral { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }

/* ---------- Brand ---------- */
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #3B82F6, #1D4ED8); color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .35); flex: none;
}
.brand-mark.sm { width: 34px; height: 34px; font-size: 15px; border-radius: 9px; }
.brand-mark.xs { width: 26px; height: 26px; font-size: 12px; border-radius: 7px; box-shadow: none; }

/* =========================================================================
   LOGIN
   ========================================================================= */
.auth-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(37, 99, 235, .10), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(15, 23, 42, .08), transparent 60%),
    var(--bg);
}
.auth-shell {
  width: 100%; max-width: 940px; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-lg);
}
.auth-aside {
  background: linear-gradient(160deg, #0F172A 0%, #1E293B 60%, #1E3A8A 140%);
  color: #E2E8F0; padding: 40px 36px; display: flex; flex-direction: column; gap: 24px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand strong { display: block; font-size: 16px; color: #fff; }
.auth-brand span { font-size: 12.5px; color: #94A3B8; }
.auth-aside h1 { font-size: 26px; line-height: 1.25; color: #fff; font-weight: 700; letter-spacing: -.01em; }
.auth-points { list-style: none; display: flex; flex-direction: column; gap: 12px; font-size: 14px; color: #CBD5E1; }
.auth-points li { display: flex; align-items: center; gap: 10px; }
.auth-points .ico { color: #93C5FD; }
.auth-aside-foot { margin-top: auto; font-size: 12px; color: #64748B; }
.auth-card { padding: 40px 36px; display: flex; flex-direction: column; }
.auth-header { margin-bottom: 22px; }
.auth-header h2 { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.auth-header p { color: var(--text-muted); margin-top: 4px; font-size: 13.5px; }
.brand-mark-mobile { display: none; margin-bottom: 14px; }
.auth-form { display: flex; flex-direction: column; }
.auth-hint { font-size: 12px; color: var(--text-muted); margin-top: 12px; text-align: center; }
.step-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; margin-bottom: 12px; }
.step-icon .ico { width: 22px; height: 22px; }
.step-title { font-size: 17px; font-weight: 700; }
.step-desc { color: var(--text-muted); font-size: 13.5px; margin: 4px 0 16px; }
.step-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.qr-frame { display: flex; justify-content: center; padding: 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); margin-bottom: 14px; background: var(--surface-2); }
.qr-frame img { width: 180px; height: 180px; }
.auth-footer { margin-top: auto; padding-top: 22px; font-size: 12px; color: var(--text-faint); display: flex; align-items: center; gap: 6px; justify-content: center; }

/* =========================================================================
   DASHBOARD LAYOUT
   ========================================================================= */
.dashboard-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--nav-bg); color: var(--nav-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; }
.brand-text h1 { font-size: 15px; color: #fff; font-weight: 700; line-height: 1.2; }
.brand-text span { font-size: 11.5px; color: var(--nav-muted); }
.sidebar-close { display: none; margin-left: auto; color: var(--nav-text); }
.nav-menu { flex: 1; overflow-y: auto; padding: 6px 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--nav-muted); font-weight: 700; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px;
  background: transparent; border: none; color: var(--nav-text); cursor: pointer; font-size: 13.5px; font-weight: 500; text-align: left;
}
.nav-item .ico { color: #94A3B8; }
.nav-item:hover { background: var(--nav-bg-2); color: #fff; }
.nav-item.active { background: rgba(59, 130, 246, .18); color: #fff; }
.nav-item.active .ico { color: #93C5FD; }
.nav-count { margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--nav-bg-2); color: var(--nav-text); }
.nav-count:empty { display: none; }
.sidebar-footer { border-top: 1px solid rgba(148, 163, 184, .14); padding: 12px 14px; display: flex; align-items: center; gap: 8px; }
.user-info { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: #334155; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.user-details { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 13px; color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11px; color: var(--nav-muted); text-transform: uppercase; letter-spacing: .05em; }
.sidebar-footer .btn-icon { color: var(--nav-text); }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 35; }

.main-content { flex: 1; min-width: 0; padding: 24px 28px 40px; }
.mobile-bar { display: none; }
.top-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.page-subtitle { color: var(--text-muted); font-size: 13.5px; margin-top: 2px; }
.top-actions { display: flex; gap: 8px; }

/* ---------- Help Guides ---------- */
a.btn { text-decoration: none; }
.help-table td { vertical-align: middle; }
.help-video-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.help-video-cell > div { min-width: 0; }
.help-thumb { width: 96px; height: 54px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); flex: none; display: block; }
.help-thumb-lg { width: 160px; height: 90px; }
.help-thumb-ph { display: grid; place-items: center; color: var(--text-faint); }
.help-thumb-ph .ico { width: 22px; height: 22px; }
.help-url { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; color: var(--primary); font-size: 12.5px; text-decoration: none; }
.help-url:hover { text-decoration: underline; }
.help-order { display: inline-flex; gap: 4px; align-items: center; }
.help-order .icon-btn { width: 28px; height: 28px; }
.help-order .icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.help-preview { display: flex; align-items: center; gap: 14px; padding: 10px 12px; margin-bottom: 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
.help-preview-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
tr.help-disabled td { opacity: .6; }
tr.help-disabled td.cell-actions { opacity: 1; }
@media (max-width: 720px) {
  .help-thumb { width: 72px; height: 40px; }
  .help-url { max-width: 52vw; }
}

/* ---------- Cards / KPIs ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); min-width: 0; }
.card + .card { margin-top: 16px; }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head.padded { padding: 16px 20px; margin: 0; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .card + .card { margin-top: 0; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.settings-grid > .card + .card { margin-top: 0; }
.span-2 { grid-column: span 2; }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-card {
  display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); text-align: left; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
button.kpi-card:hover { border-color: var(--primary-border); box-shadow: var(--shadow-md); }
.kpi-card.is-static { cursor: default; }
.kpi-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.tone-blue { background: var(--primary-soft); color: var(--primary); }
.tone-green { background: var(--success-soft); color: var(--success); }
.tone-violet { background: var(--violet-soft); color: var(--violet); }
.tone-amber { background: var(--warning-soft); color: var(--warning); }
.tone-red { background: var(--danger-soft); color: var(--danger); }
.kpi-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.kpi-value-sm { font-size: 16px; }

/* ---------- Toolbar ---------- */
.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-box { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.search-box .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); width: 16px; height: 16px; }
.search-box input { padding-left: 34px; }
.filter-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.select-input { width: auto; min-width: 140px; }

/* ---------- Tables ---------- */
.table-responsive { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
  font-weight: 600; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 13.5px; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #FAFBFD; }
.card:not(.card-flush) .data-table th:first-child, .card:not(.card-flush) .data-table td:first-child { padding-left: 4px; }
.cell-sub { display: block; font-size: 12px; color: var(--text-muted); }
.cell-wrap { white-space: pre-wrap; word-break: break-word; max-width: 460px; }
.cell-trunc { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack-trace { white-space: pre-wrap; word-break: break-word; font-size: 11.5px; background: var(--surface-2); padding: 8px; border-radius: var(--radius-sm); margin-top: 6px; }
details > summary { cursor: pointer; color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.key-pill { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 6px 4px 9px; max-width: 100%; }
.key-pill > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-pill-block { display: flex; padding: 9px 12px; font-family: var(--font-sans); font-size: 14px; }
.copy-icon-btn { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 5px; border: none; background: transparent; color: var(--text-muted); cursor: pointer; flex: none; }
.copy-icon-btn:hover { background: var(--border); color: var(--text); }
.copy-icon-btn .ico { width: 14px; height: 14px; }
.row-actions { display: inline-flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.ts, .device-meter, .nowrap { white-space: nowrap; }
.data-table th.text-right, .data-table td.text-right { text-align: right; }
.licenses-table .key-pill { max-width: 210px; }
.licenses-table td, .licenses-table th { padding-left: 12px; padding-right: 12px; }
.licenses-table .row-actions { gap: 4px; }
.licenses-table .cell-sub { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-meter { display: inline-flex; align-items: center; gap: 8px; }
.meter { width: 46px; height: 6px; border-radius: 99px; background: var(--border); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.meter.full > i { background: var(--warning); }
.meter-0 > i { width: 0; } .meter-10 > i { width: 10%; } .meter-20 > i { width: 20%; } .meter-25 > i { width: 25%; }
.meter-30 > i { width: 30%; } .meter-33 > i { width: 33%; } .meter-40 > i { width: 40%; } .meter-50 > i { width: 50%; }
.meter-60 > i { width: 60%; } .meter-67 > i { width: 67%; } .meter-70 > i { width: 70%; } .meter-75 > i { width: 75%; }
.meter-80 > i { width: 80%; } .meter-90 > i { width: 90%; } .meter-100 > i { width: 100%; }

.table-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; flex-wrap: wrap; }
.pagination-buttons { display: flex; align-items: center; gap: 8px; }
.page-number { min-width: 28px; text-align: center; font-weight: 600; }

/* Empty states */
.empty-state { text-align: center; padding: 38px 16px !important; color: var(--text-muted); }
.empty-state .ico { width: 34px; height: 34px; color: var(--text-faint); margin-bottom: 8px; }
.empty-state strong { display: block; color: var(--text-2); font-size: 14px; margin-bottom: 2px; }
.empty-state .btn { margin-top: 12px; }
.data-table tbody tr.empty-row:hover td { background: transparent; }

/* ---------- Releases ---------- */
.release-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.release-version { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0; }
.current-release-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 14px; font-size: 13px; }
.file-picker { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; background: var(--surface-2); position: relative; }
.file-picker-name { font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-info { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.upload-meta { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.sha-row code { word-break: break-all; }
.progress-track { height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.upload-status { font-size: 12.5px; }

/* ---------- Modals ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 24px; z-index: 100; overflow-y: auto; }
.modal-overlay.modal-top { z-index: 120; }
.modal-card { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 560px; padding: 20px 22px; box-shadow: var(--shadow-lg); animation: pop .16s ease-out; }
.modal-wide { max-width: 760px; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); width: 32px; height: 32px; border-radius: var(--radius-sm); display: grid; place-items: center; }
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.danger-zone { margin-top: 18px; padding: 14px; border: 1px solid var(--danger-border); background: var(--danger-soft); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.danger-zone strong { color: var(--danger-dark); font-size: 13.5px; }
.device-summary { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.mono-inline { font-family: var(--font-mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); padding: 4px 8px; border-radius: var(--radius-sm); word-break: break-all; }
.backup-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.backup-codes code { padding: 8px; text-align: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; letter-spacing: .05em; }
.confirm-body { display: flex; gap: 14px; }
.confirm-body h3 { font-size: 16px; margin-bottom: 4px; }
.confirm-body p { white-space: pre-line; font-size: 13.5px; }
.confirm-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--danger-soft); color: var(--danger); }
.confirm-icon.info { background: var(--primary-soft); color: var(--primary); }

/* ---------- Toasts ---------- */
.toast-container { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(380px, calc(100vw - 36px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: var(--radius-md); background: #0F172A; color: #F1F5F9; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: pop .18s ease-out; border-left: 4px solid #64748B; }
.toast-success { border-left-color: #22C55E; }
.toast-error { border-left-color: #EF4444; }
.toast-info { border-left-color: #3B82F6; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .grid-2, .settings-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; max-width: 460px; }
  .auth-aside { display: none; }
  .brand-mark-mobile { display: grid; }

  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar-close { display: inline-flex; }
  .main-content { padding: 0 16px 32px; }
  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    position: sticky; top: 0; z-index: 30; margin: 0 -16px 16px; padding: 10px 12px;
    background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
  }
  .mobile-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
  .hide-sm { display: none; }
}
@media (max-width: 720px) {
  body { font-size: 14px; }
  .auth-card { padding: 28px 22px; }
  .top-bar { align-items: center; }
  .page-title { font-size: 19px; }
  .page-subtitle { font-size: 12.5px; }
  .kpi-grid, .kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-card { padding: 12px; gap: 10px; }
  .kpi-icon { width: 34px; height: 34px; }
  .kpi-value { font-size: 20px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .search-box { max-width: none; min-width: 0; flex-basis: 100%; }
  .filter-group { width: 100%; }
  .filter-group .select-input { flex: 1; min-width: 0; }
  .card { padding: 16px; }
  .card-flush { padding: 0; }
  .modal-card { padding: 18px 16px; }
  .modal-overlay { padding: 12px 10px; }
  .toast-container { left: 12px; right: 12px; bottom: 12px; max-width: none; }

  /* Tables become stacked cards */
  .data-table.stack-sm thead { display: none; }
  .data-table.stack-sm, .data-table.stack-sm tbody, .data-table.stack-sm tr, .data-table.stack-sm td { display: block; width: 100%; }
  .data-table.stack-sm tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .data-table.stack-sm tbody tr:last-child { border-bottom: none; }
  .data-table.stack-sm td { border: none; padding: 3px 0 !important; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  .data-table.stack-sm td::before { content: attr(data-label); font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; text-align: left; flex: none; }
  .data-table.stack-sm td[data-label=""]::before, .data-table.stack-sm td:not([data-label])::before { content: none; }
  .data-table.stack-sm td.cell-primary { display: block; text-align: left; padding-bottom: 6px !important; }
  .data-table.stack-sm td.cell-primary::before { content: none; }
  .data-table.stack-sm td.cell-actions { justify-content: flex-start; padding-top: 8px !important; }
  .data-table.stack-sm td.cell-actions .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  .licenses-table .key-pill { max-width: 100%; }
  .licenses-table .cell-sub { max-width: 60vw; }
  .kpi-grid > .kpi-card:first-child { grid-column: span 2; }
  .data-table.stack-sm td.empty-state { display: block; text-align: center; }
  .data-table.stack-sm .cell-wrap, .data-table.stack-sm .cell-trunc { max-width: 62vw; text-align: right; }
  .data-table tbody tr:hover td { background: transparent; }
  .backup-codes { grid-template-columns: 1fr; }
}

/* Help Guides: video source toggle + server upload */
.seg-toggle { display: inline-flex; gap: 4px; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
.seg-btn { border: 0; background: transparent; padding: 6px 12px; border-radius: var(--radius-sm); font: inherit; font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.seg-btn.active { background: var(--surface, #fff); color: var(--primary-dark, var(--primary)); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg-btn:disabled { opacity: .5; cursor: not-allowed; }
#helpUploadTrack { margin: 2px 0 6px; }
.help-upload-status { margin: 0 0 10px; }
.help-upload-status.is-error { color: var(--danger); }
.help-upload-preview { width: 100%; max-height: 220px; border-radius: var(--radius-md); background: #000; margin-bottom: 12px; }
.input-with-btn { display: flex; gap: 8px; align-items: center; }
.input-with-btn input[type=text] { flex: 1; min-width: 0; }
.help-thumb-upload { position: relative; overflow: hidden; white-space: nowrap; cursor: pointer; }
.visually-hidden-file { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

/* Posts & Pages Activity Data */
.act-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.act-subtabs { display: flex; gap: 8px; }
.act-filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--border, #e2e8f0); background: var(--bg-subtle, rgba(148, 163, 184, 0.06)); }
.act-date-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.act-preset.active { background: var(--primary, #2563eb); color: #fff; border-color: var(--primary, #2563eb); }
.act-filter-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.act-input, .act-select { height: 32px; padding: 0 10px; border: 1px solid var(--border, #cbd5e1); border-radius: 6px; background: var(--surface, #fff); color: inherit; font-size: 13px; }
.act-search { min-width: 200px; }
.act-url-cell { display: flex; align-items: center; gap: 6px; max-width: 380px; }
.act-url-link { color: var(--primary, #2563eb); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; max-width: 320px; }
.act-url-link:hover { text-decoration: underline; }
.act-user-meta { font-size: 12px; opacity: 0.72; }
.btn-xs { padding: 4px 9px; font-size: 12px; line-height: 1.2; }
