/* ==========================================================================
   tt24pay — Admin Console
   Design tokens + shared components (login + dashboard)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Noto+Sans+Thai:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --font-ui: 'Inter', 'Noto Sans Thai', -apple-system, 'Segoe UI', sans-serif;

  /* Surfaces */
  --bg-app: #0b0912;
  --bg-sidebar: #120e1e;
  --bg-topbar: #140f22;
  --bg-surface: #171224;
  --bg-surface-2: #1c1630;
  --bg-elevated: #221a38;
  --bg-input: #1a1428;
  --bg-hover: rgba(139,92,246,0.09);
  --bg-active: rgba(139,92,246,0.17);
  --bg-scrim: rgba(8,6,14,0.65);

  /* Borders */
  --border-subtle: #241d38;
  --border-strong: #362a54;
  --border-focus: #a78bfa;

  /* Text */
  --text-primary: #f6f4fb;
  --text-secondary: #ada0c4;
  --text-muted: #786d94;
  --text-inverse: #17112a;

  /* Brand accent (purple) */
  --accent-400: #a78bfa;
  --accent-500: #8b5cf6;
  --accent-600: #7c3aed;
  --accent-700: #6d28d9;
  --accent-contrast: #ffffff;
  --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #6366f1 100%);

  /* Status — fixed scale, never themed */
  --status-good: #0ca30c;
  --status-good-bg: rgba(12,163,12,0.16);
  --status-warning: #fab219;
  --status-warning-bg: rgba(250,178,25,0.16);
  --status-serious: #ec835a;
  --status-serious-bg: rgba(236,131,90,0.16);
  --status-critical: #d03b3b;
  --status-critical-bg: rgba(208,59,59,0.16);

  /* Chart categorical (dark steps) */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #4caf4c;
  --series-7: #9085e9;
  --series-8: #e66767;

  --chart-surface: #171224;
  --chart-grid: rgba(255,255,255,0.07);
  --chart-axis: rgba(255,255,255,0.18);

  --shadow-card: 0 1px 2px rgba(0,0,0,0.35), 0 10px 28px -10px rgba(0,0,0,0.55);
  --shadow-elevated: 0 20px 55px -15px rgba(0,0,0,0.65);
  --shadow-focus: 0 0 0 3px rgba(167,139,250,0.35);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --ease: cubic-bezier(.4,0,.2,1);
}

[data-theme="light"] {
  color-scheme: light;
  --bg-app: #f6f4fb;
  --bg-sidebar: #ffffff;
  --bg-topbar: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-2: #f7f4fc;
  --bg-elevated: #ffffff;
  --bg-input: #f7f5fb;
  --bg-hover: rgba(124,58,237,0.06);
  --bg-active: rgba(124,58,237,0.11);
  --bg-scrim: rgba(40,30,60,0.35);

  --border-subtle: #eae4f5;
  --border-strong: #ddd2f2;
  --border-focus: #7c3aed;

  --text-primary: #1c1530;
  --text-secondary: #675d80;
  --text-muted: #978caf;
  --text-inverse: #ffffff;

  --status-good-bg: rgba(12,163,12,0.10);
  --status-warning-bg: rgba(250,178,25,0.18);
  --status-serious-bg: rgba(236,131,90,0.14);
  --status-critical-bg: rgba(208,59,59,0.10);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #1f8a1f;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  --chart-surface: #ffffff;
  --chart-grid: rgba(28,21,48,0.07);
  --chart-axis: rgba(28,21,48,0.16);

  --shadow-card: 0 1px 2px rgba(40,20,80,0.04), 0 10px 26px -12px rgba(70,30,120,0.14);
  --shadow-elevated: 0 24px 60px -18px rgba(60,20,110,0.22);
  --shadow-focus: 0 0 0 3px rgba(124,58,237,0.22);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s var(--ease), color .25s var(--ease);
}
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
::selection { background: var(--accent-500); color: #fff; }

.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 22px; height: 22px; }

/* Scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; border: 1px solid transparent;
  transition: all .15s var(--ease); white-space: nowrap; letter-spacing: .01em;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent-gradient); color: #fff; box-shadow: 0 6px 18px -6px rgba(124,58,237,.55); }
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 8px 22px -6px rgba(124,58,237,.7); }
.btn-secondary { background: var(--bg-surface-2); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--accent-400); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: rgba(208,59,59,.12); color: #f0a4a4; border-color: rgba(208,59,59,.35); }
.btn-danger:hover { background: rgba(208,59,59,.2); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 7px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); border: 1px solid transparent; }
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-subtle); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.field-hint { font-size: 11.5px; color: var(--text-muted); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .icon { position: absolute; left: 13px; color: var(--text-muted); pointer-events: none; }
.input, select.input, textarea.input {
  width: 100%; height: 44px; border-radius: var(--radius-sm); border: 1.5px solid var(--border-strong);
  background: var(--bg-input); color: var(--text-primary); padding: 0 14px; font-size: 14px;
  outline: none; transition: border-color .15s, box-shadow .15s, background .2s;
}
.input-wrap .input { padding-left: 42px; }
textarea.input { height: auto; padding: 10px 14px; resize: vertical; min-height: 72px; }
.input::placeholder { color: var(--text-muted); }
.input:focus { border-color: var(--border-focus); box-shadow: var(--shadow-focus); }
.input.has-error { border-color: var(--status-critical); }
.input-toggle { position: absolute; right: 8px; background: transparent; border: none; color: var(--text-muted); width: 32px; height: 32px; border-radius: 7px; display: flex; align-items: center; justify-content: center; }
.input-toggle:hover { color: var(--text-primary); background: var(--bg-hover); }

.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text-secondary); cursor: pointer; user-select: none; }
.checkbox-row input[type="checkbox"] { appearance: none; width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border-strong); background: var(--bg-input); position: relative; cursor: pointer; flex-shrink: 0; }
.checkbox-row input[type="checkbox"]:checked { background: var(--accent-gradient); border-color: transparent; }
.checkbox-row input[type="checkbox"]:checked::after { content: ''; position: absolute; left: 5px; top: 1px; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* Switch */
.switch { position: relative; display: inline-block; width: 40px; height: 23px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .2s var(--ease); cursor: pointer; }
.switch .track::before { content: ''; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--accent-gradient); }
.switch input:checked + .track::before { transform: translateX(17px); }

/* ---------- Badges / Pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: var(--radius-pill); font-size: 11.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.pill .icon { width: 12px; height: 12px; stroke-width: 2.4; }
.pill-good { background: var(--status-good-bg); color: var(--status-good); }
.pill-warning { background: var(--status-warning-bg); color: #d99a12; }
[data-theme="dark-noop"] .pill-warning{ color: var(--status-warning); }
.pill-serious { background: var(--status-serious-bg); color: var(--status-serious); }
.pill-critical { background: var(--status-critical-bg); color: var(--status-critical); }
.pill-neutral { background: var(--bg-surface-2); color: var(--text-secondary); border: 1px solid var(--border-subtle); }
.pill-accent { background: var(--bg-active); color: var(--accent-400); }

.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 6px; font-size: 11px; font-weight: 600; background: var(--bg-surface-2); border: 1px solid var(--border-subtle); color: var(--text-secondary); }

/* ---------- Layout shell ---------- */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 264px; flex-shrink: 0; background: var(--bg-sidebar); border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; transition: width .2s var(--ease);
}
.app-shell.collapsed .sidebar { width: 78px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 20px 20px 16px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-gradient); display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 4px 14px -4px rgba(124,58,237,.6); }
.brand-mark span { font-size: 14px; font-weight: 800; color: #fff; letter-spacing: -.02em; }
.brand-text { overflow: hidden; white-space: nowrap; }
.brand-text .name { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.brand-text .sub { font-size: 10.5px; color: var(--text-muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.app-shell.collapsed .brand-text { display: none; }

.nav-scroll { flex: 1; overflow-y: auto; padding: 6px 14px; }
.nav-group { margin-bottom: 4px; }
.nav-group-label { font-size: 10.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; padding: 14px 10px 6px; }
.app-shell.collapsed .nav-group-label { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 11px; border-radius: 10px;
  color: var(--text-secondary); font-size: 13.5px; font-weight: 600; margin-bottom: 2px; position: relative;
  transition: background .15s, color .15s;
}
.nav-item .icon { color: var(--text-muted); transition: color .15s; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item:hover .icon { color: var(--accent-400); }
.nav-item.active { background: var(--bg-active); color: var(--text-primary); }
.nav-item.active .icon { color: var(--accent-400); }
.nav-item.active::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--accent-gradient); }
.nav-item span.label { overflow: hidden; white-space: nowrap; }
.app-shell.collapsed .nav-item span.label { display: none; }
.app-shell.collapsed .nav-item { justify-content: center; }
.nav-item .nav-badge { margin-left: auto; }
.app-shell.collapsed .nav-badge { display: none; }

.sidebar-foot { padding: 14px; border-top: 1px solid var(--border-subtle); }
.profile-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; cursor: pointer; }
.profile-card:hover { background: var(--bg-hover); }
.avatar { width: 34px; height: 34px; border-radius: 9px; background: var(--accent-gradient); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12.5px; font-weight: 800; flex-shrink: 0; }
.profile-meta { overflow: hidden; white-space: nowrap; flex: 1; }
.profile-meta .pname { font-size: 13px; font-weight: 700; }
.profile-meta .prole { font-size: 11px; color: var(--text-muted); }
.app-shell.collapsed .profile-meta { display: none; }

.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 66px; flex-shrink: 0; background: var(--bg-topbar); border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; gap: 16px;
}
.topbar-title h1 { font-size: 16.5px; font-weight: 800; letter-spacing: -.01em; }
.topbar-title p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.search-box { display: none; align-items: center; gap: 8px; width: 260px; height: 38px; padding: 0 12px; border-radius: 10px; background: var(--bg-surface-2); border: 1px solid var(--border-subtle); color: var(--text-muted); }
@media (min-width: 900px) { .search-box { display: flex; } }
.search-box input { background: transparent; border: none; outline: none; color: var(--text-primary); font-size: 13px; width: 100%; }
.search-box input::placeholder { color: var(--text-muted); }
.search-box kbd { font-size: 10.5px; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 5px; padding: 2px 5px; color: var(--text-muted); }

.icon-btn-badge { position: relative; }
.dot-badge { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--status-critical); border: 2px solid var(--bg-topbar); }

