:root {
  --bg: #d2d6da;
  --surface: #dde1e5;
  --surface-2: #c8cdd2;
  --text: #0f1418;
  --muted: #3f464b;
  --faint: #5e6469;
  --line: #a3aab0;
  --accent: #c0392b;
  --max: 920px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, Menlo, "Liberation Mono", monospace;
}

html { color-scheme: light; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  text-rendering: optimizeLegibility;
}

a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 44px 18px 80px;
}

/* Header */

header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 22px;
  margin-bottom: 28px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.brand-link {
  display: inline-flex;
  color: var(--text);
  border-bottom: 0;
}
.brand-link:hover { color: var(--accent); }

.brand-mark { width: 32px; height: 32px; display: block; }

.brand-row .site { margin: 0; }

.site {
  font-size: 11px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: .22em;
  font-family: var(--mono);
}

h1 {
  margin: 12px 0 0;
  font-size: clamp(24px, 3.2vw, 32px);
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1.15;
}

.subtitle {
  margin-top: 14px;
  color: var(--muted);
  max-width: 64ch;
  font-size: 14px;
  line-height: 1.55;
}

/* Nav */

nav {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
}

nav a {
  color: var(--muted);
  border-bottom: 1px solid transparent;
  padding-bottom: 3px;
}

nav a:hover { color: var(--accent); border-bottom-color: var(--accent); }
nav a.current { color: var(--text); border-bottom-color: var(--accent); }

/* Sections */

main section {
  margin-top: 30px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

main section:first-child { border-top: 0; padding-top: 0; }

h2 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--text);
}

h3 {
  margin: 20px 0 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text);
}

p {
  margin: 0 0 12px;
  color: var(--text);
}

ul, ol {
  margin: 10px 0 14px 18px;
  color: var(--text);
}

li { margin: 6px 0; }

strong { color: var(--text); font-weight: 700; }

/* Footer */

footer {
  margin-top: 40px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  color: var(--faint);
  font-size: 11px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .12em;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

footer a {
  color: var(--faint);
  border-bottom-color: transparent;
}
footer a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* Fact strip */

.facts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1px;
  background: var(--line);
  margin-top: 16px;
  border: 1px solid var(--line);
}

.fact {
  background: var(--surface);
  padding: 16px 18px;
}

.fact-label {
  font-size: 10px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: .16em;
  font-family: var(--mono);
}

.fact-value {
  font-size: 22px;
  font-weight: 700;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-family: var(--mono);
}

.fact-detail {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

/* Tables */

.table-wrap {
  margin-top: 16px;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 700;
  white-space: nowrap;
  font-family: var(--mono);
}

table.data tbody td {
  padding: 9px 12px;
  border-top: 1px solid var(--line);
  color: var(--text);
  vertical-align: top;
}

table.data tbody tr:first-child td { border-top: 0; }

table.data tbody td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-family: var(--mono);
}

table.data tbody td.nowrap {
  white-space: nowrap;
  font-family: var(--mono);
}

table.data tbody td.muted { color: var(--faint); }

table.data tbody tr.cap-bound td.num.weight { color: var(--accent); }

table.data tbody tr.cap-bound td.num.weight::after {
  content: ' \2605';
  color: var(--accent);
}

/* Sector summary */

.sector-summary {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 18px 20px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text);
}

.sector-summary dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 20px;
  margin: 0;
}

.sector-summary dt {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
}

.sector-summary dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  color: var(--muted);
}

/* Notes / callouts */

.note {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 16px 20px;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.55;
}

.note p:last-child { margin-bottom: 0; }

/* Long-form prose pages */

