/* ===================================================================
   Shikkha Nexus — Apple visionOS Glass Design System
   =================================================================== */

/* ── Google Fonts ──────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Color Roles ─────────────────────────────────────────────────── */
:root {
  --md-sys-color-primary:               #1565C0;
  --md-sys-color-on-primary:            #FFFFFF;
  --md-sys-color-primary-container:     #D1E4FF;
  --md-sys-color-on-primary-container:  #001D36;

  --md-sys-color-secondary:             #00897B;
  --md-sys-color-on-secondary:          #FFFFFF;
  --md-sys-color-secondary-container:   #B2DFDB;
  --md-sys-color-on-secondary-container:#003731;

  --md-sys-color-tertiary:              #6750A4;
  --md-sys-color-on-tertiary:           #FFFFFF;
  --md-sys-color-tertiary-container:    #EADDFF;
  --md-sys-color-on-tertiary-container: #21005D;

  --md-sys-color-error:                 #B3261E;
  --md-sys-color-on-error:              #FFFFFF;
  --md-sys-color-error-container:       #F9DEDC;
  --md-sys-color-on-error-container:    #410E0B;

  --md-sys-color-surface:               #EEF2FF;
  --md-sys-color-on-surface:            #1A1C1E;
  --md-sys-color-surface-variant:       #E1E2EC;
  --md-sys-color-on-surface-variant:    #44464F;
  --md-sys-color-surface-container-low: rgba(255,255,255,0.55);
  --md-sys-color-surface-container:     rgba(255,255,255,0.40);
  --md-sys-color-surface-container-high:rgba(255,255,255,0.70);

  --md-sys-color-outline:               #74777F;
  --md-sys-color-outline-variant:       rgba(196,198,208,0.6);

  /* Stage colors */
  --stage-research:    #1565C0;
  --stage-inquiry:     #00838F;
  --stage-uiux:        #7B1FA2;
  --stage-engineering: #EF6C00;
  --stage-security:    #C62828;
  --stage-qaqc:        #2E7D32;
  --stage-production:  #AD1457;
  --stage-marketing:   #F9A825;
  --stage-done:        #37474F;

  --md-sys-typescale-body-font: 'Inter', system-ui, sans-serif;
  --md-sys-shape-corner-medium: 14px;
  --md-sys-shape-corner-large:  20px;
  --md-sys-shape-corner-xl:     28px;

  /* Glass tokens */
  --glass-bg:           rgba(255,255,255,0.52);
  --glass-bg-dark:      rgba(255,255,255,0.28);
  --glass-border:       rgba(255,255,255,0.75);
  --glass-border-outer: rgba(200,205,220,0.50);
  --glass-blur:         18px;
  --glass-shadow:       0 8px 32px rgba(31,38,135,0.10), 0 1.5px 6px rgba(31,38,135,0.07);
  --glass-shadow-deep:  0 20px 60px rgba(31,38,135,0.14), 0 4px 16px rgba(31,38,135,0.08);
  --glass-inset:        inset 0 1px 0 rgba(255,255,255,0.85);

  /* Elevation */
  --md-elevation-1: 0 1px 2px rgba(0,0,0,.10), 0 1px 3px rgba(0,0,0,.07);
  --md-elevation-2: 0 1px 2px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.09);
  --md-elevation-3: 0 4px 16px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.07);
}

/* ═══════════════════════════════════════════════════════════════════
   DARK MODE — WCAG AA compliant, glass-dark surfaces
   on-surface: #E8EAF0 (≥ 7:1 on #0c0f1a)
   on-surface-variant: #B0B3C0 (≥ 4.5:1)
   ═══════════════════════════════════════════════════════════════════ */
