/*
 * public/bios.css — design system + component styles.
 * ──────────────────────────────────────────────────────────────────
 * Color ramps: fixed hue+saturation per role, lightness swept
 * [95,90,80,70,60,50,40,30,20,10,5]%. Minimalist palette (2026-08-18
 * revision): text/background are near-identical true neutral grays
 * (hue 222, sat 9%/5% — barely tinted, reads as clean gray/white
 * rather than the earlier visibly-colored ramps); primary is a single
 * restrained blue accent; secondary/accent are muted, low-saturation
 * supporting colors reserved for data (chart series, the "up"
 * indicator) rather than structural chrome. Light values live on the
 * bare :root; dark values apply two ways so the manual toggle
 * (theme.js) can win over the OS setting in both directions: guarded
 * media query, and an explicit [data-theme="dark"] override.
 * ──────────────────────────────────────────────────────────────────
 */
:root {
  --text-50: #f1f2f3;
  --text-100: #e3e5e8;
  --text-200: #c7cad1;
  --text-300: #acb0b9;
  --text-400: #9095a2;
  --text-500: #747b8b;
  --text-600: #5d626f;
  --text-700: #464a53;
  --text-800: #2e3138;
  --text-900: #17191c;
  --text-950: #0c0c0e;

  --background-50: #f2f2f3;
  --background-100: #e4e5e7;
  --background-200: #c9cbcf;
  --background-300: #afb1b6;
  --background-400: #94979e;
  --background-500: #797d86;
  --background-600: #61646b;
  --background-700: #494b50;
  --background-800: #303236;
  --background-900: #18191b;
  --background-950: #0c0c0d;

  --primary-50: #ecf2f8;
  --primary-100: #dae4f1;
  --primary-200: #b5cae3;
  --primary-300: #8fafd6;
  --primary-400: #6a94c8;
  --primary-500: #457aba;
  --primary-600: #376195;
  --primary-700: #294970;
  --primary-800: #1c314a;
  --primary-900: #0e1825;
  --primary-950: #070c13;

  --secondary-50: #eff4f5;
  --secondary-100: #e0e8eb;
  --secondary-200: #c1d1d7;
  --secondary-300: #a2bac3;
  --secondary-400: #83a3af;
  --secondary-500: #638d9c;
  --secondary-600: #50707c;
  --secondary-700: #3c545d;
  --secondary-800: #28383e;
  --secondary-900: #141c1f;
  --secondary-950: #0a0e10;

  --accent-50: #eef6f3;
  --accent-100: #deede7;
  --accent-200: #bddbcf;
  --accent-300: #9cc9b6;
  --accent-400: #7ab89e;
  --accent-500: #59a686;
  --accent-600: #47856b;
  --accent-700: #366350;
  --accent-800: #244236;
  --accent-900: #12211b;
  --accent-950: #09110d;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --text-50: #0c0c0e;
    --text-100: #17191c;
    --text-200: #2e3138;
    --text-300: #464a53;
    --text-400: #5d626f;
    --text-500: #747b8b;
    --text-600: #9095a2;
    --text-700: #acb0b9;
    --text-800: #c7cad1;
    --text-900: #e3e5e8;
    --text-950: #f1f2f3;

    --background-50: #0c0c0d;
    --background-100: #18191b;
    --background-200: #303236;
    --background-300: #494b50;
    --background-400: #61646b;
    --background-500: #797d86;
    --background-600: #94979e;
    --background-700: #afb1b6;
    --background-800: #c9cbcf;
    --background-900: #e4e5e7;
    --background-950: #f2f2f3;

    --primary-50: #070c13;
    --primary-100: #0e1825;
    --primary-200: #1c314a;
    --primary-300: #294970;
    --primary-400: #376195;
    --primary-500: #457aba;
    --primary-600: #6a94c8;
    --primary-700: #8fafd6;
    --primary-800: #b5cae3;
    --primary-900: #dae4f1;
    --primary-950: #ecf2f8;

    --secondary-50: #0a0e10;
    --secondary-100: #141c1f;
    --secondary-200: #28383e;
    --secondary-300: #3c545d;
    --secondary-400: #50707c;
    --secondary-500: #638d9c;
    --secondary-600: #83a3af;
    --secondary-700: #a2bac3;
    --secondary-800: #c1d1d7;
    --secondary-900: #e0e8eb;
    --secondary-950: #eff4f5;

    --accent-50: #09110d;
    --accent-100: #12211b;
    --accent-200: #244236;
    --accent-300: #366350;
    --accent-400: #47856b;
    --accent-500: #59a686;
    --accent-600: #7ab89e;
    --accent-700: #9cc9b6;
    --accent-800: #bddbcf;
    --accent-900: #deede7;
    --accent-950: #eef6f3;
  }
}

