/* ============================================================
   EEC Marine Monitoring — Design System v1.0
   Staff Portal: Dark theme (Humiint-inspired)
   Public Site:  Light marine theme (government branding)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ── 1. CSS Custom Properties ─────────────────────────────── */
:root {
  /* Brand — DMCR Navy + Ocean Teal */
  --color-primary:        #1B3A6B;
  --color-primary-light:  #E8EEF6;
  --color-primary-dark:   #0E2244;
  --color-accent:         #00A78E;
  --color-accent-light:   #E0F7F3;
  --color-accent-dark:    #007D6A;

  /* Backgrounds — Light theme (public default) */
  --bg-base:       #F3F6FA;
  --bg-surface:    #EAF0F7;
  --bg-elevated:   #FFFFFF;
  --bg-subtle:     #FFFFFF;

  /* Borders */
  --border-dim:    rgba(0,0,0,0.07);
  --border-mid:    rgba(0,0,0,0.13);
  --border-strong: rgba(0,0,0,0.22);

  /* Text */
  --text-primary:   #1A1D23;
  --text-secondary: #5A6170;
  --text-muted:     #9BA3B2;

  /* CTA — Ocean blue */
  --cta:           #1B6EC2;
  --cta-hover:     #1A7FE0;
  --cta-dim:       rgba(27,110,194,0.08);

  /* Semantic */
  --success:       #22A869;
  --success-dim:   rgba(34,168,105,0.10);
  --warning:       #EF9F27;
  --warning-dim:   rgba(239,159,39,0.10);
  --danger:        #E24B4A;
  --danger-dim:    rgba(226,75,74,0.10);
  --info:          #378ADD;
  --info-dim:      rgba(55,138,221,0.10);

  /* NOAA Bleaching Alert Level ramp */
  --alert-0-fill:  #FFFFFF;  --alert-0-text: #444441;
  --alert-1-fill:  #B3E5FC;  --alert-1-text: #0C447C;
  --alert-2-fill:  #FFF176;  --alert-2-text: #633806;
  --alert-3-fill:  #FF9800;  --alert-3-text: #412402;
  --alert-4-fill:  #E53935;  --alert-4-text: #ffffff;
  --alert-5-fill:  #4A148C;  --alert-5-text: #ffffff;

  /* Buoy status */
  --status-online:   #22A869;
  --status-warning:  #EF9F27;
  --status-alert:    #E24B4A;
  --status-offline:  #9BA3B2;

  /* Shoreline SCR */
  --scr-severe:    #E24B4A;
  --scr-eroding:   #EF9F27;
  --scr-stable:    #639922;
  --scr-accreting: #22A869;

  /* Sensor parameter chart colors */
  --param-water-temp: #E24B4A;
  --param-ph:         #7B5FD9;
  --param-do:         #378ADD;
  --param-salinity:   #22A869;
  --param-turbidity:  #BA7517;
  --param-par:        #EF9F27;

  /* QARTOD quality flags */
  --qc-pass:    #22A869;
  --qc-suspect: #EF9F27;
  --qc-fail:    #E24B4A;

  /* Fonts */
  --font-display: 'Kanit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --font-mono:    'IBM Plex Mono', 'SF Mono', monospace;
  --font-thai:    'Kanit', 'Noto Sans Thai', sans-serif;

  /* Spacing */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  24px;
  --space-6:  32px;
  --space-7:  48px;
  --space-8:  64px;
  --space-9:  96px;

  /* Radii */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs:  0 1px 3px rgba(0,0,0,0.06);
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.14);

  /* Transitions */
  --transition-fast: 0.12s ease;
  --transition-base: 0.20s ease;
  --transition-slow: 0.35s ease;
}

/* ── 1b. Dark Theme (Staff Portal) ───────────────────────── */
html[data-theme="dark"] {
  --bg-base:       #0B1121;
  --bg-surface:    #111827;
  --bg-elevated:   #1A2332;
  --bg-subtle:     #0F1729;

  --border-dim:    rgba(255,255,255,0.07);
  --border-mid:    rgba(255,255,255,0.12);
  --border-strong: rgba(255,255,255,0.22);

  --text-primary:   #E8EDF5;
  --text-secondary: #8B9AB5;
  --text-muted:     #4A5E80;

  --cta-dim:       rgba(27,110,194,0.15);
  --success-dim:   rgba(34,168,105,0.15);
  --warning-dim:   rgba(239,159,39,0.15);
  --danger-dim:    rgba(226,75,74,0.15);
  --info-dim:      rgba(55,138,221,0.15);

  --shadow-xs:  0 1px 3px  rgba(0,0,0,0.30);
  --shadow-sm:  0 2px 8px  rgba(0,0,0,0.40);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.52);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.62);
}

