/* LedgerLens: an accounting ledger. Paper and navy ink, refund red, ruled lines, square corners, borders not shadows. */
:root {
  --paper: #fbf8f1;
  --sheet: #fffdf8;
  --paper-deep: #f2ecdf;
  --ink: #1b2a4a;
  --ink-deep: #101a30;
  --muted: #586078;
  --rule: #d9d1be;
  --rule-strong: #8a8370;
  --rule-blue: #cfd8e7;
  --col-rule: #efd6d1;
  --margin-red: #d88f86;
  --red: #b23a3a;
  --error: #b23a3a;
  --error-ink: #9c2f2f;
  --error-tint: #f7e4e0;
  --warning: #9a6a12;
  --warning-ink: #74500c;
  --warning-tint: #f5ebd3;
  --good-ink: #1b2a4a;
  --good-tint: #e6ebf4;
  --series-gross: #6c84b3;
  --series-refund: #b23a3a;
  --series-net: #1b2a4a;
  --radius: 2px;
  --radius-button: 2px;
  --font-head: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --font-body: "Source Sans 3", "Source Sans Pro", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "Source Code Pro", ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.55 var(--font-body);
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; letter-spacing: -0.005em; margin: 0; line-height: 1.2; }
p { margin: 0; }
a { color: var(--ink); text-decoration-color: var(--margin-red); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
button, input, summary { font: inherit; color: inherit; }
button { cursor: pointer; }
code { font-family: var(--font-mono); font-size: .86em; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: var(--radius); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 16px; top: -80px; z-index: 20; background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: var(--radius-button); }
.skip-link:focus { top: 12px; }

.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 32px; }

/* Masthead: the head of a ledger page. Navy top edge, double rule under the title bar, ruled sheet below. */
.masthead {
  background:
    radial-gradient(120% 90% at 0% 0%, rgba(255, 253, 248, .95), rgba(255, 253, 248, 0) 60%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-deep) 100%);
  border-top: 6px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 48px;
}
.masthead-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 72px; border-bottom: 3px double var(--ink); }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: var(--ink); text-decoration: none; font-family: var(--font-head); font-weight: 700; font-size: 22px; letter-spacing: -0.01em; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.masthead-tools { display: flex; align-items: center; gap: 18px; }
.masthead-note { font-size: 14px; color: var(--muted); font-style: italic; font-family: var(--font-head); }
.bar-button { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; background: transparent; border: 1px solid var(--rule-strong); border-radius: var(--radius); font-size: 14px; font-weight: 600; color: var(--ink); transition: border-color .18s var(--ease), background-color .18s var(--ease); }
.bar-button:hover { border-color: var(--ink); background: var(--sheet); }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 5px; font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--ink); background: var(--sheet); border: 1px solid var(--rule-strong); border-bottom-width: 2px; border-radius: 3px; }

.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 48px; align-items: start; padding-top: 40px; }
.hero-copy { display: flex; flex-direction: column; border-left: 3px double var(--margin-red); padding-left: 28px; }
.hero h1 { order: 1; font-size: clamp(34px, 3.9vw, 50px); font-weight: 600; line-height: 1.08; letter-spacing: -0.015em; max-width: 16ch; text-wrap: balance; }
.kicker { order: 2; margin-top: 14px; font-family: var(--font-head); font-style: italic; font-size: 19px; line-height: 1.4; color: var(--muted); }
.lede { order: 3; margin-top: 18px; font-size: 18px; line-height: 1.6; color: var(--ink); max-width: 34em; }
.dataset { order: 4; margin-top: 24px; padding-top: 10px; font-size: 14px; color: var(--muted); border-top: 1px solid var(--rule); max-width: 34em; }
.dataset strong { color: var(--ink); font-weight: 600; }