:root[data-theme="dark"] {
  --text-50: #0c0c0e;
  --text-100: #17191c;
  --text-200: #2e3138;
  --text-300: #464a53;
  --text-400: #5d626f;
  --text-500: #747b8b;
  --text-600: #9095a2;
  --text-700: #acb0b9;
  --text-800: #c7cad1;
  --text-900: #e3e5e8;
  --text-950: #f1f2f3;

  --background-50: #0c0c0d;
  --background-100: #18191b;
  --background-200: #303236;
  --background-300: #494b50;
  --background-400: #61646b;
  --background-500: #797d86;
  --background-600: #94979e;
  --background-700: #afb1b6;
  --background-800: #c9cbcf;
  --background-900: #e4e5e7;
  --background-950: #f2f2f3;

  --primary-50: #070c13;
  --primary-100: #0e1825;
  --primary-200: #1c314a;
  --primary-300: #294970;
  --primary-400: #376195;
  --primary-500: #457aba;
  --primary-600: #6a94c8;
  --primary-700: #8fafd6;
  --primary-800: #b5cae3;
  --primary-900: #dae4f1;
  --primary-950: #ecf2f8;

  --secondary-50: #0a0e10;
  --secondary-100: #141c1f;
  --secondary-200: #28383e;
  --secondary-300: #3c545d;
  --secondary-400: #50707c;
  --secondary-500: #638d9c;
  --secondary-600: #83a3af;
  --secondary-700: #a2bac3;
  --secondary-800: #c1d1d7;
  --secondary-900: #e0e8eb;
  --secondary-950: #eff4f5;

  --accent-50: #09110d;
  --accent-100: #12211b;
  --accent-200: #244236;
  --accent-300: #366350;
  --accent-400: #47856b;
  --accent-500: #59a686;
  --accent-600: #7ab89e;
  --accent-700: #9cc9b6;
  --accent-800: #bddbcf;
  --accent-900: #deede7;
  --accent-950: #eef6f3;
}

/* ── semantic + system tokens ── */
:root {
  --up: var(--accent-600);
  --down: #ca5649;
  --down-tint: color-mix(in srgb, var(--down) 14%, var(--background-50));

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px; --space-12: 48px;

  --radius-sm: 7px; --radius-md: 11px; --radius-lg: 16px; --radius-xl: 22px; --radius-full: 999px;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --text-xs: .72rem; --text-sm: .8125rem; --text-base: .875rem; --text-md: .95rem;
  --text-lg: 1.15rem; --text-xl: 1.55rem; --text-2xl: 2.1rem;

  --ease: cubic-bezier(.4,0,.2,1);
  --t-fast: 120ms var(--ease);
  --t-base: 200ms var(--ease);

  --shadow-sm: 0 1px 2px rgba(10,14,20,.05), 0 1px 1px rgba(10,14,20,.04);
  --shadow-md: 0 6px 16px rgba(10,14,20,.08), 0 2px 5px rgba(10,14,20,.04);
  --shadow-lg: 0 20px 48px rgba(10,14,20,.16), 0 6px 14px rgba(10,14,20,.06);

  --sidebar-w: 240px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
    --shadow-md: 0 6px 20px rgba(0,0,0,.4);
    --shadow-lg: 0 24px 56px rgba(0,0,0,.55);
  }
}
:root[data-theme="dark"] {
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow-md: 0 6px 20px rgba(0,0,0,.4);
  --shadow-lg: 0 24px 56px rgba(0,0,0,.55);
}

