/* =============================================================================
   Onix Operations Dashboard — Design System
   -----------------------------------------------------------------------------
   Structure:
     1.  Design tokens (CSS variables) + themes
     2.  Reset & base
     3.  Layout (app shell, sidebar, topbar, content)
     4.  Components (buttons, cards, tables, badges, modals, toasts…)
     5.  Charts
     6.  View-specific helpers
     7.  Responsive
   ============================================================================= */

/* ----------------------------------------------------------------------------
   1. DESIGN TOKENS
   ---------------------------------------------------------------------------- */
:root {
  /* Brand */
  --brand-1: #6366f1;
  --brand-2: #8b5cf6;
  --brand-3: #22d3ee;
  --brand-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --brand-grad-soft: linear-gradient(135deg, rgba(99,102,241,.16), rgba(139,92,246,.16));

  /* Status */
  --success: #34d399;
  --warning: #fbbf24;
  --danger:  #fb7185;
  --info:    #38bdf8;

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 999px;

  /* Spacing scale */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --fw-medium: 500; --fw-semi: 600; --fw-bold: 700; --fw-black: 800;

  /* Motion */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --t-fast: .15s; --t: .25s; --t-slow: .4s;

  --sidebar-w: 268px;
  --topbar-h: 72px;
}

/* ---- Dark theme (default) ---- */
:root, [data-theme="dark"] {
  --bg:          #0a0e1a;
  --bg-grad:     radial-gradient(1200px 600px at 80% -10%, rgba(99,102,241,.10), transparent 60%),
                 radial-gradient(900px 500px at -10% 110%, rgba(34,211,238,.08), transparent 55%);
  --surface:     #111726;
  --surface-2:   #161d30;
  --surface-3:   #1b2336;
  --elevated:    #1a2236;
  --border:      rgba(255,255,255,.07);
  --border-2:    rgba(255,255,255,.12);
  --text:        #e9edf6;
  --text-muted:  #93a0b8;
  --text-dim:    #5e6a82;
  --shadow:      0 1px 2px rgba(0,0,0,.4), 0 8px 24px -8px rgba(0,0,0,.5);
  --shadow-lg:   0 24px 60px -16px rgba(0,0,0,.65);
  --glow:        0 0 0 1px rgba(99,102,241,.4), 0 8px 30px -6px rgba(99,102,241,.45);
  --track:       rgba(255,255,255,.06);
  color-scheme: dark;
}

/* ---- Light theme ---- */
[data-theme="light"] {
  --bg:          #f4f6fb;
  --bg-grad:     radial-gradient(1200px 600px at 80% -10%, rgba(99,102,241,.10), transparent 60%),
                 radial-gradient(900px 500px at -10% 110%, rgba(34,211,238,.10), transparent 55%);
  --surface:     #ffffff;
  --surface-2:   #ffffff;
  --surface-3:   #f1f4fa;
  --elevated:    #ffffff;
  --border:      rgba(15,23,42,.08);
  --border-2:    rgba(15,23,42,.14);
  --text:        #0f172a;
  --text-muted:  #5b6678;
  --text-dim:    #93a0b8;
  --shadow:      0 1px 2px rgba(15,23,42,.06), 0 12px 28px -12px rgba(15,23,42,.18);
  --shadow-lg:   0 24px 60px -16px rgba(15,23,42,.22);
  --glow:        0 0 0 1px rgba(99,102,241,.35), 0 10px 30px -8px rgba(99,102,241,.35);
  --track:       rgba(15,23,42,.06);
  color-scheme: light;
}

/* ----------------------------------------------------------------------------
   2. RESET & BASE
   ---------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
  overflow: hidden;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  background: var(--bg-grad);
  pointer-events: none;
  z-index: 0;
}
h1, h2, h3, h4 { line-height: 1.2; font-weight: var(--fw-bold); letter-spacing: -.02em; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; color: inherit; }
/* Inline icons default to text size; charts & sized containers override below. */
svg { display: inline-block; vertical-align: middle; width: 1em; height: 1em; }
ul { list-style: none; padding: 0; }
[hidden] { display: none !important; }
::selection { background: rgba(99,102,241,.35); }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-dim); background-clip: content-box; }

