/* ═══════════════════════════════════════════════════════════════════
   CYLVY DESIGN SYSTEM v2.0
   Premium B2B Intelligence UI
   ═══════════════════════════════════════════════════════════════════ */

/* ── Font smoothing ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

/* ══════════════════════════════════════════════════════════════════
   1. CSS CUSTOM PROPERTIES — LIGHT MODE
   ══════════════════════════════════════════════════════════════════ */
:root {
  /* shadcn/ui core tokens */
  --background:         0 0% 98%;
  --foreground:         224 40% 8%;
  --card:               0 0% 100%;
  --card-foreground:    224 40% 8%;
  --popover:            0 0% 100%;
  --popover-foreground: 224 40% 8%;
  --primary:            258 90% 60%;
  --primary-foreground: 0 0% 100%;
  --secondary:          220 16% 94%;
  --secondary-foreground: 224 40% 8%;
  --muted:              220 16% 94%;
  --muted-foreground:   220 12% 52%;
  --accent:             258 90% 60%;
  --accent-foreground:  0 0% 100%;
  --destructive:        0 84% 60%;
  --destructive-foreground: 0 0% 100%;
  --border:             220 16% 90%;
  --input:              220 16% 90%;
  --ring:               258 90% 60%;
  --radius:             0.5rem;

  /* Material surfaces */
  --s0: #FFFFFF;
  --s1: #F5F6F8;
  --s2: #ECEEF2;
  --s3: #E2E5EB;
  --s4: #D8DCE5;
  --s5: #C8CDD8;

  /* Chrome rim */
  --cr-bright:  rgba(255,255,255,0.95);
  --cr-light:   rgba(255,255,255,0.60);
  --cr-mid:     rgba(180,185,200,0.40);
  --cr-dark:    rgba(100,108,128,0.35);
  --cr-shadow:  rgba(60,68,88,0.25);

  /* Chromatic aberration */
  --chroma-r:   rgba(255,80,80,0.055);
  --chroma-b:   rgba(80,120,255,0.055);
  --chroma-v:   rgba(160,80,255,0.04);

  /* Specular */
  --hi-peak:    rgba(255,255,255,0.90);
  --hi-mid:     rgba(255,255,255,0.40);
  --hi-soft:    rgba(255,255,255,0.18);
  --hi-trace:   rgba(255,255,255,0.06);

  /* Glass */
  --glass-bg:     rgba(255,255,255,0.62);
  --glass-border: rgba(255,255,255,0.78);
  --glass-shadow: rgba(15,23,42,0.08);
  --glass-inset:  rgba(255,255,255,0.88);

  /* Prismatic */
  --prism-r:  rgba(255,100,100,0.18);
  --prism-y:  rgba(255,220,80,0.14);
  --prism-g:  rgba(80,220,160,0.14);
  --prism-b:  rgba(80,140,255,0.18);
  --prism-v:  rgba(180,80,255,0.16);

  /* Data display */
  --data-positive: #10B981;
  --data-negative: #EF4444;
  --data-neutral:  #6B7280;
  --data-accent:   hsl(var(--primary));

  /* Easing */
  --ease-spring:  cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-snap:    cubic-bezier(0.32, 0.72, 0, 1);
  --ease-smooth:  cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-in-back: cubic-bezier(0.36, 0, 0.66, -0.56);

  /* Duration */
  --dur-instant: 80ms;
  --dur-fast:    150ms;
  --dur-mid:     250ms;
  --dur-slow:    400ms;
  --dur-sweep:   550ms;

  /* Radius aliases */
  --r-sm:   6px;
  --r-md:   8px;
  --r-lg:   12px;
  --r-xl:   16px;
  --r-2xl:  20px;
  --r-full: 9999px;
}

/* ══════════════════════════════════════════════════════════════════
   2. DARK MODE TOKENS
   ══════════════════════════════════════════════════════════════════ */
