/* ─────────────────────────────────────────────────────────────────
   KARS CRM Dashboard — Design System v1.0
   Anchor: serious clinical authority
   See DESIGN.md for full spec.
   ───────────────────────────────────────────────────────────────── */

:root {
  /* Color — light mode (operations canvas) */
  --canvas:        #FAF7F2;
  --surface:       #FFFFFF;
  --surface-elev:  #FFFFFF;
  --border:        #E4E0D8;
  --border-strong: #D4CFC2;
  --text:          #14181F;
  --muted:         #5C6470;
  --muted-2:       #828892;
  --accent:        #0A2540;
  --accent-soft:   #DDE4EE;
  --critical:      #7E1B16;
  --critical-soft: #F5E2E0;
  --warning:       #A8721A;
  --warning-soft:  #F4E5C9;
  --success:       #1A5D3F;
  --success-soft:  #DCEAE2;
  --chart:         #365A82;

  /* Typography */
  --serif: "Instrument Serif", "Source Serif 4", Georgia, serif;
  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "Geist Mono", "JetBrains Mono", ui-monospace, "SF Mono", monospace;

  /* Radii — square-ish, NEVER pill */
  --r-sm: 2px;
  --r-md: 4px;
  --r-lg: 6px;
  --r-xl: 8px;

  /* Spacing scale (4px base) */
  --s-2xs: 2px;  --s-xs: 4px;  --s-sm: 8px;  --s-md: 16px;
  --s-lg: 24px;  --s-xl: 32px; --s-2xl: 48px; --s-3xl: 64px; --s-4xl: 96px;

  /* Layout */
  --sidebar-w: 240px;

  /* Subtle paper grain on canvas (5% opacity max) */
  --grid-bg: radial-gradient(circle at 1px 1px, rgba(20,24,31,0.05) 1px, transparent 0);

  /* Motion */
  --easing-out: cubic-bezier(0.16, 1, 0.3, 1);
  --easing-in: ease-in;
  --easing-move: ease-in-out;
}

[data-theme="dark"] {
  --canvas:        #0F1218;
  --surface:       #1A1F26;
  --surface-elev:  #1F252E;
  --border:        #262C36;
  --border-strong: #353D4A;
  --text:          #E8E5DD;
  --muted:         #8B919A;
  --muted-2:       #6B7280;
  --accent:        #3B6A99;
  --accent-soft:   #1A2B3F;
  --critical-soft: #2A1614;
  --warning-soft:  #2A2014;
  --success-soft:  #142A1F;
  --grid-bg: radial-gradient(circle at 1px 1px, rgba(232,229,221,0.04) 1px, transparent 0);
}

/* ─────────────────────────────────────────────────────────────────
   Base
   ───────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--canvas);
  background-image: var(--grid-bg);
  background-size: 22px 22px;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "ss02";
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* ─────────────────────────────────────────────────────────────────
   Layout: shell with persistent left sidebar
   ───────────────────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--accent);
  color: rgba(255, 255, 255, 0.86);
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  padding: 0 22px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 22px;
}
.sidebar-mark {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: #fff;
  line-height: 1;
}
.sidebar-sub {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 6px;
}
.sidebar-nav {
  padding: 0 12px;
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}
.sidebar-nav-section {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  padding: 14px 12px 6px;
}
.sidebar-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  font-family: var(--sans);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: background 120ms var(--easing-out), color 120ms var(--easing-out);
}
.sidebar-nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-decoration: none;
}
.sidebar-nav-item.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.sidebar-nav-item i {
  font-size: 14px;
  opacity: 0.7;
  width: 14px;
}

.sidebar-search {
  padding: 0 14px;
  margin: 16px 0 8px;
}
.sidebar-search input {
  width: 100%;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--r-md);
  font-family: var(--sans);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
  outline: none;
  transition: border-color 160ms var(--easing-out);
}
.sidebar-search input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}
.sidebar-search input:focus {
  border-color: rgba(255, 255, 255, 0.3);
}

.sidebar-foot {
  flex-shrink: 0;
  padding: 16px 22px 0;
  margin-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
}
.sidebar-brand, .sidebar-search { flex-shrink: 0; }
/* Slim scrollbar inside nav so it doesn't dominate visually */
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
}
.sidebar-nav { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent; }