html.dark {
  /* Brand — lightened for dark bg, min 4.5:1 */
  --md-sys-color-primary:               #93C5FD;   /* blue-300  */
  --md-sys-color-on-primary:            #0A2A4A;
  --md-sys-color-primary-container:     #1B3A5C;
  --md-sys-color-on-primary-container:  #DBEAFE;

  --md-sys-color-secondary:             #6EE7B7;   /* emerald-300 */
  --md-sys-color-on-secondary:          #022C22;
  --md-sys-color-secondary-container:   #064E3B;
  --md-sys-color-on-secondary-container:#D1FAE5;

  --md-sys-color-tertiary:              #C4B5FD;   /* violet-300 */
  --md-sys-color-on-tertiary:           #2E1065;
  --md-sys-color-tertiary-container:    #3B0764;
  --md-sys-color-on-tertiary-container: #EDE9FE;

  --md-sys-color-error:                 #FCA5A5;   /* red-300 */
  --md-sys-color-on-error:              #450A0A;
  --md-sys-color-error-container:       #7F1D1D;
  --md-sys-color-on-error-container:    #FEE2E2;

  /* Surfaces */
  --md-sys-color-surface:               #0C0F1A;
  --md-sys-color-on-surface:            #E8EAF0;   /* WCAG ≥7:1 */
  --md-sys-color-surface-variant:       #1C2035;
  --md-sys-color-on-surface-variant:    #B0B3C0;   /* WCAG ≥4.5:1 */
  --md-sys-color-surface-container-low: rgba(255,255,255,0.042);
  --md-sys-color-surface-container:     rgba(255,255,255,0.065);
  --md-sys-color-surface-container-high:rgba(255,255,255,0.095);

  --md-sys-color-outline:               #6B6F80;
  --md-sys-color-outline-variant:       rgba(107,111,128,0.40);

  /* Dark glass tokens */
  --glass-bg:           rgba(22,28,46,0.72);
  --glass-bg-dark:      rgba(14,18,32,0.82);
  --glass-border:       rgba(255,255,255,0.095);
  --glass-border-outer: rgba(255,255,255,0.065);
  --glass-blur:         20px;
  --glass-shadow:       0 8px 32px rgba(0,0,0,0.42), 0 1.5px 6px rgba(0,0,0,0.30);
  --glass-shadow-deep:  0 20px 60px rgba(0,0,0,0.55), 0 4px 16px rgba(0,0,0,0.38);
  --glass-inset:        inset 0 1px 0 rgba(255,255,255,0.07);
}

/* ── Dark body ───────────────────────────────────────────────────── */
html.dark body {
  background-color: #0c0f1a;
  background-image:
    radial-gradient(ellipse at 20% 20%, rgba(30,60,160,0.55) 0%, transparent 55%),
    radial-gradient(ellipse at 82% 8%,  rgba(80,30,160,0.42) 0%, transparent 50%),
    radial-gradient(ellipse at 58% 88%, rgba(10,80,110,0.38) 0%, transparent 50%),
    radial-gradient(ellipse at 8%  78%, rgba(20,50,130,0.32) 0%, transparent 45%);
}
html.dark body::before {
  background: radial-gradient(circle, rgba(40,80,210,0.22) 0%, transparent 70%);
}
html.dark body::after {
  background: radial-gradient(circle, rgba(100,40,210,0.18) 0%, transparent 70%);
}

/* ── Sidebar nav ─────────────────────────────────────────────────── */
html.dark #nav-rail {
  background: rgba(14,18,32,0.82);
  border-right-color: rgba(255,255,255,0.07);
}
/* All inactive nav items — readable white-ish */
html.dark .nav-item {
  color: rgba(224,228,240,0.62);   /* WCAG ≥ 3:1 — "large text" passes */
}
html.dark .nav-item:hover {
  color: rgba(224,228,240,0.88);
}
html.dark .nav-item:hover .nav-icon {
  background: rgba(255,255,255,0.09);
}
/* Active nav item — full white + accent pill */
html.dark .nav-item.active {
  color: #FFFFFF;
}
html.dark .nav-item.active .nav-icon {
  background: rgba(147,197,253,0.18);   /* primary-300 tint */
  color: var(--md-sys-color-primary);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.10);
}

