  :root {
    color-scheme: light;
    --page:           #f9f9f7;
    --surface-1:      #fcfcfb;
    --text-primary:   #0b0b0b;
    --text-secondary: #52514e;
    --text-muted:     #6e6c66;
    --gridline:       #e1e0d9;
    --baseline:       #c3c2b7;
    --border:         rgba(11,11,11,0.10);
    --series-1:       #2a78d6;   /* blue: accent / chaseable — dots, bars, borders */
    --series-1-text:  #1f5fb5;   /* accent as TEXT (>=4.5:1 on page/surface) */
    --series-1-fill:  #1f5fb5;   /* accent as a FILL under white text */
    --series-3:       #1baf7a;   /* aqua: secondary single-hue bars */
    --series-3-text:  #0d7d54;   /* aqua as TEXT */
    --series-5:       #c2571f;   /* orange: timeline 'commented' badge */
    --series-7:       #4a3aa7;   /* violet: timeline 'created' badge */
    --track:          #cde2fb;   /* sequential 100: meter track */
    --de-emphasis:    #c3c2b7;   /* context series */
    --critical:       #d03b3b;
    --warning:        #fab219;
    --warning-text:   #8a6400;   /* amber as TEXT (raw amber fails contrast on light) */
    --good:           #006300;   /* success text (light) */
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark;
      --page:           #0d0d0d;
      --surface-1:      #1a1a19;
      --text-primary:   #ffffff;
      --text-secondary: #c3c2b7;
      --text-muted:     #898781;
      --gridline:       #2c2c2a;
      --baseline:       #383835;
      --border:         rgba(255,255,255,0.10);
      --series-1:       #3987e5;
      --series-1-text:  #5b9cf0;
      --series-1-fill:  #2161b8;
      --series-3:       #199e70;
      --series-3-text:  #199e70;
      --series-5:       #d97a45;
      --series-7:       #9085e9;
      --track:          #184f95;
      --de-emphasis:    #52514e;
      --critical:       #e05b5b;
      --warning:        #fab219;
      --warning-text:   #fab219;
      --good:           #0ca30c;   /* success text (dark) */
    }
  }
  * { box-sizing: border-box; margin: 0; }
  body {
    background: var(--page); color: var(--text-primary);
    font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
    padding: 20px 28px 20px 288px; max-width: 1860px; margin: 0 auto;
  }
  #side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; overflow-y: auto;
          background: var(--surface-1); border-right: 1px solid var(--border);
          padding: 14px 10px; z-index: 5; }
  .side-title select { font: inherit; font-size: 11px; color: var(--text-muted);
                       background: transparent; border: 1px solid var(--gridline);
                       border-radius: 6px; padding: 1px 4px; float: right; cursor: pointer; }
  .side-title { font-size: 11.5px; font-weight: 600; color: var(--text-muted);
                text-transform: uppercase; letter-spacing: 0.04em; margin: 12px 8px 4px; }
  .side-item { display: flex; justify-content: space-between; align-items: baseline; gap: 6px;
               padding: 5px 8px; border-radius: 7px; font-size: 13px;
               color: var(--text-secondary); text-decoration: none; }
  .side-item:hover { background: var(--page); color: var(--text-primary); }
  .side-item.active { background: var(--page); color: var(--text-primary); font-weight: 600; }
  .side-home { font-weight: 550; color: var(--text-primary); }
  .side-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-count { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
  /* Account footer (auth on only): who is signed in + password/sign-out. */
  .side-account { margin: 16px 8px 4px; padding-top: 10px; border-top: 1px solid var(--gridline); }
  .side-acct-who { font-size: 12px; color: var(--text-secondary); overflow: hidden;
                   text-overflow: ellipsis; white-space: nowrap; }
  .side-acct-actions { display: flex; gap: 10px; margin-top: 4px; }
  .side-acct-actions button { background: none; border: none; padding: 0; font: inherit;
                              font-size: 11.5px; color: var(--text-muted); cursor: pointer; }
  .side-acct-actions button:hover { color: var(--text-primary); text-decoration: underline; }
  #acct-form { display: grid; gap: 6px; margin-top: 8px; }
  #acct-form input { font: inherit; font-size: 12px; padding: 5px 7px; border-radius: 6px;
                     border: 1px solid var(--gridline); background: var(--page);
                     color: var(--text-primary); }
  #acct-form button { font: inherit; font-size: 12px; padding: 5px; border-radius: 6px;
                      border: 1px solid var(--border); background: var(--surface-1);
                      color: var(--text-primary); cursor: pointer; }
  #pw-msg { font-size: 11.5px; color: var(--text-muted); }
  @media (max-width: 1150px) { #side { display: none; } body { padding-left: 28px; } }
  header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
  header button { background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border);
             border-radius: 8px; padding: 6px 14px; font: inherit; font-size: 13px; cursor: pointer; }
  header button:hover { border-color: var(--baseline); }
  header button:disabled { color: var(--text-muted); cursor: wait; }
  #pullbar { display: none; height: 4px; border-radius: 2px; overflow: hidden;
             background: var(--track); margin: -6px 0 14px; }
  #pullbar.on { display: block; }
  #pullbar > div { height: 100%; width: 100%; background: var(--series-1);
                   border-radius: 2px; transform: scaleX(0); transform-origin: left;
                   transition: transform 0.6s ease; }
  #pullbar.indeterminate > div { width: 30%; animation: pb-slide 1.2s ease-in-out infinite; }
  @keyframes pb-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(334%); } }
  .spin { display: inline-block; animation: pb-rot 1s linear infinite; }
  @keyframes pb-rot { to { transform: rotate(360deg); } }
  .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
  .chiplabel { font-size: 12px; color: var(--text-muted); min-width: 46px; }
  #diffmode { font: inherit; font-size: 12.5px; color: var(--text-primary);
              background: var(--page); border: 1px solid var(--gridline);
              border-radius: 8px; padding: 2px 8px; margin: 0 4px; }
  .chip { background: var(--surface-1); color: var(--text-secondary); border: 1px solid var(--gridline);
          border-radius: 14px; padding: 3px 11px; font: inherit; font-size: 12px; cursor: pointer; }
  .chip:disabled { opacity: 0.6; cursor: wait; }
  .chip.active { border-color: var(--series-1); color: var(--text-primary); font-weight: 600; }
  .scrolly { min-height: 500px; max-height: 78vh; overflow-y: auto; }
  .scrolly thead th { position: sticky; top: 0; background: var(--surface-1); }
  h1 { font-size: 19px; font-weight: 650; }
  .sub { color: var(--text-muted); font-size: 13px; }
  .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
  .card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
  .tile .label { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 4px; }
  .tile .value { font-size: 30px; font-weight: 600; }
  .tile .note  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
  .tile.alert .value { color: var(--critical); }
  .meter { height: 8px; border-radius: 4px; background: var(--track); margin-top: 8px; overflow: hidden; }
  .meter > div { height: 100%; background: var(--series-1); border-radius: 4px 0 0 4px; }
  .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
  @media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
  .card h2 { font-size: 13.5px; font-weight: 600; margin-bottom: 10px; }
  .card h2 .sub { font-weight: 400; }
  .legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
  .legend span { display: inline-flex; align-items: center; gap: 5px; }
  .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
  svg text { font: 11px system-ui, sans-serif; fill: var(--text-muted); }
  svg .val { fill: var(--text-secondary); font-variant-numeric: tabular-nums; }
  svg .cat { fill: var(--text-secondary); }
  .wide { overflow-x: auto; }
  table { border-collapse: collapse; width: 100%; font-size: 13px; }
  th { text-align: left; color: var(--text-muted); font-weight: 500; font-size: 12px;
       border-bottom: 1px solid var(--gridline); padding: 4px 10px 6px 0; }
  td { border-bottom: 1px solid var(--gridline); padding: 6px 10px 6px 0; vertical-align: top; }
  tr:last-child td { border-bottom: none; }
  td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
  .overdue-date { color: var(--critical); font-weight: 550; }
  .slip-bad  { color: var(--critical); font-weight: 550; }
  .slip-good { color: var(--good); font-weight: 550; }
  .chg-group { margin-bottom: 10px; }
  .chg-group h3 { font-size: 12.5px; color: var(--text-secondary); font-weight: 600; margin-bottom: 3px; }
  .chg-group ul { list-style: none; font-size: 13px; }
  .chg-group li { padding: 2px 0; border-bottom: 1px solid var(--gridline); }
  .chg-group li:last-child { border-bottom: none; }
  .flag { display: inline-block; font-size: 11.5px; color: var(--text-secondary);
          background: var(--page); border: 1px solid var(--gridline); border-radius: 4px;
          padding: 0 6px; margin: 1px 3px 1px 0; }
  .st { display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
        color: var(--text-secondary); background: var(--page); border: 1px solid var(--gridline);
        border-radius: 10px; padding: 1px 9px; white-space: nowrap; }
  .st i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
  .empty { color: var(--text-muted); padding: 14px 0; }
  a.wp { color: inherit; font-weight: inherit; text-decoration: underline;
         text-decoration-color: var(--baseline); text-decoration-thickness: 1px;
         text-underline-offset: 2px; }
  a.wp:hover { color: var(--series-1-text); text-decoration-color: var(--series-1); }
  dialog { background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border);
           border-radius: 12px; padding: 18px 20px; width: min(440px, 90vw); }
  dialog::backdrop { background: rgba(0,0,0,0.45); }
  dialog h2 { font-size: 15px; margin-bottom: 4px; }
  dialog p { margin-bottom: 10px; }
  .dlg-search { width: 100%; font: inherit; font-size: 13px; padding: 7px 10px; margin-bottom: 8px;
                background: var(--page); color: var(--text-primary);
                border: 1px solid var(--gridline); border-radius: 8px; }
  .dlg-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--gridline);
              border-radius: 8px; padding: 4px 0; }
  .dlg-list label { display: flex; align-items: center; gap: 9px; padding: 6px 12px;
                    font-size: 13px; cursor: pointer; }
  .dlg-list label:hover { background: var(--page); }
  .dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
  .noload-strip { background: var(--page); border: 1px solid var(--gridline); border-radius: 8px;
                  padding: 8px 12px; font-size: 13px; margin-bottom: 10px; }
  .noload-strip b { color: var(--critical); }
  #tooltip { position: fixed; pointer-events: none; display: none; z-index: 10;
             max-width: min(340px, 85vw);
             background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
             padding: 8px 10px; font-size: 12.5px; box-shadow: 0 4px 14px rgba(0,0,0,0.18); }
  #tooltip .t-title { font-weight: 600; margin-bottom: 2px; }
  #tooltip .t-row { color: var(--text-secondary); }
  details.drafts summary { cursor: pointer; font-size: 13.5px; font-weight: 600; }
  .draft-body { color: var(--text-secondary); font-size: 12.5px; margin: 6px 0 10px; }
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
             overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  .skip-link { position: absolute; left: -9999px; top: 0; z-index: 20;
               background: var(--surface-1); color: var(--text-primary);
               border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; }
  .skip-link:focus { left: 8px; top: 8px; }
  @media (prefers-reduced-motion: reduce) {
    /* Busy state stays visible, it just stops moving: the indeterminate bar
       becomes a full dimmed track and the spinner glyph holds still. */
    #pullbar > div { transition: none; }
    #pullbar.indeterminate > div { animation: none; width: 100%; transform: none; opacity: 0.4; }
    .spin { animation: none; }
  }