/* Main content area */
.main {
  padding: 64px 56px 96px;
  max-width: 1280px;
  width: 100%;
}

/* Page header rhythm */
.page-breadcrumb {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}
.page-h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 8px;
}
.page-h1 em { font-style: italic; color: var(--accent); }
.page-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  line-height: 1.5;
  color: var(--muted);
  margin: 0 0 40px;
  max-width: 720px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.page-actions-spacer { flex: 1; }

/* ─────────────────────────────────────────────────────────────────
   Section rule (between major content blocks)
   ───────────────────────────────────────────────────────────────── */
.rule {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  margin: 32px 0 20px;
}
.rule-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.005em;
  color: var(--text);
}
.rule-title em { font-style: italic; color: var(--muted); font-size: 18px; }
.rule-line { height: 1px; background: var(--border-strong); }
.rule-meta {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ─────────────────────────────────────────────────────────────────
   KPI card grid
   ───────────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
.kpi-grid--3 { grid-template-columns: repeat(3, 1fr); }
.kpi-grid--2 { grid-template-columns: repeat(2, 1fr); }

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px 22px;
  position: relative;
  transition: transform 160ms var(--easing-out), box-shadow 160ms var(--easing-out);
}
.kpi:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px -4px rgba(20, 24, 31, 0.08);
}
.kpi-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-value {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.015em;
  color: var(--text);
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}
.kpi-value-unit {
  font-family: var(--sans);
  font-size: 16px;
  color: var(--muted);
  font-variant-numeric: normal;
  font-weight: 400;
  letter-spacing: 0;
}
.kpi-meta {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted-2);
}
.kpi--critical {
  border-color: var(--critical);
  border-left: 3px solid var(--critical);
}
.kpi--critical .kpi-value { color: var(--critical); }
.kpi--success {
  border-left: 3px solid var(--success);
}
.kpi--success .kpi-value { color: var(--success); }
.kpi--warning {
  border-left: 3px solid var(--warning);
}
.kpi--accent {
  border-left: 3px solid var(--accent);
}

/* ─────────────────────────────────────────────────────────────────
   Generic surface card
   ───────────────────────────────────────────────────────────────── */
.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.surface-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.surface-head-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: -0.005em;
  color: var(--text);
  margin: 0;
}
.surface-head-meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.surface-body { padding: 20px; }

/* ─────────────────────────────────────────────────────────────────
   Tables (compact, tabular-nums)
   ───────────────────────────────────────────────────────────────── */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 13px;
}
.tbl th {
  text-align: left;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--canvas);
  white-space: nowrap;
}
.tbl td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: var(--canvas); }
.tbl .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.tbl .name {
  font-weight: 500;
  color: var(--text);
}
.tbl .muted {
  color: var(--muted-2);
  font-size: 12px;
}
.tbl-mono {
  font-family: var(--mono);
  font-size: 12px;
}

/* ─────────────────────────────────────────────────────────────────
   Badges (semantic)
   ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  border-radius: var(--r-sm);
  border: 1px solid;
  white-space: nowrap;
  vertical-align: middle;
}
.badge--critical { color: var(--critical); border-color: var(--critical); background: var(--critical-soft); }
.badge--warning  { color: var(--warning);  border-color: var(--warning);  background: var(--warning-soft); }
.badge--success  { color: var(--success);  border-color: var(--success);  background: var(--success-soft); }
.badge--accent   { color: var(--accent);   border-color: var(--accent);   background: var(--accent-soft); }
.badge--neutral  { color: var(--muted);    border-color: var(--border-strong); background: var(--canvas); }
.badge .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ─────────────────────────────────────────────────────────────────
   Progress bars (for risk scores in tables)
   ───────────────────────────────────────────────────────────────── */
.progress {
  display: inline-block;
  width: 80px;
  height: 6px;
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 8px;
}
.progress > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 240ms var(--easing-out);
}
.progress--critical > i { background: var(--critical); }
.progress--warning > i  { background: var(--warning); }
.progress--success > i  { background: var(--success); }