.dark {
  --background:         224 40% 6%;
  --foreground:         210 20% 94%;
  --card:               224 35% 9%;
  --card-foreground:    210 20% 94%;
  --popover:            224 35% 9%;
  --popover-foreground: 210 20% 94%;
  --primary:            258 80% 65%;
  --primary-foreground: 0 0% 100%;
  --secondary:          224 28% 14%;
  --secondary-foreground: 210 20% 94%;
  --muted:              224 28% 14%;
  --muted-foreground:   220 12% 52%;
  --accent:             258 80% 65%;
  --accent-foreground:  0 0% 100%;
  --destructive:        0 62% 40%;
  --destructive-foreground: 0 0% 100%;
  --border:             224 28% 16%;
  --input:              224 28% 16%;
  --ring:               258 80% 65%;

  --s0: #2A3045;
  --s1: #222840;
  --s2: #1C2238;
  --s3: #161C30;
  --s4: #111828;
  --s5: #0C1220;

  --cr-bright:  rgba(255,255,255,0.18);
  --cr-light:   rgba(255,255,255,0.10);
  --cr-mid:     rgba(255,255,255,0.05);
  --cr-dark:    rgba(0,0,0,0.30);
  --cr-shadow:  rgba(0,0,0,0.50);

  --chroma-r:   rgba(255,80,80,0.08);
  --chroma-b:   rgba(80,140,255,0.08);
  --chroma-v:   rgba(180,80,255,0.06);

  --hi-peak:    rgba(255,255,255,0.14);
  --hi-mid:     rgba(255,255,255,0.07);
  --hi-soft:    rgba(255,255,255,0.04);
  --hi-trace:   rgba(255,255,255,0.02);

  --glass-bg:     rgba(17,24,40,0.70);
  --glass-border: rgba(255,255,255,0.08);
  --glass-shadow: rgba(0,0,0,0.40);
  --glass-inset:  rgba(255,255,255,0.06);

  --prism-r:  rgba(255,100,100,0.28);
  --prism-y:  rgba(255,220,80,0.22);
  --prism-g:  rgba(80,220,160,0.22);
  --prism-b:  rgba(80,140,255,0.28);
  --prism-v:  rgba(180,80,255,0.26);
}

/* ══════════════════════════════════════════════════════════════════
   3. BACKGROUND SYSTEM — Three Layers
   ══════════════════════════════════════════════════════════════════ */

/* Layer 0 — Cityscape photo, fixed, full-viewport */
html {
  background-image: url('/static/img/cityscape_light_compressed.jpg');
  background-size: cover;
  background-position: center top;
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-color: #F0F2F8; /* fallback if image fails */
}

/* Layer 1 — Crosshatch grid overlay */
html::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(180,190,210,0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(180,190,210,0.10) 1px, transparent 1px);
  background-size: 16px 16px;
}

.dark html::before,
html.dark::before {
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 16px 16px;
}

/* Layer 2 — Frosted wash over photo + grid */
body {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  background: rgba(235,238,248,0.82);
}

html.dark body {
  background: rgba(6,8,18,0.82);
}

/* Layer 3 — Content sits above all background layers */
#root, .app-shell {
  position: relative;
  z-index: 1;
}

/* ══════════════════════════════════════════════════════════════════
   4. TYPOGRAPHY
   ══════════════════════════════════════════════════════════════════ */
.text-display  { font-size: 3rem;     line-height: 1;    font-weight: 700; letter-spacing: -0.04em; }
.text-hero     { font-size: 2.25rem;  line-height: 1;    font-weight: 700; letter-spacing: -0.03em; }
.text-title    { font-size: 1.5rem;   line-height: 1.2;  font-weight: 600; letter-spacing: -0.02em; }
.text-heading  { font-size: 1.125rem; line-height: 1.4;  font-weight: 600; letter-spacing: -0.01em; }
.text-body     { font-size: 0.875rem; line-height: 1.6;  font-weight: 400; }
.text-small    { font-size: 0.8125rem;line-height: 1.5;  font-weight: 400; }
.text-caption  { font-size: 0.6875rem;line-height: 1.4;  font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; }
.text-mono     { font-family: 'JetBrains Mono', monospace; font-size: 0.8125rem; }

