/* The page around the grid. The grid brings its own stylesheet. */

:root {
  --ink: #101828;
  --ink-soft: #475467;
  --line: #e4e7ec;
  --page: #f7f8fa;
  --panel: #ffffff;
  --accent: #123a6b;
  --live: #1b8a3f;
  --alarm: #b42318;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/*
 * The page scrolls; it is not pinned to the viewport.
 *
 * This began as the earthquake edition's layout, where every tab holds a grid
 * and a grid scrolls inside itself — so locking the page to 100% of the
 * viewport and letting the tab host clip was right there. It is wrong here:
 * the Statistics tab is a tall stack of cards, not a grid, and under the old
 * rules it was cut off at the bottom of the window with no way to scroll to
 * the rest of it. `min-height` rather than `height`, and nothing clips.
 */
#app {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100%;
  padding: 16px 20px 12px;
}

/* The masthead */

.head {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
}

.head h1 {
  color: var(--accent);
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 0 3px;
}

.lede {
  color: var(--ink-soft);
  margin: 0;
  max-width: 88ch;
}

.head-note {
  align-items: center;
  color: var(--ink-soft);
  display: flex;
  font-size: 12px;
  gap: 10px;
}

.pill {
  align-items: center;
  background: var(--accent);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 11px;
  font-weight: 600;
  gap: 6px;
  letter-spacing: 0.02em;
  padding: 4px 10px;
  text-transform: uppercase;
}

/* The pulse that shows a poll landed. */
.dot {
  background: #9fe0b4;
  border-radius: 50%;
  height: 7px;
  transition: background 0.2s ease, transform 0.2s ease;
  width: 7px;
}

.dot.beat {
  background: #ffffff;
  transform: scale(1.5);
}

.freshness {
  white-space: nowrap;
}

.freshness.failed {
  color: var(--alarm);
  font-weight: 600;
}

/* The tiles */

.kpi-strip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 5fr) minmax(240px, 2fr);
  padding: 9px 11px;
}

.kpi-panel {
  min-width: 0;
}

/* A tile for a reading that is words rather than a number. */
.kpi-named {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 8px 12px;
}