/* ----------------------------------------------------------------------------
   SPLASH
   ---------------------------------------------------------------------------- */
.splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: var(--bg);
}
.splash__logo { display: flex; align-items: center; gap: 12px; font-size: 28px; font-weight: var(--fw-black); letter-spacing: -.03em; }
.splash__bar { width: 180px; height: 4px; border-radius: 99px; background: var(--track); overflow: hidden; }
.splash__bar span { display: block; height: 100%; width: 40%; border-radius: 99px; background: var(--brand-grad);
  animation: splashSlide 1s var(--ease) infinite; }
@keyframes splashSlide { 0%{ transform: translateX(-120%);} 100%{ transform: translateX(360%);} }
.brand-mark {
  display: inline-grid; place-items: center;
  background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 8px rgba(99,102,241,.5));
}

/* ----------------------------------------------------------------------------
   3. LAYOUT
   ---------------------------------------------------------------------------- */
.app {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}
.app.is-collapsed { --sidebar-w: 76px; }

/* ---- Sidebar ---- */
.sidebar {
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-width: 0;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h); padding: 0 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar__brand .brand-mark { font-size: 26px; }
.sidebar__brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.sidebar__brand-text strong { font-size: 18px; font-weight: var(--fw-black); letter-spacing: -.02em; }
.sidebar__brand-text small { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; }
.sidebar__collapse { margin-left: auto; }
.app.is-collapsed .sidebar__brand-text,
.app.is-collapsed .sidebar__collapse { display: none; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-group__label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim);
  padding: 14px 12px 6px; font-weight: var(--fw-semi);
}
.app.is-collapsed .nav-group__label { text-align: center; font-size: 0; padding: 10px 0 4px; }
.app.is-collapsed .nav-group__label::after { content: "•"; font-size: 14px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-md);
  color: var(--text-muted); font-weight: var(--fw-medium); font-size: 14px;
  position: relative; transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.is-active { background: var(--brand-grad-soft); color: var(--text); }
