/* Layout concept: a survey index. Each record is a catalogue card with a live data sketch on top
   (data, analytics, insight, impact) and a separate description panel underneath. */
:root {
  --bg: #F1F3F3;
  --surface: #FFFFFF;
  --vizbg: #E6EBEC;
  --ink: #0F1B24;
  --mute: #56666F;
  --line: #D3DADD;
  --accent: #2B3FD6;
  --accent-soft: #E4E7FB;
  --accent2: #D98300;
  --err: #B3261E;
  --font-display: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0C1319; --surface: #131C24; --vizbg: #0A1015; --ink: #E8EEF2; --mute: #97A6B0;
    --line: #25333D; --accent: #8593FF; --accent-soft: #1C2440; --accent2: #F0A83A; --err: #FF6B60; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0C1319; --surface: #131C24; --vizbg: #0A1015; --ink: #E8EEF2; --mute: #97A6B0;
  --line: #25333D; --accent: #8593FF; --accent-soft: #1C2440; --accent2: #F0A83A; --err: #FF6B60; color-scheme: dark;
}
html { color-scheme: light dark; }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; padding-inline: 20px; padding-block: 0; }
.wrap { max-width: 1240px; margin-inline: auto; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

header.top { display: flex; flex-wrap: wrap; gap: 16px 48px; align-items: end; justify-content: space-between; padding-block: 44px 28px; }
.name { font-family: var(--font-display); font-weight: 700; font-size: clamp(2.2rem, 5.5vw, 3.9rem); line-height: 1; letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
.name span { color: var(--accent); }
.lede { margin: 12px 0 0; color: var(--mute); max-width: 52ch; font-size: 1.05rem; }
.stamp { font-family: var(--font-mono); font-size: 12px; color: var(--mute); text-align: right; line-height: 1.7; }
.stamp b { color: var(--ink); font-weight: 500; }

.bar { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: center; padding-block: 16px; border-block: 1px solid var(--line); }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { font: 500 14px var(--font-body); color: var(--mute); background: none; border: 0; border-radius: 6px; padding: 8px 16px; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; }
.seg button .n { font-family: var(--font-mono); font-size: 11px; opacity: .8; }
.seg button[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.search { flex: 1 1 260px; min-width: 0; position: relative; }
.search input { width: 100%; font: 400 15px var(--font-body); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 10px 38px; }
.search input::placeholder { color: var(--mute); }
.search svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; stroke: var(--mute); fill: none; stroke-width: 2; }
.count { font-family: var(--font-mono); font-size: 12px; color: var(--mute); white-space: nowrap; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; padding-block: 16px 26px; align-items: center; }
.filters .lbl, .chips .lbl { font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); margin-right: 4px; }
.fchip { font: 500 13px var(--font-body); color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.fchip:hover { border-color: var(--mute); }
.fchip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }

.grid { display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 350px), 1fr)); padding-bottom: 64px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }

.vizzone { background: var(--vizbg); border-bottom: 1px solid var(--line); }
.viz { position: relative; aspect-ratio: 16 / 9; max-width: 100%; }
.viz canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tag { position: absolute; top: 10px; left: 12px; font-family: var(--font-mono); font-size: 11px; color: var(--mute); letter-spacing: .04em; }
.draft { position: absolute; top: 8px; right: 10px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent2); border: 1px solid var(--accent2); border-radius: 4px; padding: 2px 6px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; margin: 0; border-top: 1px solid var(--line); }
.facts div { padding: 10px 14px 11px; min-width: 0; }
.facts div:nth-child(odd) { border-right: 1px solid var(--line); }
.facts div:nth-child(n+3) { border-top: 1px solid var(--line); }
.facts dt { font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin: 0 0 3px; }
.facts dd { margin: 0; font-size: 13px; line-height: 1.4; }

.desc { padding: 18px 18px 20px; display: flex; flex-direction: column; gap: 14px; flex: 1; min-width: 0; }
.who { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: start; }
.logo { width: 46px; height: 46px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--ink); overflow: hidden; }
.logo:has(img) { background: #fff; }
.logo.wide { width: 112px; }
.who:has(.logo.wide) { grid-template-columns: auto minmax(0, 1fr); }
.who:has(.logo.wide) .period { grid-column: 2; text-align: left; padding-top: 0; }
.logo.wide img { object-fit: contain; }
.logo img { width: 100%; height: 100%; object-fit: contain; }
.who h2 { font-family: var(--font-display); font-size: 1.28rem; line-height: 1.15; margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
.role { margin: 3px 0 0; color: var(--mute); font-size: 13.5px; }
.period { font-family: var(--font-mono); font-size: 12px; color: var(--mute); text-align: right; white-space: nowrap; padding-top: 3px; }
.sum { margin: 0; }
.metrics { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0; padding: 12px 0; border-block: 1px dashed var(--line); }
.metrics div { min-width: 0; }
.metrics dt { font-family: var(--font-mono); font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; }
.metrics dd { margin: 0; font-size: 12px; color: var(--mute); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { font-size: 12.5px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; color: var(--ink); }
.chip.imp { background: var(--accent-soft); border-color: transparent; color: var(--ink); }
.empty { grid-column: 1 / -1; padding: 60px 0; text-align: center; color: var(--mute); }

.demo { border-top: 1px dashed var(--line); padding-top: 14px; }
.demo-toggle, .demo-open { display: inline-block; text-decoration: none; font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .03em; background: var(--accent-soft); color: var(--accent); border: none; border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.demo-toggle:hover, .demo-open:hover { filter: brightness(0.95); }
.demo-panel { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.demo-panel input[type="password"] { font-family: var(--font-mono); font-size: 13px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; background: var(--surface); color: var(--ink); min-width: 0; flex: 1 1 140px; }
.demo-panel button.unlock { font-size: 12.5px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; background: var(--surface); color: var(--ink); cursor: pointer; }
.demo-request { font-size: 12px; color: var(--mute); }
.demo-request a { color: var(--mute); text-decoration: underline; }
.demo-msg { font-size: 12px; margin: 0; width: 100%; }
.demo-msg.err { color: var(--err); }
.demo-launch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--accent); font-weight: 500; text-decoration: none; }
footer { border-top: 1px solid var(--line); padding-block: 22px 40px; font-family: var(--font-mono); font-size: 12px; color: var(--mute); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }

@media (max-width: 520px) {
  .who { grid-template-columns: auto minmax(0, 1fr); }
  .period { grid-column: 2; text-align: left; padding-top: 0; }
  .stamp { text-align: left; }
}

.motion { font: 500 12px var(--font-mono); color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer; white-space: nowrap; }
.motion:hover { border-color: var(--mute); }
