/* TOPI export. Dark product UI: layered surfaces, one restrained accent,
 * motion that confirms actions rather than decorating them. */

:root {
  --bg: #0b0d10;
  --bg-glow: #12161c;
  --panel: #14181e;
  --panel-2: #1a1f27;
  --panel-3: #222833;
  --border: #242b35;
  --border-soft: #1c222b;
  --border-strong: #323b48;

  --text: #e8ecf2;
  --text-2: #b3bdcc;
  --muted: #7d8899;
  --faint: #5a6473;

  /* #4c9aff drives UI chrome; charts use the validated #3987e5 */
  --accent: #4c9aff;
  --accent-2: #6fb0ff;
  --accent-wash: rgba(76, 154, 255, 0.10);
  --accent-ring: rgba(76, 154, 255, 0.28);

  --ok: #3fb950;
  --warn: #d6a129;
  --err: #f0645c;

  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, 0.7);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --fast: 140ms;
  --mid: 220ms;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 12% -12%, var(--bg-glow) 0%, transparent 62%),
    radial-gradient(900px 420px at 100% 0%, #10141a 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
::selection { background: var(--accent-ring); color: #fff; }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: #3f4a5a; background-clip: content-box; }

/* ── controls ───────────────────────────────────────────────────── */

input, select, button, .btn {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease),
              box-shadow var(--fast) var(--ease), transform var(--fast) var(--ease),
              color var(--fast) var(--ease), opacity var(--mid) var(--ease);
}
input::placeholder { color: var(--faint); }
input:hover, select:hover { border-color: var(--border-strong); }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
input[type="date"], input[type="search"] { color-scheme: dark; }

button, .btn {
  cursor: pointer;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: transparent;
  color: #06203f;
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-sm);
}
button:hover, .btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
button:active, .btn:active { transform: translateY(0) scale(0.985); filter: brightness(0.97); }

button.ghost, .btn.ghost {
  background: var(--panel-2);
  color: var(--text-2);
  border-color: var(--border);
  font-weight: 500;
  box-shadow: none;
}
button.ghost:hover, .btn.ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--panel-3);
  filter: none;
}
button.ghost.active, .viewtoggle.active {
  color: var(--accent);
  border-color: var(--accent-ring);
  background: var(--accent-wash);
}
button:disabled, .btn:disabled { opacity: 0.38; cursor: not-allowed; transform: none; filter: none; }
button.sm, .btn.sm { padding: 5px 10px; font-size: 12.5px; }
button.icon { padding: 6px 9px; line-height: 1; }

.linkbtn {
  padding: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: none;
  border: none;
  box-shadow: none;
  cursor: pointer;
}
.linkbtn:hover { color: var(--accent-2); transform: none; filter: none; text-decoration: underline; }

/* ── login ──────────────────────────────────────────────────────── */

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: 330px;
  padding: 36px 32px 30px;
  text-align: center;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: rise var(--mid) var(--ease) both;
}
.login-card h1 { margin: 0; font-size: 26px; letter-spacing: -0.7px; font-weight: 650; }
.login-card h1 span { color: var(--accent); font-weight: 400; }
.login-card .muted { color: var(--muted); margin: 6px 0 26px; font-size: 13px; }
.login-card input { width: 100%; padding: 10px 12px; text-align: center; }
.login-card button { width: 100%; margin-top: 12px; padding: 10px; }
.login-card .error { margin: 0 0 14px; color: var(--err); font-size: 13px; animation: shake 340ms var(--ease); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  30%, 70% { transform: translateX(4px); }
  50% { transform: translateX(-4px); }
}

/* ── header ─────────────────────────────────────────────────────── */

header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 22px;
  background: rgba(17, 21, 27, 0.8);
  backdrop-filter: blur(14px) saturate(150%);
  border-bottom: 1px solid var(--border-soft);
}
header h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -0.4px; }
header h1 span { color: var(--accent); font-weight: 400; }
header form { display: contents; }
.spacer { flex: 1; }