/* ── Bottom nav ──────────────────────────────────────────────────── */
html.dark #bottom-nav {
  background: rgba(12,15,26,0.90);
  border-top-color: rgba(255,255,255,0.07);
}
html.dark .bottom-nav-item        { color: rgba(224,228,240,0.55); }
html.dark .bottom-nav-item:hover  { color: rgba(224,228,240,0.85); }
html.dark .bottom-nav-item.active { color: var(--md-sys-color-primary); }

/* ── Stat / counter cards ────────────────────────────────────────── */
/* The number color is handled in JS (statCard fn).
   Label text uses on-surface-variant which is #B0B3C0 — readable. */
html.dark .stat-card {
  background: rgba(22,28,46,0.72);
}

/* ── Login screen & card ─────────────────────────────────────────── */
html.dark #login-screen {
  background-color: #0c0f1a !important;
  background-image:
    radial-gradient(ellipse at 20% 20%, rgba(30,60,160,.55) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 10%, rgba(80,30,160,.42) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 90%, rgba(10,80,110,.38) 0%, transparent 50%) !important;
}
html.dark #login-card {
  background: rgba(18,24,42,0.82);
  border-color: rgba(255,255,255,0.09);
}

/* ── Inputs ──────────────────────────────────────────────────────── */
html.dark .md-input {
  background: rgba(255,255,255,0.055);
  border-color: rgba(255,255,255,0.11);
  color: #E8EAF0;
}
html.dark .md-input::placeholder { color: rgba(176,179,192,0.45); }
html.dark .md-input:focus {
  background: rgba(255,255,255,0.085);
  border-color: rgba(147,197,253,0.60);
  box-shadow: 0 0 0 3px rgba(147,197,253,.10), inset 0 1px 2px rgba(0,0,0,.22);
}
html.dark .md-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23B0B3C0'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
}
html.dark .md-label { color: var(--md-sys-color-primary); }

