/* Tokens. --brand is per country (config.theme). Series colours are the
   validated categorical slots 1-3 (all-pairs, both themes); the rest is "other". */
:root {
  color-scheme: light;
  --brand-light: #0e6577;
  --brand-dark: #5cb8c8;
  --brand: var(--brand-light);
  --brand-ink: #ffffff;
  --brand-tint: color-mix(in srgb, var(--brand) 9%, transparent);
  --page: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #f0f2ef;
  --border: #dfe2dd;
  --border-strong: #c9cdc6;
  --text-primary: #111312;
  --text-secondary: #4f5450;
  --text-muted: #6b706c;
  --danger: #b42318;
  --ok-bg: #e3f4e8; --ok-ink: #1d6b37;
  --warn-bg: #fdf1d3; --warn-ink: #7a4f00;
  --off-bg: #eceeeb; --off-ink: #4f5450;
  --info-bg: #e6eef8; --info-ink: #24508a;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-other: #8a8984;
  --overlay: #b4483c;
  --halo: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 20 / 0.06), 0 6px 20px rgb(16 24 20 / 0.05);
  --rail-w: 280px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand: var(--brand-dark);
    --brand-ink: #0b1a1d;
    --page: #121312;
    --surface: #1a1b1a;
    --surface-2: #222422;
    --border: #333632;
    --border-strong: #454944;
    --text-primary: #eff0ed;
    --text-secondary: #c1c4bd;
    --text-muted: #a0a49c;
    --danger: #f97066;
    --ok-bg: #173a24; --ok-ink: #8fdba6;
    --warn-bg: #3d2f00; --warn-ink: #ffd666;
    --off-bg: #2a2c29; --off-ink: #c1c4bd;
    --info-bg: #1b2d47; --info-ink: #a9c7f0;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-other: #8f8e88;
    --overlay: #e07a6e;
    --halo: #1a1b1a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: var(--brand-dark);
  --brand-ink: #0b1a1d;
  --page: #121312;
  --surface: #1a1b1a;
  --surface-2: #222422;
  --border: #333632;
  --border-strong: #454944;
  --text-primary: #eff0ed;
  --text-secondary: #c1c4bd;
  --text-muted: #a0a49c;
  --danger: #f97066;
  --ok-bg: #173a24; --ok-ink: #8fdba6;
  --warn-bg: #3d2f00; --warn-ink: #ffd666;
  --off-bg: #2a2c29; --off-ink: #c1c4bd;
  --info-bg: #1b2d47; --info-ink: #a9c7f0;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-other: #8f8e88;
  --overlay: #e07a6e;
  --halo: #1a1b1a;
}

* { box-sizing: border-box; }
/* Author display rules must not defeat the hidden attribute. */
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text-primary);
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}
.masthead { grid-row: 1; }
.banner { grid-row: 2; }
.shell { grid-row: 3; }
.footer { grid-row: 4; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Masthead + main navigation */
.masthead { background: var(--surface); border-bottom: 1px solid var(--border); }
.masthead-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px 10px; }
.brand { display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; min-width: 0; }
.emblem {
  flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; overflow: hidden;
  background: var(--brand); color: var(--brand-ink); font-weight: 700; letter-spacing: 0.04em;
}
.emblem img { width: 100%; height: 100%; object-fit: contain; background: var(--surface); }
.brand-text { display: grid; min-width: 0; }
.eyebrow { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--brand); }
.site-name { font-size: 1.45rem; font-weight: 650; letter-spacing: -0.01em; }
.authority { font-size: 0.85rem; color: var(--text-secondary); }
.masthead-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.updated { color: var(--text-muted); font-size: 0.82rem; }
.updated.is-stale { color: var(--warn-ink); background: var(--warn-bg); padding: 2px 8px; border-radius: 999px; }
.mainnav { display: flex; gap: 4px; padding: 0 16px; overflow-x: auto; min-width: 0; }
.masthead { min-width: 0; }
.mainnav a {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px 11px; border-bottom: 3px solid transparent;
  color: var(--text-secondary); text-decoration: none; font-weight: 550; white-space: nowrap;
}
.mainnav a:hover { color: var(--text-primary); }
.mainnav a.is-active { color: var(--brand); border-bottom-color: var(--brand); }