/* ── 1c. Font Size Scaling ───────────────────────────────── */
html[data-font-size="small"]  .main-content { zoom: 0.9; }
html[data-font-size="large"]  .main-content { zoom: 1.1; }

/* ── 2. Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font-body); cursor: pointer; }
input, select, textarea { font-family: var(--font-body); }
img { display: block; max-width: 100%; }
ul { list-style: none; }

/* Global modern thin scrollbar */
*, *::before, *::after {
  scrollbar-width: thin;
  scrollbar-color: rgba(100,130,180,0.2) transparent;
}
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(100,130,180,0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(100,130,180,0.35); }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(100,160,255,0.15); }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(100,160,255,0.3); }

/* ── 3. Typography ────────────────────────────────────────── */
.text-hero  { font-family: var(--font-display); font-size: 47px; font-weight: 700; line-height: 1.1;  letter-spacing: -0.02em; }
.text-h1    { font-family: var(--font-display); font-size: 31px; font-weight: 600; line-height: 1.2;  letter-spacing: -0.01em; }
.text-h2    { font-family: var(--font-display); font-size: 23px; font-weight: 600; line-height: 1.3; }
.text-h3    { font-family: var(--font-body);    font-size: 17px; font-weight: 600; line-height: 1.4; }
.text-body  { font-family: var(--font-body);    font-size: 14px; font-weight: 400; line-height: 1.65; color: var(--text-secondary); }
.text-small { font-family: var(--font-body);    font-size: 12px; font-weight: 400; line-height: 1.5;  color: var(--text-secondary); }
.text-label { font-family: var(--font-body);    font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.text-mono  { font-family: var(--font-mono);    font-size: 13px; font-weight: 400; }
.text-thai  { font-family: var(--font-thai); }

/* ── 4. Layout ────────────────────────────────────────────── */
.container { max-width: 1280px; margin: 0 auto; padding: 0 var(--space-6); }

/* ── 5. Navbar ────────────────────────────────────────────── */
.navbar {
  height: 60px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-mid);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-5);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar__logo {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.navbar__logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.navbar__search {
  flex: 1;
  max-width: 400px;
  position: relative;
}
.navbar__search input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 14px;
  padding: 8px 16px 8px 36px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.navbar__search input::placeholder { color: var(--text-muted); }
.navbar__search input:focus { border-color: var(--cta); box-shadow: 0 0 0 3px var(--cta-dim); }
.navbar__search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.navbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); }
.navbar__icon-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition-fast);
}
.navbar__icon-btn:hover { background: var(--bg-surface); color: var(--text-primary); }
.navbar__badge {
  position: absolute;
  top: -3px; right: -3px;
  min-width: 16px; height: 16px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg-subtle);
}
.navbar__avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-mid);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-accent);
  cursor: pointer;
  transition: border-color var(--transition-fast);
  overflow: hidden;
}
.navbar__avatar:hover { border-color: var(--text-secondary); }