/* Data values — always tabular-nums */
.data-val-xl {
  font-size: 2.5rem; font-weight: 700; letter-spacing: -0.04em;
  line-height: 1; font-variant-numeric: tabular-nums;
  color: hsl(var(--foreground));
}
.data-val-lg {
  font-size: 1.875rem; font-weight: 700; letter-spacing: -0.03em;
  line-height: 1; font-variant-numeric: tabular-nums;
  color: hsl(var(--foreground));
}
.data-val {
  font-size: 1.25rem; font-weight: 600; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.data-val-sm {
  font-size: 0.9375rem; font-weight: 600; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.data-label {
  font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: hsl(var(--muted-foreground));
}
.data-delta-pos { font-size: 0.75rem; font-weight: 500; color: var(--data-positive); }
.data-delta-neg { font-size: 0.75rem; font-weight: 500; color: var(--data-negative); }

/* ══════════════════════════════════════════════════════════════════
   5. GLASS EFFECTS — Three surfaces only
   ══════════════════════════════════════════════════════════════════ */

/* KPI cards / hero panels */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-2xl);
  box-shadow:
    0 1px 0 var(--glass-inset) inset,
    0 -1px 0 rgba(0,0,0,0.04) inset,
    0 8px 32px var(--glass-shadow),
    0 2px 8px rgba(0,0,0,0.04);
  transition: box-shadow var(--dur-mid) ease, border-color var(--dur-mid) ease;
}
.glass-card:hover {
  box-shadow:
    0 1px 0 var(--hi-peak) inset,
    0 -1px 0 rgba(0,0,0,0.06) inset,
    0 12px 40px var(--glass-shadow),
    0 4px 12px rgba(0,0,0,0.06);
}

/* Topbar */
.glass-bar {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--glass-border);
  box-shadow:
    0 1px 0 var(--glass-inset) inset,
    0 1px 8px var(--glass-shadow);
}

/* Active nav item */
.glass-active {
  background: rgba(124,58,237,0.08);
  border: 1px solid rgba(124,58,237,0.18);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.50) inset,
    0 2px 8px rgba(124,58,237,0.10);
}
.dark .glass-active {
  background: rgba(139,92,246,0.12);
  border: 1px solid rgba(139,92,246,0.22);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.06) inset,
    0 2px 8px rgba(139,92,246,0.18);
}

/* Regular card hover */
.card-hover {
  transition: background var(--dur-fast) ease, border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.card-hover:hover {
  background: rgba(255,255,255,0.80);
  border-color: rgba(255,255,255,0.85);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.90) inset,
    0 4px 16px rgba(15,23,42,0.08);
}
.dark .card-hover:hover {
  background: rgba(30,41,59,0.80);
  border-color: rgba(255,255,255,0.10);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.06) inset,
    0 4px 16px rgba(0,0,0,0.35);
}

/* ══════════════════════════════════════════════════════════════════
   6. MATERIAL SYSTEM
   ══════════════════════════════════════════════════════════════════ */

/* Base shell */
.mat-base {
  background: linear-gradient(162deg, var(--s0) 0%, var(--s1) 30%, var(--s2) 60%, var(--s3) 100%);
  box-shadow:
    0 1px 3px rgba(0,0,0,0.08),
    0 4px 16px rgba(0,0,0,0.06),
    inset 0 1px 0 var(--hi-mid);
}

/* Inset surface */
.mat-inset {
  background: linear-gradient(162deg, var(--s3) 0%, var(--s4) 50%, var(--s3) 100%);
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.12),
    inset 0 1px 2px rgba(0,0,0,0.08);
}

/* Chrome rim — use as absolute child inside position:relative parent */
.rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(
    138deg,
    var(--cr-bright)  0%,
    var(--cr-light)   14%,
    var(--chroma-r)   20%,
    var(--cr-mid)     30%,
    transparent       48%,
    transparent       52%,
    var(--cr-dark)    68%,
    var(--chroma-b)   76%,
    var(--cr-shadow)  88%,
    var(--cr-mid)     100%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* Specular highlight overlay */
.specular {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    172deg,
    var(--hi-mid)   0%,
    var(--hi-soft)  22%,
    transparent     52%,
    var(--hi-trace) 100%
  );
  pointer-events: none;
}

/* Specular sweep on hover */
.sweep-on-hover {
  position: relative;
  overflow: hidden;
}
.sweep-on-hover::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 40%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255,255,255,0.20),
    rgba(255,255,255,0.28),
    rgba(255,255,255,0.20),
    transparent
  );
  transform: translateX(-150%) skewX(-15deg);
  transition: transform var(--dur-sweep) var(--ease-smooth);
  pointer-events: none;
}
.sweep-on-hover:hover::after {
  transform: translateX(350%) skewX(-15deg);
}

/* ══════════════════════════════════════════════════════════════════
   7. PRISMATIC DISC
   ══════════════════════════════════════════════════════════════════ */