/* ─────────────────────────────────────────────────────────────────
   Buttons
   ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 160ms var(--easing-out);
  background: transparent;
  color: var(--text);
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: #051A2E; color: #fff; }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--secondary:hover { border-color: var(--text); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--border-strong); }
.btn--critical { background: var(--critical); color: #fff; }
.btn--critical:hover { background: #5C120E; color: #fff; }
.btn--sm { padding: 6px 12px; font-size: 12px; }

/* ─────────────────────────────────────────────────────────────────
   Pull-quote (replaces "Untuk Anak SD" yellow callout boxes)
   ───────────────────────────────────────────────────────────────── */
.pullquote {
  margin: 32px 0;
  padding: 28px 32px 28px 28px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0 var(--r-md) var(--r-md) 0;
}
.pullquote-eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}
.pullquote-eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.pullquote-eyebrow em {
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}
.pullquote-text {
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  color: var(--text);
  margin: 0;
  max-width: 760px;
}
.pullquote-text b,
.pullquote-text strong {
  font-style: normal;
  font-family: var(--sans);
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95em;
}
.pullquote-text ul,
.pullquote-text ol {
  margin: 12px 0 0;
  padding-left: 24px;
}
.pullquote-text li {
  margin: 4px 0;
  font-size: 17px;
}

/* ─────────────────────────────────────────────────────────────────
   Form controls
   ───────────────────────────────────────────────────────────────── */
.input {
  font-family: var(--sans);
  font-size: 13px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  outline: none;
  transition: border-color 160ms var(--easing-out);
}
.input:focus { border-color: var(--accent); }

/* ─────────────────────────────────────────────────────────────────
   Footer
   ───────────────────────────────────────────────────────────────── */
.foot {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ─────────────────────────────────────────────────────────────────
   Two-column layout helper
   ───────────────────────────────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 32px;
}
.two-col--equal { grid-template-columns: 1fr 1fr; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 32px; }

/* ─────────────────────────────────────────────────────────────────
   Theme toggle
   ───────────────────────────────────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--r-md);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 160ms var(--easing-out);
}
.theme-toggle:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

/* ─────────────────────────────────────────────────────────────────
   Reduced motion
   ───────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─────────────────────────────────────────────────────────────────
   Responsive (collapse sidebar on narrow screens)
   ───────────────────────────────────────────────────────────────── */
/* ─────────────────────────────────────────────────────────────────
   Mobile responsive — hamburger + bottom nav + drawer
   ───────────────────────────────────────────────────────────────── */

/* Hamburger button — fixed top-right, mobile only */
.mob-hamburger {
  display: none;
  position: fixed;
  top: 14px; right: 16px;
  z-index: 200;
  width: 44px; height: 44px;
  background: var(--accent);
  border: none; border-radius: var(--r-md);
  color: white; font-size: 20px;
  cursor: pointer;
  align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(10,37,64,0.30);
}
.mob-hamburger.open { background: var(--critical); }

/* Drawer overlay */
.mob-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10,37,64,0.50);
  backdrop-filter: blur(4px);
  z-index: 150;
}
.mob-overlay.open { display: block; }

