:root {
  --ink: #15202b;
  --muted: #5c6672;
  --line: #d5dbe3;
  --panel: #f3f6f8;
  --accent: #1f4e5f;
  --air: #0b6e4f;
  --metro: #6b5b95;
  --font: "IBM Plex Sans", "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: #e4eaef;
}

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

.shell { min-height: 100dvh; display: flex; flex-direction: column; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.top__brand {
  display: flex;
  flex-direction: column;
  gap: 0.02rem;
}

.top__brand a {
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
}

.top__brand strong {
  font-size: 1.05rem;
  letter-spacing: -0.03em;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tabs a {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 0.38rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink);
}

.tabs a.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.page {
  flex: 1;
  max-width: 880px;
  margin: 0 auto;
  padding: 1.25rem 1.1rem 3rem;
  width: 100%;
}

.page--wide {
  max-width: 1080px;
}

.lead h1 {
  margin: 0;
  letter-spacing: -0.03em;
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1.2;
}

.lead h1 span { color: var(--accent); }

.lead p {
  margin: 0.45rem 0 0;
  color: var(--muted);
  line-height: 1.45;
  max-width: 46rem;
}

.lead .take {
  margin: 0.7rem 0 0;
  padding: 0.85rem 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  font-size: 1.02rem;
  line-height: 1.45;
  max-width: 46rem;
}

.picks {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.7rem;
  align-items: end;
  margin: 1.2rem 0 0.9rem;
}

.picks label {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.picks select {
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  width: 100%;
}

.swap {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  width: 2.4rem;
  height: 2.4rem;
  font-size: 1.1rem;
  cursor: pointer;
  margin-bottom: 0.05rem;
}

.swap:hover { border-color: var(--ink); }

.warn {
  margin: 0 0 0.65rem;
  padding: 0.65rem 0.8rem;
  background: #fff8ee;
  border: 1px solid #ead9c4;
  border-radius: 10px;
  color: #6a4a28;
  font-size: 0.88rem;
  line-height: 1.4;
}

.units {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.rows {
  display: grid;
  gap: 0.65rem;
}

.row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem 0.95rem;
}

.row h3 {
  margin: 0;
  font-size: 0.92rem;
  letter-spacing: -0.02em;
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 0.55rem;
}

.col span {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.col strong {
  display: block;
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--accent);
  margin: 0.12rem 0 0.28rem;
}

.col strong.is-unknown {
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--muted);
}

.col em {
  display: block;
  font-style: normal;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  line-height: 1.3;
}

.bar {
  height: 8px;
  border-radius: 99px;
  background: #e2e8ee;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--air);
}

.col:last-child .bar i { background: var(--metro); }

.block-title {
  margin: 1.6rem 0 0.45rem;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.density {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.sources {
  margin-top: 2.2rem;
}

.sources h2 {
  margin: 0;
  letter-spacing: -0.03em;
}

.sources > p {
  margin: 0.35rem 0 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

.source-files {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.88rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 1rem 0 0.35rem;
}

.filters button {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 0.32rem 0.65rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.filters button.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.1rem;
  margin: 0.55rem 0 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.legend i {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 99px;
  margin-right: 0.35rem;
  vertical-align: -0.05rem;
}

.legend i.is-thin {
  background: #fff;
  border: 2px solid currentColor;
  box-sizing: border-box;
}

.plot-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.85rem 0.55rem;
  margin: 0.85rem 0;
}

.plot-card h2 {
  margin: 0 0 0.15rem;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
}

.plot-card p {
  margin: 0 0 0.55rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.plot-card svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.plot-card .dot {
  cursor: pointer;
}

.plot-card .dot:focus {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.plot-card .axis {
  stroke: var(--line);
  stroke-width: 1;
}

.plot-card .grid {
  stroke: #edf1f4;
  stroke-width: 1;
}

.plot-card .tick {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--muted);
}

.plot-card .axis-label {
  font-size: 11px;
  fill: var(--muted);
}

.plot-card .city-label {
  font-size: 10px;
  fill: var(--ink);
  pointer-events: none;
}

.tip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  box-shadow: 0 8px 24px rgba(21, 32, 43, 0.12);
  max-width: 16rem;
  font-size: 0.82rem;
  line-height: 1.35;
}

.tip[hidden] { display: none; }

.tip strong { display: block; margin-bottom: 0.15rem; }

.tip span {
  display: block;
  color: var(--muted);
}

.bars-block {
  display: grid;
  gap: 0.85rem;
  margin: 0.85rem 0 1.2rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.bar-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.bar-card h3 {
  margin: 0;
  font-size: 0.92rem;
  letter-spacing: -0.02em;
}

.bar-card p {
  margin: 0.2rem 0 0.7rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(4.5rem, 38%) 1fr 3.2rem;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.28rem;
  font-size: 0.78rem;
}

.bar-row a {
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row a:hover { text-decoration: underline; }

.bar-row .n {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-align: right;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.data-table th,
.data-table td {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f7f9fb;
  position: sticky;
  top: 0;
}

.data-table th button {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 700;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  cursor: pointer;
  padding: 0;
}

.data-table th.is-sort button { color: var(--ink); }

.data-table td.n {
  font-family: var(--mono);
  font-size: 0.8rem;
}

.data-table a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.data-table a:hover { text-decoration: underline; }

.data-table tr.is-thin td.n-shops { color: #8a5a28; }

@media (max-width: 640px) {
  .picks { grid-template-columns: 1fr; }
  .swap { width: 100%; }
  .pair { grid-template-columns: 1fr; gap: 0.7rem; }
  .top { flex-wrap: wrap; }
}