/* ── Chips ───────────────────────────────────────────────────────── */
html.dark .chip-todo          { background:rgba(29,78,216,0.22);  color:#93C5FD; border-color:rgba(147,197,253,.22); }
html.dark .chip-in-progress   { background:rgba(194,65,12,0.22);  color:#FCD34D; border-color:rgba(252,211,77,.22);  }
html.dark .chip-done          { background:rgba(6,78,59,0.30);    color:#6EE7B7; border-color:rgba(110,231,183,.22); }
html.dark .chip-approved      { background:rgba(6,78,59,0.30);    color:#6EE7B7; border-color:rgba(110,231,183,.22); }
html.dark .chip-rejected      { background:rgba(127,29,29,0.30);  color:#FCA5A5; border-color:rgba(252,165,165,.22); }
html.dark .chip-locked        { background:rgba(30,41,59,0.50);   color:#94A3B8; border-color:rgba(148,163,184,.20); }
html.dark .chip-warning       { background:rgba(161,98,7,0.22);   color:#FCD34D; border-color:rgba(252,211,77,.22);  }
html.dark .chip-review-pending{ background:rgba(194,65,12,0.22);  color:#FCD34D; border-color:rgba(252,211,77,.28);  }
html.dark .chip-tl-badge      { background:rgba(109,40,217,0.22); color:#C4B5FD; border-color:rgba(196,181,253,.25); }

/* ── Cards ───────────────────────────────────────────────────────── */
html.dark .md-card,
html.dark .md-card-filled {
  background: rgba(22,28,46,0.72);
  border-color: rgba(255,255,255,0.08);
}
html.dark .md-card:hover {
  background: rgba(26,34,56,0.80);
  border-color: rgba(255,255,255,0.13);
}

/* ── Stage panels ────────────────────────────────────────────────── */
html.dark .stage-panel {
  background: rgba(20,26,44,0.68);
  border-color: rgba(255,255,255,0.07);
}
html.dark .stage-panel.current  { border-color: rgba(147,197,253,0.40); }
html.dark .stage-panel.completed{ border-color: rgba(110,231,183,0.30); }

html.dark .stage-header {
  background: rgba(255,255,255,0.035);
}
html.dark .stage-header:hover {
  background: rgba(255,255,255,0.065);
}
html.dark .stage-body {
  background: rgba(255,255,255,0.025);
  border-top-color: rgba(255,255,255,0.07);
}

/* ── Task rows ───────────────────────────────────────────────────── */
html.dark .task-row:hover {
  background: rgba(255,255,255,0.055);
  border-color: rgba(255,255,255,0.09);
}

/* ── Gatekeeper ──────────────────────────────────────────────────── */
html.dark .gate-panel {
  background: rgba(255,255,255,0.035);
  border-color: rgba(107,111,128,0.38);
}
html.dark .gate-approved {
  background: rgba(6,78,59,0.22);
  border-color: rgba(110,231,183,0.30);
}
html.dark .vote-card {
  background: rgba(255,255,255,0.045);
  border-color: rgba(255,255,255,0.08);
}

/* ── Progress ────────────────────────────────────────────────────── */
html.dark .progress-track {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.055);
}

/* ── Modal ───────────────────────────────────────────────────────── */
html.dark #modal-overlay { background: rgba(0,0,0,0.62); }
html.dark #modal-box {
  background: rgba(16,21,38,0.88);
  border-color: rgba(255,255,255,0.09);
}

/* ── Toast ───────────────────────────────────────────────────────── */
html.dark .toast {
  background: rgba(30,36,56,0.90);
  color: #E8EAF0;
  border-color: rgba(255,255,255,0.10);
}
html.dark .toast-success { background: rgba(6,78,59,0.90); }
html.dark .toast-error   { background: rgba(127,29,29,0.90); }
html.dark .toast-warn    { background: rgba(124,45,18,0.90); }

/* ── Buttons ─────────────────────────────────────────────────────── */
html.dark .md-btn-tonal {
  background: rgba(110,231,183,0.12);
  border-color: rgba(110,231,183,0.18);
  color: #6EE7B7;
}
html.dark .md-btn-outlined {
  background: rgba(255,255,255,0.055);
  border-color: rgba(255,255,255,0.13);
  color: var(--md-sys-color-primary);
}
html.dark .md-btn-outlined:hover:not(:disabled) {
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.18);
}
html.dark .md-btn-text { color: var(--md-sys-color-primary); }
html.dark .md-btn-text:hover { background: rgba(147,197,253,.10); }

/* ── FAB ─────────────────────────────────────────────────────────── */
html.dark .md-fab {
  background: rgba(22,28,46,0.80);
  border-color: rgba(255,255,255,0.09);
  color: var(--md-sys-color-primary);
}

/* ── Error alert in login ────────────────────────────────────────── */
html.dark #login-error {
  background: rgba(127,29,29,0.40) !important;
  border-color: rgba(252,165,165,.22) !important;
  color: #FCA5A5 !important;
}

/* ── Divider / scrollbar ─────────────────────────────────────────── */
html.dark .divider { background: rgba(255,255,255,0.07); }
html.dark ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.11); }
html.dark ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.20); }

/* Smooth theme transition */
*, *::before, *::after {
  transition-property: background-color, border-color, color, box-shadow, opacity;
  transition-duration: 0.25s;
  transition-timing-function: ease;
}
/* But keep animations unaffected */
.spinner, .progress-fill, .pipe-dot, .md-btn, .md-fab,
.nav-item, .task-row, .md-card, .stage-panel {
  transition: background .25s, border-color .25s, color .25s,
              box-shadow .25s, transform .15s, opacity .2s;
}

* { box-sizing: border-box; }

/* ── Animated mesh background ────────────────────────────────────── */
body {
  font-family: var(--md-sys-typescale-body-font);
  color: var(--md-sys-color-on-surface);
  margin: 0;
  min-height: 100vh;
  background-color: #dbe4f7;
  background-image:
    radial-gradient(ellipse at 20% 20%, rgba(99,153,255,0.35) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 10%, rgba(172,120,255,0.28) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 85%, rgba(100,200,220,0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 10% 80%, rgba(130,180,255,0.20) 0%, transparent 45%);
  background-attachment: fixed;
}

/* Subtle animated gradient orbs */
body::before {
  content: '';
  position: fixed;
  top: -20vh; left: -10vw;
  width: 60vw; height: 60vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(100,140,255,0.18) 0%, transparent 70%);
  animation: orb1 18s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: '';
  position: fixed;
  bottom: -15vh; right: -10vw;
  width: 50vw; height: 50vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(160,100,255,0.14) 0%, transparent 70%);
  animation: orb2 22s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}