.banner { padding: 10px 24px; font-weight: 500; background: var(--warn-bg); color: var(--warn-ink); }

/* Shell: context rail + view */
.shell { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 0; }
.rail { background: var(--surface-2); border-right: 1px solid var(--border); padding: 22px 20px; overflow-y: auto; min-height: 0; }
.view { overflow-y: auto; min-height: 0; position: relative; }
.view:focus { outline: none; }
.rail-section { display: grid; gap: 16px; }
.rail-label {
  font-size: 0.72rem; font-weight: 650; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted);
  border-left: 3px solid var(--brand); padding-left: 9px;
}
.rail-hint { margin: 0; color: var(--text-secondary); font-size: 0.88rem; }
.rail-entity { display: grid; gap: 8px; justify-items: start; }
.rail-entity strong { font-size: 1.1rem; overflow-wrap: anywhere; }
.stat { display: grid; }
.stat-value { font-size: 2rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-secondary); }
.stat-sub { color: var(--text-muted); font-size: 0.82rem; }
.back { display: inline-flex; align-items: center; gap: 4px; font-weight: 550; text-decoration: none; }
.back:hover { text-decoration: underline; }

.page { padding: 24px 28px 40px; max-width: 1320px; display: grid; gap: 16px; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.page-title { font-size: 1.5rem; font-weight: 650; }
.page-sub { margin: 4px 0 0; color: var(--text-secondary); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.search-box {
  display: flex; align-items: center; gap: 8px; flex: 1 1 320px; max-width: 520px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--text-muted);
}
.search-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.search-box .search { border: 0; background: none; padding: 10px 0; box-shadow: none; }
.search-box .search:focus { outline: none; }

.title-card {
  display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--brand); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow);
}
.title-card h1 { font-size: 1.4rem; font-weight: 650; overflow-wrap: anywhere; }
.title-card .swatch { width: 14px; height: 14px; margin: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-title { font-size: 0.8rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  display: inline-flex; gap: 6px; align-items: center; padding: 9px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent;
  color: var(--text-secondary); text-decoration: none; font-weight: 550; white-space: nowrap;
}
.tab:hover { color: var(--text-primary); }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-count { font-size: 0.75rem; background: var(--surface-2); color: var(--text-secondary); border-radius: 999px; padding: 1px 7px; }

/* Key/value grid: two pairs per row on wide screens */
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.fact { display: grid; grid-template-columns: minmax(130px, 38%) 1fr; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.fact dt { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); padding-top: 2px; }
.fact dd { margin: 0; overflow-wrap: anywhere; }
.facts .fact:nth-child(odd) { padding-right: 24px; }

/* Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 550; padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-primary); cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--text-muted); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--brand); }
.btn-quiet { background: transparent; justify-self: start; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.link { color: var(--brand); font-weight: 550; text-decoration: none; }
.link:hover { text-decoration: underline; }
button.link { background: none; border: 0; padding: 0; font: inherit; font-weight: 550; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text-primary); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px; width: 100%;
}
input[type="checkbox"] { width: auto; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
.field { display: grid; gap: 4px; font-size: 0.82rem; font-weight: 550; color: var(--text-secondary); }
.icon-btn { font-size: 1.5rem; line-height: 1; background: none; border: 0; color: var(--text-secondary); cursor: pointer; padding: 2px 6px; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .table-wrap { box-shadow: none; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.data-table thead th {
  font-size: 0.74rem; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted);
  background: var(--surface); white-space: nowrap;
}
.data-table .filter-row td { padding: 0 8px 10px; }
.data-table .filter-row input, .data-table .filter-row select { padding: 5px 8px; font-size: 0.85rem; min-width: 110px; }
.data-table tbody tr[data-href] { cursor: pointer; }
.data-table tbody tr:hover { background: var(--brand-tint); }
.data-table tbody tr:last-child td, .data-table tbody tr:last-child th { border-bottom: 0; }
.data-table tbody a { font-weight: 550; text-decoration: none; }
.data-table tbody a:hover { text-decoration: underline; }
.data-table tr.empty td { color: var(--text-muted); text-align: center; padding: 28px; }
.data-table.compact th, .data-table.compact td { padding: 7px 10px; }
.data-table tbody th { font-weight: 600; }
.col-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.col-num { text-align: right !important; font-variant-numeric: tabular-nums; }
.mono { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sort { all: unset; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.sort:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sort-mark { font-size: 0.7rem; color: var(--text-muted); }
.sort.is-asc .sort-mark, .sort.is-desc .sort-mark { color: var(--brand); }
.type-cell { display: inline-flex; gap: 8px; align-items: center; }
.type-cell .swatch { margin: 0; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.badge-active { background: var(--ok-bg); color: var(--ok-ink); }
.badge-pending { background: var(--warn-bg); color: var(--warn-ink); }
.badge-inactive { background: var(--off-bg); color: var(--off-ink); }
.badge-neutral { background: var(--info-bg); color: var(--info-ink); }
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chip { padding: 1px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: 0.8rem; white-space: nowrap; }
.chip-more { color: var(--text-muted); }

.pager { display: flex; gap: 4px; align-items: center; }
.pager .pg {
  min-width: 32px; height: 32px; display: inline-grid; place-items: center; padding: 0 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-primary); text-decoration: none; font-size: 0.9rem;
}
.pager .pg:hover { border-color: var(--text-muted); }
.pager .pg.is-current { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.pager .pg.is-disabled { color: var(--text-muted); opacity: 0.5; }
.pg-gap { color: var(--text-muted); padding: 0 2px; }
.pager-slot:empty { display: none; }
.pager-slot:last-child { justify-self: end; }

.message { margin: 0; color: var(--text-secondary); }
.message-error { color: var(--danger); }

/* Licence type colour: one custom property per slot drives map, tables and legend. */
.lic-slot-1 { --c: var(--series-1); }
.lic-slot-2 { --c: var(--series-2); }
.lic-slot-3 { --c: var(--series-3); }
.lic-slot-other { --c: var(--series-other); }
.swatch { flex: none; display: inline-block; width: 11px; height: 11px; border-radius: 3px; background: var(--c); }

/* Maps */
.leaflet-container { font: inherit; background: var(--surface-2); }
.map-full { position: absolute; inset: 0; }
.map-split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(300px, 2fr); gap: 20px; align-items: start; }
.detail-map-wrap { position: relative; min-height: 460px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.detail-map { position: absolute; inset: 0; }
.beacons { min-width: 0; }
path.lic { fill: var(--c); fill-opacity: 0.22; stroke: var(--c); stroke-width: 2px; stroke-opacity: 0.95; }
path.lic:hover { fill-opacity: 0.42; }
path.lic.is-selected { fill-opacity: 0.45; stroke-width: 3.5px; filter: drop-shadow(0 0 2px var(--halo)) drop-shadow(0 0 1px var(--halo)); }
path.lic.is-hidden { display: none; }
path.overlay { fill: var(--overlay); fill-opacity: 0.12; stroke: var(--overlay); stroke-dasharray: 5 4; }
/* Mines and quarries: filled when operating, hollow when closed; colour is a second cue. */
path.site-pt { stroke: var(--surface); fill-opacity: 0.95; }
path.site-active { fill: var(--ok-ink); }
path.site-other { fill: var(--warn-ink); }
path.site-inactive { fill: var(--surface); stroke: var(--off-ink); stroke-width: 2px; }
path.concession { fill: var(--text-primary); fill-opacity: 0.12; stroke: var(--text-primary); stroke-dasharray: 4 3; }
.site-mark { display: inline-block; width: 10px; height: 10px; border-radius: 50%; box-sizing: border-box; flex: none; }
.site-mark-active { background: var(--ok-ink); }
.site-mark-other { background: var(--warn-ink); }
.site-mark-inactive { background: var(--surface); border: 2px solid var(--off-ink); }
path.site-mine { stroke-width: 2px; }
.site-mark-mine { width: 13px; height: 13px; background: var(--text-secondary); }
.site-mark-quarry { width: 8px; height: 8px; background: var(--text-secondary); }
.geo-downloads { display: flex; flex-wrap: wrap; gap: 6px; }
.btn-small { padding: 5px 9px; font-size: 0.82rem; }
.legend-points { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.rail-count { color: var(--text-muted); font-size: 0.85rem; }
.map-layer { margin-top: 12px; }
.message.flag { display: flex; gap: 8px; align-items: center; font-weight: 550; padding: 10px 12px; margin-bottom: 12px; border-radius: 8px; background: color-mix(in srgb, var(--danger) 10%, transparent); }
.financials th[scope=row] { font-weight: 550; text-align: left; white-space: nowrap; }
.financials td.is-negative { color: var(--danger); }
.data-table td .badge { margin-left: 6px; }
path.beacon { fill: var(--surface); stroke: var(--text-primary); }
path.beacon.is-active { fill: var(--brand); stroke: var(--brand); }
.legend {
  background: var(--surface); color: var(--text-primary); padding: 8px 10px; border-radius: 8px; box-shadow: var(--shadow);
  font-size: 0.85rem; min-width: 170px;
}
.legend-title { font-weight: 650; margin-bottom: 4px; }
.legend-row { display: grid; grid-template-columns: 11px 1fr auto; gap: 8px; align-items: center; padding: 2px 0; }
.legend-count { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.leaflet-control-layers { background: var(--surface); color: var(--text-primary); border-radius: 8px !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text-primary); }
.popup { display: grid; gap: 4px; justify-items: start; }
.popup-sub { color: var(--text-secondary); font-size: 0.85rem; }
.popup-link { font-weight: 600; margin-top: 4px; }
.map-filters { display: grid; gap: 12px; }

.footer {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 8px 24px; font-size: 0.8rem; color: var(--text-muted); background: var(--surface); border-top: 1px solid var(--border);
}

/* Account controls and dialog */
.account-box { display: flex; align-items: center; gap: 8px; }
.account-box[hidden] { display: none; }
.account-notice { margin: 12px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--info-bg); color: var(--info-ink); }
.field-row { display: grid; gap: 4px; }
.field-row > label { font-weight: 550; }
.field-hint { color: var(--text-muted); font-size: 0.82rem; }
.account-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.btn-block { width: 100%; justify-content: center; }
.btn-provider { background: #fff; color: #1f1f1f; border: 1px solid #747775; font-weight: 550; gap: 10px; }
.btn-provider:hover { background: #f8f9fa; }
.provider-mark { width: 18px; height: 18px; flex: none; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 0.85rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.list-status:empty { display: none; }
.table-wrap.is-loading { opacity: 0.55; transition: opacity 0.2s 0.15s; }
.popup-extra { display: grid; gap: 4px; justify-items: start; }
.popup-extra:empty { display: none; }

dialog {
  width: min(480px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px; background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog .muted, .muted { color: var(--text-muted); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { font-size: 1.2rem; }
dialog form { display: grid; gap: 12px; margin-top: 12px; }
dialog form > label { display: grid; gap: 4px; font-weight: 500; }
dialog label.check, label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.field-error { color: var(--danger); font-size: 0.85rem; font-weight: 400; }
.field-error:empty { display: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-status { margin: 12px 0 0; }
.form-status:empty { display: none; }
.form-status.is-ok { color: var(--ok-ink); }
.form-status.is-error { color: var(--danger); }

/* Narrow screens: rail above content; tables scroll inside their frame. */
@media (max-width: 1000px) {
  .map-split { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; }
  .facts .fact:nth-child(odd) { padding-right: 4px; }
}
.nav-short { display: none; }
@media (max-width: 480px) {
  .mainnav .icon { display: none; }
  .nav-long { display: none; }
  .nav-short { display: inline; }
  .mainnav a { padding: 10px 5px 11px; font-size: 0.85rem; }
}
@media (max-width: 800px) {
  body { height: auto; min-height: 100dvh; }
  .masthead-inner { padding: 12px 16px 8px; align-items: flex-start; }
  .menu-name, .menu-caret { display: none; } /* avatar only on small screens */
  .site-name { font-size: 1.2rem; }
  .updated { display: none; }
  .mainnav { padding: 0 4px; gap: 0; }
  .mainnav a { padding: 10px 8px 11px; gap: 6px; }
  .shell { display: block; }
  .rail { border-right: 0; border-bottom: 1px solid var(--border); padding: 16px; }
  .rail-hint { display: none; }
  .stat-value { font-size: 1.5rem; }
  .view { overflow: visible; }
  .page { padding: 16px; }
  body[data-view="map"] .view { height: 70vh; }
  .fact { grid-template-columns: 1fr; gap: 2px; }
  .footer { padding: 8px 16px; }
}

/* Static text pages (terms of service) */
.doc-page { height: auto; min-height: 100dvh; display: block; overflow: auto; }
.doc { max-width: 760px; margin: 0 auto; padding: 32px 24px 64px; line-height: 1.6; }
.doc h2 { font-size: 1.1rem; margin: 28px 0 8px; }
.doc p, .doc ul { margin: 0 0 12px; }
.doc ul { padding-left: 22px; }
.doc li { margin-bottom: 6px; }
.doc-meta { color: var(--text-muted); font-size: 0.9rem; }
.doc-page .masthead-inner { max-width: 760px; margin: 0 auto; }
.footer-links { display: inline-flex; gap: 16px; flex-wrap: wrap; }

/* Overview (landing page) */
.overview { display: grid; gap: 16px; }
.overview > .card, .chart-pair > .card { margin: 0; }
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 32px; padding: 24px; }
.hero-main { display: grid; gap: 4px; }
.hero-label { color: var(--text-secondary); font-weight: 550; }
.hero-value { font-size: 3.5rem; line-height: 1; font-weight: 650; letter-spacing: -0.02em; color: var(--text-primary); }
.hero-story { margin: 0; max-width: 34ch; color: var(--text-secondary); font-size: 1.05rem; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.kpi { display: grid; gap: 2px; align-content: start; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.kpi-label { color: var(--text-secondary); font-size: 0.85rem; font-weight: 550; }
.kpi-value { font-size: 1.75rem; font-weight: 650; color: var(--text-primary); }
.kpi-sub { color: var(--text-muted); font-size: 0.85rem; }
.delta { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }
.delta-ref { color: var(--text-muted); font-weight: 400; }
.chart-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.chart-card { min-width: 0; }
.chart-sub { margin: -4px 0 12px; color: var(--text-muted); font-size: 0.9rem; }
.chart { position: relative; }
.chart svg { display: block; overflow: visible; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart-axis { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-value { fill: var(--text-primary); font-size: 12px; font-weight: 600; }
.chart-hit { fill: transparent; }
.chart-col { outline: none; cursor: default; }
.chart-col.is-hover .chart-mark, .chart-col:focus-visible .chart-mark { filter: brightness(1.12); }
.chart-col:focus-visible .chart-hit { fill: var(--brand-tint); }
.c-slot-1 { fill: var(--series-1); background: var(--series-1); }
.c-slot-2 { fill: var(--series-2); background: var(--series-2); }
.c-slot-3 { fill: var(--series-3); background: var(--series-3); }
.c-slot-other { fill: var(--series-other); background: var(--series-other); }
.c-accent { fill: var(--brand); background: var(--brand); }
.c-muted { fill: var(--series-other); background: var(--series-other); opacity: 0.55; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 8px; font-size: 0.85rem; color: var(--text-secondary); }
.chart-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; min-width: 120px; padding: 8px 10px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-size: 0.85rem; }
.chart-tip-title { color: var(--text-secondary); margin-bottom: 4px; }
.chart-tip-row { display: flex; align-items: center; gap: 6px; }
.chart-tip-row strong { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.chart-tip-row span:last-child { color: var(--text-secondary); }
.chart-tip-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.chart-table { margin-top: 8px; font-size: 0.85rem; }
.chart-table summary { cursor: pointer; color: var(--text-muted); }
.chart-table[open] summary { margin-bottom: 8px; }
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 32%) 1fr; align-items: center; gap: 12px; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.bar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-fill { display: block; height: 14px; border-radius: 0 4px 4px 0; flex: none; max-width: calc(100% - 48px); }
.bar-value { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.overview-note { margin: 0; color: var(--text-muted); font-size: 0.85rem; }
.rail-links { display: grid; gap: 8px; margin-top: 4px; }
@media (max-width: 800px) {
  .hero-value { font-size: 2.75rem; }
  .chart-pair { grid-template-columns: 1fr; }
}
.chart-card .card-title { text-transform: none; letter-spacing: 0; font-size: 1.05rem; color: var(--text-primary); margin-bottom: 6px; }

/* Admin: users table */
.admin > * { min-width: 0; } /* let the users table scroll inside its card */
.admin .toolbar { margin-bottom: 12px; }
.admin .data-table td { cursor: default; }
.user-cell { display: grid; gap: 2px; }
.user-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 600; color: var(--text-primary); }
.user-email { color: var(--text-muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.admin-users th, .admin-users td { white-space: nowrap; }
.admin-users td:first-child { white-space: normal; min-width: 200px; }

/* My account: downloads, API keys, API docs */
.my-account > .card, .api-docs > .card { margin: 0; }
.api-docs { display: grid; gap: 16px; }
.api-docs .card > p, .api-docs .card li { max-width: 72ch; }
.api-docs h3 { margin: 20px 0 8px; font-size: 1rem; }
.api-endpoint { padding: 10px 0; border-top: 1px solid var(--border); }
.api-endpoint p { margin: 4px 0; }
.api-path { display: flex; align-items: center; gap: 8px; }
.api-path code { font-size: 0.95rem; font-weight: 600; }
.api-method { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 4px; background: var(--info-bg); color: var(--info-ink); }
.api-params { margin: 8px 0 4px; }
.api-params td:first-child { white-space: nowrap; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; }
pre.code { margin: 8px 0 12px; padding: 12px 14px; overflow-x: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; font-size: 0.85rem; line-height: 1.5; }
.notice-box { margin: 12px 0; padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-ink); font-weight: 550; }
.meter { display: block; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 6px 0; }
.meter-fill { display: block; height: 100%; min-width: 2px; background: var(--brand); border-radius: 999px; }
.meter-label { margin: 0; }
.keys-tab { display: grid; gap: 16px; }
.key-form { display: grid; gap: 10px; max-width: 520px; }
.key-form .btn { justify-self: start; }
.key-form-title { margin: 20px 0 8px; font-size: 1rem; }
.key-created { border-color: var(--brand); }
.key-created h3 { margin: 0 0 6px; }
.key-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.key-value { padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; overflow-wrap: anywhere; user-select: all; flex: 1 1 260px; }
.filters-cell { max-width: 320px; white-space: normal; color: var(--text-secondary); }
.my-account > *, .api-docs > *, .keys-tab > *, .api-endpoint, .api-group { min-width: 0; } /* let code and tables scroll inside their cards */
.table-note { margin: 10px 0 0; }

/* Profile, issues and admin settings forms */
.profile-form { display: grid; gap: 16px; max-width: 720px; }
.profile-form .card { margin: 0; display: grid; gap: 12px; }
.field-label { font-weight: 550; }
.field-value { color: var(--text-primary); overflow-wrap: anywhere; }
.check-list { display: grid; gap: 10px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.form-status { margin: 0; color: var(--text-secondary); }
.form-status.is-error { color: var(--danger); }
.issues-page .toolbar p { margin: 0; }
.issues-title { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.issue-form { display: grid; gap: 12px; margin: 0; }
.issue-form textarea { min-height: 120px; resize: vertical; }
.field-narrow { max-width: 220px; }
.file-list { margin: 4px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.file-list li { display: flex; gap: 10px; align-items: center; font-size: 0.9rem; overflow-wrap: anywhere; }
.issue-list { display: grid; }
.issue { border-top: 1px solid var(--border); }
.issue-toggle { all: unset; box-sizing: border-box; width: 100%; display: grid; gap: 6px; padding: 12px 4px; cursor: pointer; }
.issue-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.issue-toggle:hover .issue-title { text-decoration: underline; }
.issue-title { font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
.issue-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--text-muted); font-size: 0.85rem; }
.issue-detail { padding: 0 4px 14px; }
.issue-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 8px; }

/* Header account menu */
.user-menu-wrap { position: relative; }
.user-button { display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border: 0; border-radius: 999px; background: transparent; color: var(--text-primary); font: inherit; font-weight: 600; cursor: pointer; }
.user-button:hover, .user-button[aria-expanded="true"] { background: var(--surface-2); }
.user-button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.02em; }
.menu-name { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-caret { color: var(--text-secondary); font-size: 0.8rem; }
.user-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 1000; min-width: 230px; padding: 6px 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgb(0 0 0 / 0.16); }
.user-menu[hidden] { display: none; }
.user-menu-head { display: grid; gap: 2px; padding: 8px 16px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-menu-head span { color: var(--text-muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.user-menu a, .user-menu button { display: block; width: 100%; padding: 10px 16px; border: 0; background: none; color: var(--text-primary); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.user-menu a:hover, .user-menu button:hover, .user-menu a:focus, .user-menu button:focus { background: var(--surface-2); outline: none; }
.user-menu hr { margin: 6px 0; border: 0; border-top: 1px solid var(--border); }
.avatar-large { width: 56px; height: 56px; font-size: 1.2rem; flex: none; }
.color-field { border: 0; padding: 0; margin: 0; min-width: 0; }
.color-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch-option { position: relative; display: inline-grid; cursor: pointer; }
.swatch-option input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.swatch-dot { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.swatch-option input:checked + .swatch-dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text-primary); }
.swatch-option input:focus-visible + .swatch-dot { outline: 2px solid var(--brand); outline-offset: 4px; }

/* Monthly Analysis Report sign-up box */
.report-box {
  display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 24px; align-items: center;
  padding: 28px; border-radius: 16px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, #1b8a99 0%, #0f6b78 38%, #0a3f48 100%);
  box-shadow: 0 18px 40px rgb(10 63 72 / 0.28);
}
.report-copy { display: grid; gap: 12px; justify-items: start; min-width: 0; }
.report-badge { padding: 3px 10px; border-radius: 999px; background: rgb(255 255 255 / 0.16); border: 1px solid rgb(255 255 255 / 0.3); font-size: 0.78rem; font-weight: 650; letter-spacing: 0.03em; }
.report-title { margin: 0; font-size: 1.6rem; line-height: 1.2; color: #fff; }
.report-lead { margin: 0; font-size: 1.05rem; color: rgb(255 255 255 / 0.92); max-width: 52ch; }
.report-points { margin: 4px 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.report-points li { position: relative; padding-left: 26px; color: rgb(255 255 255 / 0.9); }
.report-points li::before { content: ""; position: absolute; left: 0; top: 0.35em; width: 16px; height: 16px; border-radius: 50%; background: #fff no-repeat center / 10px 10px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1.5 5.2 4 7.6 8.6 2.6' fill='none' stroke='%230f6b78' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.report-points strong { color: #fff; }
.report-cta { margin-top: 4px; padding: 12px 22px; border: 0; border-radius: 10px; background: #fff; color: #0a3f48; font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer; box-shadow: 0 6px 16px rgb(0 0 0 / 0.18); }
.report-cta:hover { background: #e9f6f7; }
.report-cta:focus-visible, .report-leave:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.report-joined { display: grid; gap: 6px; padding: 12px 14px; border-radius: 10px; background: rgb(255 255 255 / 0.12); }
.report-joined-text { margin: 0; }
.report-leave { justify-self: start; padding: 0; border: 0; background: none; color: #fff; font: inherit; font-size: 0.88rem; text-decoration: underline; cursor: pointer; }
.report-error { margin: 0; padding: 6px 10px; border-radius: 6px; background: rgb(0 0 0 / 0.25); }
.report-small { margin: 0; font-size: 0.82rem; color: rgb(255 255 255 / 0.75); }
.report-art { display: grid; place-items: center; }
.report-sheet { width: 180px; aspect-ratio: 3 / 4; padding: 16px; border-radius: 10px; background: #fff; transform: rotate(3deg); box-shadow: 0 20px 36px rgb(0 0 0 / 0.3); display: flex; flex-direction: column; gap: 8px; }
.sheet-kicker { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #0f6b78; }
.sheet-line { height: 6px; width: 70%; border-radius: 3px; background: #dde3e1; }
.sheet-line-wide { width: 92%; height: 9px; background: #b8c4c1; }
.sheet-line-short { width: 45%; }
.sheet-bars { flex: 1; display: flex; align-items: flex-end; gap: 5px; padding: 6px 0; border-bottom: 1px solid #dde3e1; }
.sheet-bars span { flex: 1; border-radius: 3px 3px 0 0; background: #2a78d6; }
.sheet-bars span:nth-child(6) { background: #eb6834; }
@media (max-width: 800px) {
  .report-box { grid-template-columns: 1fr; padding: 22px; }
  .report-art { display: none; }
}
