/* J-Book explorer.
   Palette values come from the validated reference instance; the categorical
   slots are used in fixed order so a series keeps its hue when a filter
   changes which series are on screen. */

:root {
  color-scheme: light;
  --surface-1:  #fcfcfb;
  --plane:      #f9f9f7;
  --raised:     #ffffff;
  --ink:        #0b0b0b;
  --ink-2:      #52514e;
  --ink-muted:  #898781;
  --grid:       #e1e0d9;
  --axis:       #c3c2b7;
  --border:     rgba(11,11,11,0.10);
  --border-2:   rgba(11,11,11,0.16);

  --s1: #2a78d6;  --s2: #eb6834;  --s3: #1baf7a;  --s4: #eda100;
  --s5: #e87ba4;  --s6: #008300;  --s7: #4a3aa7;  --s8: #e34948;

  --good:     #0ca30c;
  --warning:  #fab219;
  --serious:  #ec835a;
  --critical: #d03b3b;
  --good-ink: #006300;

  --seq-100: #cde2fb; --seq-200: #9ec5f4; --seq-300: #6da7ec;
  --seq-400: #3987e5; --seq-500: #256abf; --seq-600: #184f95;
  --seq-700: #0d366b;

  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --plane:     #0d0d0d;
    --raised:    #222221;
    --ink:       #ffffff;
    --ink-2:     #c3c2b7;
    --ink-muted: #898781;
    --grid:      #2c2c2a;
    --axis:      #383835;
    --border:    rgba(255,255,255,0.10);
    --border-2:  rgba(255,255,255,0.18);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --good-ink: #0ca30c;
    --seq-100: #0d366b; --seq-200: #184f95; --seq-300: #256abf;
    --seq-400: #3987e5; --seq-500: #6da7ec; --seq-600: #9ec5f4;
    --seq-700: #cde2fb;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19; --plane: #0d0d0d; --raised: #222221;
  --ink: #ffffff; --ink-2: #c3c2b7; --ink-muted: #898781;
  --grid: #2c2c2a; --axis: #383835;
  --border: rgba(255,255,255,0.10); --border-2: rgba(255,255,255,0.18);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --good-ink: #0ca30c;
  --seq-100: #0d366b; --seq-200: #184f95; --seq-300: #256abf;
  --seq-400: #3987e5; --seq-500: #6da7ec; --seq-600: #9ec5f4;
  --seq-700: #cde2fb;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--plane); color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--s1); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--surface-1); border-right: 1px solid var(--border);
  padding: 18px 14px; position: sticky; top: 0; height: 100vh;
  overflow-y: auto; display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: baseline; gap: 8px; padding: 0 6px; }
.brand b { font-size: 15px; letter-spacing: -0.01em; }
.brand span { font-size: 11px; color: var(--ink-muted); }

.picker { display: flex; flex-direction: column; gap: 4px; }
.picker label { font-size: 10.5px; text-transform: uppercase;
                letter-spacing: .06em; color: var(--ink-muted); padding-left: 2px; }
.picker select { width: 100%; }
.picker label + select { margin-bottom: 6px; }
.picker .span { font-size: 11px; padding: 4px 2px 0; line-height: 1.4; }

/* The data grid: a fixed header over a virtualised body. */
.grid-wrap { border: 1px solid var(--border); border-radius: var(--radius);
             overflow: auto; max-height: 72vh; background: var(--surface-1); }
.grid-wrap table { font-size: 12.5px; }
.grid-wrap th { white-space: nowrap; }
.grid-wrap td { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.grid-wrap td.long { max-width: 520px; white-space: normal; }
.filters { display: grid; gap: 8px;
           grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
           margin-bottom: 12px; }
.filters .f { display: flex; flex-direction: column; gap: 3px; }
.filters .f label { font-size: 10.5px; text-transform: uppercase;
                    letter-spacing: .05em; color: var(--ink-muted); }
.rt { display: inline-flex; align-items: center; gap: 5px; font-size: 11px;
      padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border-2); }
.rt .dot { width: 6px; height: 6px; border-radius: 50%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--border-2); background: var(--surface-1);
                border-radius: 999px; padding: 3px 10px; font-size: 12px;
                cursor: pointer; }
.chips button.on { background: var(--s1); border-color: var(--s1); color: #fff; }
.loadmore { text-align: center; padding: 14px; color: var(--ink-muted);
            font-size: 12.5px; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px;
  border-radius: 7px; color: var(--ink-2); font-size: 13.5px;
}
.nav a:hover { background: var(--plane); text-decoration: none; color: var(--ink); }
.nav a.on { background: var(--s1); color: #fff; }
.nav a.on .ic { opacity: 1; }
.nav .ic { width: 15px; text-align: center; opacity: .65; font-size: 13px; }
.nav .sec {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-muted); padding: 12px 10px 4px;
}

.main { min-width: 0; padding: 22px 26px 60px; }
.head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px;
        flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 21px; letter-spacing: -0.015em; font-weight: 650; }