/* ── reset + base ── */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font-sans); font-size: var(--text-base);
  background: var(--background-50); color: var(--text-950);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button { font-family: inherit; }
input, select { font-family: inherit; color-scheme: inherit; }
::selection { background: color-mix(in srgb, var(--primary-500) 35%, transparent); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--background-300); border-radius: var(--radius-full); border: 2px solid var(--background-50); }
::-webkit-scrollbar-track { background: transparent; }
a { color: inherit; }

/* accent-color themes native checkboxes/radios/range without a custom
   SVG replacement — a light touch that still looks intentional. */
input[type=checkbox], input[type=radio] { accent-color: var(--primary-600); width: 15px; height: 15px; cursor: pointer; }

/* ══════════════════════════════════════════════════════════════════
   APP SHELL — sidebar + main content, shared by index.html/admin.html
   ══════════════════════════════════════════════════════════════════ */
:root { --sidebar-w-collapsed: 68px; }
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--background-100); border-right: 1px solid var(--background-200);
  height: 100vh; position: sticky; top: 0;
}
/* The width transition is opt-in via this class, added a tick after
   first paint (shell.js) — declaring it unconditionally on .sidebar
   makes some browsers animate the very first layout (auto/0 -> 240px)
   as an on-load flicker, since `transition` can catch that initial
   resolution too, not just later class-toggle changes. */
.sidebar.transitions-ready { transition: width var(--t-base); }
.sidebar-brand {
  display: flex; align-items: center; gap: 9px; padding: 16px 12px 14px 18px;
  font-weight: 700; font-size: var(--text-md); letter-spacing: -.01em; white-space: nowrap; overflow: hidden;
}
/* The real Kausar logo is a wide wordmark (171x43), not a square icon,
   so it only appears where there's room to show it at readable size —
   expanded sidebar, mobile topbar, login. .brand-icon (the old square
   gradient badge) is the fallback for the collapsed rail (68px, see
   below), where the wordmark can't fit at any legible size. */
.brand-logo { height: 24px; width: auto; display: block; }
.brand-suffix { overflow: hidden; text-overflow: ellipsis; }
.brand-icon {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0; display: none;
  background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
  place-items: center; color: var(--primary-50); font-size: 13px; font-weight: 800;
}
.sidebar-source-switch { display: flex; gap: 4px; padding: 0 14px 10px; flex-wrap: wrap; }
.source-pill {
  border: none; background: var(--background-200); color: var(--text-700); border-radius: var(--radius-full);
  padding: 5px 11px; font-size: var(--text-xs); font-weight: 600; cursor: pointer; transition: background var(--t-fast), color var(--t-fast);
}
.source-pill:hover { background: var(--background-300); }
.source-pill.active { background: var(--primary-600); color: var(--primary-50); }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-section-label {
  font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-500); padding: 14px 10px 6px; white-space: nowrap;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-700); text-decoration: none; font-size: var(--text-sm); font-weight: 500;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left; white-space: nowrap; overflow: hidden;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-item:hover { background: var(--background-200); color: var(--text-950); }
.nav-item.active { background: color-mix(in srgb, var(--primary-500) 16%, var(--background-100)); color: var(--primary-700); font-weight: 600; }
.nav-item .nav-icon { display: inline-flex; width: 18px; flex-shrink: 0; }
.nav-item .nav-icon svg { width: 16px; height: 16px; }
.nav-item-sub { font-size: var(--text-xs); color: var(--text-500); font-weight: 400; margin-left: auto; }