/* Bottom navigation bar */
.mob-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--accent);
  z-index: 140;
  padding: 0 4px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.mob-bottom-nav-inner {
  display: flex;
  height: 100%;
  align-items: stretch;
  justify-content: space-around;
}
.mob-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  text-decoration: none;
  color: rgba(255,255,255,0.60);
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 4px;
  transition: color 120ms;
  min-width: 44px; /* touch target */
}
.mob-nav-item i { font-size: 20px; }
.mob-nav-item.active,
.mob-nav-item:hover { color: #fff; }

@media (max-width: 960px) {
  /* Hide desktop sidebar, show hamburger + bottom nav */
  .sidebar      { display: none; }
  .mob-hamburger { display: flex; }
  .mob-bottom-nav { display: block; }

  .app-shell { grid-template-columns: 1fr; }
  .main {
    padding: 16px 14px 80px;  /* bottom: space for nav bar */
  }

  /* Sidebar as drawer when open */
  .sidebar.mob-open {
    display: flex;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(280px, 80vw);
    height: 100%;
    z-index: 160;
    overflow-y: auto;
    animation: drawerIn 220ms cubic-bezier(0.16,1,0.3,1);
  }
  @keyframes drawerIn {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
  }

  /* Typography scale down */
  .page-h1          { font-size: 28px; }
  .page-sub         { font-size: 14px; }

  /* KPIs: 2 columns on phone */
  .kpi-grid,
  .kpi-grid--3      { grid-template-columns: repeat(2, 1fr); }
  .kpi-value        { font-size: 28px; }

  /* Grids → single column */
  .two-col,
  .two-col--equal,
  .three-col        { grid-template-columns: 1fr; }

  /* Tables → horizontal scroll container */
  .surface-body > .tbl,
  .surface-body > table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Kanban → scroll horizontally */
  .kanban           { grid-template-columns: repeat(6, minmax(240px, 1fr)); overflow-x: auto; }

  /* KPI pair spacing */
  .page-actions     { flex-direction: column; gap: 8px; }
  .page-actions-spacer { display: none; }
  .page-actions .btn { width: 100%; text-align: center; }

  /* Mockup: hide side panels */
  .mockup-side      { display: none; }
  .mockup-shell     { grid-template-columns: 1fr; }
  .phone            { width: 100%; max-width: 390px; }

  /* Search scorecard: 1 col */
  .scorecard        { grid-template-columns: 1fr 1fr; }

  /* Forecast band: stacked */
  .forecast-band    { grid-template-columns: 1fr; }
  .band-cell        { border-right: none; border-bottom: 1px solid var(--border); padding: 16px 0; }
  .band-cell:last-child { border-bottom: none; }

  /* Rule bar: wrap */
  .rule             { flex-wrap: wrap; gap: 8px; }
  .rule-line        { display: none; }
}

@media (max-width: 480px) {
  /* Smallest phones: single-column KPIs */
  .kpi-grid,
  .kpi-grid--3 { grid-template-columns: 1fr; }
  .main        { padding: 12px 12px 80px; }
  .scorecard   { grid-template-columns: 1fr; }
  .step-nav    { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────────────────────────────
   Loading screen + skeleton
   ───────────────────────────────────────────────────────────────── */

/* Full-page loading screen */
#page-loader {
  position: fixed;
  inset: 0;
  background: var(--canvas);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  transition: opacity 300ms var(--easing-out);
}
#page-loader.fade-out {
  opacity: 0;
  pointer-events: none;
}
.loader-mark {
  font-family: var(--serif);
  font-style: italic;
  font-size: 40px;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.loader-bar {
  width: 180px;
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  overflow: hidden;
}
.loader-bar::after {
  content: '';
  display: block;
  height: 100%;
  width: 40%;
  background: var(--accent);
  border-radius: 1px;
  animation: loader-slide 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes loader-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
.loader-sub {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

/* Skeleton shimmer — applied to any element with .skel */
@keyframes skel-shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}
.skel {
  background: linear-gradient(
    90deg,
    var(--border) 25%,
    var(--canvas) 50%,
    var(--border) 75%
  );
  background-size: 1200px 100%;
  animation: skel-shimmer 1.6s ease-in-out infinite;
  border-radius: var(--r-sm);
  color: transparent !important;
}
.skel * { visibility: hidden; }

/* KPI skeleton */
.kpi.skel {
  height: 110px;
  border-radius: var(--r-md);
}
/* Surface / table skeleton */
.surface.skel, .surface.skel * {
  visibility: hidden;
}
.surface.skel {
  min-height: 200px;
}
/* Skeleton text lines */
.skel-line {
  height: 14px;
  margin-bottom: 10px;
  border-radius: var(--r-sm);
}
.skel-line.short { width: 40%; }
.skel-line.medium { width: 65%; }
.skel-line.long { width: 90%; }
.skel-line.full { width: 100%; }
.skel-h1 {
  height: 42px;
  width: 55%;
  margin-bottom: 12px;
  border-radius: var(--r-sm);
}
.skel-badge {
  display: inline-block;
  height: 20px;
  width: 72px;
  border-radius: var(--r-sm);
  vertical-align: middle;
}

/* Lazy-load fade-in for images and heavy sections */
.lazy-section {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 400ms var(--easing-out), transform 400ms var(--easing-out);
}
.lazy-section.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .loader-bar::after    { animation: none; }
  .skel                 { animation: none; }
  .lazy-section         { opacity: 1; transform: none; }
}
