/* ============================================================
   SKARDIA · Design System
   Operational control platform — enterprise UI tokens
   Light + Dark themes, switchable accent.
   ============================================================ */

/* ---- Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Hanken+Grotesk:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ============================================================
   1. TOKENS
   ============================================================ */
:root {
  /* Typography */
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-ui: 'Hanken Grotesk', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --text-xs: 11.5px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 28px;
  --text-3xl: 36px;

  /* Spacing scale */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px; --s9: 56px;

  /* Radii */
  --r-xs: 5px; --r-sm: 7px; --r: 10px; --r-lg: 14px; --r-xl: 20px;
  --r-pill: 999px;

  /* Accent (green — default brand). Swappable via [data-accent]. */
  --accent: #16A34A;
  --accent-strong: #15803D;
  --accent-deep: #15803D;
  --accent-soft: rgba(22, 163, 74, .14);
  --accent-line: rgba(22, 163, 74, .35);
  --accent-contrast: #FFFFFF;

  /* Semantic (stable across themes, soft variants per theme) */
  --success: #059669;
  --warning: #D97706;
  --danger: #E03E3E;
  --info: #2563EB;

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

/* Accent variants */
[data-accent="amber"] {
  --accent: #F59E0B; --accent-strong: #D97706; --accent-deep: #B45309;
  --accent-soft: rgba(245, 158, 11, .14); --accent-line: rgba(245, 158, 11, .35);
  --accent-contrast: #1A1206;
}
[data-accent="indigo"] {
  --accent: #6366F1; --accent-strong: #4F46E5; --accent-deep: #4338CA;
  --accent-soft: rgba(99, 102, 241, .14); --accent-line: rgba(99, 102, 241, .35);
  --accent-contrast: #FFFFFF;
}
[data-accent="teal"] {
  --accent: #0D9488; --accent-strong: #0F766E; --accent-deep: #115E59;
  --accent-soft: rgba(13, 148, 136, .14); --accent-line: rgba(13, 148, 136, .35);
  --accent-contrast: #FFFFFF;
}

/* ---- LIGHT THEME ---- */
:root, [data-theme="light"] {
  --bg: #F4F6F8;
  --bg-tint: #EEF1F4;
  --surface: #FFFFFF;
  --surface-2: #F6F8FA;
  --surface-3: #EEF1F5;
  --border: #E5E9EF;
  --border-strong: #D3D9E2;
  --text: #0C1322;
  --text-2: #4A5568;
  --text-3: #8A94A6;
  --text-inv: #FFFFFF;

  --sidebar-bg: #0B1120;
  --sidebar-grad: linear-gradient(180deg, #0E1526 0%, #0A0F1C 100%);
  --sidebar-text: #C4CBD8;
  --sidebar-muted: #687387;
  --sidebar-active-bg: rgba(255, 255, 255, .06);
  --sidebar-border: rgba(255, 255, 255, .07);

  --btn-primary-bg: #111A2E;
  --btn-primary-bg-hover: #1E293F;
  --btn-primary-text: #FFFFFF;

  --success-soft: #E7F6EF; --success-text: #07764E;
  --warning-soft: #FBEFD9; --warning-text: #9A5B05;
  --danger-soft: #FBE9E9;  --danger-text: #B5302F;
  --info-soft: #E8EFFD;    --info-text: #1D4ED8;

  --shadow-sm: 0 1px 2px rgba(12, 19, 34, .05);
  --shadow: 0 1px 3px rgba(12, 19, 34, .08), 0 1px 2px rgba(12, 19, 34, .05);
  --shadow-md: 0 6px 16px -6px rgba(12, 19, 34, .14), 0 2px 6px rgba(12, 19, 34, .06);
  --shadow-lg: 0 18px 40px -12px rgba(12, 19, 34, .22);
  --ring: 0 0 0 3px var(--accent-soft);
}

/* ---- DARK THEME ---- */
[data-theme="dark"] {
  --bg: #080C15;
  --bg-tint: #0B1120;
  --surface: #111827;
  --surface-2: #161F30;
  --surface-3: #1D2738;
  --border: #232E42;
  --border-strong: #303D55;
  --text: #F1F4F9;
  --text-2: #A7B0C0;
  --text-3: #6B7686;
  --text-inv: #0C1322;

  --sidebar-bg: #060910;
  --sidebar-grad: linear-gradient(180deg, #0A0F1C 0%, #05080F 100%);
  --sidebar-text: #C4CBD8;
  --sidebar-muted: #5E6979;
  --sidebar-active-bg: rgba(255, 255, 255, .07);
  --sidebar-border: rgba(255, 255, 255, .06);

  --btn-primary-bg: #F1F4F9;
  --btn-primary-bg-hover: #FFFFFF;
  --btn-primary-text: #0C1322;

  --success-soft: rgba(5, 150, 105, .16);  --success-text: #34D399;
  --warning-soft: rgba(217, 119, 6, .18);  --warning-text: #FBBF24;
  --danger-soft: rgba(224, 62, 62, .18);   --danger-text: #F87171;
  --info-soft: rgba(37, 99, 235, .2);      --info-text: #60A5FA;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 3px rgba(0, 0, 0, .5);
  --shadow-md: 0 8px 20px -8px rgba(0, 0, 0, .6);
  --shadow-lg: 0 22px 48px -14px rgba(0, 0, 0, .7);
  --ring: 0 0 0 3px var(--accent-soft);
}

/* ============================================================
   2. BASE
   ============================================================ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.015em; margin: 0; color: var(--text); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
a { color: var(--accent-deep); text-decoration: none; }
::selection { background: var(--accent-soft); }

/* Scrollbars */
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }

/* ============================================================
   3. APP SHELL
   ============================================================ */
.app { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar-grad);
  border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sb-brand { display: flex; align-items: center; gap: var(--s3); padding: var(--s5) var(--s5) var(--s4); }
.sb-mark { width: 40px; height: 40px; flex: none; }
.sb-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.sb-brand-name { font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); color: #fff; letter-spacing: -.01em; }
.sb-brand-sub { font-size: 10px; font-weight: 600; letter-spacing: .14em; color: var(--sidebar-muted); text-transform: uppercase; }

.sb-search {
  margin: 0 var(--s4) var(--s4); display: flex; align-items: center; gap: var(--s2);
  background: rgba(255,255,255,.05); border: 1px solid var(--sidebar-border);
  border-radius: var(--r-sm); padding: 9px var(--s3); color: var(--sidebar-muted);
  font-size: var(--text-sm); cursor: text; transition: border-color .15s var(--ease);
}
.sb-search:hover { border-color: rgba(255,255,255,.16); }
.sb-search svg { width: 15px; height: 15px; flex: none; }
.sb-search .kbd { margin-left: auto; font-family: var(--font-mono); font-size: 10px; background: rgba(255,255,255,.08); padding: 2px 6px; border-radius: 4px; }

.sb-nav { flex: 1; overflow-y: auto; padding: 0 var(--s3) var(--s5); }
.sb-section { padding: var(--s4) var(--s3) var(--s2); font-size: 10px; font-weight: 700; letter-spacing: .13em; color: var(--sidebar-muted); text-transform: uppercase; }
.sb-link {
  display: flex; align-items: center; gap: var(--s3); padding: 9px var(--s3);
  border-radius: var(--r-sm); color: var(--sidebar-text); font-size: var(--text-sm);
  font-weight: 500; cursor: pointer; position: relative; transition: background .14s var(--ease), color .14s var(--ease);
  margin-bottom: 1px;
}
.sb-link svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.sb-link:hover { background: rgba(255,255,255,.04); color: #fff; }
.sb-link.active { background: var(--sidebar-active-bg); color: #fff; }
.sb-link.active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.sb-link.active svg { opacity: 1; color: var(--accent); }
.sb-badge { margin-left: auto; font-size: 11px; font-weight: 600; background: rgba(255,255,255,.08); color: var(--sidebar-text); padding: 1px 8px; border-radius: var(--r-pill); }

.sb-foot { padding: var(--s3) var(--s4); border-top: 1px solid var(--sidebar-border); display: flex; align-items: center; gap: var(--s3); }
.sb-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-contrast); display: grid; place-items: center; font-weight: 700; font-size: var(--text-sm); flex: none; }
.sb-user { line-height: 1.2; flex: 1; min-width: 0; }
.sb-user b { display: block; color: #fff; font-size: var(--text-sm); font-weight: 600; }
.sb-user span { font-size: var(--text-xs); color: var(--sidebar-muted); }

/* ---- Main ---- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: var(--s4); padding: var(--s4) var(--s7);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.crumb { display: flex; align-items: center; gap: var(--s2); font-size: var(--text-sm); color: var(--text-3); }
.crumb b { color: var(--text-2); font-weight: 600; }
.crumb svg { width: 14px; height: 14px; opacity: .5; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }

.page { padding: var(--s6) var(--s7) var(--s8); }
.page-head { display: flex; align-items: flex-start; gap: var(--s4); margin-bottom: var(--s6); }
.page-title { font-size: var(--text-2xl); font-weight: 600; }
.page-sub { color: var(--text-2); font-size: var(--text-md); margin-top: 2px; }
.page-head-actions { margin-left: auto; display: flex; gap: var(--s2); }

/* ============================================================
   4. BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  font-family: var(--font-ui); font-size: var(--text-sm); font-weight: 600;
  padding: 9px 15px; border-radius: var(--r-sm); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; transition: all .15s var(--ease); line-height: 1;
}
.btn svg { width: 16px; height: 16px; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-primary { background: var(--btn-primary-bg); color: var(--btn-primary-text); }
.btn-primary:hover { background: var(--btn-primary-bg-hover); }

.btn-accent { background: var(--accent); color: var(--accent-contrast); }
.btn-accent:hover { background: var(--accent-strong); }

.btn-ghost { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--text-3); }

.btn-subtle { background: var(--surface-3); color: var(--text-2); }
.btn-subtle:hover { background: var(--border); color: var(--text); }

.btn-sm { padding: 6px 11px; font-size: var(--text-xs); }
.btn-lg { padding: 12px 20px; font-size: var(--text-md); }

/* Icon button — uniform, neutral by default */
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center;
  border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer; transition: all .14s var(--ease);
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.icon-btn.is-danger:hover { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-soft); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* ============================================================
   5. FORM CONTROLS
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: var(--text-sm); font-weight: 600; color: var(--text-2); }
.label .req { color: var(--danger); }
.input, .select, .textarea {
  font-family: var(--font-ui); font-size: var(--text-base); color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); padding: 10px 13px; width: 100%; transition: all .15s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A94A6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px; cursor: pointer; }

.search-input { position: relative; display: flex; align-items: center; }
.search-input svg { position: absolute; left: 13px; width: 17px; height: 17px; color: var(--text-3); pointer-events: none; }
.search-input .input { padding-left: 40px; }

/* Segmented control */
.segment { display: inline-flex; background: var(--surface-3); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.segment button {
  font-family: var(--font-ui); font-size: var(--text-sm); font-weight: 600; color: var(--text-2);
  background: transparent; border: none; padding: 6px 14px; border-radius: var(--r-xs); cursor: pointer; transition: all .15s var(--ease);
}
.segment button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Toggle */
.switch { position: relative; width: 42px; height: 24px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 99px; transition: background .18s var(--ease); }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; box-shadow: var(--shadow-sm); transition: transform .18s var(--ease); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* ============================================================
   6. CARDS / SURFACES
   ============================================================ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: var(--s5); }
.card-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: var(--text-md); font-weight: 600; }
.card-head .card-head-actions { margin-left: auto; display: flex; gap: var(--s2); align-items: center; }