.head p { margin: 3px 0 0; color: var(--ink-2); font-size: 13px; max-width: 74ch; }
.head .spacer { flex: 1; }

/* ---------- controls ---------- */
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
            margin-bottom: 14px; }
select, input[type=search], input[type=text], textarea {
  font: inherit; color: var(--ink); background: var(--surface-1);
  border: 1px solid var(--border-2); border-radius: 8px; padding: 6px 10px;
}
input[type=search] { min-width: 240px; }
textarea { font-family: var(--mono); font-size: 12.5px; width: 100%;
           resize: vertical; line-height: 1.55; }
.btn {
  background: var(--surface-1); border: 1px solid var(--border-2);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: var(--axis); }
.btn.primary { background: var(--s1); border-color: var(--s1); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.seg { display: inline-flex; border: 1px solid var(--border-2);
       border-radius: 8px; overflow: hidden; }
.seg button { background: var(--surface-1); border: 0; padding: 6px 12px;
              cursor: pointer; font-size: 13px; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--s1); color: #fff; }

/* ---------- cards ---------- */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px;
}
.card > h2 { margin: 0 0 3px; font-size: 14.5px; font-weight: 640;
             letter-spacing: -0.005em; }
.card > .sub { margin: 0 0 14px; color: var(--ink-muted); font-size: 12px; }
/* Cards in a row size to their own content rather than stretching to match
   the tallest sibling, which otherwise leaves a short chart floating in white. */
.grid { display: grid; gap: 16px; align-items: start; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }

/* ---------- stat tiles ---------- */
.tiles { display: grid; gap: 12px;
         grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
         margin-bottom: 16px; }
.tile {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 15px;
}
.tile .k { font-size: 11px; color: var(--ink-muted); text-transform: uppercase;
           letter-spacing: .055em; }
.tile .v { font-size: 25px; font-weight: 630; letter-spacing: -0.025em;
           margin-top: 5px; line-height: 1.1; }
.tile .v small { font-size: 13px; font-weight: 500; color: var(--ink-2);
                 letter-spacing: 0; }
.tile .n { font-size: 12px; color: var(--ink-2); margin-top: 4px; }

/* ---------- tables ---------- */
.tw { overflow-x: auto; border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 7px 11px; border-bottom: 1px solid var(--grid);
         white-space: nowrap; }
th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-muted); font-weight: 600; position: sticky; top: 0;
  background: var(--surface-1); z-index: 1; border-bottom: 1px solid var(--axis);
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th .arr { opacity: .45; font-size: 9px; margin-left: 3px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--plane); }
td.wrap { white-space: normal; min-width: 220px; }
.tw.tall { max-height: 68vh; overflow-y: auto; }

/* ---------- chips & pills ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px;
  padding: 2px 8px; border-radius: 999px; background: var(--plane);
  border: 1px solid var(--border); color: var(--ink-2); white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.chip.ghost { background: transparent; }
.pill { font-size: 11px; padding: 1px 7px; border-radius: 5px;
        border: 1px solid var(--border-2); color: var(--ink-2); }
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.st .ic { font-weight: 700; }
.st.ok   { color: var(--good-ink); }
.st.warn { color: var(--warning-ink, #a9741a); }
.st.bad  { color: var(--critical); }
.muted { color: var(--ink-muted); }
.mono { font-family: var(--mono); font-size: 12px; }

/* ---------- charts ---------- */
.chart { width: 100%; display: block; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart text { fill: var(--ink-muted); font-size: 10.5px; }
.chart text.lbl { fill: var(--ink-2); }
.chart text.val { fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; }
.legend .it { display: inline-flex; align-items: center; gap: 6px;
              font-size: 12px; color: var(--ink-2); }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }

.tip {
  position: fixed; pointer-events: none; z-index: 90; opacity: 0;
  transition: opacity .1s; background: var(--raised); color: var(--ink);
  border: 1px solid var(--border-2); border-radius: 8px; padding: 8px 11px;
  font-size: 12px; box-shadow: 0 6px 22px rgba(0,0,0,.16); max-width: 320px;
}
.tip.on { opacity: 1; }
.tip b { display: block; margin-bottom: 4px; font-size: 12.5px; }
.tip .r { display: flex; justify-content: space-between; gap: 16px; }
.tip .r span:last-child { font-variant-numeric: tabular-nums; }