.prose h2 {
  margin-top: 34px;
  font-size: 14px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.prose section:first-of-type h2,
.prose > h2:first-of-type {
  margin-top: 0;
  border-top: 0;
  padding-top: 0;
}

.prose h3 {
  margin: 22px 0 8px;
  font-size: 13px;
}

.prose p, .prose li {
  color: var(--text);
  line-height: 1.6;
}

.prose .keyval {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 16px 20px;
  margin: 16px 0;
  font-size: 13px;
}

.prose .keyval dt {
  color: var(--text);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: 12px;
}

.prose .keyval dd {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
}

/* Reconstitution log entries */

.log-entry {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 18px 20px;
  margin-top: 16px;
}

.log-entry .log-date {
  font-size: 11px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-family: var(--mono);
}

.log-entry h3 {
  margin: 6px 0 10px;
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
}

.log-entry .log-counts {
  margin-top: 10px;
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

/* Contact form */

form {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 20px;
  max-width: 540px;
}

label {
  display: block;
  margin-top: 14px;
  font-size: 11px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-family: var(--mono);
}

input, textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  margin-top: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-family: var(--mono);
  font-size: 13px;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea { min-height: 140px; resize: vertical; }

button {
  margin-top: 18px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-family: var(--mono);
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

::selection {
  background: var(--accent);
  color: #ffffff;
}

/* Live index level — homepage headline strip */

.fact-value.delta-up,
.fact-detail.delta-up   { color: #3e6b34; }

.fact-value.delta-down,
.fact-detail.delta-down { color: var(--accent); }

.as-of {
  margin-top: 12px;
  font-size: 11px;
  color: var(--faint);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .12em;
}

/* Level-history chart */

.chart-card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 18px;
  margin-top: 16px;
}

.chart-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: var(--faint);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-bottom: 12px;
}

.chart-meta strong {
  color: var(--text);
  font-weight: 700;
}

#history-chart {
  width: 100%;
  height: auto;
  display: block;
}

#history-chart .axis { stroke: var(--line); stroke-width: 1; }
#history-chart .grid { stroke: var(--line); stroke-width: 1; opacity: 0.55; }
#history-chart .base-line {
  stroke: var(--accent);
  stroke-width: 1;
  stroke-dasharray: 4 3;
  opacity: 0.55;
}
#history-chart .tick {
  fill: var(--faint);
  font-size: 10px;
  font-family: var(--mono);
}
#history-chart .curve {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
#history-chart .point { fill: var(--accent); }
#history-chart .chart-empty {
  fill: var(--faint);
  font-size: 13px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .12em;
}

@media print {
  /* Screen palette is concrete blue-grey + oxide red. For paper we redefine
     the design tokens to a clean black-on-white scheme; the accent stays
     red so the note left-stripe and cap-bound ★ keep their semantic cue. */

  :root {
    --bg:        #ffffff;
    --surface:   #ffffff;
    --surface-2: #ffffff;
    --text:      #000000;
    --muted:     #1a1a1a;
    --faint:     #555555;
    --line:      #000000;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 10.5pt;
    line-height: 1.45;
    -webkit-font-smoothing: auto;
  }

  .wrap {
    max-width: none;
    padding: 0;
  }

  /* Hide chrome that's not useful on paper. */
  nav,
  form,
  input,
  textarea,
  button { display: none !important; }

  /* The cap-bound row also picked up surface tinting on screen via cascade —
     reset to transparent so the table reads as plain black-on-white. */
  table.data tbody tr.cap-bound { background: transparent !important; }

  /* Links become plain underlined black; URL is appended after external
     links so the reference is preserved on paper. */
  a {
    color: #000;
    text-decoration: none;
  }
  a[href^="http"]::after,
  a[href^="https"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #555;
    border-bottom: 0;
  }
  /* Don't double the URL on brand/footer links where the surrounding context
     already supplies it. */
  .brand-link::after,
  footer a::after { content: ""; }

  /* Force the few accent strokes we kept (note left-stripe, ★) to render. */
  *,
  *::before,
  *::after {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Page-break hints. */
  h1, h2, h3 { page-break-after: avoid; }
  section,
  .fact,
  .note,
  .log-entry,
  .sector-summary,
  .prose .keyval { page-break-inside: avoid; }
  table.data thead { display: table-header-group; }
  table.data tr { page-break-inside: avoid; }
}