#sync-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 10px;
  font-size: 12px; color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  white-space: nowrap;
}
#sync-badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(63, 185, 80, 0.16);
  transition: background var(--fast) var(--ease);
}
#sync-badge.busy .dot {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(214, 161, 41, 0.18);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.3; transform: scale(0.82); } }

/* ── filter bar ─────────────────────────────────────────────────── */

.filterbar {
  position: sticky; top: 53px; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 22px;
  background: rgba(15, 18, 23, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.fgroup { position: relative; display: inline-flex; align-items: center; gap: 7px; }
.flabel {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.7px;
  text-transform: uppercase; color: var(--faint);
}
.vrule { width: 1px; height: 20px; background: var(--border); }
.filterbar input { padding: 5px 9px; font-size: 13px; }

.chips { display: inline-flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px;
  font-size: 12.5px; color: var(--text-2);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer; user-select: none;
  transition: all var(--fast) var(--ease);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip input { accent-color: var(--accent); margin: 0; width: 13px; height: 13px; cursor: pointer; }
.chip em { font-style: normal; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.chip:has(input:checked) { color: var(--accent); border-color: var(--accent-ring); background: var(--accent-wash); }
.chip:has(input:checked) em { color: var(--accent); opacity: 0.75; }

.dropbtn::after { content: ' ▾'; color: var(--faint); }
.droppanel {
  position: absolute; top: calc(100% + 7px); left: 0; z-index: 40;
  width: 280px; padding: 9px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: drop 150ms var(--ease) both;
}
@keyframes drop { from { opacity: 0; transform: translateY(-6px) scale(0.98); } }
.dropsearch { width: 100%; margin-bottom: 8px; font-size: 13px; }
.droplist { max-height: 264px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.droplist label {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; font-size: 13px; color: var(--text-2);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.droplist label:hover { background: var(--panel-3); color: var(--text); }
.droplist input { accent-color: var(--accent); margin: 0; flex: none; }
.droplist span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropempty { padding: 8px; font-size: 13px; margin: 0; }
.dropfooter { padding: 8px 8px 2px; border-top: 1px solid var(--border); margin-top: 7px; }

/* ── layout ─────────────────────────────────────────────────────── */

main {
  padding: 20px 22px 60px;
  max-width: 1760px;
  margin: 0 auto;
  transition: opacity var(--mid) var(--ease);
}
main.loading { opacity: 0.5; }

section { margin-bottom: 18px; }

.panel {
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 60%), var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.panel h2 {
  display: flex; align-items: center; gap: 0;
  margin: 0 0 14px;
  font-size: 11.5px; font-weight: 650; letter-spacing: 0.7px;
  text-transform: uppercase; color: var(--muted);
}
.panel h2 .tools { display: inline-flex; gap: 6px; margin-left: auto; }
.panel h2 .count {
  margin-left: 10px; padding: 2px 9px;
  font-size: 11px; letter-spacing: 0; text-transform: none;
  color: var(--accent); background: var(--accent-wash);
  border: 1px solid var(--accent-ring); border-radius: 99px;
  font-variant-numeric: tabular-nums;
}

.viewtoggle {
  padding: 3px 10px;
  font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0;
  color: var(--faint);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 99px;
  box-shadow: none;
}
.viewtoggle:hover { color: var(--text-2); border-color: var(--border-strong); background: var(--panel-2); filter: none; }

.grouptitle {
  margin: 18px 0 10px;
  font-size: 10.5px; font-weight: 650; letter-spacing: 0.7px;
  text-transform: uppercase; color: var(--faint);
}
.grouptitle:first-of-type { margin-top: 4px; }

/* stat cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 12px; }
.card {
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.022), transparent 70%), var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--mid) var(--ease), transform var(--mid) var(--ease);
  animation: rise 320ms var(--ease) both;
}
.cards .card:nth-child(2) { animation-delay: 30ms; }
.cards .card:nth-child(3) { animation-delay: 60ms; }
.cards .card:nth-child(4) { animation-delay: 90ms; }
.cards .card:nth-child(5) { animation-delay: 120ms; }
.cards .card:nth-child(6) { animation-delay: 150ms; }
.card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.card .k { font-size: 10.5px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; color: var(--faint); }
.card .v { margin-top: 4px; font-size: 24px; font-weight: 640; letter-spacing: -0.8px; line-height: 1.2; }
.card .v.err { color: var(--err); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1080px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── charts ─────────────────────────────────────────────────────── */

/* Fixed height so switching between chart and table never resizes the card. */
.viz-host { height: 330px; overflow-y: auto; }
.viz { display: block; }

.viz-mark { cursor: pointer; transition: fill var(--fast) var(--ease); transform-box: fill-box; }
.viz-mark:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.viz-host .viz-mark { animation: growY 420ms var(--ease) both; transform-origin: bottom; }
.viz-host .viz-h .viz-mark { animation-name: growX; transform-origin: left; }
@keyframes growY { from { transform: scaleY(0); opacity: 0.4; } }
@keyframes growX { from { transform: scaleX(0); opacity: 0.4; } }

.viz-tick, .viz-value { pointer-events: none; font-variant-numeric: tabular-nums; }

.viz-tooltip {
  position: fixed; z-index: 60;
  display: flex; flex-direction: column; gap: 1px;
  padding: 8px 11px;
  background: rgba(24, 29, 37, 0.97);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  animation: fade 110ms var(--ease) both;
}
/* Required: the rule above sets display:flex, which outranks the UA sheet's
 * [hidden] { display: none }. Without this the element stays on screen no
 * matter how correctly the script sets hidden = true. */
.viz-tooltip[hidden] { display: none; }

.viz-tooltip strong { font-size: 15px; font-weight: 640; letter-spacing: -0.3px; }
.viz-tooltip span { font-size: 11.5px; color: var(--muted); max-width: 250px; }

.viz-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.viz-table th, .viz-table td { padding: 5px 8px; border-bottom: 1px solid var(--border-soft); text-align: left; }
.viz-table th {
  position: sticky; top: 0;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--faint); font-weight: 600; background: var(--panel);
}
.viz-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* period brush */
.brush { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-soft); }
.brush-track { position: relative; height: 22px; }
.brush-track::before {
  content: '';
  position: absolute; left: 0; right: 0; top: 9px; height: 4px;
  background: var(--panel-3); border-radius: 99px;
}
.brush-fill {
  position: absolute; top: 9px; height: 4px;
  background: var(--accent); border-radius: 99px;
  transition: left var(--fast) var(--ease), width var(--fast) var(--ease);
}
.brush-track input[type="range"] {
  position: absolute; left: 0; top: 0; width: 100%; height: 22px;
  margin: 0; padding: 0;
  -webkit-appearance: none; appearance: none;
  background: none; border: none; box-shadow: none;
  pointer-events: none;
}
.brush-track input[type="range"]:focus-visible { box-shadow: none; }
.brush-track input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: auto;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--panel);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  cursor: ew-resize;
  transition: transform var(--fast) var(--ease);
}
.brush-track input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.18); }
.brush-track input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--panel);
  cursor: ew-resize;
}
.brush-track input[type="range"]::-moz-range-track { background: none; border: none; }
.brush-legend {
  display: flex; align-items: center; gap: 10px;
  margin-top: 4px; font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
/* "Tout" is an available action, not a current state: grey at rest, accent on
 * hover. Accent at rest read as if the full range were selected. */
.brush-legend .linkbtn { margin-left: auto; color: var(--muted); }
.brush-legend .linkbtn:hover { color: var(--accent); }
.brush-legend .linkbtn[hidden] { display: none; }

/* ── table ──────────────────────────────────────────────────────── */

.tablepanel { padding: 0; overflow: hidden; }

.tabletoolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.searchbox { position: relative; display: flex; align-items: center; flex: 1; max-width: 460px; }
.searchbox svg { position: absolute; left: 11px; width: 15px; height: 15px; color: var(--faint); pointer-events: none; }
.searchbox input { width: 100%; padding: 8px 40px 8px 34px; font-size: 13px; }
.searchbox kbd {
  position: absolute; right: 10px;
  padding: 1px 6px;
  font: 11px var(--mono); color: var(--faint);
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  pointer-events: none;
}
.searchbox input:focus + kbd { opacity: 0; }
.pagesize { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; }
.pagesize select { padding: 4px 8px; font-size: 12.5px; }

.table-wrap { overflow-x: auto; max-height: 70vh; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }

th, td { padding: 9px 13px; text-align: left; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
th {
  position: sticky; top: 0; z-index: 2;
  font-size: 10.5px; font-weight: 650; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--faint); background: var(--panel-2); user-select: none;
}
th[data-sort] { cursor: pointer; transition: color var(--fast) var(--ease); }
th[data-sort]:hover { color: var(--text); }
th.sorted { color: var(--accent); }

tbody tr { transition: background var(--fast) var(--ease); }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: none; }
tr.error td { color: var(--err); }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }
td.nowrap { white-space: nowrap; }
td.mono { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
td.wrap, td.wrap-wide { white-space: normal; }
td.wrap, th.wrap { max-width: 170px; }
td.wrap-wide, th.wrap-wide { max-width: 250px; }

td.empty { padding: 0; }
.emptybox { display: flex; flex-direction: column; gap: 4px; align-items: center; padding: 46px 20px; }
.emptybox strong { font-size: 14px; font-weight: 600; }
.emptybox span { font-size: 13px; }

.tag {
  display: inline-block; padding: 1.5px 8px;
  font-size: 11px; font-weight: 500;
  color: var(--accent); background: var(--accent-wash);
  border: 1px solid var(--accent-ring); border-radius: 99px;
}

/* Score RSE: one hue at increasing strength (sequential), ink text on top. */
.score {
  display: inline-flex; align-items: baseline; gap: 1px;
  min-width: 58px; justify-content: center;
  padding: 2px 8px;
  font-weight: 600; font-variant-numeric: tabular-nums;
  border: 1px solid; border-radius: 99px;
}
.score-max { font-size: 10.5px; font-weight: 400; color: var(--muted); }
/* Past the midpoint the fill is dark enough that muted ink loses contrast. */
.score.strong { color: #fff; }
.score.strong .score-max { color: rgba(255, 255, 255, 0.72); }

.pdfbtn.icon { display: inline-flex; align-items: center; justify-content: center; padding: 5px; margin: 0; }
.pdfbtn.icon svg { width: 15px; height: 15px; }

/* segmented control (document kind inside the preview modal) */
.segmented { display: inline-flex; padding: 2px; background: var(--panel-3); border-radius: 99px; gap: 2px; }
.segmented[hidden] { display: none; }
.segmented button {
  padding: 4px 12px;
  font-size: 12.5px; font-weight: 500;
  color: var(--muted);
  background: transparent; border: none; border-radius: 99px;
  box-shadow: none;
}
.segmented button:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); filter: none; transform: none; }
.segmented button.active { color: var(--accent); background: var(--accent-wash); }

