  :root, .viz-root {
    color-scheme: light;
    --surface-1:      #fcfcfb;
    --page-plane:     #f9f9f7;
    --text-primary:   #0b0b0b;
    --text-secondary: #52514e;
    --text-muted:     #898781;
    --gridline:       #e1e0d9;
    --baseline:       #c3c2b7;
    --border:         rgba(11,11,11,0.10);
    --card:           #ffffff;
    --series-1:       #2a78d6;   /* blue */
    --series-2:       #eb6834;   /* orange */
    --series-3:       #1baf7a;   /* aqua */
    --seq-250:        #86b6ef;
    --seq-350:        #5598e7;
    --seq-450:        #2a78d6;
    --seq-550:        #1c5cab;
    --seq-650:        #104281;
    --good:           #0ca30c;
    --good-text:      #006300;
    --warning:        #fab219;
    --serious:        #ec835a;
    --critical:       #d03b3b;
    --brand-1:        #0b5c34;   /* MRD ministry green */
    --brand-2:        #178a4c;
    --brand-accent:   #2a78d6;   /* kept for links/info accents, distinct from status/series colors */
  }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page-plane:     #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,0.10);
    --card:           #222221;
    --series-1:       #3987e5;
    --series-2:       #d95926;
    --series-3:       #199e70;
    --seq-250:        #184f95;
    --seq-350:        #1c5cab;
    --seq-450:        #256abf;
    --seq-550:        #3987e5;
    --seq-650:        #86b6ef;
    --good:           #0ca30c;
    --good-text:      #0ca30c;
    --warning:        #fab219;
    --serious:        #ec835a;
    --critical:       #e66767;
    --brand-1:        #0a4a2a;
    --brand-2:        #1f9d5c;
    --brand-accent:   #3987e5;
  }

  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  body {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--page-plane);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
  }
  a { color: inherit; }
  button { font-family: inherit; }

  /* ---------- Utility ---------- */
  .hidden { display: none !important; }
  .muted { color: var(--text-muted); }
  .secondary { color: var(--text-secondary); }
  .tabular { font-variant-numeric: tabular-nums; }

  /* ---------- Login / landing screen ---------- */
  #screen-landing {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 20%, var(--brand-2) 0%, transparent 40%), var(--brand-1);
    padding: 24px;
  }
  .landing-card {
    background: var(--card);
    border-radius: 16px;
    max-width: 880px;
    width: 100%;
    box-shadow: 0 30px 60px rgba(0,0,0,0.35);
    overflow: hidden;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
  }
  .landing-brand {
    background: linear-gradient(160deg, var(--brand-1), var(--brand-2));
    color: #fff;
    padding: 40px 36px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .landing-brand .mark {
    display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: 0.5px;
  }
  .landing-brand .mark .dot { width: 12px; height: 12px; border-radius: 3px; background: #fff; }
  .landing-brand h1 { font-size: 26px; line-height: 1.25; margin: 24px 0 8px; }
  .landing-brand p { color: rgba(255,255,255,0.82); font-size: 14px; line-height: 1.6; }
  .landing-brand .foot { font-size: 12px; color: rgba(255,255,255,0.65); }
  .landing-pick { padding: 36px 32px; }
  .landing-pick h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 0 0 16px; }
  .role-btn {
    width: 100%;
    text-align: left;
    display: flex; align-items: center; gap: 14px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: border-color .15s, transform .05s;
  }
  .role-btn:hover { border-color: var(--brand-2); }
  .role-btn:active { transform: scale(0.99); }
  .role-btn .ic {
    width: 38px; height: 38px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
    background: var(--brand-2); color: #fff; font-weight: 700; font-size: 15px; flex: none;
  }
  .role-btn .tx strong { display: block; font-size: 14px; }
  .role-btn .tx span { display: block; font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
  .role-btn .arrow { margin-left: auto; color: var(--text-muted); }
  .theme-toggle-landing {
    margin-top: 18px; font-size: 12.5px; color: var(--text-muted); display: flex; align-items: center; gap: 8px;
  }

  /* ---------- App shell ---------- */
  .app-shell { display: none; min-height: 100vh; grid-template-columns: 240px 1fr; }
  .app-shell.active { display: grid; }
  .sidebar {
    background: var(--brand-1);
    color: #fff;
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
  }
  .sidebar .mark { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 16px; padding: 0 8px 20px; }
  .sidebar .mark .dot { width: 10px; height: 10px; border-radius: 3px; background: #fff; }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
  .sidebar nav button {
    display: flex; align-items: center; gap: 10px;
    background: transparent; border: none; color: rgba(255,255,255,0.75);
    padding: 10px 12px; border-radius: 8px; font-size: 13.5px; text-align: left; cursor: pointer;
  }
  .sidebar nav button .ico { width: 18px; text-align: center; opacity: 0.9; }
  .sidebar nav button:hover { background: rgba(255,255,255,0.08); color: #fff; }
  .sidebar nav button.active { background: rgba(255,255,255,0.14); color: #fff; font-weight: 600; }
  .sidebar .spacer { flex: 1; }
  .sidebar .switch-role {
    border-top: 1px solid rgba(255,255,255,0.14); padding-top: 12px; margin-top: 12px;
  }
  .sidebar .switch-role button {
    width: 100%; background: rgba(255,255,255,0.08); border: none; color: #fff;
    padding: 9px 12px; border-radius: 8px; font-size: 12.5px; cursor: pointer;
  }

  .main { padding: 26px 34px 60px; max-width: 1180px; }
  .topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
  .topbar h1 { font-size: 21px; margin: 0; }
  .topbar .sub { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
  .top-actions { display: flex; align-items: center; gap: 10px; }
  .icon-btn {
    width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: var(--card);
    color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px;
  }
  .avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--brand-2); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
  }

  .view { display: none; }
  .view.active { display: block; }

  .grid { display: grid; gap: 16px; }
  .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .grid.cols-2 { grid-template-columns: 1.3fr 1fr; }
  @media (max-width: 980px) { .grid.cols-4 { grid-template-columns: repeat(2,1fr); } .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

  .card {
    background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px;
  }
  .card h3 { margin: 0 0 2px; font-size: 14px; }
  .card .card-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }

  .stat-tile .stat-label { font-size: 12.5px; color: var(--text-muted); display: flex; align-items: center; justify-content: space-between; }
  .stat-tile .stat-value { font-size: 30px; font-weight: 700; margin-top: 6px; }
  .stat-tile .stat-delta { font-size: 12.5px; margin-top: 6px; display: flex; align-items: center; gap: 5px; }
  .stat-tile .stat-delta.up { color: var(--good-text); }
  .stat-tile .stat-delta.down { color: var(--critical); }

  /* ---------- chips / status ---------- */
  .chip {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
    padding: 4px 9px 4px 7px; border-radius: 100px; border: 1px solid var(--border); background: var(--surface-1);
    color: var(--text-secondary);
  }
  .chip .swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
  .chip.good .swatch { background: var(--good); }
  .chip.warning .swatch { background: var(--warning); }
  .chip.critical .swatch { background: var(--critical); }
  .chip.info .swatch { background: var(--series-1); }

  /* ---------- progress bar ---------- */
  .pbar { height: 8px; border-radius: 5px; background: var(--gridline); overflow: hidden; }
  .pbar > span { display: block; height: 100%; border-radius: 5px 0 0 5px; background: var(--series-1); }
  .pbar.good > span { background: var(--good); }
  .pbar.warning > span { background: var(--warning); }
  .pbar.critical > span { background: var(--critical); }

  /* ---------- lists ---------- */
  .goal-item { border-bottom: 1px solid var(--gridline); padding: 14px 0; }
  .goal-item:last-child { border-bottom: none; }
  .goal-item .row-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
  .goal-item .title { font-size: 13.5px; font-weight: 600; }
  .goal-item .meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
  .goal-item .pct { font-size: 12.5px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

  .timeline-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--gridline); }
  .timeline-item:last-child { border-bottom: none; }
  .timeline-item .tdot { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-1); border: 1px solid var(--border); display:flex; align-items:center; justify-content:center; font-size: 13px; flex: none; }
  .timeline-item .ttitle { font-size: 13px; font-weight: 600; }
  .timeline-item .tmeta { font-size: 11.5px; color: var(--text-muted); margin: 2px 0 4px; }
  .timeline-item .tbody { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }

  table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  table.data-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); padding: 8px 10px; border-bottom: 1px solid var(--gridline); }
  table.data-table td { padding: 10px 10px; border-bottom: 1px solid var(--gridline); vertical-align: middle; }
  table.data-table tr:last-child td { border-bottom: none; }
  .name-cell { display: flex; align-items: center; gap: 10px; }
  .name-cell .mini-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--seq-450); color: #fff; font-size: 11.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }

  .btn {
    border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
    padding: 7px 12px; border-radius: 7px; font-size: 12.5px; cursor: pointer; font-weight: 600;
  }
  .btn.primary { background: var(--brand-2); color: #fff; border-color: transparent; }
  .btn.ghost { background: transparent; }
  .btn-row { display: flex; gap: 8px; }

  .legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-top: 10px; }
  .legend .li { display: flex; align-items: center; gap: 6px; }
  .legend .sw { width: 10px; height: 10px; border-radius: 2px; }

  .chart-card .chart-head { display: flex; justify-content: space-between; align-items: flex-start; }
  .chart-toggle { font-size: 11.5px; color: var(--text-muted); background: none; border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; cursor: pointer; }

  .tooltip {
    position: fixed; pointer-events: none; background: var(--brand-1); color: #fff; font-size: 12px;
    padding: 7px 10px; border-radius: 7px; line-height: 1.4; box-shadow: 0 8px 20px rgba(0,0,0,0.25);
    transform: translate(-50%, -115%); z-index: 50; white-space: nowrap; opacity: 0; transition: opacity .1s;
  }
  .tooltip.show { opacity: 1; }
  .tooltip b { font-weight: 700; }

  .bar-hit:hover rect.bar-fill, .bar-hit:focus rect.bar-fill { filter: brightness(1.08); }
  .dot-hit { cursor: pointer; }

  .form-grid { display: grid; gap: 14px; }
  .field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
  .field select, .field textarea, .field input {
    width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; font-size: 13px;
    font-family: inherit; background: var(--surface-1); color: var(--text-primary);
  }
  .field textarea { resize: vertical; min-height: 70px; }
  .rating-scale { display: flex; gap: 8px; }
  .rating-scale button {
    flex: 1; padding: 10px 0; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1); cursor: pointer; font-weight: 700;
  }
  .rating-scale button.sel { background: var(--brand-2); color: #fff; border-color: transparent; }

  .table-view { font-size: 12.5px; }
  .table-view th, .table-view td { padding: 6px 8px; }

  .banner {
    display: flex; align-items: center; gap: 10px; background: var(--surface-1); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 14px; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 18px;
  }
  .banner b { color: var(--text-primary); }