/* Toolbar (table header strip) */
.toolbar { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.toolbar .grow { flex: 1; min-width: 200px; }

/* ============================================================
   7. BADGES / CHIPS / PILLS
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: var(--text-xs); font-weight: 600;
  padding: 3px 9px; border-radius: var(--r-pill); line-height: 1.4; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger-text); }
.badge-info    { background: var(--info-soft);    color: var(--info-text); }
.badge-neutral { background: var(--surface-3); color: var(--text-2); }
.badge-accent  { background: var(--accent-soft); color: var(--accent-deep); }

/* Filter chips */
.chips { display: flex; gap: var(--s2); flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: var(--text-sm); font-weight: 600;
  padding: 7px 14px; border-radius: var(--r-pill); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2); cursor: pointer; transition: all .14s var(--ease);
}
.chip .count { font-size: var(--text-xs); background: var(--surface-3); color: var(--text-3); padding: 0 7px; border-radius: var(--r-pill); }
.chip:hover { border-color: var(--text-3); color: var(--text); }
.chip.active { background: var(--text); color: var(--text-inv); border-color: var(--text); }
.chip.active .count { background: rgba(255,255,255,.18); color: #fff; }

/* ============================================================
   8. TABLE
   ============================================================ */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.tbl thead th {
  text-align: left; font-size: var(--text-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); padding: 12px var(--s5); background: var(--surface-2);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; white-space: nowrap;
}
.tbl tbody td { padding: 14px var(--s5); border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.tbl tbody tr { transition: background .12s var(--ease); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: none; }
.cell-strong { font-weight: 600; }
.cell-sub { color: var(--text-3); font-size: var(--text-sm); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Person cell */
.person { display: flex; align-items: center; gap: var(--s3); }
.person .av { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: var(--text-sm); color: #fff; }
.person .pn { line-height: 1.25; }
.person .pn b { font-weight: 600; }
.person .pn span { display: block; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-3); }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s4); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.kpi-top { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.kpi-ic { width: 38px; height: 38px; border-radius: var(--r-sm); display: grid; place-items: center; flex: none; }
.kpi-ic svg { width: 19px; height: 19px; }
.kpi-label { font-size: var(--text-xs); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.kpi-val { font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 600; letter-spacing: -.02em; line-height: 1; }
.kpi-delta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-sm); font-weight: 600; margin-top: var(--s3); }
.kpi-delta.up { color: var(--success-text); }
.kpi-delta.down { color: var(--danger-text); }

/* Empty state */
.empty { text-align: center; padding: var(--s9) var(--s5); color: var(--text-3); }
.empty svg { width: 44px; height: 44px; margin-bottom: var(--s4); opacity: .5; }
.empty h4 { font-size: var(--text-md); color: var(--text-2); margin-bottom: 4px; }

/* Utilities */
.flex { display: flex; } .items-center { align-items: center; } .gap2 { gap: var(--s2); } .gap3 { gap: var(--s3); } .gap4 { gap: var(--s4); }
.ml-auto { margin-left: auto; } .grow { flex: 1; }
.muted { color: var(--text-3); }

/* ============================================================
   9. ALERTS / BANNERS
   ============================================================ */
.alert {
  display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s4);
  border-radius: var(--r); border: 1px solid var(--border); background: var(--surface);
  font-size: var(--text-sm); color: var(--text-2); line-height: 1.5;
}
.alert .a-ic { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert .a-ic svg { width: 20px; height: 20px; }
.alert b { color: var(--text); font-weight: 600; display: block; margin-bottom: 2px; }
.alert .a-close { margin-left: auto; flex: none; background: none; border: none; color: var(--text-3); cursor: pointer; width: 24px; height: 24px; display: grid; place-items: center; border-radius: var(--r-xs); }
.alert .a-close:hover { background: var(--surface-3); color: var(--text); }
.alert .a-close svg { width: 15px; height: 15px; }
.alert-success { background: var(--success-soft); border-color: transparent; color: var(--success-text); }
.alert-success b, .alert-warning b, .alert-danger b, .alert-info b { color: inherit; }
.alert-warning { background: var(--warning-soft); border-color: transparent; color: var(--warning-text); }
.alert-danger  { background: var(--danger-soft);  border-color: transparent; color: var(--danger-text); }
.alert-info    { background: var(--info-soft);    border-color: transparent; color: var(--info-text); }

/* ============================================================
   10. TABS
   ============================================================ */
.tabs { display: flex; gap: var(--s5); border-bottom: 1px solid var(--border); }
.tab {
  position: relative; padding: var(--s3) 0; font-family: var(--font-ui); font-size: var(--text-md);
  font-weight: 600; color: var(--text-3); background: none; border: none; cursor: pointer;
  transition: color .14s var(--ease);
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--text); }
.tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; }
.tab .count { margin-left: 6px; font-size: var(--text-xs); font-weight: 600; background: var(--surface-3); color: var(--text-3); padding: 1px 7px; border-radius: var(--r-pill); }