.theme-toggle { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px; border-radius: 10px; background: var(--bg-surface-2); border: 1px solid var(--border-subtle); }
.theme-toggle .icon { color: var(--text-muted); }

.topbar-divider { width: 1px; height: 26px; background: var(--border-subtle); margin: 0 2px; }

.content { flex: 1; overflow-y: auto; padding: 26px 28px 60px; }
.view { display: none; animation: fadeUp .28s var(--ease); }
.view.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.view-head h2 { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.view-head p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.view-actions { display: flex; gap: 10px; }

/* ---------- Cards / Grid ---------- */
.card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.card-pad { padding: 20px 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border-subtle); gap: 12px; flex-wrap: wrap; }
.card-head h3 { font-size: 14.5px; font-weight: 700; }
.card-head p { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
@media (max-width: 1180px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .stat-grid { grid-template-columns: 1fr; } }

.stat-tile { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.stat-tile-top { display: flex; align-items: center; justify-content: space-between; }
.stat-tile-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: var(--bg-active); color: var(--accent-400); }
.stat-tile .label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.stat-tile .value { font-size: 25px; font-weight: 800; letter-spacing: -.01em; }
.stat-delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; }
.stat-delta.up { color: var(--status-good); }
.stat-delta.down { color: var(--status-critical); }
.stat-delta .icon { width: 13px; height: 13px; stroke-width: 2.6; }
.stat-spark { margin-top: 2px; }

.chart-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 1050px) { .chart-grid { grid-template-columns: 1fr; } }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
@media (max-width: 980px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid-3 { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
.data-table thead th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding: 12px 22px; border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
.data-table tbody td { padding: 14px 22px; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table .primary-cell { color: var(--text-primary); font-weight: 600; }
.data-table .mono { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; font-size: 12px; letter-spacing: -.01em; }
.cell-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.toolbar { display: flex; align-items: center; gap: 10px; padding: 16px 22px; flex-wrap: wrap; border-bottom: 1px solid var(--border-subtle); }
.toolbar .input-wrap { flex: 1; min-width: 180px; }
.select-chip { height: 38px; padding: 0 12px; border-radius: 9px; background: var(--bg-surface-2); border: 1px solid var(--border-subtle); color: var(--text-secondary); font-size: 12.5px; font-weight: 600; outline: none; }

/* ---------- Chart primitives ---------- */
.chart-svg { width: 100%; height: auto; overflow: visible; }
.chart-tooltip { position: absolute; pointer-events: none; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 9px; padding: 8px 11px; font-size: 12px; box-shadow: var(--shadow-elevated); opacity: 0; transition: opacity .1s; z-index: 5; white-space: nowrap; }
.chart-tooltip .tt-date { color: var(--text-muted); font-size: 10.5px; margin-bottom: 3px; font-weight: 600; }
.chart-tooltip .tt-val { font-weight: 700; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 14px 22px 20px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-secondary); }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.legend-item b { color: var(--text-primary); font-weight: 700; }

.bar-track { height: 28px; border-radius: 8px; overflow: hidden; display: flex; background: var(--bg-surface-2); }
.bar-seg { height: 100%; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: var(--bg-scrim); backdrop-filter: blur(3px); display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-overlay.open { display: flex; animation: fadeIn .15s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { width: 100%; max-width: 560px; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-elevated); max-height: 88vh; display: flex; flex-direction: column; animation: modalIn .18s var(--ease); }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--border-subtle); }
.modal-head h3 { font-size: 15.5px; font-weight: 800; }
.modal-head p { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.modal-body { padding: 20px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border-subtle); }

.segmented { display: flex; background: var(--bg-surface-2); border: 1px solid var(--border-subtle); border-radius: 10px; padding: 3px; }
.segmented button { flex: 1; height: 34px; border: none; background: transparent; border-radius: 8px; font-size: 12.5px; font-weight: 700; color: var(--text-muted); transition: all .15s; }
.segmented button.active { background: var(--bg-elevated); color: var(--text-primary); box-shadow: var(--shadow-card); }

.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .check-grid { grid-template-columns: 1fr; } }