.kpi-named-value {
  font-size: 18px;
  font-weight: 650;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi-named-label {
  color: var(--ink-soft);
  font-size: 12px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Charts */

.chart-wrap {
  display: grid;
  flex: 0 0 auto;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  height: 210px;
}

.chart-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  padding: 4px;
}

.chart-error {
  color: var(--alarm);
  font-size: 12px;
  padding: 10px;
}

/* The controls */

.actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.actions[hidden] {
  display: none;
}

.actions-label {
  color: var(--ink-soft);
  font-size: 12px;
  margin-right: 2px;
}

.actions-gap {
  width: 14px;
}

.action {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 4px 11px;
}

.action:hover {
  background: #eef2f7;
  border-color: #c7d2e0;
}

.action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.action.toggle.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Tabs and panes */

/*
 * The tab host sizes to whatever the active panel holds.
 *
 * The tabs module does not size or clip its panels — it ships no CSS for them
 * at all — so the clipping was entirely this file's: `flex: 1` with
 * `overflow: hidden`, which suits a grid that scrolls internally and cuts the
 * Statistics panel in half.
 *
 * `height: 420` in the Rates tab's grid config does NOT size its host —
 * `GridConfig` has no top-level `height` field (checked against
 * `lattice-grid.d.ts`), so that number is inert and always was. The grid
 * fills whatever height its host element resolves to via ordinary CSS, the
 * same as any other block content, so on a plain `display: flex; flex-direction:
 * column` panel with no `flex`/`height` of its own it collapses to the few
 * rows its content naturally reaches (the "5 rows painted" symptom).
 *
 * So the Rates panel gets an explicit height here, capped so a short window
 * still leaves room for the tab strip and the page's header above it — and
 * ONLY the Rates panel: the Statistics tab is a stack of cards, not a grid,
 * and must stay free to grow to its content and page-scroll (that is what
 * `125b49c1` fixed; giving `.tabs-host` or every `[role='tabpanel']` a height
 * again would clip it a second time).
 */
.tabs-host {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  padding: 10px 12px 12px;
}

.tabs-host [role='tabpanel'] {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tabs-host [role='tabpanel'][data-tab-id='rates'] {
  height: min(560px, calc(100vh - 220px));
  min-height: 0;
}

.tabs-host [role='tabpanel'][data-tab-id='rates'] > * {
  flex: 1;
  min-height: 0;
}

/* Waiting and failure */

.loading {
  margin: auto;
  max-width: 480px;
  text-align: center;
}

.loading h1 {
  color: var(--accent);
  font-size: 20px;
  margin: 0 0 8px;
}

.loading-message {
  color: var(--ink-soft);
  margin: 0 0 14px;
}

.loading-bar {
  background: var(--line);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}

.loading-fill {
  background: var(--accent);
  height: 100%;
  transition: width 0.2s ease;
  width: 0;
}

/* The credit line */

.foot {
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
  padding-top: 10px;
}

.foot p {
  margin: 0 0 2px;
}

.foot a {
  color: var(--accent);
}

/* Said when the saved copy is standing in for data that could not be fetched. */
.notice {
  background: #fdf3e3;
  border: 1px solid #f0d9a8;
  border-radius: 7px;
  color: #6b4d12;
  margin: 8px 0 0;
  padding: 6px 10px;
}

/* ------------------------------------------------------------------ */
/* The statistics tab                                                  */
/* ------------------------------------------------------------------ */

.stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.stats-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stats-basis {
  color: var(--ink-soft);
  font-size: 12px;
  margin-left: auto;
}

/* The verdicts: the point of the page, so they sit above the plots. */

.verdict {
  background: #f4f7fb;
  border: 1px solid #d7e1ee;
  border-radius: 10px;
  padding: 12px 16px;
}

.verdict h2 {
  color: var(--accent);
  font-size: 15px;
  font-weight: 650;
  margin: 0 0 8px;
}

.verdict-list {
  columns: 2;
  column-gap: 28px;
  margin: 0;
  padding-left: 20px;
}

.verdict-list li {
  break-inside: avoid;
  margin-bottom: 8px;
  max-width: 88ch;
}

@media (max-width: 1100px) {
  .verdict-list {
    columns: 1;
  }
}

.verdict-text {
  display: block;
}

.verdict-source {
  color: var(--ink-soft);
  display: block;
  font-size: 11px;
  margin-top: 2px;
  word-break: break-word;
}

/* The five analyses */

.stats-board {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
}

.stats-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 12px 14px 14px;
}

.stats-card h3 {
  color: var(--accent);
  font-size: 14px;
  font-weight: 650;
  margin: 0;
}

.stats-lede {
  color: var(--ink-soft);
  font-size: 12px;
  margin: 0;
}

.stats-plots {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  min-width: 0;
}

.stats-plot {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 220px;
  min-width: 0;
  overflow: hidden;
  padding: 3px;
}

.stats-figures {
  display: grid;
  gap: 2px 12px;
  grid-template-columns: minmax(140px, auto) 1fr;
  margin: 0;
  font-size: 12px;
}

.stats-figures dt {
  color: var(--ink-soft);
}

.stats-figures dd {
  margin: 0;
}

.stats-source {
  color: #7b8794;
  font-size: 11px;
}

.stats-note {
  color: var(--ink-soft);
  font-size: 12px;
  margin: 0;
}

@media (max-width: 900px) {
  .stats-board {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The overview charts step aside for the statistics tab, which has its own. */
.chart-wrap[hidden] {
  display: none;
}

/* ------------------------------------------------------------------ */
/* The currency edition's own additions                                */
/* ------------------------------------------------------------------ */

.head-lede {
  margin: 0.35rem 0 0.6rem;
  max-width: 62rem;
  color: #4a5568;
  font-size: 0.95rem;
  line-height: 1.5;
}

.stats-list {
  margin: 0.6rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #2d3748;
}

.stats-list li {
  margin-bottom: 0.35rem;
}

.anomaly-note {
  color: #4a5568;
}

.anomaly-unknown {
  color: #8a94a6;
  font-style: italic;
}

.chart-note {
  margin: 0.4rem 0 0.9rem;
  color: #8a94a6;
  font-size: 0.8rem;
  line-height: 1.5;
  max-width: 70rem;
}
