:root {
  color-scheme: light;
  --bg: #f3f5f2;
  --surface: #fff;
  --surface-2: #eef2ef;
  --ink: #17201e;
  --muted: #65706d;
  --line: #d8dfdb;
  --line-strong: #bec9c4;
  --accent: #096b57;
  --good: #167149;
  --warn: #9a650b;
  --bad: #a23b35;
  --radius: 6px;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --sans: "IBM Plex Sans", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.42 var(--sans); letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
:focus-visible { outline: 3px solid rgba(9, 107, 87, .28); outline-offset: 2px; }
.shell { width: min(1480px, 100%); margin: 0 auto; padding-inline: 24px; }

.topbar { position: sticky; top: 0; z-index: 30; background: rgba(243, 245, 242, .97); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.topbar__inner { min-height: 56px; display: flex; align-items: center; gap: 22px; }
.brand { display: flex; align-items: baseline; gap: 9px; min-width: 198px; text-decoration: none; }
.brand strong { font-size: 19px; }
.brand span { color: var(--muted); font: 11px/1 var(--mono); }
.nav { display: flex; gap: 3px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-label--compact { display: none; }
.nav a { display: inline-flex; align-items: center; min-height: 40px; padding: 7px 9px; color: var(--muted); text-decoration: none; border-radius: 4px; }
.nav a:hover, .nav a.is-active { color: var(--ink); background: var(--surface-2); }
.service-state { margin-left: auto; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(154, 101, 11, .12); }
.dot[data-state="ok"] { background: var(--good); box-shadow: 0 0 0 3px rgba(22, 113, 73, .12); }
.dot[data-state="warning"] { background: var(--warn); box-shadow: 0 0 0 3px rgba(154, 101, 11, .12); }
.dot[data-state="error"] { background: var(--bad); box-shadow: 0 0 0 3px rgba(162, 59, 53, .12); }

main { padding-block: 18px 42px; }
.page-head { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
.page-head__copy { min-width: 0; }
.eyebrow { margin: 0 0 3px; color: var(--accent); font: 600 11px/1.2 var(--mono); text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 3px; font-size: 28px; line-height: 1.08; }
.page-head p, .section-intro p { max-width: 78ch; margin-bottom: 0; color: var(--muted); overflow-wrap: anywhere; }
.button, .tab, input, select { min-height: 36px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.button:hover { border-color: var(--line-strong); background: #fafcfb; }
.button:disabled { opacity: .5; cursor: default; }
.button--refresh > span:first-child { font: 17px/1 var(--sans); }
.notice { padding: 9px 12px; margin-bottom: 12px; border: 1px solid; border-radius: var(--radius); }
.notice--error { color: var(--bad); background: #fff7f6; border-color: #eed3d0; }
.notice--warning { color: #6d4807; background: #fff9eb; border-color: #ead8ae; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.metric { min-width: 0; padding: 9px 14px 10px; }
.metric + .metric { border-left: 1px solid var(--line); }
.metric span, .metric small { display: block; color: var(--muted); font-size: 10px; }
.metric strong { display: block; margin: 2px 0 1px; font: 600 19px/1.12 var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.tabs { position: sticky; top: 56px; z-index: 20; display: flex; gap: 3px; margin: 0 0 10px; padding-top: 2px; background: var(--bg); border-bottom: 1px solid var(--line); scroll-margin-top: 56px; }
.tab { min-height: 37px; padding: 6px 11px; border-color: transparent; border-bottom: 2px solid transparent; border-radius: 4px 4px 0 0; background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); background: var(--surface-2); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel[hidden] { display: none; }

.surface { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.surface__head { min-height: 52px; padding: 9px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.surface__head h2 { margin: 0; font-size: 15px; }
.surface__head p { margin: 1px 0 0; color: var(--muted); font-size: 11px; }
.as-of { flex: 0 0 auto; color: var(--muted); font: 10px/1.3 var(--mono); font-variant-numeric: tabular-nums; }

.rate-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.rate { min-width: 0; padding: 10px 12px; }
.rate + .rate { border-left: 1px solid var(--line); }
.rate span, .rate small { display: block; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rate strong { display: block; margin: 2px 0; font: 600 17px/1.2 var(--mono); font-variant-numeric: tabular-nums; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); gap: 10px; margin-top: 10px; }
.market-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.indicator-list { display: grid; }
.indicator-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 7px 12px; align-items: center; }
.indicator-row + .indicator-row { border-top: 1px solid var(--line); }
.indicator-row span, .indicator-row small { display: block; }
.indicator-row span { font-size: 12px; }
.indicator-row small { color: var(--muted); font-size: 9px; }
.indicator-row strong { font: 600 12px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

.table-wrap { overflow-x: auto; overscroll-behavior-inline: contain; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { position: relative; background: #f8faf8; color: var(--muted); font-size: 9px; font-weight: 600; white-space: nowrap; }
td { font-size: 11px; }
td.numeric, th.numeric { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfb; }
.muted { color: var(--muted); }
.loading-line { height: 12px; margin: 9px; border-radius: 3px; background: var(--surface-2); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .48; } }
.empty { padding: 16px; color: var(--muted); }

.section-intro { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 8px; }
.section-intro h2 { margin-bottom: 1px; font-size: 17px; }
.filter-bar { display: grid; grid-template-columns: minmax(240px, 1fr) auto auto auto; align-items: end; gap: 10px; margin-bottom: 10px; padding: 9px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.search-control, .limit-control { display: grid; gap: 3px; color: var(--muted); font-size: 10px; }
.search-control input { width: 100%; padding: 6px 9px; }
.limit-control select { min-width: 72px; max-width: 220px; padding: 5px 8px; }
.filter-result { align-self: center; min-width: 130px; color: var(--muted); font: 10px var(--mono); text-align: right; white-space: nowrap; }
.table-groups { display: grid; gap: 14px; }
.table-group h2 { margin: 0 0 6px; font-size: 15px; }
.table-group__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.data-card { overflow: hidden; }
.data-card__head { min-height: 44px; padding: 7px 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
.data-card__head h3 { margin: 0; font-size: 13px; }
.data-card__head p { margin: 1px 0 0; color: var(--muted); font-size: 9px; }
.data-card__head span { color: var(--muted); font: 9px var(--mono); white-space: nowrap; }

.news-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.news-grid[data-language]:not([data-language="all"]) { grid-template-columns: 1fr; }
.news-grid[data-language]:not([data-language="all"]) .news-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.news-grid[data-language]:not([data-language="all"]) .news-column > header { grid-column: 1 / -1; }
.news-grid[data-language]:not([data-language="all"]) .news-item:nth-of-type(even) { border-left: 1px solid var(--line); }
.news-column { overflow: hidden; }
.news-column > header { min-height: 42px; padding: 8px 11px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.news-column > header strong { font: 600 11px var(--mono); }
.news-column > header span { color: var(--muted); font-size: 10px; }
.news-item { padding: 10px 11px; }
.news-item + .news-item { border-top: 1px solid var(--line); }
.news-item time { color: var(--muted); font: 9px var(--mono); }
.news-item h3 { margin: 3px 0; font-size: 12px; line-height: 1.35; }
.news-item p { display: -webkit-box; margin: 0; color: var(--muted); font-size: 10px; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.news-item a { text-underline-offset: 2px; }

.terminal-toolbar { min-height: 42px; margin-bottom: 10px; padding: 2px 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.segmented { display: inline-flex; align-items: center; padding: 2px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-2); }
.segmented button { min-height: 30px; padding: 4px 9px; border: 0; border-radius: 3px; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; white-space: nowrap; }
.segmented button:hover { color: var(--ink); }
.segmented button.is-active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 2px rgba(23, 32, 30, .12); font-weight: 600; }
.segmented--small button { min-height: 26px; padding: 3px 7px; font-size: 9px; }
.segmented--languages { flex: 0 0 auto; }
.terminal-depth { display: flex; align-items: center; gap: 10px; color: var(--muted); font: 9px var(--mono); white-space: nowrap; }
.terminal-depth span + span { padding-left: 10px; border-left: 1px solid var(--line); }
.terminal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.chart-card { position: relative; min-height: 316px; overflow: hidden; }
.chart-card--wide { grid-column: span 1; }
.chart-card__head { min-height: 52px; padding: 8px 11px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
.chart-card__head h2 { margin: 0; font-size: 13px; }
.chart-card__head p { margin: 1px 0 0; color: var(--muted); font-size: 10px; }
.chart-card__actions { display: flex; align-items: center; gap: 7px; }
.chart { width: 100%; height: 262px; }
.chart--large { height: 278px; }
.chart-state { position: absolute; inset: 53px 0 0; display: grid; place-items: center; padding: 16px; background: rgba(255, 255, 255, .9); color: var(--muted); font-size: 11px; text-align: center; z-index: 2; }
.chart-state[hidden] { display: none; }
.market-pulse { min-height: 316px; overflow: hidden; }
.movers { display: grid; }
.mover { position: relative; min-height: 43px; padding: 6px 11px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; overflow: hidden; }
.mover + .mover { border-top: 1px solid var(--line); }
.mover::before { position: absolute; inset: 0 auto 0 0; width: var(--mover-width); max-width: 100%; background: rgba(22, 113, 73, .06); content: ""; }
.mover.is-negative::before { background: rgba(162, 59, 53, .06); }
.mover__identity, .mover__value { position: relative; z-index: 1; }
.mover__identity strong, .mover__identity small { display: block; }
.mover__identity strong { font: 600 11px var(--mono); }
.mover__identity small { max-width: 38ch; color: var(--muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mover__value { text-align: right; }
.mover__value strong, .mover__value small { display: block; font-family: var(--mono); }
.mover__value strong { color: var(--good); font-size: 11px; }
.mover.is-negative .mover__value strong { color: var(--bad); }
.mover__value small { color: var(--muted); font-size: 8px; }
.chart-card canvas, .chart-card svg { outline: 0; }
.diagnostics-card { margin-top: 10px; overflow: hidden; }

.quality-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.quality-metrics > div { min-width: 0; padding: 9px 12px; }
.quality-metrics > div + div { border-left: 1px solid var(--line); }
.quality-metrics span, .quality-metrics strong { display: block; }
.quality-metrics span { color: var(--muted); font-size: 9px; }
.quality-metrics strong { margin-top: 2px; font: 600 16px var(--mono); font-variant-numeric: tabular-nums; }
.quality-source-card { overflow: hidden; }
.quality-status { display: inline-flex; align-items: center; min-height: 20px; padding: 2px 6px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.quality-status[data-state="healthy"], .quality-status[data-quality="verified"] { color: var(--good); background: #f2faf6; border-color: #c8e0d3; }
.quality-status[data-state="warning"], .quality-status[data-quality="warning"] { color: var(--warn); background: #fff9eb; border-color: #ead8ae; }
.quality-status[data-state="critical"], .quality-status[data-quality="rejected"] { color: var(--bad); background: #fff7f6; border-color: #eed3d0; }
.freshness-status { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.freshness-status::before { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); content: ""; }
.freshness-status[data-freshness="fresh"]::before { background: var(--good); }
.freshness-status[data-freshness="aging"]::before { background: var(--warn); }
.freshness-status[data-freshness="stale"]::before { background: var(--bad); }
.methods-panel { margin-top: 10px; overflow: hidden; }
.method-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.method-card { min-width: 0; padding: 10px 12px; }
.method-card + .method-card { border-left: 1px solid var(--line); }
.method-card h3 { margin-bottom: 3px; color: var(--muted); font-size: 10px; font-weight: 500; }
.method-card strong { display: block; margin-bottom: 3px; font: 600 12px var(--mono); }
.method-card p { margin: 0; color: var(--muted); font-size: 10px; }
.reference-card { margin-top: 10px; overflow: hidden; }
.reference-links { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.reference-links a { min-width: 0; padding: 9px 11px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-decoration: none; }
.reference-links a:nth-child(4n) { border-right: 0; }
.reference-links a:nth-last-child(-n + 4) { border-bottom: 0; }
.reference-links a:hover { background: var(--surface-2); }
.reference-links strong, .reference-links span { display: block; }
.reference-links strong { font-size: 11px; }
.reference-links span { margin-top: 1px; color: var(--muted); font-size: 9px; }

.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; }
.footer { border-top: 1px solid var(--line); padding: 15px 0 24px; color: var(--muted); font-size: 11px; }
.footer__inner { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.footer a { text-decoration-color: var(--line-strong); text-underline-offset: 3px; }

@media (max-width: 1100px) {
  .rate-grid { grid-template-columns: repeat(3, 1fr); }
  .rate:nth-child(4) { border-left: 0; border-top: 1px solid var(--line); }
  .rate:nth-child(5), .rate:nth-child(6) { border-top: 1px solid var(--line); }
  .market-grid { grid-template-columns: 1fr; }
  .method-grid, .reference-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .method-card:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .method-card:nth-child(4) { border-top: 1px solid var(--line); }
  .reference-links a:nth-child(4n) { border-right: 1px solid var(--line); }
  .reference-links a:nth-child(2n) { border-right: 0; }
  .reference-links a:nth-last-child(-n + 4) { border-bottom: 1px solid var(--line); }
  .reference-links a:nth-last-child(-n + 2) { border-bottom: 0; }
}

@media (max-width: 900px) {
  .terminal-grid { grid-template-columns: 1fr; }
  .overview-grid, .table-group__grid { grid-template-columns: 1fr; }
  .news-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .shell { padding-inline: 14px; }
  .topbar__inner { min-height: 52px; gap: 7px; }
  .brand { min-width: 0; }
  .brand strong { font-size: 17px; }
  .brand span, .service-state span { display: none; }
  .button, input, select { min-height: 44px; }
  .nav { order: 2; flex: 1 1 auto; }
  .nav a { min-width: 44px; min-height: 44px; padding: 6px; font-size: 10px; }
  .service-state { order: 3; flex: 0 0 auto; margin-left: 3px; }
  main { padding-block: 12px 32px; }
  .page-head { min-height: 54px; gap: 10px; margin-bottom: 8px; }
  h1 { font-size: 23px; }
  .page-head p { display: -webkit-box; font-size: 11px; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .button--refresh { width: 44px; min-width: 44px; min-height: 44px; padding: 0; }
  .button--refresh > span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .metrics, .quality-metrics { display: flex; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
  .metrics::-webkit-scrollbar, .quality-metrics::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
  .metric { flex: 0 0 126px; padding: 8px 10px; scroll-snap-align: start; }
  .metric + .metric { border-left: 1px solid var(--line); }
  .metric strong { font-size: 17px; }
  .tabs { top: 52px; margin-inline: -14px; padding-inline: 14px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tab { flex: 0 0 auto; min-width: 44px; min-height: 44px; padding-inline: 12px; white-space: nowrap; }
  .section-intro { align-items: flex-start; }
  .section-intro > .segmented { align-self: flex-end; }
  .filter-bar { grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
  .search-control { grid-column: 1 / -1; }
  .filter-result { grid-column: 1 / -1; min-width: 0; text-align: left; }
  .terminal-toolbar { align-items: flex-start; flex-direction: column; }
  .segmented { max-width: 100%; overflow-x: auto; }
  .segmented button { flex: 1 0 auto; min-width: 44px; min-height: 44px; }
  .segmented--small button { min-width: 44px; min-height: 44px; }
  .terminal-depth { width: 100%; justify-content: space-between; gap: 5px; }
  .terminal-depth span + span { padding-left: 5px; }
  .chart-card, .market-pulse { min-height: 298px; }
  .chart, .chart--large { height: 244px; }
  .chart-card__head { min-height: 54px; align-items: flex-start; }
  .chart-card__head .segmented { width: auto; flex: 0 0 auto; }
  .chart-card__actions { align-items: flex-end; flex-direction: column; }
  .chart-state { inset-block-start: 55px; }
  .mover { min-height: 44px; }
  .quality-metrics > div { flex: 0 0 132px; padding: 8px 10px; scroll-snap-align: start; }
  .quality-metrics > div + div { border-left: 1px solid var(--line); }
  .method-grid, .reference-links { grid-template-columns: 1fr; }
  .method-card + .method-card, .method-card:nth-child(3), .method-card:nth-child(4) { border-left: 0; border-top: 1px solid var(--line); }
  .reference-links a, .reference-links a:nth-child(4n), .reference-links a:nth-child(2n), .reference-links a:nth-last-child(-n + 4) { border-right: 0; border-bottom: 1px solid var(--line); }
  .reference-links a:last-child { border-bottom: 0; }
  .news-grid[data-language]:not([data-language="all"]) .news-column { grid-template-columns: 1fr; }
  .news-grid[data-language]:not([data-language="all"]) .news-item:nth-of-type(even) { border-left: 0; }
  .diagnostics-card .surface__head { align-items: flex-start; flex-direction: column; }
  .table-wrap th:first-child, .table-wrap td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
  .table-wrap th:first-child { z-index: 2; background: #f8faf8; }
}

@media (max-width: 430px) {
  .nav-label--full { display: none; }
  .nav-label--compact { display: inline; }
  .page-head p { max-width: 31ch; }
  .section-intro { min-height: 0; flex-direction: column; }
  .section-intro > .segmented { align-self: stretch; }
  .rate-grid { grid-template-columns: repeat(2, 1fr); }
  .rate:nth-child(3), .rate:nth-child(5) { border-left: 0; }
  .rate:nth-child(3) { border-top: 1px solid var(--line); }
}

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