@keyframes orb1 { from { transform: translate(0,0) scale(1); } to { transform: translate(8vw,6vh) scale(1.12); } }
@keyframes orb2 { from { transform: translate(0,0) scale(1); } to { transform: translate(-6vw,-8vh) scale(1.08); } }

#app-shell, #nav-rail, #bottom-nav, #main-content, #modal-overlay { position: relative; z-index: 1; }

/* ── Typography ──────────────────────────────────────────────────── */
.md-display-sm  { font-size: 2.25rem; font-weight: 300; line-height: 2.75rem; letter-spacing: -.5px; }
.md-headline-md { font-size: 1.75rem; font-weight: 300; line-height: 2.25rem; letter-spacing: -.3px; }
.md-headline-sm { font-size: 1.5rem;  font-weight: 400; line-height: 2rem; letter-spacing: -.2px; }
.md-title-lg    { font-size: 1.375rem; font-weight: 500; line-height: 1.75rem; }
.md-title-md    { font-size: 1rem;    font-weight: 500; line-height: 1.5rem; letter-spacing: .1px; }
.md-title-sm    { font-size: .875rem; font-weight: 500; line-height: 1.25rem; letter-spacing: .05px; }
.md-label-lg    { font-size: .875rem; font-weight: 500; line-height: 1.25rem; letter-spacing: .05px; }
.md-body-md     { font-size: .875rem; font-weight: 400; line-height: 1.375rem; letter-spacing: .15px; }
.md-body-sm     { font-size: .75rem;  font-weight: 400; line-height: 1rem;    letter-spacing: .3px; }

/* ── Glass mixin (applied to surface elements) ───────────────────── */
.md-card,
.md-card-filled {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border-radius: var(--md-sys-shape-corner-large);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow), var(--glass-inset);
  transition: box-shadow .25s, transform .2s, border-color .2s;
}
.md-card:hover {
  box-shadow: var(--glass-shadow-deep), var(--glass-inset);
  border-color: rgba(255,255,255,0.92);
  transform: translateY(-1px);
}
.md-card-filled {
  background: rgba(255,255,255,0.35);
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.md-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 100px;
  font-size: .875rem;
  font-weight: 500;
  letter-spacing: .1px;
  border: none;
  cursor: pointer;
  transition: box-shadow .2s, opacity .15s, transform .15s;
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
}
.md-btn:active { transform: scale(.97); }
.md-btn:disabled { opacity: .38; cursor: not-allowed; }

