/* Finance Statement Report Analysis — design tokens
   Brief-mandated: page gradient #0f5b73 -> #1581a3, surfaces/buttons #093442, white type.
   Identity: every number wears its provenance (reported / calculated / auditor / AI) and every
   assessment reads as a signal ledger of green, orange and red. */
:root {
  --bg-a: #0f5b73;
  --bg-b: #1581a3;
  --panel: #093442;
  --panel-2: #0c3f50;
  --panel-3: #104b5e;
  --line: rgba(255, 255, 255, .11);
  --line-strong: rgba(255, 255, 255, .22);
  --ink: #ffffff;
  --ink-2: rgba(255, 255, 255, .76);
  --ink-3: rgba(255, 255, 255, .55);
  --green: #5fe0a6;
  --orange: #ffb547;
  --red: #ff7d7d;
  --reported: #a6dcff;
  --calculated: #cdbdff;
  --auditor: #ffd98a;
  --ai: #8ff3e4;
  --radius-lg: 16px;
  --radius: 10px;
  --radius-sm: 6px;
  --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --rail: 252px;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); font-family: var(--sans); line-height: 1.5;
  background: linear-gradient(135deg, var(--bg-a) 0%, var(--bg-b) 100%) fixed;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
a { color: var(--ink); text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--auditor); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.2; font-weight: 600; }
h1 { font-family: var(--serif); font-size: 2rem; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--ink-3); }
.soft { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 1.25rem 1rem;
  background: rgba(9, 52, 66, .72); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 1.1rem;
}
.brand { display: flex; gap: .7rem; align-items: center; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name { font-family: var(--serif); font-size: 1.02rem; line-height: 1.15; }
.brand-name small { display: block; font-family: var(--sans); font-size: .74rem; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: .78rem; color: var(--ink-3); padding: 0 .6rem .25rem; }
.nav-link {
  display: flex; align-items: center; gap: .6rem; padding: .48rem .6rem; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-size: .95rem;
}
.nav-link:hover { background: var(--panel-2); color: var(--ink); }
.nav-link.active { background: var(--panel); color: var(--ink); box-shadow: inset 3px 0 0 var(--ai); }
.nav-link svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.company-switch select { width: 100%; }
.rail-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: .9rem; font-size: .88rem; }
.rail-foot form { display: inline; }
.main { padding: 1.75rem 2.25rem 3rem; min-width: 0; }
.wrap { max-width: 1240px; margin: 0 auto; }
.topbar { display: none; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-head p { color: var(--ink-2); margin: .25rem 0 0; max-width: 70ch; }
.crumb { font-size: .85rem; color: var(--ink-3); margin-bottom: .35rem; }
.crumb a { color: var(--ink-2); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ surfaces */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.25rem 1.35rem; }
.panel + .panel { margin-top: 1rem; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .9rem; }
.panel-head h2, .panel-head h3 { margin: 0; }
.inset { background: var(--panel-2); border-radius: var(--radius); padding: .9rem 1rem; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.stack > * + * { margin-top: 1rem; }

/* ------------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; gap: .45rem; padding: .56rem 1rem; border-radius: var(--radius-sm);
  background: var(--panel); color: var(--ink); border: 1px solid var(--line-strong); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn:hover { background: var(--panel-3); }
.btn-primary { background: #062631; border-color: var(--ai); }
.btn-primary:hover { background: #0a3140; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { border-color: rgba(255, 125, 125, .55); color: #ffd1d1; }
.btn-sm { padding: .32rem .65rem; font-size: .86rem; font-weight: 500; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label { display: block; font-size: .9rem; color: var(--ink-2); margin-bottom: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; padding: .55rem .7rem; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: #06222c; color: var(--ink); font: inherit;
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
textarea { min-height: 96px; resize: vertical; }
select option { background: #06222c; }
.field { margin-bottom: .95rem; }
.field-hint { font-size: .82rem; color: var(--ink-3); margin-top: .25rem; }
.check { display: flex; gap: .5rem; align-items: center; font-size: .93rem; color: var(--ink); margin: 0; }
.check input { width: 16px; height: 16px; accent-color: var(--ai); }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.chip-toggle span {
  display: inline-block; padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--line-strong);
  color: var(--ink-2); cursor: pointer; font-size: .9rem;
}
.chip-toggle input:checked + span { background: var(--panel-3); color: var(--ink); border-color: var(--ai); }
.chip-toggle input:focus-visible + span { outline: 2px solid var(--auditor); }
.segmented { display: inline-flex; background: #06222c; border-radius: 999px; padding: 3px; border: 1px solid var(--line); }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; padding: .38rem .95rem; border-radius: 999px; cursor: pointer; color: var(--ink-2); }
.segmented input:checked + span { background: var(--panel-3); color: var(--ink); }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: .82rem; padding: .5rem .6rem; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
table.data td { padding: .52rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr.group td { color: var(--ink-3); font-size: .82rem; padding-top: 1rem; border-bottom-color: var(--line-strong); }
table.data tr:hover td { background: rgba(255, 255, 255, .025); }
table.data input[type=text] { padding: .3rem .5rem; text-align: right; max-width: 190px; }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* ------------------------------------------------------------------ provenance tags */
.prov {
  display: inline-block; font-size: .72rem; line-height: 1; padding: .22rem .45rem; border-radius: 4px; margin: 0 .15rem;
  vertical-align: 1px; white-space: nowrap; font-weight: 600;
}
.prov-reported { color: var(--reported); border: 1px solid rgba(166, 220, 255, .55); }
.prov-comparative { color: var(--reported); border: 1px dashed rgba(166, 220, 255, .55); }
.prov-manual { color: var(--ink); border: 1px solid var(--line-strong); }
.prov-calculated, .prov-derived { color: var(--calculated); border: 1px dashed rgba(205, 189, 255, .6); }
.prov-auditor { color: #1d1606; background: var(--auditor); }
.prov-ai { color: var(--ai); border: 1px dotted rgba(143, 243, 228, .8); }
.verified { color: var(--green); font-size: .8rem; }
.conf-low { color: var(--orange); }

/* ------------------------------------------------------------------ signals */
.dot { width: .62rem; height: .62rem; border-radius: 50%; display: inline-block; flex: none; }
.dot.green { background: var(--green); } .dot.orange { background: var(--orange); } .dot.red { background: var(--red); }
.signal-pill { display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .75rem; border-radius: 999px; font-weight: 600; font-size: .9rem; }
.signal-pill.green { background: rgba(95, 224, 166, .14); color: var(--green); }
.signal-pill.orange { background: rgba(255, 181, 71, .14); color: var(--orange); }
.signal-pill.red { background: rgba(255, 125, 125, .16); color: var(--red); }

/* the ledger: one segment per indicator, critical first */
.ledger { display: flex; gap: 3px; height: 14px; margin: .35rem 0 .5rem; }
.ledger span { flex: 1; border-radius: 3px; min-width: 6px; }
.ledger .green { background: var(--green); } .ledger .orange { background: var(--orange); } .ledger .red { background: var(--red); }
.ledger-lg { height: 26px; gap: 4px; }
.ledger-counts { display: flex; gap: 1.1rem; font-size: .9rem; color: var(--ink-2); }
.ledger-counts b { font-size: 1.15rem; color: var(--ink); margin-right: .2rem; }

.indicator { border-left: 3px solid var(--line-strong); padding: .75rem .9rem .8rem 1rem; background: var(--panel-2); border-radius: 0 var(--radius) var(--radius) 0; }
.indicator + .indicator { margin-top: .6rem; }
.indicator.green { border-left-color: var(--green); }
.indicator.orange { border-left-color: var(--orange); }
.indicator.red { border-left-color: var(--red); }
.indicator-top { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.indicator h4 { margin: 0; font-size: 1rem; }
.indicator .meta { font-size: .8rem; color: var(--ink-3); }
.indicator .why { margin: .45rem 0 0; color: var(--ink-2); font-size: .93rem; }
.indicator .calc { margin: .35rem 0 0; font-size: .82rem; color: var(--ink-3); }
.moved { font-size: .78rem; color: var(--ai); }

/* ------------------------------------------------------------------ figures & stats */
.figure { padding: .85rem 1rem; background: var(--panel-2); border-radius: var(--radius); }
.figure .label { font-size: .84rem; color: var(--ink-3); }
.figure .value { font-size: 1.45rem; font-weight: 600; letter-spacing: -.01em; margin: .1rem 0; }
.figure .foot { font-size: .8rem; color: var(--ink-3); display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.meter { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--ai); }
.year-card { display: block; padding: .8rem .9rem; border-radius: var(--radius); background: var(--panel-2); text-decoration: none; }
.year-card:hover { background: var(--panel-3); }
.year-card strong { font-size: 1.1rem; }

/* ------------------------------------------------------------------ report reading */
.report-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 1.75rem; align-items: start; }
.toc { position: sticky; top: 1.25rem; font-size: .9rem; }
.toc a { display: block; padding: .3rem .55rem; color: var(--ink-2); text-decoration: none; border-radius: var(--radius-sm); }
.toc a:hover { background: var(--panel-2); color: var(--ink); }
.prose { font-family: var(--serif); font-size: 1.07rem; line-height: 1.68; max-width: 74ch; color: rgba(255, 255, 255, .92); }
.prose p { margin: 0 0 .9rem; }
.prose ul, .prose ol { padding-left: 1.2rem; }
.prose strong { color: #fff; }
.prose .prov { font-family: var(--sans); }
.report-section { scroll-margin-top: 1rem; }
.verdict { font-family: var(--serif); font-size: 1.35rem; line-height: 1.4; max-width: 60ch; margin: .2rem 0 .8rem; }
.quote { border-left: 3px solid var(--auditor); padding: .55rem .9rem; margin: .6rem 0; font-family: var(--serif); font-style: italic; color: rgba(255, 255, 255, .9); background: rgba(255, 217, 138, .06); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.quote cite { display: block; font-style: normal; font-family: var(--sans); font-size: .78rem; color: var(--ink-3); margin-top: .3rem; }
.rec { display: grid; grid-template-columns: 1.6rem 1fr; gap: .6rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.rec:last-child { border-bottom: 0; }
.rec-n { font-weight: 700; color: var(--ink-3); }
.rec h4 { margin: 0 0 .2rem; }

/* ------------------------------------------------------------------ progress, flash, empty */
.progress-card { text-align: left; }
.bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .12); overflow: hidden; margin: .8rem 0 .4rem; }
.bar > i { display: block; height: 100%; width: 0; background: var(--ai); transition: width .6s ease; }
.flash-stack { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.2rem; }
.flash { padding: .7rem .95rem; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); border-left-width: 4px; }
.flash.success { border-left-color: var(--green); }
.flash.error { border-left-color: var(--red); }
.flash.info { border-left-color: var(--reported); }
.empty { padding: 2rem 1.25rem; text-align: center; color: var(--ink-2); }
.empty h3 { color: var(--ink); }
.status { font-size: .82rem; padding: .15rem .5rem; border-radius: 999px; border: 1px solid var(--line-strong); white-space: nowrap; }
.status.ready, .status.completed { color: var(--green); border-color: rgba(95, 224, 166, .5); }
.status.processing, .status.running, .status.queued { color: var(--ai); border-color: rgba(143, 243, 228, .5); }
.status.failed { color: var(--red); border-color: rgba(255, 125, 125, .5); }
.warn-list { margin: .5rem 0 0; padding-left: 1.1rem; color: var(--orange); font-size: .9rem; }
.check-row { display: flex; gap: .6rem; align-items: baseline; padding: .35rem 0; font-size: .92rem; }
.check-row .state { width: 4.2rem; flex: none; font-weight: 600; }
.state.pass { color: var(--green); } .state.warn { color: var(--orange); } .state.fail { color: var(--red); } .state.skipped { color: var(--ink-3); }

/* ------------------------------------------------------------------ assistant */
.chat-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 1rem; min-height: 70vh; }
.chat-list a { display: block; padding: .5rem .6rem; border-radius: var(--radius-sm); color: var(--ink-2); text-decoration: none; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list a.active, .chat-list a:hover { background: var(--panel-2); color: var(--ink); }
.chat-panel { display: flex; flex-direction: column; min-height: 70vh; }
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .9rem; padding: .25rem .25rem 1rem; max-height: 62vh; }
.msg { max-width: 82ch; }
.msg.user { align-self: flex-end; background: var(--panel-3); padding: .6rem .9rem; border-radius: var(--radius) var(--radius) 2px var(--radius); }
.msg.assistant { align-self: flex-start; }
.msg.assistant .body { font-family: var(--serif); font-size: 1.02rem; line-height: 1.62; }
.msg .sources { font-size: .8rem; color: var(--ink-3); margin-top: .35rem; }
.composer { display: flex; gap: .6rem; align-items: flex-end; border-top: 1px solid var(--line); padding-top: .9rem; }
.composer textarea { min-height: 52px; }
.suggest { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0; }
.suggest button { background: transparent; color: var(--ink-2); border: 1px solid var(--line-strong); border-radius: 999px; padding: .35rem .75rem; cursor: pointer; font: inherit; font-size: .88rem; }
.suggest button:hover { color: var(--ink); border-color: var(--ai); }
.thinking { color: var(--ink-3); font-style: italic; }

/* ------------------------------------------------------------------ auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card { width: min(420px, 100%); }
.auth-title { font-family: var(--serif); font-size: 1.65rem; margin: 1rem 0 .3rem; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-layout { grid-template-columns: 1fr; }
  .toc { position: static; display: flex; flex-wrap: wrap; gap: .2rem; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); z-index: 30; transform: translateX(-102%); transition: transform .2s ease; background: var(--panel); }
  body.rail-open .rail { transform: none; }
  .topbar { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; background: rgba(9, 52, 66, .85); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .main { padding: 1.1rem 1rem 2.5rem; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .chat-layout { grid-template-columns: 1fr; }
  h1 { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  body { background: #fff; color: #000; }
  .rail, .topbar, .actions, .toc { display: none !important; }
  .shell { display: block; }
  .panel { border-color: #ccc; background: #fff; color: #000; }
}

/* ------------------------------------------------------------------ svg charts */
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: rgba(255, 255, 255, .09); }
svg.chart .zero { stroke: rgba(255, 255, 255, .45); }
svg.chart .axis { fill: var(--ink-3); font-size: 11px; font-family: var(--sans); }
svg.chart .legend { fill: var(--ink-2); font-size: 12px; font-family: var(--sans); }
svg.chart .s1 { fill: var(--reported); } svg.chart .s2 { fill: var(--ai); } svg.chart .s3 { fill: var(--auditor); }
svg.chart path.line { fill: none; stroke-width: 2.5; }
svg.chart path.s1 { stroke: var(--reported); } svg.chart path.s2 { stroke: var(--ai); } svg.chart path.s3 { stroke: var(--auditor); }
svg.chart rect.negbar { opacity: .8; }
.linklike { background: none; border: 0; color: var(--ink); font: inherit; padding: 0; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.inline-form { display: inline; }
.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 1.4rem; text-align: center; background: #06222c; cursor: pointer; }
.dropzone.drag { border-color: var(--ai); background: #082a35; }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-list { margin: .6rem 0 0; padding: 0; list-style: none; font-size: .9rem; color: var(--ink-2); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; font-size: .93rem; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; }
.matrix th.rot { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; max-height: 160px; font-weight: 500; }
.matrix td { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); }
pre.code { background: #06222c; padding: .8rem; border-radius: var(--radius-sm); overflow-x: auto; font-size: .82rem; }
textarea.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .82rem; min-height: 360px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.indicator .why p { margin: 0 0 .35rem; }
.indicator .why p:last-child { margin: 0; }