.disc {
  position: relative;
  width: var(--disc-size, 34px);
  height: var(--disc-size, 34px);
  border-radius: 50%;
  flex-shrink: 0;
}
.disc-surface {
  position: absolute;
  inset: 2.5px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--s1) 0%, var(--s3) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
  color: hsl(var(--foreground));
  font-size: inherit;
}
.disc-rim {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  padding: 2.5px;
  background: linear-gradient(
    138deg,
    var(--cr-bright) 0%,
    var(--cr-light)  18%,
    var(--chroma-r)  24%,
    var(--cr-mid)    35%,
    transparent      50%,
    var(--cr-dark)   68%,
    var(--chroma-b)  78%,
    var(--cr-shadow) 90%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.disc-prism {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  padding: 2.5px;
  background: conic-gradient(
    from 160deg,
    var(--prism-r)  0deg,
    var(--prism-y)  36deg,
    var(--prism-g)  72deg,
    var(--prism-b)  108deg,
    var(--prism-v)  144deg,
    transparent     180deg,
    transparent     360deg
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.7;
  pointer-events: none;
  transition: opacity var(--dur-fast) ease;
}
.disc:hover .disc-prism { opacity: 1; }

/* ══════════════════════════════════════════════════════════════════
   8. BUTTONS
   ══════════════════════════════════════════════════════════════════ */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--r-md);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  transition: box-shadow var(--dur-fast) ease, transform var(--dur-instant) ease;
  overflow: hidden;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(162deg, hsl(258 90% 65%) 0%, hsl(258 90% 55%) 100%);
  color: white;
  box-shadow:
    0 1px 3px rgba(124,58,237,0.30),
    0 2px 8px rgba(124,58,237,0.20),
    inset 0 1px 0 rgba(255,255,255,0.25);
}
.btn-primary:hover {
  box-shadow:
    0 2px 6px rgba(124,58,237,0.40),
    0 4px 16px rgba(124,58,237,0.25),
    inset 0 1px 0 rgba(255,255,255,0.30);
  color: white;
  text-decoration: none;
}

.btn-secondary {
  background: linear-gradient(162deg, var(--s0) 0%, var(--s2) 100%);
  color: hsl(var(--foreground));
  box-shadow:
    0 1px 3px rgba(0,0,0,0.08),
    0 2px 8px rgba(0,0,0,0.05),
    inset 0 1px 0 var(--hi-mid);
}
.btn-secondary:hover {
  box-shadow:
    0 2px 6px rgba(0,0,0,0.12),
    0 4px 16px rgba(0,0,0,0.08),
    inset 0 1px 0 var(--hi-peak);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: hsl(var(--muted-foreground));
  box-shadow: none;
}
.btn-ghost:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  text-decoration: none;
}

.btn-sm { height: 30px; padding: 0 12px; font-size: 0.75rem; border-radius: var(--r-sm); }
.btn-lg { height: 44px; padding: 0 24px; font-size: 0.9375rem; border-radius: var(--r-lg); }

/* Disc icon button */
.disc-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════════
   9. BADGES
   ══════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--r-full);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-default   { background: hsl(var(--primary)); color: white; }
.badge-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); border: 1px solid hsl(var(--border)); }
.badge-outline   { background: transparent; border: 1px solid hsl(var(--border)); color: hsl(var(--muted-foreground)); }
.badge-success   { background: rgba(16,185,129,0.12); color: #10B981; border: 1px solid rgba(16,185,129,0.20); }
.badge-danger    { background: rgba(239,68,68,0.10);  color: #EF4444; border: 1px solid rgba(239,68,68,0.18); }
.badge-warning   { background: rgba(245,158,11,0.12); color: #D97706; border: 1px solid rgba(245,158,11,0.20); }

/* ══════════════════════════════════════════════════════════════════
   10. INPUTS
   ══════════════════════════════════════════════════════════════════ */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon {
  position: absolute;
  left: 12px;
  color: hsl(var(--muted-foreground));
  pointer-events: none;
  display: flex;
  align-items: center;
}
.input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border-radius: var(--r-md);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
}
.input:not(.input-has-icon) { padding-left: 12px; }
.input:focus {
  border-color: hsl(var(--ring));
  box-shadow:
    inset 0 1px 3px rgba(0,0,0,0.06),
    0 0 0 3px rgba(124,58,237,0.12);
}
.input::placeholder { color: hsl(var(--muted-foreground)); }

/* Textarea variant */
.input-textarea {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
  min-height: 80px;
}

/* ══════════════════════════════════════════════════════════════════
   11. SEGMENTED CONTROL (TABS)
   ══════════════════════════════════════════════════════════════════ */
.seg-track {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-lg);
  background: linear-gradient(162deg, var(--s3) 0%, var(--s4) 100%);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.12);
}
.seg-item {
  position: relative;
  height: 30px;
  padding: 0 14px;
  border-radius: calc(var(--r-lg) - 3px);
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: color var(--dur-fast) ease;
  white-space: nowrap;
}
.seg-item.active, .seg-item[aria-selected="true"] {
  background: linear-gradient(162deg, var(--s0) 0%, var(--s1) 100%);
  color: hsl(var(--foreground));
  box-shadow: 0 1px 3px rgba(0,0,0,0.10), inset 0 1px 0 var(--hi-mid);
}