.md-btn-filled {
  background: linear-gradient(135deg, var(--md-sys-color-primary) 0%, #1976D2 100%);
  color: var(--md-sys-color-on-primary);
  box-shadow: 0 2px 8px rgba(21,101,192,.30);
}
.md-btn-filled:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(21,101,192,.40);
  transform: translateY(-1px);
}
.md-btn-tonal {
  background: rgba(178,223,219,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.6);
  color: var(--md-sys-color-on-secondary-container);
}
.md-btn-outlined {
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid var(--glass-border-outer);
  color: var(--md-sys-color-primary);
}
.md-btn-outlined:hover:not(:disabled) {
  background: rgba(255,255,255,0.65);
  border-color: rgba(255,255,255,0.85);
}
.md-btn-text {
  background: transparent;
  color: var(--md-sys-color-primary);
  padding: 10px 12px;
}
.md-btn-text:hover { background: rgba(21,101,192,.08); }
.md-btn-danger {
  background: linear-gradient(135deg, var(--md-sys-color-error) 0%, #C62828 100%);
  color: var(--md-sys-color-on-error);
  box-shadow: 0 2px 8px rgba(179,38,30,.30);
}
.md-btn-sm { padding: 6px 16px; font-size: .75rem; }

.md-fab {
  width: 56px; height: 56px;
  border-radius: 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border: 1px solid var(--glass-border);
  color: var(--md-sys-color-primary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  box-shadow: var(--glass-shadow), var(--glass-inset);
  transition: box-shadow .2s, transform .2s;
}
.md-fab:hover {
  box-shadow: var(--glass-shadow-deep), var(--glass-inset);
  transform: translateY(-2px) scale(1.04);
}
.md-fab-extended { width: auto; padding: 0 20px; border-radius: 20px; gap: 8px; font-size: .875rem; font-weight: 500; }

/* ── Form Inputs ─────────────────────────────────────────────────── */
.md-input {
  width: 100%;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid rgba(255,255,255,0.70);
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 12px 16px;
  font-size: .875rem;
  color: var(--md-sys-color-on-surface);
  transition: border-color .2s, box-shadow .2s, background .2s;
  outline: none;
  font-family: inherit;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.06);
}
.md-input::placeholder { color: rgba(68,70,79,.5); }
.md-input:focus {
  border-color: rgba(21,101,192,0.65);
  background: rgba(255,255,255,0.75);
  box-shadow: 0 0 0 3px rgba(21,101,192,.12), inset 0 1px 2px rgba(0,0,0,.04);
}
.md-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2374777F'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  padding-right: 36px;
}
.md-label {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  color: var(--md-sys-color-primary);
  margin-bottom: 5px;
  letter-spacing: .5px;
  text-transform: uppercase;
}

/* ── Navigation Rail ─────────────────────────────────────────────── */
#nav-rail {
  width: 80px;
  background: rgba(255,255,255,0.48);
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  border-right: 1px solid var(--glass-border);
  box-shadow: 2px 0 16px rgba(31,38,135,.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 4px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  border-radius: 18px;
  cursor: pointer;
  color: var(--md-sys-color-on-surface-variant);
  font-size: .58rem;
  font-weight: 600;
  letter-spacing: .4px;
  width: 64px;
  transition: background .2s, color .2s, transform .15s;
  text-align: center;
  text-decoration: none;
  border: none;
  background: transparent;
}
.nav-item .nav-icon {
  width: 48px; height: 32px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  transition: background .2s, transform .15s;
}
.nav-item:hover .nav-icon {
  background: rgba(255,255,255,0.60);
  transform: scale(1.08);
}
.nav-item.active .nav-icon {
  background: rgba(21,101,192,0.14);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--md-sys-color-primary);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}
.nav-item.active { color: var(--md-sys-color-primary); }