.sidebar-footer { border-top: 1px solid var(--background-200); padding: 10px; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm); border: 1px solid transparent; background: none;
  color: var(--text-600); display: grid; place-items: center; cursor: pointer; font-size: 15px; flex-shrink: 0;
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--background-200); color: var(--text-950); }
.icon-btn svg { width: 16px; height: 16px; }
.sidebar-collapse-btn { margin-left: auto; }
.sidebar.collapsed .sidebar-collapse-btn { color: var(--primary-600); }

.user-menu { position: relative; flex: 1; min-width: 0; }
.user-menu-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 7px; border-radius: var(--radius-sm);
  border: none; background: none; cursor: pointer; text-align: left; color: var(--text-950);
  transition: background var(--t-fast);
}
.user-menu-trigger:hover { background: var(--background-200); }
.avatar {
  width: 26px; height: 26px; border-radius: var(--radius-full); flex-shrink: 0; background: var(--secondary-600);
  color: var(--secondary-50); display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.user-menu-name { font-size: var(--text-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-dropdown {
  position: absolute; bottom: calc(100% + 6px); left: 0; min-width: 190px; background: var(--background-100);
  border: 1px solid var(--background-300); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  padding: 6px; display: none; flex-direction: column; gap: 1px; z-index: 320;
}
.user-menu-dropdown.open { display: flex; animation: pop-in var(--t-base); }
.user-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--radius-sm); border: none;
  background: none; color: var(--text-800); font-size: var(--text-sm); cursor: pointer; text-decoration: none;
  transition: background var(--t-fast);
}
.user-menu-item:hover { background: var(--background-200); color: var(--text-950); }
.user-menu-item.danger:hover { background: var(--down-tint); color: var(--down); }
.user-menu-item-icon { display: inline-flex; flex-shrink: 0; color: var(--text-500); }
.user-menu-email { padding: 6px 10px 8px; font-size: var(--text-xs); color: var(--text-500); border-bottom: 1px solid var(--background-200); margin-bottom: 4px; }

.main-content { flex: 1; min-width: 0; padding: 26px 32px 60px; max-width: 1320px; }

@keyframes pop-in { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ── collapsed rail (desktop only — see the ≤880px block below for why) ── */
@media (min-width: 881px) {
  .sidebar.collapsed { width: var(--sidebar-w-collapsed); }
  .sidebar.collapsed .brand-logo,
  .sidebar.collapsed .brand-suffix,
  .sidebar.collapsed .sidebar-source-switch,
  .sidebar.collapsed .sidebar-section-label,
  .sidebar.collapsed .nav-item span:not(.nav-icon),
  .sidebar.collapsed .nav-item-sub,
  .sidebar.collapsed .user-menu-name { display: none; }
  .sidebar.collapsed .brand-icon { display: grid; }
  .sidebar.collapsed .sidebar-brand { flex-direction: column; gap: 10px; padding: 16px 8px 12px; }
  .sidebar.collapsed .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }
  .sidebar.collapsed .sidebar-footer { flex-direction: column; }
  .sidebar.collapsed .user-menu-trigger { justify-content: center; padding: 5px; }
  .sidebar.collapsed .sidebar-collapse-btn { margin-left: 0; }
}

/* ── mobile: sidebar becomes an off-canvas drawer, opened via a fixed
   top bar's hamburger button. Collapse (the rail above) is a desktop
   concept only — on a hidden-by-default drawer there's nothing to
   save space from, so opening it always shows full labels. ── */
.mobile-topbar {
  display: none; align-items: center; gap: 12px; position: fixed; top: 0; left: 0; right: 0; height: 56px;
  padding: 0 8px 0 6px; background: var(--background-100); border-bottom: 1px solid var(--background-200); z-index: 150;
}
.mobile-topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: var(--text-md); }
.mobile-scrim {
  display: none; position: fixed; inset: 0; background: color-mix(in srgb, var(--text-950) 42%, transparent);
  z-index: 290; opacity: 0; pointer-events: none; transition: opacity var(--t-base);
}
.mobile-scrim.in { opacity: 1; pointer-events: auto; }