/* MQTT Live Indicator */
.mqtt-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  letter-spacing: 0.03em;
}
.mqtt-pill.live     { background: var(--success-dim); color: var(--success); }
.mqtt-pill.connecting { background: var(--warning-dim); color: var(--warning); }
.mqtt-pill.offline  { background: var(--danger-dim); color: var(--danger); }
.mqtt-pill__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.mqtt-pill.live .mqtt-pill__dot { animation: mqttPulse 2s ease-in-out infinite; }
@keyframes mqttPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── 6. Sidebar ───────────────────────────────────────────── */
.sidebar {
  background: var(--bg-subtle);
  border-right: 1px solid var(--border-mid);
  padding: var(--space-3) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 1px;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.sidebar::-webkit-scrollbar-button { display: none; height: 0; }

.sidebar__body { flex: 1; overflow-y: auto; padding: var(--space-3); }
.sidebar__nav  { display: flex; flex-direction: column; gap: 2px; }
.sidebar__divider {
  padding: var(--space-4) var(--space-3) var(--space-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sidebar__footer {
  padding: var(--space-3);
  border-top: 1px solid var(--border-dim);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar__logout {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 8px var(--space-3);
  border-radius: var(--radius-md);
  background: none; border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  transition: all var(--transition-fast);
}
.sidebar__logout:hover { background: var(--danger-dim); color: var(--danger); }

.sidebar-section { padding: 2px var(--space-2); margin-top: var(--space-1); }
.sidebar-section-label {
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
  padding: 0 var(--space-3);
}
.nav-item {
  display: flex; align-items: center;
  gap: var(--space-3);
  padding: 7px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px; font-weight: 400;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}
.nav-item:hover { background: var(--bg-surface); color: var(--text-primary); }
.nav-item.active { background: var(--cta-dim); color: var(--cta); font-weight: 600; }
.nav-item.active .nav-icon { color: var(--cta); }
.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--text-muted); }
.nav-item .nav-badge {
  margin-left: auto;
  min-width: 18px; height: 18px;
  background: var(--danger);
  color: #fff;
  font-size: 10px; font-weight: 600;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

/* ── 7. Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-xs);
}
.card-sm { padding: var(--space-4); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-4);
}
.card-title { font-family: var(--font-body); font-size: 17px; font-weight: 600; color: var(--text-primary); }

/* ── 8. Badges ────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-dim);
  white-space: nowrap; line-height: 1.4;
}
.badge-primary { background: var(--cta-dim);     color: var(--cta);     border-color: transparent; }
.badge-success { background: var(--success-dim); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-dim); color: var(--warning); border-color: transparent; }
.badge-danger  { background: var(--danger-dim);  color: var(--danger);  border-color: transparent; }
.badge-info    { background: var(--info-dim);     color: var(--info);    border-color: transparent; }

/* NOAA Alert badges */
.badge-alert-0 { background: var(--alert-0-fill); color: var(--alert-0-text); border-color: transparent; }
.badge-alert-1 { background: var(--alert-1-fill); color: var(--alert-1-text); border-color: transparent; }
.badge-alert-2 { background: var(--alert-2-fill); color: var(--alert-2-text); border-color: transparent; }
.badge-alert-3 { background: var(--alert-3-fill); color: var(--alert-3-text); border-color: transparent; }
.badge-alert-4 { background: var(--alert-4-fill); color: var(--alert-4-text); border-color: transparent; }
.badge-alert-5 { background: var(--alert-5-fill); color: var(--alert-5-text); border-color: transparent; }

/* Buoy status badges */
.badge-online  { background: var(--success-dim); color: var(--status-online); border-color: transparent; }
.badge-offline { background: rgba(155,163,178,0.12); color: var(--status-offline); border-color: transparent; }

/* QARTOD flag badges */
.badge-qc-pass    { background: rgba(34,168,105,0.12); color: var(--qc-pass); border-color: transparent; }
.badge-qc-suspect { background: rgba(239,159,39,0.12); color: var(--qc-suspect); border-color: transparent; }
.badge-qc-fail    { background: rgba(226,75,74,0.12);  color: var(--qc-fail); border-color: transparent; }

/* ── 9. Buttons ───────────────────────────────────────────── */
.btn-primary {
  background: var(--cta); color: #fff; border: none;
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
  white-space: nowrap;
}
.btn-primary:hover  { background: var(--cta-hover); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 14px; font-weight: 400;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  white-space: nowrap;
}
.btn-secondary:hover { border-color: var(--border-strong); background: var(--bg-surface); }

.btn-accent {
  background: var(--color-accent); color: #fff; border: none;
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition-fast);
  white-space: nowrap;
}
.btn-accent:hover { opacity: 0.88; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary); border: none;
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 14px;
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
  white-space: nowrap;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-surface); }

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(226,75,74,0.15);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.btn-danger:hover { background: rgba(226,75,74,0.15); }

