:root {
  color-scheme: light;
  --page: #f7f7f8;
  --surface: #ffffff;
  --ink: #0d0d0d;
  --ink-2: #353740;
  --muted: #6e6e80;
  --faint: #8e8ea0;
  --line: #ececf1;
  --line-2: #d9d9e3;
  --match: #cfe9d7;
  --attention: #fdf4ef;
  --settled: #f1f8f3;
  --wash: #f7f7f8;
  --hover: #f3f3f6;
  --select: #e8e8ee;
  --primary: #0d0d0d;
  --primary-hover: #2a2b32;
  --focus: rgba(13, 13, 13, 0.18);

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

  /* categorical, one per product; validated (dataviz validator, light) in the order
     spend.mjs stacks them: training, API, ChatGPT, then products added later */
  --s-chatgpt: #1baf7a;
  --s-api: #4a3aa7;
  --s-modelTraining: #eda100;
  --s-codex: #e87ba4;
  --s-5: #2a78d6;
  --s-6: #eb6834;
  --s-other: #8e8ea0;

  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --r-card: 12px;
  --r-control: 8px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
::selection { background: #d7f3e8; color: var(--ink); }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
html { scrollbar-color: var(--line-2) transparent; }
input, select { caret-color: var(--ink); accent-color: var(--ink); }
.icon { display: block; flex: none; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 40px;
  height: 60px; padding: 0 32px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(1.4) blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { display: block; height: 20px; width: auto; }
.brand-sep { color: var(--line-2); font-size: 20px; font-weight: 300; }
.brand-formance { color: var(--muted); font-size: 15px; font-weight: 500; letter-spacing: -0.01em; }
.nav { display: flex; gap: 4px; }
.nav a {
  padding: 6px 12px; border-radius: var(--r-control);
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500;
}
.nav a:hover { color: var(--ink); background: var(--hover); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--select); }
.topbar-end { display: flex; align-items: center; gap: 12px; }
.lens { display: flex; padding: 3px; gap: 2px; background: var(--wash); border: 1px solid var(--line); border-radius: 10px; }
.lens button {
  border: 0; background: transparent; padding: 5px 14px; border-radius: 7px; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--muted);
}
.lens button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(13, 13, 13, 0.08); }
.prep { border: 1px dashed var(--line-2); background: transparent; border-radius: var(--r-control); padding: 5px 12px; font-size: 13px; color: var(--muted); cursor: pointer; }