@media (max-width: 880px) {
  .mobile-topbar { display: flex; }
  .mobile-scrim { display: block; }
  .sidebar, .sidebar.collapsed {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 300; width: min(280px, 82vw);
    transform: translateX(-100%); transition: transform var(--t-base); box-shadow: var(--shadow-lg);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-collapse-btn { display: none; }
  .main-content { padding: 74px 16px 40px; }
}

/* ══════════════════════════════════════════════════════════════════
   PAGE HEADER / TYPOGRAPHY
   ══════════════════════════════════════════════════════════════════ */
.page-eyebrow { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-500); margin-bottom: 4px; }
.page-title { font-size: var(--text-xl); font-weight: 700; letter-spacing: -.01em; margin: 0 0 3px; }
.page-subtitle { font-size: var(--text-sm); color: var(--text-600); margin: 0 0 20px; }
.back-link {
  color: var(--text-600); text-decoration: none; font-size: var(--text-sm); font-weight: 500;
  display: inline-flex; align-items: center; gap: 4px; margin-bottom: 14px; transition: color var(--t-fast);
}
.back-link:hover { color: var(--primary-600); }

.header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; }

.scope-pill {
  font-size: var(--text-xs); color: var(--primary-700); background: color-mix(in srgb, var(--primary-500) 12%, var(--background-50));
  border: 1px solid color-mix(in srgb, var(--primary-500) 30%, var(--background-50));
  border-radius: var(--radius-full); padding: 6px 12px 6px 10px; margin-bottom: 18px; display: inline-flex; align-items: center; gap: 6px;
}
.scope-pill::before { content: '◈'; font-size: 11px; }

/* ══════════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-sm); padding: 8px 15px; font-size: var(--text-sm); font-weight: 600;
  cursor: pointer; border: 1px solid transparent; transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { cursor: default; opacity: .55; transform: none; }
.btn-primary { background: var(--primary-600); color: var(--primary-50); box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--primary-700); }
.btn-secondary { background: var(--background-100); color: var(--text-800); border-color: var(--background-300); }
.btn-secondary:hover:not(:disabled) { background: var(--background-200); border-color: var(--background-400); }
.btn-ghost { background: transparent; color: var(--text-600); }
.btn-ghost:hover:not(:disabled) { background: var(--background-200); color: var(--text-950); }
.btn-danger { background: transparent; color: var(--text-600); border-color: var(--background-300); }
.btn-danger:hover:not(:disabled) { background: var(--down-tint); color: var(--down); border-color: color-mix(in srgb, var(--down) 45%, var(--background-50)); }
.btn-sm { padding: 5px 10px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-icon { width: 34px; padding: 0; }
.btn-block { width: 100%; }
.btn-spinner {
  width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════════
   CARDS — source tiles, dashboard cards, chart tiles
   ══════════════════════════════════════════════════════════════════ */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }

.entity-card {
  display: flex; flex-direction: column; gap: 10px; background: var(--background-100);
  border: 1px solid var(--background-200); border-radius: var(--radius-lg); padding: 18px;
  text-decoration: none; color: inherit; cursor: pointer;
  transition: border-color var(--t-base), box-shadow var(--t-base), transform var(--t-base);
}
.entity-card:hover { border-color: var(--primary-400); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.entity-card-disabled { opacity: .55; cursor: default; }
.entity-card-disabled:hover { border-color: var(--background-200); box-shadow: none; transform: none; }
.entity-icon {
  width: 40px; height: 40px; border-radius: var(--radius-md); display: grid; place-items: center; color: var(--primary-600);
  background: color-mix(in srgb, var(--primary-500) 16%, var(--background-100));
}
.entity-card h3 { font-size: var(--text-md); font-weight: 650; }
.entity-card p { font-size: var(--text-sm); color: var(--text-600); line-height: 1.4; }
.badge-soon {
  font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-500);
  background: var(--background-200); border-radius: var(--radius-full); padding: 3px 9px; align-self: flex-start;
}