/* ============================================================
   11. MODAL / DIALOG
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: var(--s5);
  background: color-mix(in srgb, #0A0F1C 55%, transparent); backdrop-filter: blur(3px);
  animation: ov-in .18s var(--ease);
}
@keyframes ov-in { from { opacity: 0; } }
.modal {
  width: 480px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); overflow: hidden; animation: modal-in .22s var(--ease);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal-head { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s5) var(--s5) var(--s4); }
.modal-head .m-ic { width: 38px; height: 38px; border-radius: var(--r-sm); display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-deep); }
.modal-head .m-ic svg { width: 20px; height: 20px; }
.modal-head .m-ic.danger { background: var(--danger-soft); color: var(--danger-text); }
.modal-head h3 { font-size: var(--text-lg); font-weight: 600; }
.modal-head p { color: var(--text-2); font-size: var(--text-sm); margin: 3px 0 0; }
.modal-head .m-close { margin-left: auto; }
.modal-body { padding: 0 var(--s5) var(--s5); overflow-y: auto; }
.modal-foot { display: flex; gap: var(--s2); justify-content: flex-end; padding: var(--s4) var(--s5); border-top: 1px solid var(--border); background: var(--surface-2); }

/* ============================================================
   12. DRAWER / SHEET (side panel)
   ============================================================ */