/* ---------- tree ---------- */
.tree { font-size: 13px; }
.tree .row {
  display: grid; grid-template-columns: 1fr repeat(var(--cols,5), 92px);
  gap: 0; align-items: center; border-bottom: 1px solid var(--grid);
}
.tree .row:hover { background: var(--plane); }
.tree .row.lvl0 { font-weight: 620; }
.tree .row.sub  { color: var(--ink-2); font-style: italic; }
.tree .nm { padding: 6px 10px 6px 0; display: flex; align-items: center; gap: 7px;
            min-width: 0; }
.tree .nm span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .n { text-align: right; padding: 6px 10px; font-variant-numeric: tabular-nums;
           font-size: 12.5px; }
.tree .hd { color: var(--ink-muted); font-size: 10.5px; text-transform: uppercase;
            letter-spacing: .05em; border-bottom: 1px solid var(--axis); }
.tree .tog { width: 14px; text-align: center; cursor: pointer; color: var(--ink-muted);
             font-size: 10px; flex: none; }
.tree .cat { width: 8px; height: 8px; border-radius: 2px; flex: none; }

/* ---------- calendar heat ---------- */
.cal { display: grid; gap: 2px; grid-template-columns: 84px repeat(12, 1fr); }
.cal .h { font-size: 10px; color: var(--ink-muted); text-align: center;
          padding-bottom: 3px; }
.cal .y { font-size: 11.5px; color: var(--ink-2); display: flex;
          align-items: center; font-variant-numeric: tabular-nums; }
.cal .c { aspect-ratio: 1.5; border-radius: 3px; background: var(--plane);
          display: flex; align-items: center; justify-content: center;
          font-size: 10px; color: var(--ink); cursor: default; min-height: 22px; }
.cal .c.z { background: transparent; border: 1px dashed var(--grid); }

/* ---------- misc ---------- */
.empty { color: var(--ink-muted); padding: 26px 20px; text-align: center;
         font-size: 13px; }
.card > .empty { padding: 18px 20px 4px; }
.err { color: var(--critical); font-size: 13px; padding: 10px 0; }
.crumb { font-size: 12.5px; color: var(--ink-muted); margin-bottom: 8px; }
.crumb a { color: var(--ink-2); }
.prose { max-width: 78ch; font-size: 13.5px; line-height: 1.62; color: var(--ink-2);
         white-space: pre-wrap; }
.prose mark { background: var(--seq-100); color: var(--ink);
              padding: 0 2px; border-radius: 2px; }
details.nar { border-top: 1px solid var(--grid); padding: 10px 0; }
details.nar summary { cursor: pointer; font-weight: 580; font-size: 13px;
                      list-style: none; display: flex; gap: 9px;
                      align-items: baseline; }
details.nar summary::-webkit-details-marker { display: none; }
details.nar summary::before { content: "▸"; color: var(--ink-muted); font-size: 10px; }
details.nar[open] summary::before { content: "▾"; }
details.nar .prose { margin-top: 9px; }
.spark { display: block; }
.bar-cell { display: flex; align-items: center; gap: 7px; justify-content: flex-end; }
.bar-cell .b { height: 7px; border-radius: 2px; background: var(--s1); flex: none; }
.note { font-size: 12px; color: var(--ink-muted); margin-top: 10px;
        padding-top: 10px; border-top: 1px solid var(--grid); }
.units { font-size: 11.5px; color: var(--ink-muted); }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: column; }
  .main { padding: 16px; }
}

/* ------------------------------------------------- accounts rollup tree */
table.acct td.lbl-cell { white-space: normal; min-width: 320px; }
table.acct .caret { display: inline-block; width: 14px; color: var(--ink-muted); }
table.acct tr.can { cursor: pointer; }
table.acct tr.can:hover td { background: var(--plane); }
table.acct tr.acct-sec td { font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-muted);
  background: var(--plane); border-top: 1px solid var(--line); }
table.acct tr.acct-l0 td { font-weight: 650; }
table.acct tr.acct-l1 td { font-weight: 550; }
table.acct tr.acct-l4 td, table.acct tr.acct-l3 td { font-weight: 400; }
table.acct tr.acct-res td { font-style: italic; color: var(--ink-muted); }

/* Printed-page component columns (mandatory / PL 119-21) on the accounts tree */
table.acct th.acct-part, table.acct td.acct-part {
  color: var(--ink-2); font-style: italic;
  border-left: 1px dashed var(--grid);
}

/* Clickable column headings on the All data grid */
.grid-wrap th.sortable { cursor: pointer; user-select: none; }
.grid-wrap th.sortable:hover { color: var(--ink); }