/* ── Chips ───────────────────────────────────────────────────────── */
.md-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: .75rem; font-weight: 500;
  letter-spacing: .2px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.chip-todo        { background:rgba(240,244,255,0.75); color:#1565C0; border:1px solid rgba(21,101,192,.18); }
.chip-in-progress { background:rgba(255,243,224,0.75); color:#E65100; border:1px solid rgba(230,81,0,.18); }
.chip-done        { background:rgba(232,245,233,0.75); color:#2E7D32; border:1px solid rgba(46,125,50,.18); }
.chip-approved    { background:rgba(232,245,233,0.75); color:#1B5E20; border:1px solid rgba(27,94,32,.18); }
.chip-rejected    { background:rgba(255,235,238,0.75); color:#B71C1C; border:1px solid rgba(183,28,28,.18); }
.chip-locked      { background:rgba(236,239,241,0.75); color:#546E7A; border:1px solid rgba(84,110,122,.18); }
.chip-warning     { background:rgba(255,253,231,0.75); color:#F57F17; border:1px solid rgba(245,127,23,.18); }
.chip-review-pending { background:rgba(255,243,224,0.80); color:#E65100; border:1px solid rgba(230,81,0,.25); }
.chip-tl-badge    { background:rgba(234,221,255,0.80); color:#21005D; border:1px solid rgba(103,80,164,.25); }
.chip-stage       { font-size:.65rem; padding:2px 8px; border-radius:6px; }

/* ── Stage Panel ─────────────────────────────────────────────────── */
.stage-panel {
  background: rgba(255,255,255,0.40);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--md-sys-shape-corner-large);
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: var(--glass-shadow), var(--glass-inset);
}
.stage-panel.current {
  border-color: rgba(21,101,192,0.45);
  box-shadow: 0 0 0 2px rgba(21,101,192,.10), var(--glass-shadow), var(--glass-inset);
}
.stage-panel.completed {
  border-color: rgba(0,137,123,0.35);
}
.stage-panel.locked { opacity: .60; filter: saturate(60%); }

.stage-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  background: rgba(255,255,255,0.28);
  transition: background .15s;
  user-select: none;
}
.stage-header:hover { background: rgba(255,255,255,0.45); }
.stage-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}
.stage-body {
  border-top: 1px solid rgba(255,255,255,0.50);
  padding: 16px;
  background: rgba(255,255,255,0.22);
  display: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.stage-body.open { display: block; }

/* ── Task Row ────────────────────────────────────────────────────── */
.task-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  transition: background .15s, transform .12s;
  border: 1px solid transparent;
}
.task-row:hover {
  background: rgba(255,255,255,0.55);
  border-color: var(--glass-border);
  transform: translateX(2px);
}
.task-checkbox {
  width: 18px; height: 18px; border-radius: 5px; flex-shrink: 0;
  accent-color: var(--md-sys-color-primary);
  cursor: pointer;
}
.task-checkbox:disabled { cursor: not-allowed; }

/* ── Gatekeeper Panel ────────────────────────────────────────────── */
.gate-panel {
  background: rgba(255,255,255,0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 16px;
  margin-top: 12px;
  border: 1.5px dashed rgba(116,119,127,0.45);
  box-shadow: var(--glass-inset);
}
.gate-approved {
  border-color: rgba(0,137,123,0.40);
  background: rgba(241,251,245,0.50);
}
.vote-card {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.60);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  margin-bottom: 8px;
}
.vote-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--md-sys-color-primary-container), rgba(209,228,255,0.6));
  border: 1px solid rgba(255,255,255,0.8);
  color: var(--md-sys-color-on-primary-container);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9);
}

/* ── Progress Bar ────────────────────────────────────────────────── */
.progress-track {
  height: 5px;
  background: rgba(255,255,255,0.35);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.5);
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--md-sys-color-primary) 0%, #42A5F5 100%);
  transition: width .5s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 0 8px rgba(21,101,192,.4);
}