.nav-item.is-active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: var(--brand-grad);
}
.nav-item__icon { width: 20px; height: 20px; flex: none; color: currentColor; }
.nav-item__icon svg { width: 100%; height: 100%; }
.nav-item.is-active .nav-item__icon { color: var(--brand-1); }
.nav-item__badge {
  margin-left: auto; font-size: 11px; font-weight: var(--fw-bold);
  background: var(--surface-3); color: var(--text-muted); padding: 1px 8px; border-radius: var(--r-full);
}
.nav-item.is-active .nav-item__badge { background: var(--brand-1); color: #fff; }
.app.is-collapsed .nav-item { justify-content: center; padding: 11px; }
.app.is-collapsed .nav-item__label,
.app.is-collapsed .nav-item__badge { display: none; }

.sidebar__footer { padding: 12px; border-top: 1px solid var(--border); }
.user-card {
  display: flex; align-items: center; gap: 12px; padding: 10px;
  border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border);
}
.user-card__meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-card__meta strong { font-size: 13px; font-weight: var(--fw-semi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card__meta small { font-size: 12px; color: var(--text-muted); }
.app.is-collapsed .user-card__meta { display: none; }
.app.is-collapsed .user-card { justify-content: center; }

/* ---- Main / Topbar ---- */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  height: var(--topbar-h); padding: 0 24px; flex: none;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 20;
}
.topbar__heading { min-width: 0; }
.topbar__heading h1 { font-size: 20px; font-weight: var(--fw-bold); white-space: nowrap; }
.topbar__subtitle { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__spacer { flex: 1; }
.topbar__menu { display: none; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-full); padding: 0 12px; height: 40px; width: 320px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.search:focus-within { border-color: var(--brand-1); box-shadow: 0 0 0 3px rgba(99,102,241,.18); }
.search__icon { width: 16px; height: 16px; color: var(--text-dim); flex: none; }
.search input { flex: 1; background: none; border: none; outline: none; font-size: 14px; min-width: 0; }
.search kbd {
  font-size: 11px; color: var(--text-dim); border: 1px solid var(--border-2);
  border-radius: 6px; padding: 1px 6px; background: var(--surface-3);
}

/* Dev role switcher (TEMPORARY — see index.html) */
.dev-switcher {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px 5px 10px; border-radius: var(--r-full);
  background: repeating-linear-gradient(45deg, rgba(251,191,36,.08), rgba(251,191,36,.08) 8px, transparent 8px, transparent 16px);
  border: 1px dashed rgba(251,191,36,.5);
}
.dev-switcher__tag {
  font-size: 10px; font-weight: var(--fw-black); letter-spacing: .1em;
  color: #1a1505; background: var(--warning); padding: 2px 7px; border-radius: var(--r-full);
}
.segmented { display: flex; background: var(--surface-3); border-radius: var(--r-full); padding: 3px; gap: 2px; }
.segmented__btn {
  font-size: 13px; font-weight: var(--fw-semi); color: var(--text-muted);
  padding: 6px 14px; border-radius: var(--r-full); transition: all var(--t-fast); white-space: nowrap;
}
.segmented__btn:hover { color: var(--text); }
.segmented__btn.is-active { background: var(--brand-grad); color: #fff; box-shadow: 0 4px 12px -3px rgba(99,102,241,.6); }

.content {
  flex: 1; overflow-y: auto; padding: 28px 32px 60px;
  outline: none;
}
.content > * { animation: viewIn .45s var(--ease-out); }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------------------------
   4. COMPONENTS
   ---------------------------------------------------------------------------- */

/* Icon button */
.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: var(--r-md);
  color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border);
  transition: all var(--t-fast); flex: none;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-2); transform: translateY(-1px); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn__dot, .icon-btn--badge::after {
  content: ""; position: absolute; top: 9px; right: 10px;
  width: 7px; height: 7px; border-radius: 99px; background: var(--danger);
  border: 2px solid var(--surface-2);
}
.icon-btn__dot { display: none; }

/* Avatar */
.avatar {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: var(--r-full);
  background: var(--brand-grad); color: #fff;
  font-size: 13px; font-weight: var(--fw-bold); flex: none;
  text-transform: uppercase; letter-spacing: .02em; overflow: hidden;
}
.avatar--sm { width: 30px; height: 30px; font-size: 11px; }
.avatar--lg { width: 56px; height: 56px; font-size: 18px; }
.avatar--btn { border: 1px solid var(--border-2); cursor: pointer; transition: transform var(--t-fast); }
.avatar--btn:hover { transform: translateY(-1px); }
.avatar[data-tone="2"] { background: linear-gradient(135deg,#22d3ee,#3b82f6); }
.avatar[data-tone="3"] { background: linear-gradient(135deg,#34d399,#10b981); }
.avatar[data-tone="4"] { background: linear-gradient(135deg,#fbbf24,#f59e0b); }
.avatar[data-tone="5"] { background: linear-gradient(135deg,#fb7185,#ec4899); }
.avatar[data-tone="6"] { background: linear-gradient(135deg,#a78bfa,#8b5cf6); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-md);
  font-size: 14px; font-weight: var(--fw-semi); white-space: nowrap;
  transition: all var(--t-fast); border: 1px solid transparent;
}
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--brand-grad); color: #fff; box-shadow: 0 6px 18px -6px rgba(99,102,241,.7); }
.btn--primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -6px rgba(99,102,241,.8); }
.btn--ghost { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn--ghost:hover { border-color: var(--border-2); background: var(--surface-3); }
.btn--danger { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn--danger:hover { background: color-mix(in srgb, var(--danger) 26%, transparent); }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn--block { width: 100%; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px;
  box-shadow: var(--shadow);
}
.card--pad-lg { padding: 24px; }
.card__head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.card__head h3 { font-size: 15px; font-weight: var(--fw-bold); }
.card__head p { font-size: 13px; color: var(--text-muted); }
.card__head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* Grids */
.grid { display: grid; gap: 18px; }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--main { grid-template-columns: 2fr 1fr; }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.section-gap { margin-top: 26px; }

/* KPI card */
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px 20px; box-shadow: var(--shadow);
  transition: transform var(--t), border-color var(--t);
}
.kpi:hover { transform: translateY(-3px); border-color: var(--border-2); }
.kpi__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.kpi__icon { width: 42px; height: 42px; border-radius: var(--r-md); display: grid; place-items: center; }
.kpi__icon svg { width: 20px; height: 20px; }
.kpi__icon--brand { background: var(--brand-grad-soft); color: var(--brand-1); }
.kpi__icon--success { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }
.kpi__icon--warning { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); }
.kpi__icon--info { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); }
.kpi__label { font-size: 13px; color: var(--text-muted); font-weight: var(--fw-medium); }
.kpi__value { font-size: 28px; font-weight: var(--fw-black); letter-spacing: -.03em; margin-top: 2px; }
.kpi__foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.kpi__spark { margin-top: 14px; pointer-events: none; opacity: .9; }

/* Trend pill */
.trend { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: var(--fw-bold);
  padding: 2px 8px; border-radius: var(--r-full); }
.trend svg { width: 13px; height: 13px; }
.trend--up { color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); }
.trend--down { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.trend--flat { color: var(--text-muted); background: var(--surface-3); }
.kpi__foot small { font-size: 12px; color: var(--text-dim); }

/* Badge / pill */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: var(--fw-semi); padding: 3px 10px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--text-muted);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.badge--success { color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); }
.badge--warning { color: var(--warning); background: color-mix(in srgb, var(--warning) 14%, transparent); }
.badge--danger  { color: var(--danger);  background: color-mix(in srgb, var(--danger) 14%, transparent); }
.badge--info    { color: var(--info);    background: color-mix(in srgb, var(--info) 14%, transparent); }
.badge--plain::before { display: none; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-dim); font-weight: var(--fw-semi); padding: 0 14px 12px; white-space: nowrap;
}
.table td { padding: 13px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--surface-2); }
.table .td-strong { font-weight: var(--fw-semi); }
.table .td-muted { color: var(--text-muted); }
.cell-user { display: flex; align-items: center; gap: 11px; }
.cell-user__meta { display: flex; flex-direction: column; line-height: 1.25; }
.cell-user__meta small { color: var(--text-muted); font-size: 12px; }
.table .num { font-variant-numeric: tabular-nums; }
.table .right { text-align: right; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-action {
  width: 30px; height: 30px; border-radius: var(--r-sm); display: grid; place-items: center;
  color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); transition: all var(--t-fast);
}
.row-action:hover { color: var(--text); border-color: var(--border-2); }
.row-action--danger:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.row-action svg { width: 15px; height: 15px; }

/* Store card (owner) */
.store-card {
  display: flex; flex-direction: column; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px; box-shadow: var(--shadow); transition: transform var(--t), border-color var(--t), box-shadow var(--t);
  cursor: pointer;
}
.store-card:hover { transform: translateY(-3px); border-color: var(--border-2); box-shadow: var(--shadow-lg); }
.store-card__head { display: flex; align-items: center; gap: 12px; }
.store-card__logo { width: 44px; height: 44px; border-radius: var(--r-md); display: grid; place-items: center;
  font-size: 18px; background: var(--brand-grad-soft); }
.store-card__title { flex: 1; min-width: 0; }
.store-card__title strong { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.store-card__title small { font-size: 12px; color: var(--text-muted); }
.store-card__stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mini-stat__label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.mini-stat__value { font-size: 18px; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.store-card__bar { height: 6px; border-radius: 99px; background: var(--track); overflow: hidden; }
.store-card__bar span { display: block; height: 100%; border-radius: 99px; background: var(--brand-grad); }

/* List rows */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.list-row:first-child { border-top: none; }
.list-row__main { flex: 1; min-width: 0; }
.list-row__main strong { font-size: 14px; font-weight: var(--fw-semi); display: block; }
.list-row__main small { font-size: 12.5px; color: var(--text-muted); }
.list-row__end { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Rank pill */
.rank { width: 26px; height: 26px; border-radius: var(--r-sm); display: grid; place-items: center;
  font-size: 12px; font-weight: var(--fw-bold); background: var(--surface-3); color: var(--text-muted); flex: none; }
.rank--1 { background: linear-gradient(135deg,#fbbf24,#f59e0b); color: #1a1505; }
.rank--2 { background: linear-gradient(135deg,#cbd5e1,#94a3b8); color: #0f172a; }
.rank--3 { background: linear-gradient(135deg,#d97757,#b45309); color: #fff; }

/* Progress */
.progress { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 99px; background: var(--brand-grad); transition: width var(--t-slow) var(--ease-out); }
.progress--success span { background: linear-gradient(90deg,#34d399,#10b981); }
.progress--warning span { background: linear-gradient(90deg,#fbbf24,#f59e0b); }

/* Page header */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head__text h2 { font-size: 24px; font-weight: var(--fw-black); letter-spacing: -.03em; }
.page-head__text p { color: var(--text-muted); font-size: 14px; margin-top: 2px; }
.page-head__actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* Filter pills */
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font-size: 13px; font-weight: var(--fw-medium); color: var(--text-muted);
  padding: 7px 14px; border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--border);
  transition: all var(--t-fast);
}
.pill:hover { color: var(--text); border-color: var(--border-2); }
.pill.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Empty state */
.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty__icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: var(--r-lg);
  display: grid; place-items: center; background: var(--surface-3); color: var(--text-dim); }
.empty__icon svg { width: 26px; height: 26px; }
.empty h3 { font-size: 16px; color: var(--text); margin-bottom: 4px; }
.empty p { font-size: 14px; max-width: 360px; margin: 0 auto 16px; }

/* Segment progress (tip pool, etc) */
.kv { display: flex; align-items: center; justify-content: space-between; font-size: 13px; padding: 7px 0; }
.kv + .kv { border-top: 1px solid var(--border); }
.kv span:first-child { color: var(--text-muted); }
.kv span:last-child { font-weight: var(--fw-semi); font-variant-numeric: tabular-nums; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px;
  background: rgba(5,8,16,.6); backdrop-filter: blur(6px);
  animation: fadeIn var(--t) var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 480px; background: var(--elevated);
  border: 1px solid var(--border-2); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: modalIn var(--t-slow) var(--ease-out);
}
.modal--wide { max-width: 640px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(.97); } to { opacity: 1; transform: none; } }
.modal__head { display: flex; align-items: center; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.modal__head h3 { font-size: 17px; }
.modal__head p { font-size: 13px; color: var(--text-muted); }
.modal__close { margin-left: auto; }
.modal__body { padding: 22px; max-height: 70vh; overflow-y: auto; }
.modal__foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--border); background: var(--surface); }

/* Forms */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field > label { display: block; font-size: 13px; font-weight: var(--fw-semi); margin-bottom: 7px; }
.field__row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.input, .select, .textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 11px 13px; font-size: 14px; transition: all var(--t-fast); outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand-1); box-shadow: 0 0 0 3px rgba(99,102,241,.18); }
.textarea { resize: vertical; min-height: 84px; }
.field__hint { font-size: 12px; color: var(--text-dim); margin-top: 6px; }

/* Toasts */
.toast-stack { position: fixed; bottom: 24px; right: 24px; z-index: 120; display: flex; flex-direction: column; gap: 12px; }
.toast {
  display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: 380px;
  padding: 14px 16px; border-radius: var(--r-md); background: var(--elevated);
  border: 1px solid var(--border-2); box-shadow: var(--shadow-lg);
  animation: toastIn var(--t-slow) var(--ease-out);
}
.toast.is-leaving { animation: toastOut var(--t) var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }
.toast__icon { width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center; flex: none; }
.toast__icon svg { width: 17px; height: 17px; }
.toast--success .toast__icon { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.toast--danger .toast__icon { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.toast--info .toast__icon { background: var(--brand-grad-soft); color: var(--brand-1); }
.toast__body { flex: 1; }
.toast__body strong { font-size: 14px; display: block; }
.toast__body small { font-size: 12.5px; color: var(--text-muted); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tab {
  padding: 11px 16px; font-size: 14px; font-weight: var(--fw-semi); color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all var(--t-fast);
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--brand-1); }

/* ----------------------------------------------------------------------------
   5. CHARTS
   ---------------------------------------------------------------------------- */
.chart { width: 100%; position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-grid line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 5; }
.chart-axis { fill: var(--text-dim); font-size: 11px; font-weight: 500; }

/* Area */
.chart-area__line {
  fill: none; stroke: var(--brand-1); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 3000; stroke-dashoffset: 3000; animation: drawLine 1.4s var(--ease-out) forwards;
}
@keyframes drawLine { to { stroke-dashoffset: 0; } }
.chart-area__fill { animation: fadeIn .9s var(--ease) .3s both; }
.chart-band { cursor: crosshair; }
.chart-hover-dot { fill: var(--surface); stroke: var(--brand-1); stroke-width: 3; transition: opacity var(--t-fast);
  filter: drop-shadow(0 0 6px rgba(99,102,241,.7)); }

/* Bars — grow up from baseline */
.chart-bar { transform-box: fill-box; transform-origin: bottom; animation: barGrow .7s var(--ease-out) both; transition: opacity var(--t-fast); }
.chart-bar:hover { opacity: .82; }
@keyframes barGrow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* Donut — sweep in */
.donut-arc { animation: donutIn 1s var(--ease-out) both; }
@keyframes donutIn { from { opacity: 0; } to { opacity: 1; } }
.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--elevated); border: 1px solid var(--border-2); border-radius: var(--r-sm);
  padding: 8px 11px; font-size: 12.5px; box-shadow: var(--shadow-lg); white-space: nowrap;
  transform: translate(-50%, -120%); transition: opacity var(--t-fast); opacity: 0;
}
.chart-tooltip strong { font-size: 14px; display: block; font-variant-numeric: tabular-nums; }
.chart-tooltip small { color: var(--text-muted); }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; }
.chart-legend__item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-muted); }
.chart-legend__dot { width: 10px; height: 10px; border-radius: 3px; }

/* Donut */
.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut { position: relative; flex: none; }
.donut__center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.donut__center strong { font-size: 22px; font-weight: var(--fw-black); }
.donut__center small { font-size: 11px; color: var(--text-muted); }

/* ----------------------------------------------------------------------------
   6. VIEW HELPERS
   ---------------------------------------------------------------------------- */
/* Chatbot */
.chat { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - 88px); min-height: 420px; }
.chat__log { flex: 1; overflow-y: auto; padding: 8px 4px 18px; display: flex; flex-direction: column; gap: 14px; }
.chat__msg { display: flex; gap: 11px; max-width: 78%; }
.chat__msg--user { align-self: flex-end; flex-direction: row-reverse; }
.chat__bubble { padding: 12px 15px; border-radius: var(--r-lg); font-size: 14px; line-height: 1.55; }
.chat__msg--bot .chat__bubble { background: var(--surface-2); border: 1px solid var(--border); border-top-left-radius: 4px; }
.chat__msg--user .chat__bubble { background: var(--brand-grad); color: #fff; border-top-right-radius: 4px; }
.chat__bubble ul { margin: 6px 0 0; padding-left: 18px; list-style: disc; }
.chat__bubble ul li { margin: 3px 0; }
.chat__avatar { width: 34px; height: 34px; border-radius: var(--r-full); display: grid; place-items: center; flex: none; }
.chat__avatar svg { width: 18px; height: 18px; }
.chat__avatar--bot { background: var(--brand-grad-soft); color: var(--brand-1); }
.spark { display: block; }
.chat__suggestions { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 0 14px; }
.chat__suggestion { font-size: 13px; padding: 8px 13px; border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); transition: all var(--t-fast); text-align: left; }
.chat__suggestion:hover { color: var(--text); border-color: var(--brand-1); }
.chat__form { display: flex; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.chat__form .input { border-radius: var(--r-full); }
.chat__typing { display: inline-flex; gap: 4px; align-items: center; }
.chat__typing span { width: 6px; height: 6px; border-radius: 99px; background: var(--text-dim); animation: typing 1.2s infinite; }
.chat__typing span:nth-child(2) { animation-delay: .2s; }
.chat__typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typing { 0%,60%,100%{ transform: translateY(0); opacity:.4;} 30%{ transform: translateY(-4px); opacity:1;} }

/* Announcement item */
.note { display: flex; gap: 14px; padding: 16px 0; border-top: 1px solid var(--border); }
.note:first-child { border-top: none; }
.note__mark { width: 4px; border-radius: 99px; flex: none; background: var(--brand-grad); }
.note__mark--warning { background: var(--warning); }
.note__mark--danger { background: var(--danger); }
.note__body { flex: 1; }
.note__body h4 { font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.note__body p { font-size: 13.5px; color: var(--text-muted); margin-top: 4px; line-height: 1.55; }
.note__meta { font-size: 12px; color: var(--text-dim); margin-top: 7px; }

/* Schedule */
.shift { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-top: 1px solid var(--border); }
.shift:first-child { border-top: none; }
.shift__day { width: 50px; text-align: center; flex: none; }
.shift__day strong { display: block; font-size: 18px; font-weight: var(--fw-bold); }
.shift__day small { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.shift__time { font-weight: var(--fw-semi); font-size: 14px; }
.shift__role { font-size: 12.5px; color: var(--text-muted); }

/* Helpers */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-sm { font-size: 13px; }
.fw-semi { font-weight: var(--fw-semi); }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.tabular { font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }

/* Overlay */
.overlay { display: none; }

/* ----------------------------------------------------------------------------
   7. RESPONSIVE
   ---------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .grid--main { grid-template-columns: 1fr; }
  .grid--3 { grid-template-columns: repeat(2, 1fr); }
  .span-2 { grid-column: auto; }
  .search { width: 220px; }
}
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 60;
    transform: translateX(-100%); transition: transform var(--t) var(--ease);
  }
  .app.is-mobile-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app.is-mobile-open .overlay { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(5,8,16,.55); backdrop-filter: blur(3px); }
  .topbar__menu { display: grid; }
  .grid--2, .grid--3 { grid-template-columns: 1fr; }
  .search, .dev-switcher__tag { display: none; }
  .topbar__heading h1 { font-size: 17px; }
  .content { padding: 20px 16px 48px; }
}
@media (max-width: 560px) {
  .dev-switcher { padding: 4px; }
  .segmented__btn { padding: 6px 10px; font-size: 12px; }
  .field__row { grid-template-columns: 1fr; }
  .page-head__actions { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
