/* aimoney-site: a research log, not a dashboard.
   One accent, system sans, tabular figures, hairline rules, 4px radii.
   Green and red appear only on signed numbers (.pos / .neg), never as chrome. */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #1d1d1b;
  --muted: #5f5e59;
  --rule: #dcd9d1;
  --rule-strong: #b9b5ab;
  --accent: #1f4f7a;
  --accent-ink: #ffffff;
  --pos: #1b6b3a;
  --neg: #a8321f;
  --banner-bg: #fff4d6;
  --banner-ink: #5a4300;
  --err-bg: #fbeeea;
  --err-ink: #7a2415;
  --s1: #1f4f7a;
  --s2: #8a5a00;
  --s3: #6a4c93;
  --s4: #3d3d3a;
  --s5: #0f6e7a;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151618;
    --surface: #1c1d20;
    --ink: #e9e7e1;
    --muted: #a3a09a;
    --rule: #34363a;
    --rule-strong: #4a4c51;
    --accent: #8db8e0;
    --accent-ink: #10202e;
    --pos: #6fcf8f;
    --neg: #f0927f;
    --banner-bg: #3a3014;
    --banner-ink: #f3dc9a;
    --err-bg: #3a1f1a;
    --err-ink: #f5b8aa;
    --s1: #8db8e0;
    --s2: #e0b05c;
    --s3: #b9a1e0;
    --s4: #c9c7c1;
    --s5: #6ec3cd;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;  /* every figure, dates and index levels included */
  overflow-x: hidden;
}

.wrap { max-width: 64rem; margin: 0 auto; padding: 0 16px; }

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 4px 8px; border-radius: 4px; }

.site-head { border-bottom: 1px solid var(--rule); background: var(--surface); }
.site-head .wrap { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 24px; padding-top: 14px; padding-bottom: 12px; }
.brand { font-weight: 650; font-size: 1.05rem; color: var(--ink); text-decoration: none; letter-spacing: 0.01em; }
.site-head nav { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.95rem; }
.site-head nav a { color: var(--muted); text-decoration: none; }
.site-head nav a:hover, .site-head nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; }

main { padding-top: 20px; padding-bottom: 40px; }

h1 { font-size: 1.7rem; line-height: 1.2; margin: 8px 0 8px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; margin: 36px 0 10px; font-weight: 650; padding-top: 10px; border-top: 1px solid var(--rule); }
h3 { font-size: 1.05rem; margin: 26px 0 8px; font-weight: 650; }
h4 { font-size: 0.95rem; margin: 18px 0 6px; font-weight: 600; color: var(--muted); }
p { margin: 0 0 12px; }
.lede { font-size: 1.05rem; max-width: 46rem; }
.muted, .small { color: var(--muted); }
.small { font-size: 0.875rem; }

.reflects { font-size: 0.875rem; color: var(--muted); margin: 0 0 12px; font-variant-numeric: tabular-nums; }

.draft-banner {
  background: var(--banner-bg); color: var(--banner-ink);
  border-bottom: 1px solid var(--rule-strong);
  font-weight: 650; letter-spacing: 0.04em; text-align: center; padding: 8px 16px;
}

.table-wrap { overflow-x: auto; margin: 8px 0 16px; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 0.925rem; }
caption { text-align: left; padding: 8px 10px 4px; color: var(--muted); font-size: 0.85rem; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
thead th { font-weight: 600; color: var(--muted); font-size: 0.82rem; white-space: nowrap; border-bottom-color: var(--rule-strong); }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.ref td, tr.ref th { color: var(--muted); font-style: italic; }
th[scope="row"] { font-weight: 600; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.nr { color: var(--muted); font-style: italic; }

.figures { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0; margin: 8px 0 12px;
  border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); }
.figures div { padding: 8px 10px; border-bottom: 1px solid var(--rule); }
.figures dt { font-size: 0.8rem; color: var(--muted); }
.figures dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }

.note { white-space: pre-line; border-left: 2px solid var(--rule-strong); padding: 2px 0 2px 12px; margin: 8px 0 14px; max-width: 46rem; }