.key-reveal { display: flex; align-items: center; gap: 8px; background: var(--bg-input); border: 1.5px dashed var(--border-strong); border-radius: 10px; padding: 12px 14px; }
.key-reveal code { flex: 1; font-family: 'SFMono-Regular', Consolas, monospace; font-size: 12.5px; color: var(--accent-400); overflow-x: auto; white-space: nowrap; }
.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; font-size: 12.5px; line-height: 1.5; }
.notice-warning { background: var(--status-warning-bg); color: var(--text-primary); border: 1px solid rgba(250,178,25,.35); }
.notice-warning .icon { color: var(--status-warning); flex-shrink: 0; margin-top: 1px; }

/* ---------- Report cards ---------- */
.report-card { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.report-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--bg-active); color: var(--accent-400); display: flex; align-items: center; justify-content: center; }
.report-card h4 { font-size: 14px; font-weight: 700; }
.report-card p { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.report-meta { font-size: 11px; color: var(--text-muted); border-top: 1px solid var(--border-subtle); padding-top: 12px; display: flex; justify-content: space-between; }

/* ---------- Role cards ---------- */
.role-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.role-card .rc-top { display: flex; align-items: center; gap: 10px; }
.role-badge { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.role-card h4 { font-size: 13.5px; font-weight: 700; }
.role-card .rc-count { font-size: 11px; color: var(--text-muted); }
.role-card p { font-size: 12px; color: var(--text-secondary); line-height: 1.55; }

.matrix-wrap { overflow-x: auto; }
table.matrix { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 720px; }
.matrix th, .matrix td { padding: 11px 16px; border-bottom: 1px solid var(--border-subtle); text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; color: var(--text-secondary); font-weight: 600; }
.matrix thead th { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.matrix .yes { color: var(--status-good); }
.matrix .no { color: var(--text-muted); opacity: .4; }

/* ---------- Settings ---------- */
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--border-subtle); }
.settings-row:last-child { border-bottom: none; }
.settings-row .st-label { font-size: 13.5px; font-weight: 600; }
.settings-row .st-desc { font-size: 12px; color: var(--text-muted); margin-top: 3px; max-width: 460px; line-height: 1.5; }
.settings-row .st-control { flex-shrink: 0; }

.theme-option { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 12px; border: 1.5px solid var(--border-subtle); cursor: pointer; transition: border-color .15s; }
.theme-option:hover { border-color: var(--border-strong); }
.theme-option.selected { border-color: var(--accent-500); background: var(--bg-active); }
.theme-swatch { width: 46px; height: 34px; border-radius: 8px; flex-shrink: 0; border: 1px solid rgba(255,255,255,.1); }
.theme-option .to-name { font-size: 13px; font-weight: 700; }
.theme-option .to-desc { font-size: 11px; color: var(--text-muted); }

/* ---------- Toast ---------- */
.toast-stack { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 80; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--bg-elevated); border: 1px solid var(--border-strong); box-shadow: var(--shadow-elevated); border-radius: 11px; padding: 12px 16px; font-size: 13px; font-weight: 600; animation: toastIn .2s var(--ease); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast .icon { color: var(--status-good); }

/* ---------- Responsive sidebar ---------- */
@media (max-width: 980px) {
  .sidebar { position: fixed; z-index: 40; height: 100%; left: -280px; transition: left .22s var(--ease); }
  .app-shell.mobile-open .sidebar { left: 0; }
  .app-shell.collapsed .sidebar { width: 264px; }
  .content { padding: 20px 16px 50px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Login page ---------- */
.login-shell { min-height: 100vh; display: flex; background: #0b0912; }
.login-brand {
  flex: 1.05; position: relative; display: none; flex-direction: column; justify-content: space-between;
  padding: 48px; background: radial-gradient(circle at 20% 15%, #2c1a55 0%, #0d0a18 55%), linear-gradient(160deg,#120b22,#0a0712 70%);
  overflow: hidden;
}
@media (min-width: 940px) { .login-brand { display: flex; } }
.login-brand::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(167,139,250,.35) 1px, transparent 1px);
  background-size: 26px 26px; opacity: .25; mask-image: radial-gradient(circle at 30% 30%, black, transparent 70%);
}
.login-brand-inner { position: relative; z-index: 2; }
.login-brand .brand { padding: 0; margin-bottom: 56px; }
.login-headline { font-size: 30px; font-weight: 800; color: #fff; line-height: 1.35; letter-spacing: -.01em; max-width: 420px; }
.login-headline .accent-text { background: linear-gradient(90deg,#c4b5fd,#a78bfa); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-sub { font-size: 14px; color: #b6acd1; margin-top: 14px; max-width: 400px; line-height: 1.6; }
.feature-list { margin-top: 38px; display: flex; flex-direction: column; gap: 18px; }
.feature-item { display: flex; gap: 12px; align-items: flex-start; }
.feature-item .fi-icon { width: 32px; height: 32px; border-radius: 9px; background: rgba(167,139,250,.14); border: 1px solid rgba(167,139,250,.25); display: flex; align-items: center; justify-content: center; color: #c4b5fd; flex-shrink: 0; }
.feature-item .fi-text b { display: block; font-size: 13.5px; color: #f1edfb; font-weight: 700; margin-bottom: 2px; }
.feature-item .fi-text span { font-size: 12.5px; color: #9d92bd; line-height: 1.5; }
.login-brand-foot { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: #766c94; border-top: 1px solid rgba(255,255,255,.08); padding-top: 16px; }
.status-dot-live { display: inline-flex; align-items: center; gap: 6px; }
.status-dot-live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52,211,153,.18); }

.login-panel { flex: 1; display: flex; align-items: center; justify-content: center; background: #fbfaff; padding: 32px; }
.login-card { width: 100%; max-width: 380px; }
.login-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #8b5cf6; margin-bottom: 10px; }
.login-card h1 { font-size: 24px; font-weight: 800; color: #1c1530; letter-spacing: -.01em; }
.login-card .lc-sub { font-size: 13.5px; color: #6f6488; margin-top: 6px; margin-bottom: 28px; }
.login-card .field { margin-bottom: 16px; }
.login-card .input { background: #fff; border-color: #e4dcf7; color: #1c1530; }
.login-card .input::placeholder { color: #a89bc9; }
.login-card .input:focus { border-color: #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,.15); }
.login-card .input-wrap .icon { color: #9d8fc0; }
.login-row-between { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.login-row-between a { font-size: 12.5px; font-weight: 600; color: #7c3aed; }
.login-row-between .checkbox-row { color: #6f6488; }
.login-row-between .checkbox-row input[type=checkbox] { background: #fff; border-color: #d9cdf2; }

.form-alert { display: none; align-items: flex-start; gap: 9px; background: rgba(208,59,59,.08); border: 1px solid rgba(208,59,59,.3); color: #b53434; padding: 11px 13px; border-radius: 10px; font-size: 12.5px; margin-bottom: 16px; line-height: 1.5; }
.form-alert.show { display: flex; }
.form-alert .icon { color: #d03b3b; flex-shrink: 0; margin-top: 1px; }
.shake { animation: shake .38s; }
@keyframes shake { 10%,90%{transform:translateX(-1px)} 20%,80%{transform:translateX(2px)} 30%,50%,70%{transform:translateX(-4px)} 40%,60%{transform:translateX(4px)} }

.sandbox-box { margin-top: 24px; border: 1.5px dashed #ded2f4; border-radius: 11px; padding: 12px 14px; background: #f8f5fd; }
.sandbox-box .sb-title { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: #8b5cf6; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.sandbox-box .sb-row { font-size: 12.5px; color: #574c74; font-family: 'SFMono-Regular', Consolas, monospace; line-height: 1.7; }
.sandbox-box .sb-row b { color: #1c1530; }

.login-foot-help { margin-top: 26px; text-align: center; font-size: 12.5px; color: #8a7fa8; }
.login-foot-help a { color: #7c3aed; font-weight: 600; }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .6s linear infinite; display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading .btn-label { opacity: .85; }

/* Utility */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0 !important; }