/* Import slip */
.import { background: var(--sheet); color: var(--ink); border: 1px solid var(--ink); border-radius: var(--radius); padding: 0 24px 20px; }
.import-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; border-bottom: 3px double var(--ink); margin: 0 -24px; padding: 0 24px; }
.import h2 { font-size: 21px; margin-right: auto; }
.mode-switch { display: inline-flex; border: 1px solid var(--ink); border-radius: var(--radius); }
.mode-switch button { min-height: 36px; padding: 0 14px; border: 0; background: transparent; font-size: 14px; font-weight: 600; }
.mode-switch button + button { border-left: 1px solid var(--rule); }
.mode-switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.paste { grid-column: 1 / -1; }
.paste textarea { display: block; width: 100%; min-height: 132px; padding: 10px 12px; font: 13px/1.5 var(--font-mono); color: var(--ink); background: var(--paper); border: 1px solid var(--rule-strong); border-bottom: 2px solid var(--ink); border-radius: var(--radius); resize: vertical; }
.paste textarea:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.paste-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; }
.paste-note { font-size: 13px; color: var(--muted); flex: 1 1 200px; }
.drop-anywhere { grid-column: 1 / -1; font-size: 13px; color: var(--muted); font-style: italic; font-family: var(--font-head); }
.import-toggle { display: none; }
.import-summary { display: none; font-size: 14px; color: var(--muted); margin-top: 12px; }
.import-body { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.drop { position: relative; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.drop-label {
  display: flex; flex-direction: column; gap: 4px; min-height: 112px; height: 100%;
  padding: 14px 16px; border: 1px dashed var(--rule-strong); border-radius: var(--radius); background: var(--paper);
  cursor: pointer; transition: border-color .18s var(--ease), background-color .18s var(--ease);
}
.drop-label:hover, .drop.is-over .drop-label { border-style: solid; border-color: var(--ink); background: var(--good-tint); }
.file-input:focus-visible + .drop-label { outline: 3px solid var(--ink); outline-offset: 2px; }
.drop-title { font-weight: 600; font-size: 15px; }
.drop-file { font-family: var(--font-mono); font-size: 13px; color: var(--ink); overflow-wrap: anywhere; }
.drop.is-empty .drop-file { color: var(--muted); font-family: var(--font-body); }
.drop.is-error .drop-file { color: var(--error-ink); font-family: var(--font-body); }
.drop-hint { margin-top: auto; font-size: 13px; color: var(--muted); }
.import-actions { grid-column: 1 / -1; display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.import-actions .button { flex: 1 1 160px; }
.columns-help { grid-column: 1 / -1; border-top: 1px solid var(--rule); padding-top: 4px; font-size: 14px; }
.columns-help summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; color: var(--ink); list-style: none; }
.columns-help summary::-webkit-details-marker { display: none; }
.columns-help summary::after { content: ""; width: 7px; height: 7px; margin-left: 10px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform .18s var(--ease); }
.columns-help[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.columns-body { display: grid; gap: 10px; color: var(--muted); padding-bottom: 8px; }
.columns-body strong { color: var(--ink); }
.columns-body code { color: var(--ink); overflow-wrap: anywhere; }
.sample-links a { display: inline-flex; align-items: center; min-height: 44px; }

/* Buttons: square, inked */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: var(--radius-button);
  border: 1px solid var(--ink); font-weight: 600; font-size: 15px; text-decoration: none;
  transition: background-color .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease);
}
.button.primary { background: var(--ink); color: var(--paper); }
.button.primary:hover { background: var(--ink-deep); }
.button.ghost { background: transparent; color: var(--ink); }
.button.ghost:hover { background: var(--good-tint); }
.button.secondary { background: var(--sheet); color: var(--ink); }
.button.secondary:hover { background: var(--good-tint); }
button:disabled { opacity: .45; cursor: not-allowed; }
.link-button { background: none; border: 0; padding: 0 4px; min-height: 44px; color: var(--ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--margin-red); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.link-button:hover { text-decoration-color: currentColor; }

/* Status */
.main { padding-top: 32px; padding-bottom: 48px; }
.main:focus { outline: none; }
.status-row { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 24px; }
.state-pill { flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 30px; padding: 3px 10px; border: 1px solid currentColor; border-radius: var(--radius); font-size: 13px; font-weight: 600; background: var(--good-tint); color: var(--good-ink); }
.state-pill::before { content: ""; width: 7px; height: 7px; background: currentColor; }
.state-pill.is-stale, .state-pill.is-busy { background: var(--warning-tint); color: var(--warning-ink); }
.state-pill.is-error { background: var(--error-tint); color: var(--error-ink); }
.notice { font-size: 15px; color: var(--muted); padding-top: 3px; }
.notice.error { color: var(--error-ink); }
.notice.warning { color: var(--warning-ink); }

.empty-state { background: var(--sheet); border: 1px dashed var(--rule-strong); border-radius: var(--radius); padding: 40px 32px; text-align: center; }
.empty-state h2 { font-size: 22px; margin-bottom: 8px; }
.empty-state p { color: var(--muted); }

/* View builder: the column heads of the ledger. Sticky on wide screens so the period is always in reach. */
.builder {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 16px;
  padding: 14px 0 16px; margin-bottom: 26px;
  background: var(--paper); border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule);
}
.builder-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 18px; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-name { font-family: var(--font-head); font-style: italic; font-size: 14px; color: var(--muted); }
.period-pick { display: flex; align-items: center; gap: 8px; }
.period-to { font-family: var(--font-head); font-style: italic; color: var(--muted); }
select {
  min-height: 40px; padding: 0 30px 0 10px; font: 600 14px var(--font-body); color: var(--ink);
  background: var(--sheet) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%231b2a4a' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--rule-strong); border-bottom: 2px solid var(--ink); border-radius: var(--radius); appearance: none; -webkit-appearance: none; cursor: pointer;
}
select:hover { border-color: var(--ink); }
select:disabled { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--sheet); }
.seg button { min-height: 40px; padding: 0 13px; border: 0; border-left: 1px solid var(--rule); background: transparent; font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; transition: background-color .15s var(--ease), color .15s var(--ease); }
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--good-tint); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg button:active, .tool:active, .button:active, .filters button:active { transform: translateY(1px); }
.builder-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin-left: auto; }
.tool { min-height: 40px; padding: 0 9px; background: transparent; border: 1px solid transparent; border-radius: var(--radius); font-size: 14px; font-weight: 600; color: var(--ink); text-decoration: underline; text-decoration-color: var(--margin-red); text-decoration-thickness: 1.5px; text-underline-offset: 4px; transition: background-color .15s var(--ease), border-color .15s var(--ease); }
.tool:hover:not(:disabled) { background: var(--sheet); border-color: var(--rule-strong); }
.tool:disabled { text-decoration-color: transparent; }
.views { position: relative; }
.views-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: min(360px, calc(100vw - 32px));
  background: var(--sheet); border: 1px solid var(--ink); border-top: 3px solid var(--ink); border-radius: var(--radius);
  padding: 14px 14px 12px; box-shadow: 0 18px 40px -24px rgba(16, 26, 48, .45);
}
.views-title { font-family: var(--font-head); font-style: italic; font-weight: 400; font-size: 14px; color: var(--muted); margin: 4px 0 6px; }
.views-title + .view-list { margin-bottom: 12px; }
.view-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.view-list li { border-bottom: 1px solid var(--rule); }
.view-pick { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; min-height: 48px; padding: 6px 8px; background: transparent; border: 0; text-align: left; }
.view-pick span { font-weight: 600; font-size: 14px; }
.view-pick small { font-size: 12px; color: var(--muted); font-family: var(--font-mono); }
.view-pick:hover { background: var(--good-tint); }
.saved-row { display: flex; align-items: stretch; }
.saved-row .view-pick { flex: 1; min-width: 0; }
.view-delete { flex: none; min-width: 64px; background: transparent; border: 0; border-left: 1px solid var(--rule); font-size: 13px; color: var(--error-ink); }
.view-delete:hover { background: var(--error-tint); }
.view-empty { padding: 10px 8px; font-size: 13px; color: var(--muted); }
.save-view { display: flex; gap: 8px; margin-top: 10px; }
.save-view input { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; font-size: 15px; background: var(--paper); border: 1px solid var(--rule-strong); border-bottom: 2px solid var(--ink); border-radius: var(--radius); }
.save-view .button { min-height: 44px; }