.section-heading {
  grid-column: 1 / -1; font-size: var(--text-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-500); margin: 8px 0 -2px; padding-top: 18px;
  border-top: 1px solid var(--background-200);
}
.section-heading:first-child { border-top: none; padding-top: 0; margin-top: 0; }

.tile-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.tile {
  background: var(--background-100); border: 1px solid var(--background-200); border-radius: var(--radius-lg);
  padding: 16px 18px; overflow: hidden; box-shadow: var(--shadow-sm); transition: box-shadow var(--t-base);
}
.tile:hover { box-shadow: var(--shadow-md); }
.tile-title { font-size: var(--text-sm); font-weight: 650; color: var(--text-800); margin-bottom: 10px; letter-spacing: -.005em; }
.tile-body { position: relative; }

@media (max-width: 760px) { .tile-grid > * { grid-column: 1 / -1 !important; } }

/* ══════════════════════════════════════════════════════════════════
   SKELETON / LOADING / EMPTY / ERROR
   ══════════════════════════════════════════════════════════════════ */
.skeleton-block {
  height: 100%; min-height: 64px; border-radius: var(--radius-md);
  background: linear-gradient(100deg, var(--background-200) 20%, var(--background-300) 40%, var(--background-200) 60%);
  background-size: 300% 100%; animation: shimmer 1.5s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 140% 0; } 100% { background-position: -40% 0; } }
.skeleton { color: var(--text-500); font-size: var(--text-sm); padding: 20px 0; }

.note {
  color: var(--text-600); font-size: var(--text-sm); padding: 14px 16px; background: var(--background-100);
  border: 1px dashed var(--background-300); border-radius: var(--radius-md);
}
.ms-empty { padding: 8px; font-size: var(--text-sm); color: var(--text-500); }
.error-pill {
  color: var(--down); font-size: var(--text-sm); background: var(--down-tint);
  border: 1px solid color-mix(in srgb, var(--down) 35%, var(--background-50));
  border-radius: var(--radius-md); padding: 10px 13px; display: flex; align-items: center; gap: 7px;
}

/* ══════════════════════════════════════════════════════════════════
   KPI
   ══════════════════════════════════════════════════════════════════ */
/* One real .tile per KPI (see app.js#loadKpiRow) instead of a single
   wide tile with an internal flex row — auto-fit keeps every cell the
   same width and wraps to fewer, still-equal columns on narrow screens
   rather than the old flex-wrap's uneven staggering. */