.drawer-overlay { position: fixed; inset: 0; z-index: 100; background: color-mix(in srgb, #0A0F1C 50%, transparent); backdrop-filter: blur(2px); animation: ov-in .18s var(--ease); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 101; width: 440px; max-width: 92vw;
  display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); animation: drawer-in .26s var(--ease);
}
@keyframes drawer-in { from { transform: translateX(100%); } }
.drawer-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s5); border-bottom: 1px solid var(--border); }
.drawer-head h3 { font-size: var(--text-lg); font-weight: 600; }
.drawer-head .d-close { margin-left: auto; }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--s5); }
.drawer-foot { display: flex; gap: var(--s2); padding: var(--s4) var(--s5); border-top: 1px solid var(--border); background: var(--surface-2); }

/* ============================================================
   13. TOAST
   ============================================================ */
.toast-stack { position: fixed; bottom: var(--s5); right: var(--s5); z-index: 200; display: flex; flex-direction: column; gap: var(--s3); width: 360px; max-width: calc(100vw - 32px); }
.toast {
  display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow-md); animation: toast-in .26s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } }
.toast .t-ic { width: 34px; height: 34px; border-radius: var(--r-sm); display: grid; place-items: center; flex: none; }
.toast .t-ic svg { width: 18px; height: 18px; }
.toast .t-ic.ok { background: var(--success-soft); color: var(--success-text); }
.toast .t-ic.err { background: var(--danger-soft); color: var(--danger-text); }
.toast .t-ic.info { background: var(--info-soft); color: var(--info-text); }
.toast .t-body { flex: 1; line-height: 1.4; }
.toast .t-body b { font-size: var(--text-sm); font-weight: 600; }
.toast .t-body p { margin: 2px 0 0; font-size: var(--text-xs); color: var(--text-3); }
.toast .t-close { background: none; border: none; color: var(--text-3); cursor: pointer; width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: var(--r-xs); }
.toast .t-close:hover { color: var(--text); background: var(--surface-3); }
.toast .t-close svg { width: 14px; height: 14px; }

