:root {
  --page: #f7f8f6;
  --surface: #fcfcfb;
  --ink: #14161a;
  --ink-2: #52514e;
  --muted: #767470;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --accent: #1c5cab;
  --series: #2a78d6;
  --seq: #256abf;
  --series2: #eb6834;
  --series2-ink: #b8511d;
  --scrollshadow: rgba(11,11,11,0.16);
  --track: #e8e7e0;
  --critical: #d03b3b;
  --good: #006300;
  --warn-bg: #faf3e4;
  --crit-bg: #f9ecec;
  --pin-bg: #eef3fa;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255,255,255,0.10);
    --accent: #6da7ec;
    --series: #3987e5;
    --seq: #3987e5;
    --series2: #f07a4a;
    --series2-ink: #f07a4a;
    --scrollshadow: rgba(255,255,255,0.10);
    --track: #2c2c2a;
    --critical: #e66767;
    --good: #0ca30c;
    --warn-bg: #262115;
    --crit-bg: #261616;
    --pin-bg: #16202e;
  }
}
:root[data-theme="dark"] {
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255,255,255,0.10);
  --accent: #6da7ec;
  --series: #3987e5;
  --seq: #3987e5;
  --series2: #f07a4a;
  --series2-ink: #f07a4a;
  --scrollshadow: rgba(255,255,255,0.10);
  --track: #2c2c2a;
  --critical: #e66767;
  --good: #0ca30c;
  --warn-bg: #262115;
  --crit-bg: #261616;
  --pin-bg: #16202e;
}
* { box-sizing: border-box; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15.5px;
  line-height: 1.6;
  margin: 0;
}
.serif { font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif; }
.wrap { max-width: 900px; margin: 0 auto; padding: 0 20px; }

/* top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--grid); position: sticky; top: 0; z-index: 20; }
.topbar-in { max-width: 940px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 14px; }
.brand { font-weight: 650; font-size: 17px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.topbar-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.whoami { font-size: 12px; font-weight: 650; padding: 3px 11px; border-radius: 99px; background: var(--track); color: var(--ink-2); }
.whoami.yash { background: var(--pin-bg); color: var(--accent); }
.linkbtn { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; padding: 4px; }
.linkbtn:hover { color: var(--ink); text-decoration: underline; }

/* login */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 34px 34px 30px; max-width: 400px; width: 100%; }
.login-card .co { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); }
.login-card h1 { font-size: 27px; margin: 8px 0 4px; }
.login-sub { color: var(--ink-2); font-size: 14px; margin: 0 0 18px; }
.login-err { color: var(--critical); font-weight: 600; font-size: 14px; }
.login-card label { display: block; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.login-card input { width: 100%; font-size: 16px; padding: 10px 12px; border: 1px solid var(--baseline); border-radius: 8px; background: var(--page); color: var(--ink); }
.login-card button { margin-top: 14px; width: 100%; font-size: 15px; font-weight: 650; padding: 10px; border: none; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; }
.login-card button:hover { filter: brightness(1.08); }

/* index */
.index-wrap { padding-top: 40px; padding-bottom: 80px; }
.index-h { font-size: 28px; margin: 0 0 6px; }
.index-note { color: var(--ink-2); font-size: 14px; max-width: 66ch; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-top: 24px; }
.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; text-decoration: none; color: var(--ink); }
.card:hover { border-color: var(--accent); }
.card.featured { border-left: 4px solid var(--accent); }
.card-kind { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); font-weight: 650; }
.card-title { font-size: 19px; font-weight: 600; margin: 4px 0 2px; }
.card-sub { font-size: 13px; color: var(--ink-2); }
.card-meta { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* report shell */
.report-shell { border-bottom: 1px solid var(--grid); padding-bottom: 30px; }

/* generated report fragments */
.rpt { padding-bottom: 20px; }
.rpt .mast { padding: 44px 0 20px; border-bottom: 3px solid var(--ink); margin-bottom: 26px; }
.rpt .co { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); }
.rpt h1 { font-size: 30px; margin: 6px 0 4px; font-weight: 600; }
.rpt .sub { font-size: 13px; color: var(--muted); }
.rpt h2 { font-size: 20px; margin: 34px 0 10px; font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; margin: 22px 0; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 13px 15px 11px; }
.tile .k { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.tile .v { font-size: 20px; font-weight: 650; margin-top: 4px; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile .s { font-size: 12px; color: var(--ink-2); margin-top: 3px; }
.tile .v.crit { color: var(--critical); }
.tile .v.good { color: var(--good); }
.tblwrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; padding: 6px 14px; margin: 18px 0;
  background:
    linear-gradient(to right, var(--surface) 40%, transparent) left/36px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 40%, transparent) right/36px 100% no-repeat local,
    linear-gradient(to right, var(--scrollshadow), transparent) left/12px 100% no-repeat scroll,
    linear-gradient(to left, var(--scrollshadow), transparent) right/12px 100% no-repeat scroll,
    var(--surface); }
