:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6e6d68;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.1);
  --bar: #2a78d6;
  --bar-hover: #3987e5;
  --bar-muted: #c3c2b7;
  --accent: #2a78d6;
  --accent-wash: rgba(42, 120, 214, 0.1);
  --critical: #d03b3b;
  --good: #0ca30c;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #a3a29c;
    --hairline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.1);
    --bar: #3987e5;
    --bar-hover: #5598e7;
    --bar-muted: #898781;
    --accent: #5598e7;
    --accent-wash: rgba(57, 135, 229, 0.18);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #a3a29c;
  --hairline: #2c2c2a;
  --border: rgba(255, 255, 255, 0.1);
  --bar: #3987e5;
  --bar-hover: #5598e7;
  --bar-muted: #898781;
  --accent: #5598e7;
  --accent-wash: rgba(57, 135, 229, 0.18);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 15px/1.5 var(--font);
  max-width: 1280px;
  margin-inline: auto;
  padding: 0 16px 48px;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Header */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 0 16px;
}

.topbar h1 {
  font-size: 1.6rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--text-2);
}

.updated {
  color: var(--muted);
  white-space: nowrap;
}

.updated:not(:empty)::before {
  content: "· ";
}

/* Controls */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 2px;
  gap: 2px;
}

.segmented button {
  border: 0;
  background: transparent;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  color: var(--text-2);
  white-space: nowrap;
}

.segmented button:hover {
  background: var(--accent-wash);
}

.segmented button[aria-pressed="true"] {
  background: var(--accent-wash);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.segmented .count {
  color: var(--muted);
  font-weight: 400;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 20px;
  padding: 12px 0 16px;
  border-top: 1px solid var(--hairline);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.filter-group.grow {
  flex: 1 1 200px;
}

.filter-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

input[type="date"],
input[type="search"],
select {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 10px;
  min-width: 0;
}

select {
  max-width: 260px;
}

input[type="search"] {
  width: 100%;
}

.icon-btn,
.text-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  height: 34px;
  min-width: 34px;
  padding: 0 10px;
  cursor: pointer;
}

.icon-btn:hover,
.text-btn:hover {
  background: var(--accent-wash);
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
  background: var(--surface);
}

/* Stat tiles */
.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2px;
}

.tile-label {
  color: var(--text-2);
  font-size: 0.85rem;
}

.tile-value {
  font-size: 1.75rem;
  font-weight: 600;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  transition: opacity 0.15s;
}

.layout.is-loading {
  opacity: 0.55;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 12px;
}

.panel h2 {
  font-size: 1rem;
  font-weight: 600;
}