/* ══════════════════════════════════════════════════════════════════
   12. DATA TABLE
   ══════════════════════════════════════════════════════════════════ */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  padding: 8px 16px;
  text-align: left;
  border-bottom: 1px solid hsl(var(--border));
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}
.table-row {
  border-bottom: 1px solid hsl(var(--border));
  transition: background var(--dur-fast) ease;
}
.table-row:hover { background: hsl(var(--muted)); }
.table-cell {
  padding: 12px 16px;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
}

/* ══════════════════════════════════════════════════════════════════
   13. KPI CARD LAYOUT
   ══════════════════════════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.kpi-card { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.kpi-header { display: flex; align-items: center; justify-content: space-between; }
.kpi-body   { display: flex; flex-direction: column; gap: 4px; }
.kpi-footer { padding-top: 8px; border-top: 1px solid hsl(var(--border)); }

/* ══════════════════════════════════════════════════════════════════
   14. BAR CHART PATTERN
   ══════════════════════════════════════════════════════════════════ */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 48px;
  align-items: center;
  gap: 12px;
}
.bar-track {
  height: 6px;
  border-radius: var(--r-full);
  background: hsl(var(--muted));
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, hsl(var(--primary)), hsl(258 80% 70%));
  transition: width var(--dur-slow) var(--ease-smooth);
}
.bar-val { text-align: right; }

/* ══════════════════════════════════════════════════════════════════
   15. STAT PAIR
   ══════════════════════════════════════════════════════════════════ */
.stat-pair { display: flex; flex-direction: column; gap: 4px; }
.stat-pair-row { display: flex; align-items: baseline; gap: 8px; }

/* ══════════════════════════════════════════════════════════════════
   16. NAVIGATION
   ══════════════════════════════════════════════════════════════════ */
.nav-group-label {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  padding: 0 8px;
  margin-bottom: 4px;
  transition: opacity var(--dur-fast) ease;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border-radius: var(--r-lg);
  text-decoration: none;
  color: hsl(var(--muted-foreground));
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
  margin-bottom: 2px;
}
.nav-item:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  text-decoration: none;
}
.nav-item.active { color: hsl(var(--foreground)); }
.nav-label {
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--dur-fast) ease;
}
.nav-active-bar {
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  border-radius: 0 2px 2px 0;
  background: hsl(var(--primary));
  box-shadow: 0 0 8px rgba(124,58,237,0.40);
}

/* Sidebar widths + collapse */
.sidebar {
  width: 220px;
  transition: width var(--dur-mid) var(--ease-snap);
  overflow: hidden;
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .nav-group-label,
.sidebar.collapsed .nav-label { opacity: 0; pointer-events: none; }

/* ══════════════════════════════════════════════════════════════════
   17. TOGGLE SWITCH
   ══════════════════════════════════════════════════════════════════ */
.toggle-input { display: none; }
.toggle-track {
  position: relative;
  width: 48px; height: 28px;
  border-radius: var(--r-full);
  background: linear-gradient(162deg, var(--s3) 0%, var(--s4) 100%);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.15), inset 0 1px 2px rgba(0,0,0,0.10);
  cursor: pointer;
  transition: background var(--dur-mid) var(--ease-smooth);
}
.toggle-input:checked + .toggle-track {
  background: linear-gradient(162deg, hsl(var(--primary)) 0%, hsl(258 80% 50%) 100%);
}
.toggle-knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--s0) 0%, var(--s2) 100%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.20), 0 1px 3px rgba(0,0,0,0.15);
  transition: transform var(--dur-mid) var(--ease-spring);
}
.toggle-input:checked + .toggle-track .toggle-knob {
  transform: translateX(20px);
}