/* ── Pipeline Stepper ────────────────────────────────────────────── */
.pipeline-stepper {
  display: flex; align-items: center; gap: 0;
  overflow-x: auto; padding: 8px 0; scrollbar-width: thin;
}
.pipe-step { display: flex; align-items: center; flex-shrink: 0; }
.pipe-dot {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700;
  border: 2px solid rgba(196,198,208,0.5);
  color: var(--md-sys-color-on-surface-variant);
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .15s, box-shadow .2s;
}
.pipe-dot:hover { transform: scale(1.15); }
.pipe-dot.done {
  background: linear-gradient(135deg, var(--md-sys-color-secondary), #26A69A);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,137,123,.35);
}
.pipe-dot.current {
  background: linear-gradient(135deg, var(--md-sys-color-primary), #1976D2);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 0 5px rgba(21,101,192,.15), 0 2px 8px rgba(21,101,192,.35);
}
.pipe-line {
  height: 2px; width: 32px;
  background: rgba(196,198,208,0.5);
  flex-shrink: 0;
}
.pipe-line.done {
  background: linear-gradient(90deg, var(--md-sys-color-secondary), #26A69A);
  box-shadow: 0 0 4px rgba(0,137,123,.3);
}

/* ── Dialog / Modal ──────────────────────────────────────────────── */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20,24,40,.35);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#modal-overlay.open { display: flex; }
#modal-box {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(32px) saturate(200%);
  -webkit-backdrop-filter: blur(32px) saturate(200%);
  border: 1px solid var(--glass-border);
  border-radius: var(--md-sys-shape-corner-xl);
  padding: 28px;
  width: 100%; max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--glass-shadow-deep), var(--glass-inset), 0 0 0 0.5px rgba(255,255,255,0.6);
  animation: modal-in .25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modal-in {
  from { transform: scale(.88) translateY(16px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);    opacity: 1; }
}

/* ── Toast ───────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  min-width: 280px; max-width: 480px;
}
.toast {
  padding: 13px 20px;
  border-radius: 100px;
  background: rgba(30,35,55,0.82);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
  font-size: .875rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,0.12);
  display: flex; align-items: center; gap: 10px;
  animation: toast-in .3s cubic-bezier(.34,1.56,.64,1), toast-out .25s ease 3.5s forwards;
  pointer-events: auto;
}
.toast-success { background: rgba(27,94,32,0.85); }
.toast-error   { background: rgba(183,38,30,0.85); }
.toast-warn    { background: rgba(230,81,0,0.85); }
@keyframes toast-in  { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; font-size: .65rem; font-weight: 700;
  background: linear-gradient(135deg, var(--md-sys-color-primary), #1976D2);
  color: #fff;
  box-shadow: 0 1px 4px rgba(21,101,192,.35);
}
.badge-error { background: linear-gradient(135deg, var(--md-sys-color-error), #C62828); box-shadow: 0 1px 4px rgba(183,38,30,.35); }
.badge-warn  { background: linear-gradient(135deg, #EF6C00, #F57C00); box-shadow: 0 1px 4px rgba(239,108,0,.35); }

/* ── Loader ──────────────────────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid rgba(196,198,208,.35);
  border-top-color: var(--md-sys-color-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scrollbar ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(116,119,127,.35); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(116,119,127,.55); }

/* ── Responsive / Bottom Nav ─────────────────────────────────────── */
@media (max-width: 768px) {
  #nav-rail { display: none; }
  #bottom-nav { display: flex !important; }
  #main-content { margin-left: 0 !important; padding-bottom: 80px; }
}
#bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid var(--glass-border);
  box-shadow: 0 -4px 24px rgba(31,38,135,.07);
  z-index: 100;
  height: 68px;
  align-items: stretch;
}
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px; font-size: .6rem; font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer; border: none; background: transparent;
  text-decoration: none;
  transition: color .2s, transform .15s;
  letter-spacing: .3px;
}
.bottom-nav-item:active { transform: scale(.92); }
.bottom-nav-item.active { color: var(--md-sys-color-primary); }
.bottom-nav-item .nav-icon { font-size: 1.1rem; }

/* ── Empty States ────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 56px 24px; gap: 16px; color: var(--md-sys-color-on-surface-variant);
  text-align: center;
}
.empty-icon { font-size: 3rem; opacity: .7; }

/* ── Utility ─────────────────────────────────────────────────────── */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider  { height: 1px; background: rgba(196,198,208,0.45); margin: 12px 0; }

/* ── Stat Cards (dashboard) ──────────────────────────────────────── */
.stat-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--md-sys-shape-corner-large);
  box-shadow: var(--glass-shadow), var(--glass-inset);
  padding: 20px 22px;
  transition: transform .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.9), transparent);
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--glass-shadow-deep), var(--glass-inset);
}

/* ── Section headers ─────────────────────────────────────────────── */
.glass-section-header {
  background: rgba(255,255,255,0.38);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 12px 18px;
  margin-bottom: 16px;
  box-shadow: var(--glass-inset);
}

/* ── Login card ──────────────────────────────────────────────────── */
#login-card {
  background: rgba(255,255,255,0.62);
  backdrop-filter: blur(32px) saturate(200%);
  -webkit-backdrop-filter: blur(32px) saturate(200%);
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  box-shadow: var(--glass-shadow-deep), var(--glass-inset);
  padding: 40px 36px;
  width: 100%; max-width: 400px;
  animation: modal-in .4s cubic-bezier(.34,1.56,.64,1);
}

/* ── Specular top highlight on interactive glass containers ─────── */
.md-card::before,
.stage-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.95), transparent);
  pointer-events: none;
}
.md-card { position: relative; }
.stage-panel { position: relative; }