.model-block { margin-top: 18px; }

.chart-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
@media (max-width: 760px) { .chart-grid { grid-template-columns: minmax(0, 1fr); } }
figure { margin: 8px 0 16px; }
figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
/* The chart scrolls inside its own box below ~520px instead of shrinking its 11px labels
   to an unreadable 5-6px; the page itself never scrolls sideways. */
.chart-scroll { overflow-x: auto; }
svg.chart { width: 100%; min-width: 520px; height: auto; display: block; background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; }
svg.chart .grid { stroke: var(--rule); stroke-width: 1; }
svg.chart .base { stroke: var(--rule-strong); stroke-width: 1; stroke-dasharray: 4 3; }
svg.chart .axis { fill: var(--muted); font-size: 11px; font-family: inherit; font-variant-numeric: tabular-nums; }
svg.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .lbl { font-size: 11px; font-family: inherit; font-weight: 600; }
svg.chart .s1 { stroke: var(--s1); } svg.chart .f1 { fill: var(--s1); }
svg.chart .s2 { stroke: var(--s2); } svg.chart .f2 { fill: var(--s2); }
svg.chart .s3 { stroke: var(--s3); } svg.chart .f3 { fill: var(--s3); }
svg.chart .s4 { stroke: var(--s4); } svg.chart .f4 { fill: var(--s4); }
svg.chart .s5 { stroke: var(--s5); } svg.chart .f5 { fill: var(--s5); }

ul.plain { padding-left: 18px; margin: 6px 0 12px; }
ul.plain li { margin: 3px 0; }
dl.defs dt { font-weight: 600; margin-top: 10px; }
dl.defs dd { margin: 2px 0 0 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; padding: 0 4px; overflow-wrap: anywhere; }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; font-size: 0.95rem; }

.site-foot { border-top: 1px solid var(--rule); background: var(--surface); font-size: 0.875rem; color: var(--muted); }
.site-foot .wrap { padding-top: 16px; padding-bottom: 24px; }
.standing-note { max-width: 46rem; }

/* admin */
.notice { border: 1px solid var(--rule-strong); border-radius: 4px; padding: 10px 12px; background: var(--surface); margin: 10px 0 16px; }
.notice.warn { background: var(--banner-bg); color: var(--banner-ink); }
/* Red is reserved for negative numbers, so errors use the neutral rules plus a bold "Error:"
   prefix in the markup and the accent colour on the left edge. */
.errors { background: var(--surface); color: var(--ink); border: 1px solid var(--rule-strong); border-left: 3px solid var(--accent); border-radius: 4px; padding: 10px 12px; margin: 10px 0 16px; }
.errors ul { margin: 4px 0 0; padding-left: 18px; }
.field-error { color: var(--ink); font-size: 0.85rem; border-left: 3px solid var(--accent); padding: 2px 8px; margin: 4px 0 0; }
details.prev { margin: 4px 0 8px; font-size: 0.85rem; color: var(--muted); }
details.prev pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0 0; font-size: 0.8rem; }
.risk { max-width: 46rem; }
fieldset { border: 1px solid var(--rule); border-radius: 4px; margin: 14px 0; padding: 10px 14px 14px; background: var(--surface); min-width: 0; }
legend { font-weight: 650; padding: 0 6px; }
label { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 10px; }
input[type="text"], input[type="datetime-local"], textarea {
  width: 100%; max-width: 100%; font: inherit; font-size: 0.95rem; color: var(--ink); background: var(--bg);
  border: 1px solid var(--rule-strong); border-radius: 4px; padding: 6px 8px;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; min-height: 5.5rem; }
.row { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0 14px; }
button, .button {
  font: inherit; font-size: 0.95rem; border-radius: 4px; padding: 6px 14px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); text-decoration: none; display: inline-block;
}
button.secondary { background: transparent; color: var(--accent); }
form.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hint { font-size: 0.8rem; color: var(--muted); margin: 2px 0 0; }