/* ══════════════════════════════════════════════════════════════════
   18. FOCUS & ACCESSIBILITY
   ══════════════════════════════════════════════════════════════════ */
:focus-visible {
  outline: 3px solid hsl(var(--ring));
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) { outline: none; }

/* Minimum touch target for interactive elements */
.btn, .disc-btn, .nav-item { min-height: 36px; }

/* ══════════════════════════════════════════════════════════════════
   19. SCROLLBAR STYLING
   ══════════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: hsl(var(--muted-foreground)); }

/* ══════════════════════════════════════════════════════════════════
   20. LOGO SWAP (dark/light mode)
   ══════════════════════════════════════════════════════════════════ */
.logo-light { display: block; }
.logo-dark-mode { display: none; }
html.dark .logo-light { display: none; }
html.dark .logo-dark-mode { display: block; }

/* ══════════════════════════════════════════════════════════════════
   21. UTILITY HELPERS
   ══════════════════════════════════════════════════════════════════ */
.tabular-nums { font-variant-numeric: tabular-nums; }
.card-base {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--r-lg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}
.section-gap { margin-bottom: 40px; }
.card-pad    { padding: 20px; }
.card-pad-lg { padding: 24px; }

/* ══════════════════════════════════════════════════════════════════
   22. KEYFRAME ANIMATIONS
   ══════════════════════════════════════════════════════════════════ */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(124,58,237,0.20); }
  50%       { box-shadow: 0 0 20px rgba(124,58,237,0.40); }
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-spin    { animation: spin 1s linear infinite; }
.animate-pulse   { animation: pulse-glow 2s ease-in-out infinite; }
.animate-fade-in { animation: fade-in 0.25s var(--ease-smooth) both; }

/* ══════════════════════════════════════════════════════════════════
   23. KPI GRID + CARDS
   ══════════════════════════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.kpi-card {
  padding: 18px 20px;
}
.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.kpi-body {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

/* ══════════════════════════════════════════════════════════════════
   24. TABLE ROW HOVER
   ══════════════════════════════════════════════════════════════════ */
.table-row {
  transition: background var(--dur-fast) ease;
}
.table-row:hover {
  background: hsl(var(--muted) / 50%);
}

/* ══════════════════════════════════════════════════════════════════
   25. BAR CHART PRIMITIVES
   ══════════════════════════════════════════════════════════════════ */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 56px;
  align-items: center;
  gap: 10px;
}
.bar-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: hsl(var(--muted));
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, hsl(var(--primary)), hsl(var(--primary) / 70%));
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}
.bar-val {
  text-align: right;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════
   26. SEGMENTED CONTROL
   ══════════════════════════════════════════════════════════════════ */
.seg-track {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-lg);
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
}
.seg-item {
  padding: 6px 16px;
  border-radius: calc(var(--r-lg) - 3px);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) ease;
  color: hsl(var(--muted-foreground));
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
}
.seg-item.active,
.seg-item:hover {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}
.seg-item.active {
  color: hsl(var(--primary));
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════════
   27. SIDEBAR COLLAPSED STATE
   ══════════════════════════════════════════════════════════════════ */
.sidebar {
  width: 220px;
}
.sidebar.collapsed {
  width: 64px;
}
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-group-label {
  display: none;
}
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 8px;
}

/* ══════════════════════════════════════════════════════════════════
   28. GLASS-ACTIVE (ACTIVE NAV)
   ══════════════════════════════════════════════════════════════════ */
.glass-active {
  background: hsl(var(--primary) / 8%);
  border-color: hsl(var(--primary) / 20%);
}

/* ══════════════════════════════════════════════════════════════════
   29. INPUT TEXTAREA
   ══════════════════════════════════════════════════════════════════ */
.input-textarea {
  resize: vertical;
  min-height: 40px;
}

/* ══════════════════════════════════════════════════════════════════
   30. MAT INSET  (upload zone, inner recessed areas)
   ══════════════════════════════════════════════════════════════════ */
.mat-inset {
  background: hsl(var(--muted) / 50%);
  border: 1px dashed hsl(var(--border));
  border-radius: var(--r-xl);
  transition: border-color var(--dur-fast) ease, background var(--dur-fast) ease;
}
.mat-inset:hover,
.mat-inset.dragover {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 4%);
}