.panel-sub {
  margin: 2px 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Ranked bar chart: one series, value at the bar tip, the whole row is the hit target */
.bars {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 4px;
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 6px;
  padding: 6px 6px;
  cursor: pointer;
  text-align: left;
}

.bar-row:hover {
  background: var(--accent-wash);
}

.bar-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.bar-value {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.bar-track {
  grid-column: 1 / -1;
  height: 8px;
}

.bar {
  display: block;
  height: 8px;
  min-width: 4px;
  background: var(--bar);
  border-radius: 0 4px 4px 0;
}

.bar-row:hover .bar {
  background: var(--bar-hover);
}

.bars.has-selection .bar-row:not([aria-pressed="true"]) .bar {
  background: var(--bar-muted);
}

.bar-row[aria-pressed="true"] {
  background: var(--accent-wash);
}

.bar-row[aria-pressed="true"] .bar-name {
  font-weight: 600;
}

.empty-small {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

/* Articles */
.notice {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
}

.day-heading {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-2);
  margin: 16px 0 8px;
}

.day-heading:first-child {
  margin-top: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.card-meta .source {
  color: var(--text-2);
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 8px;
  font-size: 0.75rem;
  color: var(--text-2);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}

.card-title a {
  color: var(--text);
  text-decoration: none;
}

.card-title a:hover {
  text-decoration: underline;
}

.card .summary {
  margin: 4px 0 0;
  color: var(--text-2);
}

.card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-top: 10px;
  font-size: 0.85rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  border: 1px solid var(--border);
  background: var(--page);
  border-radius: 6px;
  padding: 1px 8px;
  cursor: pointer;
  font-size: 0.82rem;
}

.tag:hover,
.tag[aria-pressed="true"] {
  background: var(--accent-wash);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.also {
  color: var(--muted);
}

.also a,
.link-btn {
  color: var(--text-2);
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.85rem;
}

.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  color: var(--text-2);
}

/* Footer */
.footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  color: var(--text-2);
  font-size: 0.85rem;
}

.footer summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.sources {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 6px 16px;
}

.sources li {
  display: flex;
  gap: 8px;
  align-items: baseline;
  min-width: 0;
}

.status-icon {
  font-weight: 700;
}

.status-ok {
  color: var(--good);
}

.status-error {
  color: var(--critical);
}

.status-wait {
  color: var(--muted);
}

.sources a {
  color: var(--text);
}

.source-detail {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fineprint {
  color: var(--muted);
  max-width: 80ch;
}

/* Tooltip */
.tooltip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  font-size: 0.85rem;
  max-width: 260px;
}

.tooltip strong {
  display: block;
  font-size: 1rem;
}

.tooltip span {
  color: var(--text-2);
}

/* Desktop: the secondary filters sit in the same row; the mobile-only toggles are hidden. */
.filter-more {
  display: contents;
}

.more-toggle,
.panel-toggle {
  display: none;
}

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

  .panel {
    position: static;
  }

  .topbar h1 {
    font-size: 1.35rem;
  }

  .updated {
    display: block;
  }

  .updated:not(:empty)::before {
    content: none;
  }

  /* iOS Safari zooms into form fields below 16px. */
  input,
  select {
    font-size: 16px;
  }

  /* The bank chart collapses so the articles follow right after the key figures. */
  .panel {
    padding: 0;
  }

  .panel-heading {
    display: none;
  }

  .panel-toggle {
    display: flex;
    align-items: baseline;
    gap: 10px;
    width: 100%;
    border: 0;
    background: none;
    padding: 12px 14px;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius);
  }

  .panel-toggle::after {
    content: "▾";
    margin-left: auto;
    color: var(--text-2);
  }

  .panel-toggle[aria-expanded="true"]::after {
    content: "▴";
  }

  .panel-toggle-title {
    font-weight: 600;
    flex: none;
  }

  .panel-peek {
    color: var(--muted);
    font-size: 0.85rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .panel-body {
    display: none;
    padding: 0 14px 12px;
  }

  .panel.open .panel-body {
    display: block;
  }

  /* Touch targets of at least 24px (WCAG 2.2, 2.5.8). */
  .tag {
    padding: 3px 10px;
  }

  .link-btn {
    padding: 4px 0;
  }
}

/* Phones: compact controls so the first articles are visible without scrolling. */
@media (max-width: 640px) {
  .topbar {
    padding: 14px 0 8px;
    align-items: center;
  }

  .subtitle [data-i18n="subtitle"] {
    display: none;
  }

  .subtitle {
    margin-top: 0;
  }

  .filters {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 0 12px;
  }

  .filter-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  #range {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #range button,
  #langs button {
    padding: 7px 8px;
  }

  .date-nav input[type="date"] {
    flex: 1 1 auto;
  }

  select {
    max-width: none;
    width: 100%;
  }

  .more-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    color: var(--text-2);
  }

  .more-toggle::after {
    content: "▾";
  }

  .more-toggle[aria-expanded="true"]::after {
    content: "▴";
  }

  .filter-more {
    display: none;
  }

  .filters.show-more .filter-more {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  #langs {
    flex-wrap: wrap;
  }

  .kpis {
    gap: 8px;
    margin-bottom: 12px;
  }

  .tile {
    padding: 8px 10px;
  }

  .tile-value {
    font-size: 1.3rem;
  }

  .tile-label {
    font-size: 0.72rem;
  }

  .topbar h1 {
    font-size: 1.2rem;
  }

  .card {
    padding: 12px 14px;
  }

  .card-title {
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .layout {
    transition: none;
  }
}