.kpi-tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi-tile-grid .tile { min-height: 104px; }
.kpi-row-value { font-size: var(--text-2xl); font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi-row-sub { font-size: var(--text-sm); color: var(--text-600); margin-top: 3px; font-variant-numeric: tabular-nums; }
.kpi-row-delta { margin-top: 8px; }
.kpi-row-note { font-size: 10.5px; color: var(--text-500); margin-top: 8px; line-height: 1.4; }

.kpi-value { font-size: var(--text-2xl); font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi-compare { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: var(--text-sm); }
.kpi-compare-label { color: var(--text-600); }
.delta-pill {
  display: inline-flex; align-items: center; gap: 3px; border-radius: var(--radius-full); padding: 2px 8px;
  font-size: var(--text-xs); font-weight: 700; font-variant-numeric: tabular-nums;
}
.delta-pill.up { color: var(--up); background: color-mix(in srgb, var(--up) 15%, var(--background-50)); }
.delta-pill.down { color: var(--down); background: var(--down-tint); }
.kpi-footnote { font-size: var(--text-xs); color: var(--text-500); margin-top: 12px; line-height: 1.5; }

/* ══════════════════════════════════════════════════════════════════
   FUNNEL
   ══════════════════════════════════════════════════════════════════ */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 130px 1fr 130px; align-items: center; gap: 14px; }
.funnel-stage-label { font-size: var(--text-sm); font-weight: 600; color: var(--text-800); text-align: right; }
.funnel-track { background: var(--background-200); border-radius: 8px; height: 30px; position: relative; overflow: hidden; }
.funnel-fill {
  height: 100%; border-radius: 8px; display: flex; align-items: center; padding-left: 12px;
  font-size: var(--text-xs); font-weight: 700; color: var(--primary-50); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.funnel-count { font-size: var(--text-sm); font-variant-numeric: tabular-nums; color: var(--text-700); }
.funnel-count b { color: var(--text-950); font-weight: 700; }
.funnel-gap {
  margin-top: 6px; display: flex; align-items: center; gap: 10px; background: var(--down-tint);
  border: 1px solid color-mix(in srgb, var(--down) 30%, var(--background-50)); border-radius: var(--radius-md); padding: 11px 15px;
}
.funnel-gap svg { flex-shrink: 0; color: var(--down); }
.funnel-gap span { font-size: var(--text-sm); color: var(--text-800); line-height: 1.5; }
.funnel-gap b { color: var(--down); }

.chart-footnote { font-size: 10.5px; color: var(--text-500); margin-top: 8px; text-align: center; }

@media (max-width: 700px) {
  .funnel-row { grid-template-columns: 90px 1fr 90px; gap: 8px; }
  .funnel-stage-label { font-size: var(--text-xs); }
}

/* ══════════════════════════════════════════════════════════════════
   TOOLTIP
   ══════════════════════════════════════════════════════════════════ */
.bios-tip {
  position: fixed; z-index: 1000; pointer-events: none; opacity: 0; transition: opacity var(--t-fast);
  background: var(--background-800); border-radius: var(--radius-sm); padding: 7px 10px; box-shadow: var(--shadow-md);
  font-size: var(--text-xs); color: var(--background-50); max-width: 260px; line-height: 1.45;
}
.bios-tip b { color: var(--background-50); }

/* ══════════════════════════════════════════════════════════════════
   FILTER TOOLBAR + DRAWER
   ══════════════════════════════════════════════════════════════════ */
.filter-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.filters-open-btn {
  background: var(--background-100); border: 1px solid var(--background-300); color: var(--text-950);
  border-radius: var(--radius-full); padding: 8px 15px; font-size: var(--text-sm); cursor: pointer; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.filters-open-btn:hover { border-color: var(--primary-400); box-shadow: var(--shadow-sm); }
.filter-count {
  background: var(--primary-600); color: var(--primary-50); border-radius: var(--radius-full);
  font-size: 10.5px; font-weight: 700; padding: 1px 6px; min-width: 17px; text-align: center;
}
.filter-summary { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-chip-date {
  background: none; border: none; padding: 0; font: inherit; font-size: var(--text-sm); color: var(--text-600); cursor: pointer;
  transition: color var(--t-fast);
}
.filter-chip-date:hover { color: var(--primary-600); }
.filter-chip {
  display: inline-flex; align-items: center; gap: 2px; background: var(--background-100); border: 1px solid var(--background-300);
  border-radius: var(--radius-full); padding: 3px 4px 3px 12px; font-size: var(--text-xs); color: var(--text-700);
}
.filter-chip-label { background: none; border: none; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.filter-chip-label:hover { color: var(--primary-600); }
.filter-chip-remove {
  background: none; border: none; padding: 4px; border-radius: 50%; display: grid; place-items: center;
  color: var(--text-500); cursor: pointer; transition: background var(--t-fast), color var(--t-fast);
}
.filter-chip-remove:hover { background: var(--background-300); color: var(--down); }

.drawer-overlay {
  position: fixed; inset: 0; background: color-mix(in srgb, var(--text-950) 42%, transparent); z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity var(--t-base); backdrop-filter: blur(2px);
}
.drawer-overlay.in { opacity: 1; pointer-events: auto; }
.drawer-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); background: var(--background-100);
  border-left: 1px solid var(--background-300); box-shadow: var(--shadow-lg); z-index: 201;
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform var(--t-base);
}
.drawer-panel.in { transform: translateX(0); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--background-200); flex-shrink: 0; }
.drawer-header h2 { font-size: var(--text-lg); font-weight: 700; }
.drawer-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; flex: 1; }
.drawer-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--background-200); flex-shrink: 0; }