.badge-err {
  padding: 1.5px 8px; font-size: 11.5px;
  color: var(--err); background: rgba(240, 100, 92, 0.1);
  border: 1px solid rgba(240, 100, 92, 0.3); border-radius: 99px;
}

.pdfbtn {
  padding: 3px 10px; margin-right: 5px;
  font-size: 11.5px; font-weight: 500;
  color: var(--text-2); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 99px;
  box-shadow: none;
}
.pdfbtn:hover { color: var(--accent); border-color: var(--accent-ring); background: var(--accent-wash); filter: none; }

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

.pager {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 12px 16px;
  font-size: 13px;
  border-top: 1px solid var(--border-soft);
}

/* ── export cards ───────────────────────────────────────────────── */

/* Master-detail: the list carries identity, the pane carries the detail. */
.exportsplit {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 14px;
  align-items: start;
}
@media (max-width: 900px) { .exportsplit { grid-template-columns: 1fr; } }

.exportnav { display: flex; flex-direction: column; gap: 3px; }
.exportitem {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  text-align: left;
  font-weight: 500;
  color: var(--text-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  box-shadow: none;
}
.exportitem:hover { background: var(--panel-2); color: var(--text); border-color: var(--border); filter: none; transform: none; }
.exportitem .name { font-size: 13.5px; }
.exportitem .kind {
  margin-left: auto;
  padding: 1px 6px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--faint);
  background: var(--panel-3);
  border-radius: 4px;
}
.exportitem.active {
  color: var(--accent);
  background: var(--accent-wash);
  border-color: var(--accent-ring);
}
.exportitem.active .kind { color: var(--accent); background: rgba(76, 154, 255, 0.16); }

