:root {
  --bg: #f8f9fa;
  --panel: #ffffff;
  --text: #202124;
  --muted: #5f6368;
  --line: #e3e5e8;
  --accent: #1a73e8;
  --accent-soft: #e8f0fe;
  --good: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --radius: 12px;
  --side: max(1.25rem, calc((100% - 1240px) / 2));
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html { font-size: clamp(15px, 0.8rem + 0.3vw, 18px); }
body { margin: 0; background: var(--bg); line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; padding: 1.8rem var(--side) 3rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.7rem; margin: 0 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
h3 { font-size: .95rem; margin: 1.2rem 0 .3rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }

/* header */
.top { display: flex; align-items: center; gap: 1.5rem; padding: .8rem var(--side); background: var(--panel);
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand svg { width: 1.6rem; height: 1.6rem; fill: none; stroke: var(--accent); stroke-width: 2.5;
  stroke-linecap: round; stroke-linejoin: round; }
.top nav { display: flex; gap: .2rem; flex: 1; flex-wrap: wrap; }
.top nav a { padding: .45rem .8rem; border-radius: 8px; color: var(--muted); }
.top nav a:hover { background: var(--bg); text-decoration: none; }
.top nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.updated { font-size: .8rem; color: var(--muted); }

/* page head */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.page-head p { margin: 0; }
.tabs { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .2rem; flex-wrap: wrap; }
.tabs a { padding: .4rem .8rem; border-radius: 8px; color: var(--muted); font-size: .9rem; white-space: nowrap; }
.tabs a:hover { text-decoration: none; background: var(--bg); }
.tabs a.on { background: var(--accent); color: #fff; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.kpi { background: var(--panel); padding: .75rem 1.1rem .8rem; }
.kpi span { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.kpi b { display: block; font-size: 1.5rem; font-weight: 700; line-height: 1.25; margin-top: .1rem; letter-spacing: -.01em; }
.kpi b.date { font-size: 1.15rem; line-height: 1.6; }
.kpi small { display: block; color: var(--muted); font-size: .75rem; }

/* cards and grid */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-top: 1rem; }
.grid .card { margin-top: 0; }
.card.wide { grid-column: 1 / -1; }
.card { min-width: 0; overflow-x: auto; }
.card p.small { margin: -.3rem 0 .6rem; }
canvas { max-width: 100%; }
.top-chart { position: relative; height: 22rem; }

/* "View SQL" */
details.sql { margin-top: .6rem; }
details.sql summary { cursor: pointer; color: var(--accent); font-size: .82rem; width: max-content; }
details.sql pre { background: #202124; color: #e8eaed; border-radius: 8px; padding: .8rem 1rem; overflow-x: auto;
  font-size: .78rem; line-height: 1.45; margin: .4rem 0 0; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table-wrap table { background: var(--panel); }
main > .table-wrap { border: 1px solid var(--line); border-radius: var(--radius); }
.pill { display: inline-block; background: var(--accent-soft); color: var(--accent); border-radius: 99px;
  padding: .05rem .55rem; font-weight: 600; font-size: .8rem; }
.live { color: var(--good); font-weight: 600; font-size: .85rem; }
.good { color: var(--good); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }

/* filters */
.filters { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .8rem; }
.filters input[type=search], .filters select { font: inherit; padding: .45rem .7rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel); }
.filters input[type=search] { min-width: 15rem; }
.check { display: flex; gap: .35rem; align-items: center; font-size: .9rem; }
.spacer { flex: 1; }
.btn { font: inherit; font-size: .9rem; padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer; }
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn.ghost { background: var(--panel); color: var(--accent); }
.pager { display: flex; gap: .8rem; align-items: center; margin: 1rem 0; }

/* topic page */
.terms { display: flex; flex-wrap: wrap; gap: .4rem; }
.term { background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: .15rem .65rem; font-size: .85rem; }

/* about page */
.flow { display: flex; align-items: stretch; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
.step { flex: 1; min-width: 180px; background: var(--accent-soft); border-radius: 10px; padding: .8rem; font-size: .88rem; }
.step b { display: block; color: var(--accent); margin-bottom: .2rem; }
.arrow { align-self: center; color: var(--muted); font-size: 1.3rem; }
.schema { background: var(--bg); border-radius: 8px; padding: .8rem; font-size: .85rem; }
table.dict td:first-child { white-space: nowrap; width: 1%; }

footer { padding: 1.2rem var(--side) 1.6rem; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); }

@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .top { gap: .6rem 1rem; }
  .top nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; margin: 0 -.4rem; }
  .top nav a { white-space: nowrap; }
  .updated { margin-left: auto; }
  .arrow { display: none; }
  .filters input[type=search] { min-width: 0; flex: 1; }
}

/* news front page */
.news-bar { display: flex; justify-content: space-between; align-items: center; gap: .8rem 1.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.day-nav, .on-this-day { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.date-form input { font: inherit; font-size: .9rem; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); }
.chip { display: inline-block; padding: .3rem .75rem; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); font-size: .85rem; }
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip.off { color: var(--muted); opacity: .6; cursor: default; }
.news-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.news-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem 1.1rem; min-width: 0; }
.news-card header { display: flex; justify-content: space-between; gap: 1rem; }
.news-card h2 { font-size: 1.1rem; margin: 0; text-transform: capitalize; }
.news-card h2 a { color: var(--text); }
.news-card .meta { margin: .3rem 0 0; color: var(--muted); font-size: .82rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.trend-pic { width: 88px; height: 88px; object-fit: cover; border-radius: 8px; flex: none; }
.stories { list-style: none; margin: .8rem 0 .7rem; padding: 0; }
.stories li { display: flex; gap: .7rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.stories li > div { min-width: 0; }
.story-pic { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; flex: none; }
.source { display: flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--muted); margin-bottom: .15rem; }
.source img { border-radius: 3px; }
.headline { display: block; color: var(--text); font-weight: 600; font-size: .93rem; line-height: 1.35; }
.headline:hover { color: var(--accent); }
.snippet { margin: .2rem 0 0; color: var(--muted); font-size: .84rem; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 760px) {
  .news-grid { grid-template-columns: 1fr; }
  .news-bar { flex-direction: column; align-items: flex-start; }
}

/* Post on X (opens X with a ready-made post) */
.xshare { display: inline-block; margin-top: .45rem; font-size: .76rem; font-weight: 600; padding: .22rem .7rem;
  border-radius: 99px; background: #0f1419; color: #fff; }
.xshare:hover { text-decoration: none; opacity: .85; }
.xshare.done { background: #eceff1; color: #6b7378; }