/* Report heading and totals strip */
.print-stale { display: none; }
.report-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 14px; }
.report-title { font-size: 30px; }
.report-sub { margin-top: 2px; font-size: 14px; color: var(--muted); font-family: var(--font-head); font-style: italic; }
.report-meta { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

.kpis {
  display: grid; grid-template-columns: minmax(0, 1.35fr) repeat(4, minmax(0, 1fr)); gap: 1px;
  background: var(--rule); border-top: 2px solid var(--ink); border-bottom: 1px solid var(--ink);
  margin-bottom: 36px;
}
.kpi { background: var(--sheet); padding: 16px 20px 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi h3 { font-family: var(--font-body); font-size: 14px; font-weight: 600; letter-spacing: 0; color: var(--muted); }
.kpi-value { font-family: var(--font-mono); font-weight: 600; font-size: clamp(20px, 2vw, 26px); letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-lead { background: var(--sheet); }
.kpi-lead .kpi-value { font-size: clamp(28px, 3vw, 38px); width: fit-content; max-width: 100%; padding-bottom: 4px; border-bottom: 4px double var(--ink); }
.kpi-change { font-size: 13px; color: var(--muted); margin-top: auto; padding-top: 6px; }
.kpi-change strong { font-weight: 600; }
.kpi-change .is-good { color: var(--good-ink); }
.kpi-change .is-bad { color: var(--error-ink); }
.kpi-change .is-flat { color: var(--muted); }

/* Tabs: ledger index tabs */
.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--ink); margin-bottom: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs [role="tab"] {
  flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px;
  background: var(--paper-deep); border: 1px solid var(--rule); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 600; font-size: 15px; color: var(--muted);
  transition: color .18s var(--ease), background-color .18s var(--ease);
}
.tabs [role="tab"]:hover { color: var(--ink); background: var(--sheet); }
.tabs [role="tab"][aria-selected="true"] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.count { font-family: var(--font-mono); font-size: 12px; font-weight: 600; background: var(--error-tint); color: var(--error-ink); border-radius: var(--radius); padding: 1px 7px; font-variant-numeric: tabular-nums; }
.tabs [aria-selected="true"] .count { background: var(--paper); color: var(--error-ink); }

/* Panels: the ledger sheet */
.panel { background: var(--sheet); border: 1px solid var(--rule); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); padding: 28px; margin-bottom: 32px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 20px; }
.panel-head h2 { font-size: 24px; }
.panel-sub { margin-top: 6px; color: var(--muted); font-size: 15px; max-width: 46em; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.key { display: inline-block; width: 12px; height: 12px; border-radius: 0; }
.key-gross { background: var(--series-gross); }
.key-refund { background: var(--series-refund); }
.key-net { width: 18px; height: 2px; background: var(--series-net); position: relative; }
.key-net::after { content: ""; position: absolute; left: 5px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--series-net); }

/* Chart */
.chart-wrap { position: relative; }
.chart { width: 100%; min-height: 240px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-body); font-size: 12px; fill: var(--muted); }
.chart .tick-label { font-family: var(--font-mono); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: #6c84b3; stroke-opacity: .28; stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--ink); stroke-opacity: 1; stroke-width: 1.5; shape-rendering: crispEdges; }
.chart .bar-gross { fill: var(--series-gross); }
.chart .bar-refund { fill: var(--series-refund); }
.chart .net-line { fill: none; stroke: var(--series-net); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .net-dot { fill: var(--sheet); stroke: var(--series-net); stroke-width: 2; }
.chart .end-label { font-family: var(--font-mono); font-size: 12px; fill: var(--ink); font-weight: 600; paint-order: stroke; stroke: var(--sheet); stroke-width: 4px; stroke-linejoin: round; }
.chart .hover-band { fill: var(--ink); fill-opacity: 0; transition: fill-opacity .15s var(--ease); }
.chart .month-col.is-active .hover-band { fill-opacity: .06; }
.chart .month-col.is-active .net-dot { r: 6; fill: var(--series-net); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart { touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart.is-running .hit { cursor: default; }
.chart .month-col[data-out] .bar-gross, .chart .month-col[data-out] .bar-refund { opacity: .28; }
.chart .month-col[data-out] text { opacity: .55; }
.chart .period-band { fill: var(--good-tint); stroke: var(--rule-blue); stroke-width: 1; }
.chart .brush { fill: var(--ink); fill-opacity: .08; stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.chart .run-area { fill: var(--series-gross); fill-opacity: .16; }
.chart .run-gross { fill: none; stroke: var(--series-gross); stroke-width: 2; stroke-linejoin: round; }
.key-bar { background: var(--ink); }
.chart-tip .tip-run { border-top: 1px solid rgba(251, 248, 241, .25); padding-top: 4px; margin-top: 2px; color: var(--paper); font-weight: 600; }

/* Ranked bars for customers, products and order sizes */
.chart.is-ranked { min-height: 0; }
.rank-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.rank-list li { border-bottom: 1px solid var(--rule-blue); }
.rank-row {
  display: grid; grid-template-columns: minmax(120px, 15em) minmax(0, 1fr) minmax(88px, auto); align-items: center; gap: 14px;
  width: 100%; min-height: 44px; padding: 6px 8px; background: transparent; border: 0; text-align: left; color: var(--ink);
  transition: background-color .15s var(--ease);
}
.rank-row:hover { background: var(--good-tint); }
.rank-row:hover .rank-bar { filter: brightness(.88); }
.rank-name { font-family: var(--font-head); font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-track { position: relative; height: 18px; }
.rank-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--series-net); border-radius: 0 2px 2px 0; transform-origin: left center; animation: rank-in .5s var(--ease) both; }
.rank-bar.rank-gross { background: var(--series-gross); }
.rank-bar.rank-refunds, .rank-bar.is-negative { background: var(--series-refund); }
.rank-bar.rank-orders { background: var(--rule-strong); }
.rank-list li:nth-child(2) .rank-bar { animation-delay: .03s; } .rank-list li:nth-child(3) .rank-bar { animation-delay: .06s; } .rank-list li:nth-child(4) .rank-bar { animation-delay: .09s; } .rank-list li:nth-child(5) .rank-bar { animation-delay: .12s; } .rank-list li:nth-child(n+6) .rank-bar { animation-delay: .15s; }
@keyframes rank-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.rank-value { font-family: var(--font-mono); font-weight: 600; font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart:focus-visible { outline-offset: 4px; }
.chart-empty { padding: 48px 0; text-align: center; color: var(--muted); }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 188px;
  background: var(--ink); color: var(--paper); border-radius: var(--radius); padding: 12px 14px; font-size: 13px;
  border-top: 3px solid var(--margin-red);
}
.chart-tip h4 { font-family: var(--font-head); font-weight: 600; font-size: 15px; margin: 0 0 8px; }
.chart-tip dl { margin: 0; display: grid; grid-template-columns: auto auto; gap: 4px 16px; }
.chart-tip dt { display: flex; align-items: center; gap: 6px; color: #cdd5e5; }
.chart-tip dd { margin: 0; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.chart-tip .key { width: 10px; height: 10px; }
.chart-tip .key-gross { background: #9fb2d6; }
.chart-tip .key-refund { background: #e27d73; }
.chart-tip .key-net { width: 10px; height: 10px; border-radius: 50%; background: var(--paper); }
.chart-tip .key-net::after { display: none; }
.chart-help { font-size: 13px; color: var(--muted); margin: 12px 0 24px; }

/* Tables: ruled ledger, red money columns */
.table-scroll { position: relative; overflow-x: auto; max-width: 100%; border: 1px solid var(--rule); border-radius: var(--radius); overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; background: var(--sheet); }
.table-scroll:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table caption { text-align: left; font-family: var(--font-head); font-weight: 600; font-size: 18px; padding: 14px 16px 10px; }
.data-table th { text-align: left; font-weight: 600; font-size: 13px; color: var(--ink); background: var(--paper); padding: 10px 16px; white-space: nowrap; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.data-table td { padding: 11px 16px; border-top: 1px solid var(--rule-blue); vertical-align: top; }
.data-table tbody tr:hover td, .data-table tbody tr:hover th { background: #f4f6fb; }
.data-table .numeric { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.numeric, .data-table th.numeric { border-left: 1px solid var(--col-rule); }
.data-table td.numeric, .data-table .mono { font-family: var(--font-mono); font-size: 13px; white-space: nowrap; }
.data-table tbody th { font-family: var(--font-head); font-weight: 600; color: var(--ink); background: none; font-size: 15px; border-top: 1px solid var(--rule-blue); border-bottom: 0; }
.data-table .is-peak th::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 8px; vertical-align: middle; background: var(--ink); transform: rotate(45deg); }
.data-table .wrap-cell { min-width: 220px; }
.data-table .muted { color: var(--muted); }
.change-up { color: var(--good-ink); }
.change-down { color: var(--error-ink); }
#month-body tr:last-child td, #month-body tr:last-child th { border-bottom: 0; }
.data-table tfoot th, .data-table tfoot td { border-top: 2px solid var(--ink); background: var(--paper); font-weight: 600; padding-top: 12px; padding-bottom: 12px; }
.data-table tfoot th { font-family: var(--font-head); font-size: 15px; text-align: left; white-space: nowrap; }
.data-table tfoot td.numeric:nth-child(5) { text-decoration: underline double; text-underline-offset: 5px; }
.data-table .row-cell { width: 1%; white-space: nowrap; text-align: right; padding-top: 4px; padding-bottom: 4px; vertical-align: middle; }
.row-link { min-height: 36px; min-width: 52px; padding: 0 10px; background: transparent; border: 1px solid var(--rule-strong); border-radius: var(--radius); font-size: 13px; font-weight: 600; color: var(--ink); transition: background-color .15s var(--ease), border-color .15s var(--ease); }
.row-link:hover { border-color: var(--ink); background: var(--good-tint); }
#issue-body .row-link { border-color: var(--ink); }
.data-table.breakdown th[scope="row"] { white-space: nowrap; max-width: 18em; overflow: hidden; text-overflow: ellipsis; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border: 1px solid currentColor; border-radius: var(--radius); font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; background: currentColor; }
.pill.error { background: var(--error-tint); color: var(--error-ink); }
.pill.warning { background: var(--warning-tint); color: var(--warning-ink); }

/* Reconciliation: a footed sum, net double underlined */
.reconcile { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px 28px; margin-top: 24px; padding: 18px 20px; background: var(--paper); border: 1px solid var(--rule); border-top: 2px solid var(--ink); border-radius: var(--radius); }
.reconcile div span { display: block; font-size: 13px; color: var(--muted); }
.reconcile strong { font-family: var(--font-mono); font-weight: 600; font-size: 18px; font-variant-numeric: tabular-nums; }
.reconcile div:last-child strong { display: inline-block; padding-bottom: 2px; border-bottom: 4px double var(--ink); }
.reconcile .op { font-family: var(--font-mono); font-size: 22px; color: var(--muted); padding-bottom: 2px; }

/* Exceptions */
.issue-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-bottom: 32px; }
.issue-group { border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; background: var(--sheet); }
.issue-group.error { border-left: 4px solid var(--error); }
.issue-group.warning { border-left: 4px solid var(--warning); }
.issue-group-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.issue-group h3 { font-size: 18px; }
.issue-group .group-count { font-family: var(--font-mono); font-size: 13px; color: var(--muted); white-space: nowrap; padding-top: 3px; }
.issue-group p { font-size: 14px; color: var(--muted); }
.issue-group .fix { color: var(--ink); }
.issue-group .fix strong { font-weight: 600; }
.issue-refs { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 4px 0 0; padding: 0; }
.issue-refs li { font-family: var(--font-mono); font-size: 12px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 2px 7px; }
.issue-group .link-button { align-self: flex-start; margin-top: auto; padding-left: 0; }
.all-clear { padding: 24px; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--good-tint); color: var(--good-ink); font-weight: 600; }

.issue-table-head { display: flex; justify-content: space-between; align-items: center; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 12px; scroll-margin-top: 16px; }
.issue-table-head h3 { font-size: 20px; }
.filters { display: inline-flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--sheet); }
.filters button { min-height: 44px; padding: 0 16px; border: 0; border-left: 1px solid var(--rule); border-radius: 0; background: transparent; font-weight: 600; font-size: 14px; color: var(--ink); transition: background-color .18s var(--ease), color .18s var(--ease); }
.filters button:first-child { border-left: 0; }
.filters button:hover { background: var(--good-tint); }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.search-row { margin-bottom: 8px; }
.field-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
input[type="search"] { width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--rule-strong); border-bottom: 2px solid var(--ink); border-radius: var(--radius-button); background: var(--sheet); font-size: 16px; }
input[type="search"]::placeholder { color: #6b7185; }
input[type="search"]:focus-visible { border-color: var(--ink); }
.code-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 14px; background: var(--warning-tint); color: var(--warning-ink); border-left: 3px solid var(--warning); border-radius: var(--radius); padding: 2px 12px; margin: 8px 0; }
.table-note { font-size: 14px; color: var(--muted); margin: 8px 0 12px; }
.paging { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 12px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.paging .button { min-height: 44px; padding: 0 16px; font-size: 14px; }

/* Fix progress */
.fix-meter { min-width: 220px; max-width: 320px; flex: 0 1 300px; }
.fix-meter-text { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.fix-meter-text strong { font-family: var(--font-mono); color: var(--ink); font-size: 18px; }
.fix-track { height: 8px; background: var(--paper-deep); border: 1px solid var(--rule); }
.fix-track span { display: block; height: 100%; width: 0; background: var(--ink); transition: width .5s var(--ease); }
.fix-meter.is-clear .fix-meter-text { color: var(--good-ink); font-weight: 600; }

/* Dialogs: a slip laid on the ledger */
.sheet-dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; color: var(--ink);
  background: var(--sheet); border: 1px solid var(--ink); border-top: 6px solid var(--ink); border-radius: var(--radius);
  box-shadow: 0 30px 70px -30px rgba(16, 26, 48, .6);
}
.sheet-dialog::backdrop { background: rgba(16, 26, 48, .42); }
.sheet-dialog[open] { animation: slip-in .22s var(--ease); }
@keyframes slip-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.fix-form, #shortcuts-dialog { padding: 20px 22px 18px; }
.dialog-head { border-bottom: 3px double var(--ink); padding-bottom: 12px; margin-bottom: 14px; }
.dialog-head h2 { font-size: 23px; overflow-wrap: anywhere; }
.dialog-sub { margin-top: 4px; font-size: 14px; color: var(--muted); }
.fix-hint { font-size: 14px; padding: 8px 12px; background: var(--paper); border-left: 3px solid var(--margin-red); margin-bottom: 14px; }
.fix-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.fix-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fix-field label { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.fix-field input { min-height: 44px; padding: 0 10px; font: 15px var(--font-mono); color: var(--ink); background: var(--paper); border: 1px solid var(--rule-strong); border-radius: var(--radius); min-width: 0; }
.fix-field input:focus-visible { outline: 3px solid var(--ink); outline-offset: 1px; }
.fix-field.is-flagged label { color: var(--error-ink); font-weight: 600; }
.fix-field.is-flagged input { border-color: var(--error); border-bottom-width: 2px; background: #fff; }
.fix-check { margin-top: 14px; font-size: 14px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--radius); min-height: 44px; }
.fix-check.is-open { background: var(--warning-tint); color: var(--warning-ink); border-color: #e2cfa2; }
.fix-check.is-clear { background: var(--good-tint); color: var(--good-ink); border-color: var(--ink); }
.dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 16px; }
.dialog-actions .link-button { margin-left: auto; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; margin: 0; font-size: 14px; align-items: baseline; }
.keys dt { display: flex; gap: 4px; flex-wrap: wrap; font-weight: 600; white-space: nowrap; }
.keys dd { margin: 0; color: var(--muted); }

/* Toast and drop overlay */
.toast {
  position: fixed; left: 50%; bottom: 20px; z-index: 50; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px); width: max-content;
  padding: 8px 8px 8px 16px; background: var(--ink); color: var(--paper); border-top: 3px solid var(--margin-red); border-radius: var(--radius);
  font-size: 14px; box-shadow: 0 16px 40px -18px rgba(16, 26, 48, .7); animation: slip-in .2s var(--ease);
}
#toast-text { overflow-wrap: anywhere; }
.toast-undo { flex: none; min-height: 40px; padding: 0 14px; background: transparent; color: var(--paper); border: 1px solid rgba(251, 248, 241, .5); border-radius: var(--radius); font-weight: 600; }
.toast-undo:hover { background: rgba(251, 248, 241, .12); }
.toast-undo:focus-visible { outline-color: var(--paper); }
.drop-overlay { position: fixed; inset: 12px; z-index: 60; display: grid; place-items: center; padding: 24px; background: rgba(251, 248, 241, .92); border: 2px dashed var(--ink); border-radius: var(--radius); pointer-events: none; }
.drop-overlay p { max-width: 24ch; text-align: center; font-family: var(--font-head); font-size: 26px; font-weight: 600; line-height: 1.25; }

/* Export */
.export { display: flex; justify-content: space-between; align-items: center; gap: 16px 32px; flex-wrap: wrap; padding: 22px 28px; background: var(--sheet); border: 1px solid var(--rule); border-top: 2px solid var(--ink); border-radius: var(--radius); }
.export h2 { font-size: 22px; margin-bottom: 4px; }
.export p { color: var(--muted); font-size: 15px; }
.export-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.export-fixed { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; padding-top: 16px; border-top: 1px solid var(--rule); }
.export-fixed p { color: var(--ink); font-weight: 600; }

@media (min-width: 1024px) {
  .builder { position: sticky; top: 0; z-index: 20; box-shadow: 0 10px 18px -18px rgba(16, 26, 48, .5); }
}

/* Footer */
.site-footer { border-top: 3px double var(--ink); padding: 22px 0 32px; font-size: 14px; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap; }
.site-footer strong { color: var(--ink); font-family: var(--font-head); font-weight: 700; }

/* Tablet */
@media (max-width: 1023px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .hero h1 { max-width: 18ch; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-lead { grid-column: 1 / -1; }
  .kpi-lead .kpi-value { font-size: 36px; }
  .kpi-value { font-size: 24px; }
}

/* Phone */
@media (max-width: 759px) {
  .wrap { padding: 0 16px; }
  .masthead { padding-bottom: 24px; --bar: 67px; }
  .masthead-bar { min-height: 64px; }
  .masthead-note { font-size: 13px; }
  .hero { padding-top: 22px; gap: 24px; }
  .hero-copy { padding-left: 14px; }
  .hero h1 { font-size: clamp(30px, 8.6vw, 38px); }
  .kicker { font-size: 17px; margin-top: 10px; }
  .lede { font-size: 16px; margin-top: 14px; }
  .dataset { margin-top: 16px; }
  .import { padding: 0 16px 16px; }
  .import-head { margin: 0 -16px; padding: 0 16px; }
  .import-toggle { display: inline-flex; align-items: center; }
  .import-body { grid-template-columns: minmax(0, 1fr); }
  .drop-label { min-height: 88px; }
  .import.is-collapsed .import-head { border-bottom: 0; }
  .import.is-collapsed .import-body { display: none; }
  .import.is-collapsed .import-summary { display: block; margin-top: 0; }
  .import.is-collapsed .mode-switch { display: none; }
  .main { padding-top: 24px; }
  .status-row { flex-direction: column; gap: 8px; }
  .kpi { padding: 14px 16px; }
  .kpi-lead .kpi-value { font-size: 30px; }
  .kpi-value { font-size: 21px; }
  .tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .tabs [role="tab"] { justify-content: center; flex-wrap: wrap; gap: 4px 6px; padding: 6px; font-size: 14px; line-height: 1.2; text-align: center; }
  .panel { padding: 18px 14px; }
  .panel-head h2 { font-size: 21px; }
  .issue-groups { grid-template-columns: minmax(0, 1fr); }
  .reconcile { flex-direction: column; align-items: stretch; gap: 8px; padding: 14px 16px; }
  .reconcile div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
  .reconcile div:last-child { border-top: 1px solid var(--ink); padding-top: 8px; }
  .reconcile .op { display: none; }
  .reconcile strong { font-size: 16px; }
  .export { padding: 18px 16px; }
  .export-actions, .export-actions .button { width: 100%; }
  .data-table { font-size: 13px; }
  .data-table th, .data-table td { padding: 10px 12px; }
  .masthead-note { display: none; }
  .import-head { flex-wrap: wrap; gap: 8px 12px; padding-top: 8px; padding-bottom: 8px; }
  .mode-switch button { min-height: 44px; }
  .builder { gap: 12px; padding-top: 12px; }
  .builder-fields { gap: 12px; width: 100%; }
  .field { width: 100%; }
  .period-pick select { flex: 1 1 0; min-width: 0; min-height: 44px; }
  .seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); width: 100%; }
  .seg button { min-height: 44px; padding: 0 8px; border-left: 0; border-top: 1px solid var(--rule); box-shadow: inset 1px 0 0 var(--rule); }
  .builder-tools { width: 100%; gap: 4px; }
  .tool { min-height: 44px; padding: 0 10px; }
  .views { position: static; }
  .views-panel { left: 0; right: 0; margin: 0 auto; }
  .builder { position: relative; }
  .report-title { font-size: 25px; }
  .rank-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name value" "track track"; gap: 4px 12px; padding: 8px 4px; }
  .rank-name { grid-area: name; font-size: 14px; }
  .rank-value { grid-area: value; font-size: 13px; }
  .rank-track { grid-area: track; height: 10px; }
  .fix-meter { flex-basis: 100%; max-width: none; }
  .fix-fields { grid-template-columns: minmax(0, 1fr); }
  .fix-form, #shortcuts-dialog { padding: 16px 16px 14px; }
  .dialog-actions .button { flex: 1 1 140px; }
  .dialog-actions .link-button { margin-left: 0; }
  .keys { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .keys dd { margin-bottom: 8px; }
  .toast { bottom: 12px; width: calc(100vw - 24px); }
  .row-link { min-height: 40px; }
  .export-fixed .export-actions, .export-fixed .button { width: 100%; }
  .builder-tools { margin-left: 0; }
  .breakdown tbody th, .breakdown thead th:first-child, .breakdown tfoot th { position: sticky; left: 0; z-index: 1; background: var(--sheet); box-shadow: 1px 0 0 var(--rule); }
  .breakdown thead th:first-child, .breakdown tfoot th { background: var(--paper); }
}
@media (max-width: 400px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .kpi { flex-direction: row; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
  .kpi-change { flex-basis: 100%; padding-top: 0; }
  .kpi-lead { flex-direction: column; flex-wrap: nowrap; align-items: flex-start; }
  .kpi-lead .kpi-change { flex-basis: auto; }
}

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

@media print {
  body { background: #fff; font-size: 11pt; }
  .masthead { background: #fff; border-top: 0; padding: 0 0 12px; border-bottom: 1px solid #999; }
  .masthead-bar { background: #fff; }
  .masthead-tools, .hero .lede, .kicker, .import, .skip-link, .status-row, .tabs, .export, .filters, .search-row, .code-filter, .paging, .chart-help, .issue-group .link-button, .builder, .row-cell, .fix-meter, .toast, .drop-overlay, dialog { display: none !important; }
  .rank-bar { animation: none; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .rank-row { grid-template-columns: 14em 1fr 7em; }
  .report-sub { color: var(--ink); }
  .brand { color: var(--ink); }
  .hero { display: block; padding-top: 0; }
  .hero-copy { border-left: 0; padding-left: 0; }
  .hero h1 { font-size: 22pt; max-width: none; }
  .dataset { color: var(--ink); border-color: #999; }
  .dataset strong { color: var(--ink); }
  .wrap { max-width: none; padding: 0; }
  .main { padding-top: 16px; }
  .panel[hidden] { display: block !important; }
  .panel { break-inside: auto; border: 1px solid #bbb; padding: 14px; margin-bottom: 16px; }
  .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .kpi { padding: 10px; }
  .kpi-lead .kpi-value, .kpi-value { font-size: 15pt; }
  .table-scroll { overflow: visible; border-color: #bbb; }
  .issue-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .issue-group, tr { break-inside: avoid; }
  .chart-tip { display: none !important; }
  .chart .bar-gross, .chart .bar-refund, .chart .net-line, .chart .net-dot, .kpis, .tabs [aria-selected="true"] { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  body.is-stale .print-stale { display: block; border: 2px solid var(--error); color: var(--error-ink); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; font-weight: 600; }
  .site-footer { border-color: #bbb; }
}