/* min-width: 0 is required: a grid item defaults to min-width:auto, so the wide
 * preview and the column chips would push the column past the panel instead of
 * scrolling inside it. min-height keeps the list from jumping when the
 * selection moves between a short and a tall format. */
.exportdetail {
  min-width: 0;
  min-height: 430px;
  padding: 16px 18px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.detail-head { display: flex; align-items: flex-start; gap: 14px; }
.detail-head h4 { margin: 0; font-size: 16px; font-weight: 630; letter-spacing: -0.3px; }
.detail-head .desc { margin: 3px 0 0; font-size: 13px; color: var(--text-2); }
.detail-head .actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.detail-head .variant { display: flex; align-items: center; gap: 8px; }
.detail-head .variant .hint { font-size: 11px; color: var(--faint); white-space: nowrap; }

.detail-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; }
.detail-meta p { margin: 0; font-size: 12px; color: var(--muted); }

.detail-block { margin-top: 14px; min-width: 0; }
.blocklabel {
  display: block; margin-bottom: 7px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.7px; text-transform: uppercase;
  color: var(--faint);
}
.cols { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.equiv code, .cols code {
  font-family: var(--mono);
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  color: var(--text-2);
}
.preview {
  margin: 0;
  height: 240px;
  overflow: auto;              /* the sample scrolls, it never widens the panel */
  padding: 11px 12px;
  font: 11.5px/1.6 var(--mono);
  white-space: pre;
  color: var(--text-2);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.pdfrow { padding: 14px 15px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); }
.pdfrow .desc { margin: 0 0 11px; font-size: 12.5px; color: var(--text-2); }
.exports { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#pdf-info { font-size: 12px; font-variant-numeric: tabular-nums; }

/* ── modal ──────────────────────────────────────────────────────── */

.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 26px; }
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(4, 6, 9, 0.72);
  backdrop-filter: blur(3px);
  animation: fade 180ms var(--ease) both;
}
.modal-box {
  position: relative;
  display: flex; flex-direction: column;
  width: min(1060px, 100%); height: min(90vh, 100%);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: pop 220ms var(--ease) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.975); } }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 15px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.modal-title { min-width: 0; }
.modal-head h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.2px; }
.modal-head p { margin: 2px 0 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#pdf-frame { flex: 1; width: 100%; border: 0; background: #23262b; }

/* ── toast ──────────────────────────────────────────────────────── */

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  max-width: 380px; padding: 12px 16px;
  font-size: 13px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  animation: slide-in 260ms var(--ease) both;
  transition: opacity 250ms var(--ease);
}
.toast.err { border-left-color: var(--err); }
@keyframes slide-in { from { opacity: 0; transform: translateX(22px); } }

/* ── responsive & motion ────────────────────────────────────────── */

@media (max-width: 860px) {
  header, .filterbar, main { padding-left: 14px; padding-right: 14px; }
  .filterbar { position: static; }
  .vrule { display: none; }
  .searchbox { max-width: none; }
  .viz-host { height: 280px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  button:hover, .btn:hover, .card:hover { transform: none; }
}