/* screen */
.screen { max-width: 1240px; margin: 0 auto; padding: 36px 32px 24px; outline: none; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.head h1 { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.status { display: flex; align-items: center; gap: 8px; margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.good { background: var(--good); }
.dot.warning { background: var(--warning); }
.dot.serious { background: var(--serious); }
.dot.live { background: var(--good); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.actions { display: flex; align-items: center; gap: 10px; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: var(--r-control);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 160ms ease-out, border-color 160ms ease-out;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.link { border: 0; background: transparent; padding: 0; height: auto; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
.btn.link:hover { text-decoration-color: var(--ink); background: transparent; }

/* figures */
.figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 0 0 18px; }
.figure { padding: 4px 0 4px 24px; border-left: 1px solid var(--line); }
.figure:first-child { padding-left: 0; border-left: 0; }
.figure .label { color: var(--muted); font-size: 13px; }
.figure .value { font-size: 26px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.3; margin-top: 2px; font-variant-numeric: tabular-nums; }
.figure .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.ledger .figure .value { font-family: var(--mono); font-size: 19px; letter-spacing: 0; line-height: 1.6; }
.ledger .figure .label { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); }

/* card */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 18px 22px 0; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.card-head .meta { color: var(--muted); font-size: 13px; }
.section { padding: 18px 22px 22px; }
.section + .section { border-top: 1px solid var(--line); }

/* spend */
.spend-card { display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.spend-chart { padding: 18px 8px 18px 22px; min-width: 0; }
.chart-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-right: 14px; }
.chart-title h2 { margin: 0; font-size: 15px; font-weight: 600; }
.chart-title .meta { color: var(--muted); font-size: 13px; }
.chart { position: relative; margin-top: 8px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis text { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .label-direct { fill: var(--ink-2); font-size: 12px; font-weight: 500; }
.chart .empty-note { fill: var(--muted); font-size: 13px; }
.chart .mark line { stroke: var(--ink-2); stroke-opacity: 0.45; stroke-width: 1; shape-rendering: crispEdges; }
.chart .mark-label { fill: var(--ink-2); font-size: 11.5px; font-weight: 500; }
.chart .crosshair { stroke: var(--ink-2); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.chart:focus-visible { outline-offset: 4px; }
.tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 190px;
  padding: 10px 12px; border-radius: 10px; background: var(--surface);
  box-shadow: 0 10px 28px rgba(13, 13, 13, 0.13), 0 2px 6px rgba(13, 13, 13, 0.08);
  font-size: 13px;
}
.tooltip .when { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.tooltip .row { display: grid; grid-template-columns: 14px auto 1fr; align-items: center; gap: 8px; line-height: 1.7; }
.tooltip .row strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip .row span:last-child { color: var(--muted); }
.tooltip .total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.key { width: 14px; height: 2px; border-radius: 1px; display: block; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

/* The counter is the thesis in one relation, the largest figures on the screen. */
.counter { margin: 14px 14px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
.counter .relation { margin: 0; color: var(--muted); font-size: 17px; line-height: 1.3; }
.counter .big { color: var(--ink); font-size: 36px; font-weight: 500; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; }
.counter .unit { font-size: 12.5px; }
.counter .why { margin: 8px 0 0; color: var(--muted); font-size: 13px; max-width: 76ch; }
.ledger .counter .big { font-family: var(--mono); font-size: 22px; font-weight: 400; letter-spacing: 0; }

/* The chart column sets the card's height; the tape fills it and fades out at the foot. */
.tape { border-left: 1px solid var(--line); padding: 18px 0 0; display: flex; flex-direction: column; min-width: 0; contain: size; overflow: hidden; }
.tape .feed { flex: 1 1 0; min-height: 0; overflow: hidden; -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent); mask-image: linear-gradient(to bottom, #000 78%, transparent); }
.tape h2 { margin: 0; padding: 0 20px 10px; font-size: 15px; font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; }
.tape h2 .meta { font-weight: 400; color: var(--muted); font-size: 13px; }
.tape ol { list-style: none; margin: 0; padding: 0; }
.tape li { padding: 9px 20px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 1px 12px; font-size: 13px; }
.tape .what { display: flex; align-items: center; gap: 7px; min-width: 0; font-weight: 500; }
.tape .what span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tape .amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.tape .when, .tape .req { color: var(--muted); font-size: 12px; }
.tape .req { text-align: right; font-variant-numeric: tabular-nums; }
.tape .empty { padding: 14px 20px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.ledger .tape li { grid-template-columns: 1fr; }
.ledger .tape .addr { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); overflow-wrap: anywhere; }

/* product list (legend) */
.list { margin: 0; padding: 0; list-style: none; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.row-btn {
  width: 100%; display: grid; grid-template-columns: 18px minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) 150px 16px; align-items: center; gap: 12px;
  padding: 13px 22px; border: 0; background: transparent; text-align: left; cursor: pointer; font-size: 14px;
}
.row-btn:hover { background: var(--hover); }
.row-btn .name { font-weight: 500; }
.row-btn .muted { color: var(--muted); font-size: 13px; }
.row-btn .amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.row-btn .chev { color: var(--faint); transition: transform 160ms ease-out; display: grid; place-items: center; }
.row-btn[aria-expanded="true"] .chev { transform: rotate(90deg); }
.tag { display: inline-block; white-space: nowrap; margin-left: 8px; padding: 1px 7px; border-radius: 999px; background: var(--wash); border: 1px solid var(--line); color: var(--muted); font-size: 11.5px; font-weight: 500; vertical-align: 1px; }
.detail { padding: 2px 22px 18px 52px; }
.detail table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.detail td { padding: 7px 0; border-top: 1px solid var(--line); }
.detail td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.detail td.muted { color: var(--muted); font-size: 13px; }
.detail .addr { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.detail .read { margin-top: 10px; color: var(--muted); font-size: 12.5px; }
.ledger .row-btn .name { font-family: var(--mono); font-size: 12.5px; font-weight: 400; }

.foot { padding: 14px 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* contracts */
.contract { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.6fr); gap: 28px; padding: 20px 22px; border-top: 1px solid var(--line); }
.contract:first-of-type { border-top: 0; }
.contract h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.contract .kind { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.contract .serves { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.meter { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; display: flex; margin-top: 4px; }
.meter span { display: block; height: 100%; background: var(--ink-2); border-radius: 4px 0 0 4px; }
.meter-legend { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 13.5px; }
.meter-legend .used { font-weight: 500; font-variant-numeric: tabular-nums; }
.meter-legend .left { color: var(--muted); font-variant-numeric: tabular-nums; }
.runway { display: flex; align-items: flex-start; gap: 8px; margin-top: 10px; font-size: 13.5px; color: var(--ink-2); }
.runway .dot { margin-top: 6px; }
.monthly { font-size: 22px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tranches { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.tranche + .tranche { padding-top: 14px; border-top: 1px dashed var(--line-2); }
.tranche.idle { padding: 12px 14px 14px; border-radius: 10px; background: var(--attention); border-top: 0; }
.tranche + .tranche.idle { margin-top: 2px; }
.tranche-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 14px; flex-wrap: wrap; margin-bottom: 6px; font-size: 13.5px; }
.tranche-name { font-weight: 600; }
.tranche-name .muted { font-weight: 400; margin-left: 4px; }
.tranche-term { color: var(--muted); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.runway-row { display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap; margin-top: 10px; }
.runway-row .runway { margin-top: 0; }
.runway.muted { color: var(--muted); }
.monthly .per { font-size: 14px; color: var(--muted); letter-spacing: 0; }
.monthly.mono, .monthly .mono { font-size: 15px; letter-spacing: 0; }
.billing { list-style: none; margin: 10px 0 0; padding: 0; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.billing li + li { margin-top: 2px; }
table.mapping { width: 100%; border-collapse: collapse; font-size: 14px; }
.mapping th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 10px 22px; border-bottom: 1px solid var(--line); }
.mapping td { padding: 11px 22px; border-top: 1px solid var(--line); vertical-align: top; }
.mapping td strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.mapping-note { margin: 0; padding: 12px 22px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.mapping-note span { display: block; max-width: 92ch; }
.ledger .contract .addr { font-family: var(--mono); font-size: 12px; color: var(--ink-2); margin-top: 6px; overflow-wrap: anywhere; }

.form { padding: 20px 22px 22px; border-top: 1px solid var(--line); background: #fcfcfd; }
.form:first-child { border-top: 0; border-radius: var(--r-card) var(--r-card) 0 0; }
.form h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 16px; align-items: end; }
.fields .wide { grid-column: span 2; }
strong { font-weight: 600; }
.field label, .field .label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }
.field input, .field select {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r-control);
  border: 1px solid var(--line-2); background: var(--surface); font-size: 14px;
}
.field input::placeholder { color: var(--muted); }
.field input:focus, .field select:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px var(--focus); }
.segmented { display: flex; gap: 0; border: 1px solid var(--line-2); border-radius: var(--r-control); overflow: hidden; height: 40px; }
.segmented label { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; margin: 0; padding: 0 8px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; border-left: 1px solid var(--line-2); white-space: nowrap; }
.segmented label:first-child { border-left: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--ink); color: #fff; }
.segmented label:has(input:focus-visible) { box-shadow: inset 0 0 0 2px var(--focus); }
.form .row-actions { display: flex; gap: 10px; margin-top: 16px; align-items: center; }
.form .hint { color: var(--muted); font-size: 13px; }
.error { color: var(--critical); font-size: 13.5px; margin-top: 10px; }
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-2); background: #fafbfa; }
.notice .dot { margin-top: 7px; }
.spend-notices { grid-column: 1 / -1; }
.notice.replay strong { color: var(--ink); font-weight: 600; }

/* close */
.lead-in { padding: 22px; font-size: 15px; color: var(--ink-2); max-width: 70ch; }
.invoices .inv { display: grid; grid-template-columns: minmax(0, 1fr) 160px minmax(0, 1.6fr); gap: 16px; align-items: center; padding: 14px 22px; border-top: 1px solid var(--line); font-size: 14px; }
.invoices .inv:first-child { border-top: 0; }
.inv .who { font-weight: 500; }
.inv .who small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; }
.inv .total { text-align: right; font-variant-numeric: tabular-nums; }
.inv .state { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.inv .state .text { display: flex; align-items: flex-start; gap: 8px; }
.inv .state .text .dot { margin-top: 7px; }
/* Every hour of the month for an invoice that did not match: the provider's hourly
   export against the ledger, one cell per hour, days left to right like the Spend chart. */
.hourmap { grid-column: 1 / -1; margin-top: 6px; padding-top: 14px; border-top: 1px dashed var(--line-2); }
.hm-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 20px; flex-wrap: wrap; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.hm-title { color: var(--ink); font-weight: 600; font-size: 14px; }
.hm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.hm-legend span { display: inline-flex; align-items: center; gap: 6px; }
.hm-key { width: 12px; height: 8px; border-radius: 2px; display: inline-block; }
.hm-key.match, .hm-grid .match { background: var(--match); fill: var(--match); }
.hm-key.missing, .hm-grid .missing { background: var(--serious); fill: var(--serious); }
.hm-key.found, .hm-grid .found { background: var(--good); fill: var(--good); }
.hm-grid .none { fill: var(--wash); }
.hm-body { display: grid; grid-template-columns: minmax(0, 646px) minmax(260px, 1fr); gap: 28px; align-items: start; }
.hm-grid svg { display: block; max-width: 100%; height: auto; outline: none; }
.hm-grid svg:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 4px; }
.hm-grid .cell { shape-rendering: crispEdges; }
.hm-grid text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.hm-grid .sel { fill: none; stroke: var(--ink); stroke-width: 1.5; pointer-events: none; }
.hm-grid .hov { fill: none; stroke: var(--ink-2); stroke-width: 1; stroke-opacity: 0.6; pointer-events: none; }
.hm-grid .hit { cursor: crosshair; }
.hm-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.hm-panel { min-height: 148px; }
.hm-when { font-weight: 600; font-size: 15px; margin-bottom: 8px; }
.hm-rows { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.hm-rows th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 0 0 6px; }
.hm-rows th.r, .hm-rows td.r { text-align: right; }
.hm-rows td { padding: 6px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.hm-rows td + td, .hm-rows th + th { padding-left: 12px; }

.hm-st { display: inline-flex; align-items: baseline; gap: 6px; color: var(--ink-2); }
.hm-st .dot { flex: none; transform: translateY(-1px); }
.hm-prod { display: inline-flex; align-items: center; gap: 8px; }
.hm-prod .swatch { margin: 0; }
.hm-rows td.r { white-space: nowrap; }
.hm-rows .batch { overflow-wrap: anywhere; font-size: 11.5px; }
.hm-under { margin-top: 3px; font-size: 12.5px; }
.hm-st.missing { color: var(--serious-ink); font-weight: 600; }
.hm-note, .hm-hint { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.hm-action { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px 16px; border-radius: 10px; background: var(--attention); color: var(--ink-2); font-size: 13.5px; }
.hm-action.done { background: var(--settled); }
.hm-action.done span { display: inline-flex; gap: 8px; align-items: baseline; }
.ledger .inv .addr { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); line-height: 1.7; }

table.journal { width: 100%; border-collapse: collapse; font-size: 14px; }
.journal th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 10px 22px; border-bottom: 1px solid var(--line); }
.journal th.r, .journal td.r { text-align: right; }
.journal td { padding: 12px 22px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.journal td.prod, .journal td.prov, .journal td.dr, .journal td.cr { white-space: nowrap; }
.journal .prod-name { display: inline-flex; align-items: center; gap: 8px; }
.journal tr.line { cursor: pointer; }
.journal tr.line:hover td { background: var(--hover); }
.journal tr.line[aria-expanded="true"] td { background: var(--select); }
.journal .acct { font-weight: 500; }
.journal .acct > div { display: flex; gap: 8px; align-items: flex-start; }
.journal .acct small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; }
.journal .disclose { width: 14px; height: 14px; margin-top: 3px; flex: none; color: var(--faint); transition: transform 160ms ease-out; }
.journal tr.line[aria-expanded="true"] .disclose { transform: rotate(90deg); color: var(--ink-2); }
.journal tr.credit td { color: var(--ink-2); }
.journal tr.totals td { font-weight: 600; border-top: 1px solid var(--line-2); }
.journal tr.drill-row td { padding: 0; background: #fbfbfc; cursor: default; }
.ledger .journal .acct small { font-family: var(--mono); font-size: 11.5px; }
.journal tr.line[aria-expanded="true"] .acct small { color: var(--ink-2); }

.drill { padding: 16px 22px 20px; transition: opacity 160ms ease-out; }
.drill.loading { opacity: 0.55; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.crumbs button { border: 0; background: transparent; padding: 2px 4px; border-radius: 5px; cursor: pointer; color: var(--ink-2); font-size: 13px; }
.crumbs button:hover { background: var(--hover); }
.crumbs .here { color: var(--ink); font-weight: 600; }
.crumbs .sep { color: var(--faint); display: grid; place-items: center; }
.bars { display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 3px; align-items: end; height: 120px; }
.bars button { position: relative; height: 100%; border: 0; padding: 0; background: transparent; cursor: pointer; display: flex; align-items: flex-end; }
.bars button span { display: block; width: 100%; max-width: 22px; margin: 0 auto; border-radius: 4px 4px 0 0; min-height: 2px; }
.bars button:hover span, .bars button:focus-visible span { filter: brightness(0.92); }
.bars-axis { display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 3px; margin-top: 6px; color: var(--muted); font-size: 11px; text-align: center; font-variant-numeric: tabular-nums; }
.hours { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.hours th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.hours td { padding: 7px 8px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.hours tr { cursor: pointer; }
.hours tr:hover td { background: var(--hover); }
.hours .r { text-align: right; }
.hours tr.flag td { background: var(--attention); }
.entry { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 28px; }
.entry h3 { grid-column: 1 / -1; margin: 0 0 4px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.entry .sub { grid-column: 1 / -1; color: var(--muted); font-size: 13.5px; margin-bottom: 14px; }
.entry dl { margin: 0; display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px 14px; font-size: 14px; align-content: start; }
.entry dt { color: var(--muted); }
.entry dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.entry .postings { grid-column: 1 / -1; margin-top: 16px; }
.postings table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-family: var(--mono); }
.postings td { padding: 6px 0; border-top: 1px solid var(--line); color: var(--ink-2); }
.postings td.r { text-align: right; }
.entry .call { grid-column: 1 / -1; margin-top: 18px; }
.call-head { margin: 0 0 6px; color: var(--muted); font-size: 12.5px; }
.call pre { margin: 0; padding: 12px 14px; background: var(--wash); border: 1px solid var(--line); border-radius: 8px; font-family: var(--mono); font-size: 12px; line-height: 1.55; color: var(--ink-2); overflow-x: auto; white-space: pre; }

.journal-wrap { overflow-x: auto; margin-top: 10px; }
.journal tr.totals .acct > div { align-items: center; }
.journal-end { margin: 0; padding: 16px 22px 18px; border-top: 1px solid var(--line); font-size: 15px; line-height: 1.55; color: var(--ink); }

/* footnote */
.footnote { max-width: 1240px; margin: 0 auto; padding: 0 32px 40px; color: var(--muted); font-size: 12.5px; }
.footnote a { color: var(--ink-2); text-decoration-color: var(--line-2); }
.footnote a:hover { text-decoration-color: currentColor; }
.footnote .mono { font-size: 12px; }

/* banner (errors, unreachable ledger) */
.banner { margin-bottom: 18px; padding: 12px 16px; border-radius: 10px; border: 1px solid #f3c6c2; background: #fdf3f2; color: #7d1f19; font-size: 14px; }

/* Tablet and the in-app browser pane: the header, title row and figures keep their
   desktop arrangement; the tape moves under the chart. */
@media (max-width: 960px) {
  .topbar { gap: 24px; padding: 0 24px; }
  .screen { padding: 28px 24px 24px; }
  .footnote { padding: 0 24px 32px; }
  .figure .value { font-size: 22px; }
  .figure { padding-left: 18px; }
  .spend-card { grid-template-columns: 1fr; }
  .tape { border-left: 0; border-top: 1px solid var(--line); contain: none; }
  .tape .feed { flex: none; }
  .tape li:nth-child(n+6) { display: none; }
  .row-btn { grid-template-columns: 18px minmax(0, 1fr) minmax(0, 1fr) 140px 16px; }
  .row-btn .hide-sm { display: none; }
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hm-body { grid-template-columns: 1fr; }
  .journal th, .journal td { padding-left: 16px; padding-right: 16px; }
}

/* Phones: one column. Journal rows stack account over provider and amount, the way the
   invoice rows do. */
@media (max-width: 640px) {
  .topbar { grid-template-columns: auto 1fr; gap: 10px 16px; padding: 10px 16px; height: auto; min-height: 60px; }
  .topbar-end { justify-self: end; }
  .nav { grid-column: 1 / -1; order: 3; }
  .screen { padding: 24px 16px; }
  .footnote { padding: 0 16px 32px; }
  .head { flex-direction: column; align-items: flex-start; gap: 16px; }
  .figures { grid-template-columns: 1fr; gap: 12px; }
  .figure { padding-left: 0; border-left: 0; }
  .figure .value { font-size: 26px; }
  .counter .big { font-size: 30px; }
  .row-btn { grid-template-columns: 18px minmax(0, 1fr) auto 16px; grid-template-areas: "sw name amount chev" "sw line amount chev"; gap: 0 10px; padding: 12px 16px; }
  .row-btn .swatch { grid-area: sw; }
  .row-btn .name { grid-area: name; }
  .row-btn .line { grid-area: line; }
  .row-btn .amount { grid-area: amount; }
  .row-btn .chev { grid-area: chev; }
  .card-head { flex-direction: column; align-items: flex-start; gap: 2px; padding: 16px 16px 0; }
  .contract { grid-template-columns: 1fr; gap: 14px; padding: 18px 16px; }
  .fields { grid-template-columns: 1fr; }
  .fields .wide { grid-column: auto; }
  .segmented { flex-direction: column; height: auto; }
  .segmented label { min-height: 40px; border-left: 0; border-top: 1px solid var(--line-2); }
  .segmented label:first-child { border-top: 0; }
  .invoices .inv { grid-template-columns: 1fr; gap: 6px; padding: 14px 16px; }
  .inv .total { text-align: left; }
  .hm-head { flex-direction: column; }
  .entry { grid-template-columns: 1fr; }
  .drill { padding: 14px 16px 18px; }
  .journal-end { padding: 14px 16px 16px; }
  .mapping-note { padding-left: 16px; padding-right: 16px; }
  table.mapping, .mapping tbody, .mapping tr, .mapping td { display: block; }
  .mapping thead { display: none; }
  .mapping tr { padding: 12px 16px; border-top: 1px solid var(--line); }
  .mapping td { padding: 0; border: 0; }
  .mapping td + td { margin-top: 3px; }

  table.journal, .journal tbody { display: block; }
  .journal thead { display: none; }
  .journal tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "acct acct acct" "prod prov amt"; gap: 2px 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
  .journal tr.credit { grid-template-areas: "acct acct acct" "prov prov amt"; }
  .journal td { display: block; padding: 0; border: 0; }
  .journal td.acct { grid-area: acct; }
  .journal td.prod { grid-area: prod; padding-left: 22px; color: var(--muted); font-size: 13px; }
  .journal td.prod .swatch { display: none; }
  .journal td.prov { grid-area: prov; color: var(--muted); font-size: 13px; }
  .journal td.prod:not(:empty) + td.prov::before { content: "on "; }
  .journal td.prod, .journal td.prov { white-space: normal; min-width: 0; }
  .journal tr.credit td.prov { padding-left: 22px; }
  .journal td.dr, .journal td.cr { grid-area: amt; }
  .journal td.dr:empty, .journal td.cr:empty, .journal td.prov:empty, .journal td.prod:empty { display: none; }
  .journal td.dr:not(:empty)::before { content: "Debit "; color: var(--muted); font-size: 12.5px; }
  .journal td.cr:not(:empty)::before { content: "Credit "; color: var(--muted); font-size: 12.5px; }
  .journal tr.line[aria-expanded="true"] { background: var(--select); }
  .journal tr.line[aria-expanded="true"] td { background: transparent; }
  .journal tr.line[aria-expanded="true"] td.prov, .journal tr.line[aria-expanded="true"] td.prod, .journal tr.line[aria-expanded="true"] td.dr::before { color: var(--ink-2); }
  .journal tr.totals { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; border-top: 1px solid var(--line-2); }
  .journal tr.totals td { border-top: 0; }
  .journal tr.totals td.acct { flex: 1 0 100%; }
  .journal tr.totals .acct > div { align-items: flex-start; }
  .journal tr.totals .acct .dot { margin-top: 7px; }
  .journal tr.totals td.dr { text-align: left; }
  .journal tr.drill-row { display: block; padding: 0; }
  .journal tr.drill-row td { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* login, on a hosted copy: one card, one field, one black button */
.login { max-width: 440px; margin: 0 auto; padding: 72px 24px 40px; }
.login-card { padding: 28px 28px 30px; }
.login-card h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.login-lead { margin: 8px 0 22px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.login-form { display: grid; gap: 8px; }
.login-form label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.login-form input { height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--r-control); background: var(--surface); font: inherit; font-size: 14px; color: var(--ink); caret-color: var(--ink); }
.login-form input:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px var(--focus); }
.login-form input[aria-invalid="true"] { border-color: var(--serious-ink); }
.login-form .btn { margin-top: 10px; justify-self: start; }
.login-error { margin: 2px 0 0; color: var(--serious-ink); font-size: 13px; }
.login-note { margin: 14px 2px 0; color: var(--muted); font-size: 12.5px; }
@media (max-width: 640px) { .login { padding: 40px 16px 32px; } .login-card { padding: 22px 18px 24px; } }