/* ============================================================
   14. TOOLTIP
   ============================================================ */
.tip { position: relative; display: inline-flex; }
.tip > .tip-bub {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px);
  background: #0C1322; color: #fff; font-size: var(--text-xs); font-weight: 500; white-space: nowrap;
  padding: 6px 10px; border-radius: var(--r-xs); pointer-events: none; opacity: 0; transition: opacity .14s var(--ease), transform .14s var(--ease); z-index: 50;
}
[data-theme="dark"] .tip > .tip-bub { background: #F1F4F9; color: #0C1322; }
.tip > .tip-bub::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: #0C1322; }
[data-theme="dark"] .tip > .tip-bub::after { border-top-color: #F1F4F9; }
.tip:hover > .tip-bub { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   15. STATES — loading / empty / error
   ============================================================ */
/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; border-radius: var(--r-sm); animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.skeleton-text { height: 12px; border-radius: var(--r-pill); }
.skeleton-circle { border-radius: 50%; }

/* Spinner */
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.lg { width: 36px; height: 36px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* State block — empty / error / loading / no-access */
.state { text-align: center; padding: var(--s9) var(--s5); }
.state .state-ic { width: 56px; height: 56px; border-radius: var(--r-lg); display: grid; place-items: center; margin: 0 auto var(--s4); background: var(--surface-3); color: var(--text-3); }
.state .state-ic svg { width: 28px; height: 28px; }
.state .state-ic.danger { background: var(--danger-soft); color: var(--danger-text); }
.state .state-ic.accent { background: var(--accent-soft); color: var(--accent-deep); }
.state h4 { font-size: var(--text-lg); color: var(--text); margin-bottom: 6px; }
.state p { color: var(--text-2); font-size: var(--text-sm); max-width: 42ch; margin: 0 auto var(--s5); line-height: 1.5; }
.state .state-actions { display: flex; gap: var(--s2); justify-content: center; }

/* Progress bar */
.progress { height: 8px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill); transition: width .4s var(--ease); }