.btn-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  color: var(--text-secondary);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.btn-icon:hover { border-color: var(--border-mid); color: var(--text-primary); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

/* ── 10. Forms ────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group:last-child { margin-bottom: 0; }
.form-label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.form-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition-fast);
}
.form-input:focus { border-color: var(--cta); box-shadow: 0 0 0 3px var(--cta-dim); }
.form-input::placeholder { color: var(--text-muted); }
.form-select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239BA3B2' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.25rem;
}
.form-select:focus { border-color: var(--cta); }
textarea.form-input { resize: vertical; min-height: 100px; line-height: 1.6; }

/* ── 11. Filter Tabs ──────────────────────────────────────── */
.filter-tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.filter-tab {
  padding: 6px 16px;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex; align-items: center; gap: 0.35rem;
  white-space: nowrap;
}
.filter-tab:hover { color: var(--text-primary); border-color: var(--border-strong); }
.filter-tab.active {
  background: var(--cta-dim);
  border-color: rgba(27,110,194,0.35);
  color: var(--cta);
  font-weight: 600;
}

/* ── 12. Tables ───────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-mid);
  background: var(--bg-surface);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-dim);
  color: var(--text-secondary);
}
.data-table tr:hover td { background: rgba(27,110,194,0.03); }
.data-table td:first-child { color: var(--text-primary); font-weight: 500; }

/* ── 13. Stats ────────────────────────────────────────────── */
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition-base);
}
.stat-card:hover { border-color: var(--border-mid); }
.stat-card__icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-3);
}
.stat-card__value {
  font-family: var(--font-mono);
  font-size: 28px; font-weight: 500;
  color: var(--text-primary);
  line-height: 1; margin-bottom: var(--space-1);
}
.stat-card__label { font-size: 13px; color: var(--text-secondary); }
.stat-card__sub   { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.dash-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
@media (max-width: 900px)  { .dash-stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px)  { .dash-stat-grid { grid-template-columns: 1fr; } }

/* ── 14. Toggle switch ────────────────────────────────────── */
.toggle { position: relative; width: 40px; height: 22px; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--border-mid);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-base);
}
.toggle input:checked + .toggle-track { background: var(--cta); }
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition-base);
}
.toggle input:checked ~ .toggle-thumb { transform: translateX(18px); }

/* ── 15. Modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  z-index: 500;
  padding: var(--space-5);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-xl);
  max-width: 560px; width: 100%;
  box-shadow: var(--shadow-lg);
  animation: fadeSlideUp 0.2s ease;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5) var(--space-6) var(--space-4);
  flex-shrink: 0;
}
.modal-body {
  overflow-y: auto; flex: 1;
  padding: 0 var(--space-6) var(--space-5);
}
.modal-footer {
  padding: var(--space-4) var(--space-6);
  flex-shrink: 0;
  border-top: 1px solid var(--border-dim);
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3);
}
.modal-title { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-surface); border: none;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: color var(--transition-fast);
}
.modal-close:hover { color: var(--text-primary); }

/* ── 16. Toast Notifications ──────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 999;
  display: flex; flex-direction: column; gap: var(--space-3);
  pointer-events: none;
}
.toast {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastSlideIn 0.3s ease;
  display: flex; align-items: center; gap: var(--space-3);
  max-width: 380px;
  pointer-events: auto;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--info); }
.toast__icon { flex-shrink: 0; width: 18px; height: 18px; }
.toast__message { flex: 1; }
.toast__close {
  width: 20px; height: 20px; flex-shrink: 0;
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}
.toast__close:hover { opacity: 1; }

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── 17. Animations ───────────────────────────────────────── */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-enter { animation: fadeSlideUp 0.25s ease forwards; }

@keyframes skeleton {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}
.skeleton {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  animation: skeleton 1.6s ease-in-out infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-mid);
  border-top-color: var(--cta);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ── 18. Dividers ─────────────────────────────────────────── */
.divider { height: 1px; background: var(--border-dim); margin: var(--space-5) 0; }

/* ── 19. Empty States ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-9) var(--space-6);
  color: var(--text-muted);
}
.empty-state__icon { width: 48px; height: 48px; margin: 0 auto var(--space-4); opacity: 0.4; }
.empty-state__title { font-size: 17px; font-weight: 600; color: var(--text-secondary); margin-bottom: var(--space-2); }
.empty-state__body  { font-size: 14px; color: var(--text-muted); line-height: 1.6; max-width: 320px; margin: 0 auto var(--space-5); }

/* ── 20. Utility Classes ──────────────────────────────────── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); } .gap-5 { gap: var(--space-5); } .gap-6 { gap: var(--space-6); }
.ml-auto { margin-left: auto; }
.mt-auto { margin-top: auto; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--space-2); } .mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); } .mb-5 { margin-bottom: var(--space-5); } .mb-6 { margin-bottom: var(--space-6); }
.mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.font-mono { font-family: var(--font-mono); }
.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.overflow-x-auto { overflow-x: auto; }

/* ── 21. Responsive ───────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar-section-label { display: none; }
  .nav-item span { display: none; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .text-hero { font-size: 32px; }
  .text-h1   { font-size: 24px; }
}