figure { margin: 18px 0; border: 1px solid var(--border); border-radius: 10px; padding: 18px 18px 12px; overflow-x: auto;
  background:
    linear-gradient(to right, var(--surface) 40%, transparent) left/36px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 40%, transparent) right/36px 100% no-repeat local,
    linear-gradient(to right, var(--scrollshadow), transparent) left/12px 100% no-repeat scroll,
    linear-gradient(to left, var(--scrollshadow), transparent) right/12px 100% no-repeat scroll,
    var(--surface); }
figcaption { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
figure .ftitle { font-size: 14px; font-weight: 600; margin: 0 0 2px; }
figure .fsub { font-size: 12.5px; color: var(--ink-2); margin: 0 0 10px; }
.legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--ink-2); margin: 2px 0 8px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; border: 1px solid var(--baseline); }
.sw-line { display: inline-block; width: 18px; height: 0; border-top: 2px dashed var(--muted); }

/* chart text (SVG) */
svg text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.axlab { fill: var(--ink-2); font-size: 12px; }
.vallab { fill: var(--ink); font-size: 12px; font-variant-numeric: tabular-nums; }
.mutlab { fill: var(--muted); color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.dim { color: var(--muted); }

table { border-collapse: collapse; width: 100%; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 10px 12px 6px 0; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td { padding: 6px 12px 6px 0; border-bottom: 1px solid var(--grid); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.total td { font-weight: 650; border-top: 2px solid var(--baseline); }
tr.cat td { font-weight: 650; font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); padding-top: 15px; border-bottom: 1px solid var(--baseline); }
.pos { color: var(--good); }
.neg { color: var(--critical); font-weight: 600; }
.note-box { border-left: 4px solid var(--baseline); background: var(--surface); border-radius: 0 8px 8px 0; padding: 12px 16px; margin: 18px 0; font-size: 14px; color: var(--ink-2); }

/* comments */
.comments-wrap { padding-top: 34px; padding-bottom: 90px; }
.comments-wrap h2 { font-size: 22px; margin: 0 0 14px; }
.pinned-block { border-left: 4px solid var(--accent); background: var(--pin-bg); border-radius: 0 8px 8px 0; padding: 12px 16px; margin: 0 0 18px; }
.pinned-block .ph { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); font-weight: 650; margin-bottom: 6px; }
.comment { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin: 10px 0; }
.comment.pinned { border-left: 4px solid var(--accent); }
.c-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.c-author { font-weight: 650; font-size: 13.5px; }
.c-author.yash { color: var(--accent); }
.c-time { font-size: 12px; color: var(--muted); }
.c-del { margin-left: auto; background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; }
.c-del:hover { color: var(--critical); }
.c-text { white-space: pre-wrap; overflow-wrap: break-word; font-size: 14.5px; }
.c-empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
#composer { margin-top: 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
#composer label { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
#composer textarea { width: 100%; min-height: 90px; font: inherit; font-size: 14.5px; padding: 10px 12px; border: 1px solid var(--baseline); border-radius: 8px; background: var(--page); color: var(--ink); resize: vertical; }
.composer-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.pinlab { font-size: 13px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 7px; }
#composer button[type="submit"] { font-size: 14px; font-weight: 650; padding: 9px 20px; border: none; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; }
#composer button[type="submit"]:hover { filter: brightness(1.08); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.histtbl td:first-child { white-space: nowrap; }
@media (max-width: 480px) { .topbar-sub { display: none; } }

/* dashboard tabs */
.tabs { display: flex; gap: 2px; max-width: 940px; margin: 0 auto; padding: 10px 20px 0; border-bottom: 1px solid var(--grid); overflow-x: auto; }
.tab { font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-2); background: none; border: none; border-bottom: 2px solid transparent; padding: 9px 14px 10px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabpanel[hidden] { display: none; }
.ovnote { padding-top: 16px; display: flex; justify-content: flex-end; }
.ovlink { font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; }
.ovlink:hover { text-decoration: underline; }
/* compare matrix */
.cmp table td:first-child, .cmp table th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; white-space: nowrap; padding-right: 16px; }
.cmp th { line-height: 1.25; }
.cmp th .dim { font-weight: 500; }
.rowmax { font-weight: 700; color: var(--accent); }