/* generic centered modal — used by the admin console */
.modal-overlay {
  position: fixed; inset: 0; background: color-mix(in srgb, var(--text-950) 45%, transparent); z-index: 200;
  display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; backdrop-filter: blur(2px);
  animation: fade-in var(--t-base);
}
.modal-panel {
  background: var(--background-100); border: 1px solid var(--background-300); border-radius: var(--radius-lg); width: 100%; max-width: 620px;
  max-height: calc(100vh - 96px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: modal-in var(--t-base);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--background-200); }
.modal-header h2 { font-size: var(--text-lg); font-weight: 700; }
.modal-close, .drawer-close {
  background: transparent; border: none; color: var(--text-600); font-size: 15px; cursor: pointer; width: 30px; height: 30px;
  border-radius: var(--radius-sm); display: grid; place-items: center; transition: background var(--t-fast), color var(--t-fast);
}
.modal-close:hover, .drawer-close:hover { background: var(--background-200); color: var(--text-950); }
.modal-body { padding: 18px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--background-200); flex-shrink: 0; }

.modal-fgrp { display: flex; flex-direction: column; gap: 6px; }
.fgrp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.modal-fgrp label { font-size: var(--text-xs); font-weight: 650; color: var(--text-700); text-transform: uppercase; letter-spacing: .03em; }

.ms-actions { display: flex; gap: 12px; flex-shrink: 0; }
.ms-action-link {
  background: none; border: none; padding: 0; margin: 0; font-size: var(--text-xs); font-weight: 650;
  color: var(--primary-600); cursor: pointer; transition: color var(--t-fast);
}
.ms-action-link:hover { color: var(--primary-800); text-decoration: underline; }

/* ══════════════════════════════════════════════════════════════════
   FORM CONTROLS
   ══════════════════════════════════════════════════════════════════ */
.date-controls { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.date-controls select, .date-controls input[type=date],
.input, .modal-fgrp input[type=email], .modal-fgrp input[type=text], .modal-fgrp select,
.grant-add-form select, .grant-add-form input[type=text], .grant-add-form input[type=email] {
  background: var(--background-50); border: 1px solid var(--background-300); color: var(--text-950);
  border-radius: var(--radius-sm); padding: 8px 10px; font-size: var(--text-sm); width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.date-controls select, .date-controls input[type=date] { width: auto; padding: 6px 9px; }
.date-controls input:focus, .date-controls select:focus, .input:focus,
.modal-fgrp input:focus, .modal-fgrp select:focus, .grant-add-form input:focus, .grant-add-form select:focus {
  outline: none; border-color: var(--primary-500); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-500) 22%, transparent);
}
.date-sep { color: var(--text-500); font-size: var(--text-sm); }
.date-error { display: none; color: var(--down); font-size: var(--text-xs); margin-top: 4px; }
.modal-fgrp code { background: var(--background-50); border: 1px solid var(--background-300); border-radius: 5px; padding: 2px 6px; color: var(--accent-700); font-size: .82em; }

.ms-search {
  background: var(--background-50); border: 1px solid var(--background-300); color: var(--text-950); border-radius: var(--radius-sm);
  padding: 7px 10px; font-size: var(--text-sm); margin-bottom: 2px;
}
.ms-search:focus { outline: none; border-color: var(--primary-500); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-500) 22%, transparent); }
.ms-list { max-height: 210px; overflow-y: auto; border: 1px solid var(--background-200); border-radius: var(--radius-md); padding: 4px; }
.ms-opt { display: flex; align-items: center; gap: 9px; padding: 7px 9px; font-size: var(--text-sm); border-radius: var(--radius-sm); cursor: pointer; }
.ms-opt:hover { background: var(--background-200); }

@media (max-width: 700px) {
  .drawer-panel { width: 100vw; }
  .modal-overlay { padding: 0; align-items: stretch; }
  .modal-panel { max-width: none; max-height: none; border-radius: 0; }
}
