/* PreData dashboard. Cool fog paper, navy ink; state colours carry meaning only. No web fonts
   (nothing loads from third parties). Signature: the pulse strip of the last 60 polls. */
:root {
  --paper: #e9edf1;
  --panel: #ffffff;
  --ink: #142032;
  --muted: #5e6b7e;
  --line: #d3dae3;
  --go: #127a57;
  --hold: #c27c0e;
  --stop: #b42318;
  --mark: #2b54c8;
  --wait: #e0b100;
  --wait-ink: #8a6a00;
  --mark-bg: #eef2fd;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-family: var(--sans);
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); }
a { color: var(--mark); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 2px; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 24px;
  background: var(--ink); color: #fff; }
.brand { font-weight: 800; letter-spacing: .04em; text-transform: uppercase; font-size: .95rem; }
.who { margin-right: 10px; opacity: .75; }
.inline { display: inline; }

button { font: inherit; cursor: pointer; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); padding: 8px 16px; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
button.link { background: none; border: none; color: inherit; text-decoration: underline; padding: 0; }
input { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); }
label { color: var(--muted); font-size: .9rem; }

/* login */
.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 28px;
  width: min(360px, 100%); display: grid; gap: 14px; }
.card h1 { margin: 0; font-size: 1.4rem; letter-spacing: .04em; text-transform: uppercase; }
.card .sub { margin: -8px 0 4px; color: var(--muted); }
.card label { display: grid; gap: 4px; }
.error { margin: 0; color: var(--stop); font-weight: 600; }

/* state band */
.band { display: grid; grid-template-columns: minmax(280px, 1fr) 2fr; gap: 32px; padding: 24px;
  background: var(--panel); border-bottom: 4px solid var(--muted); }
/* Status at a glance (Marcel, 2026-10-29): green runs, yellow waits for Robert (Authenticator,
   captcha) or is signing in, red does not run, orange runs throttled. */
.band { border-bottom-width: 6px; }
.band[data-state="running"] { border-bottom-color: var(--go); background: #e9f6f0; }
.band[data-state="throttled"] { border-bottom-color: var(--hold); background: #fdf1e3; }
.band[data-state^="mfa"], .band[data-state="starting"], .band[data-waiting="1"] { border-bottom-color: var(--wait); background: #fff8d6; }
.band[data-state="stopped"], .band[data-state="login_required"], .band[data-state="error"] { border-bottom-color: var(--stop); background: #fdecea; }
.eyebrow { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.state-word { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 800; line-height: 1.1; margin: 4px 0 6px; }
.state-word::before { content: ""; display: inline-block; width: .55em; height: .55em; border-radius: 50%;
  background: currentColor; margin-right: .3em; vertical-align: .12em; }
.band[data-state="running"] .state-word { color: var(--go); }
.band[data-state="running"] .state-word::before { animation: pulse 1.6s ease-in-out infinite; }
.band[data-state="throttled"] .state-word { color: var(--hold); }
.band[data-state^="mfa"] .state-word, .band[data-state="starting"] .state-word, .band[data-waiting="1"] .state-word { color: var(--wait-ink); }
.band[data-state="stopped"] .state-word, .band[data-state="login_required"] .state-word, .band[data-state="error"] .state-word { color: var(--stop); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.state-detail { min-height: 1.3em; color: var(--muted); }
.band[data-state="login_required"] .state-detail { color: var(--stop); font-weight: 600; }
.actions { display: flex; gap: 10px; margin-top: 14px; }
.mfa { margin-top: 12px; padding: 14px; border-radius: 8px; background: #fff7e8; border: 1px solid #f0d6a8; }
.mfa strong { display: block; font-family: var(--mono); font-size: 96px; line-height: 1; margin-top: 6px; }
.mfa .row { display: flex; gap: 8px; margin-top: 8px; }
.mfa input { font-family: var(--mono); font-size: 1.6rem; width: 8ch; letter-spacing: .15em; }

.pulse-block { display: grid; grid-template-rows: auto 1fr auto; gap: 8px; min-height: 150px; }
.pulse { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding: 6px 0;
  border-bottom: 1px solid var(--line); }
.tick { flex: 1 1 0; min-width: 3px; max-width: 12px; border-radius: 2px 2px 0 0; background: var(--go); }
.tick.slow { background: var(--hold); }
.tick.bad { background: var(--stop); }
.legend { font-size: .8rem; color: var(--muted); }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; vertical-align: -1px; }
.sw.ok { background: var(--go); } .sw.slow { background: var(--hold); } .sw.bad { background: var(--stop); }

/* layout */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; padding: 20px 24px; }
.col-main, .col-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-content: start; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.panel h2 { margin: 0 0 10px; font-size: 1rem; }

/* folding panels (panels.js): click the title; folded leaves only the title row */
.panel h2.foldable { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px; }
.fold { border: none; background: none; padding: 0; width: 1.1em; height: 1.1em; cursor: pointer; color: var(--muted); }
.fold::before { content: ""; display: block; width: .45em; height: .45em; margin: auto;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg);
  transition: transform .15s; }
.panel.folded .fold::before { transform: rotate(-45deg); }
.panel.folded { padding-bottom: 6px; }
.panel.folded > :not(.panel-head):not(h2) { display: none; }
.panel.folded .panel-head > :not(h2) { display: none; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 10px; }
.count { font-family: var(--mono); color: var(--muted); font-weight: 400; margin-left: 4px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.col-main .panel { overflow-x: auto; } /* wide tables scroll inside their panel, never into the side column */
.hint, .empty { color: var(--muted); font-size: .9rem; margin: 0 0 10px; }

table.leads { width: 100%; border-collapse: collapse; font-size: .9rem; }
.leads th { text-align: left; font-weight: 600; color: var(--muted); font-size: .78rem;
  text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--line); padding: 6px 8px; }
.leads td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; }
.leads .num { text-align: right; white-space: nowrap; }
.leads td.mono { white-space: nowrap; }
.leads tr.watched td { background: var(--mark-bg); }
.leads tr.watched td:first-child { box-shadow: inset 4px 0 0 var(--mark); }
.leads .title { color: var(--muted); font-size: .8rem; max-width: 30ch; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.leads .sub { color: var(--muted); font-size: .8rem; }
.flag { display: inline-block; margin: 4px 4px 0 0; padding: 1px 6px; border-radius: 4px; font-size: .72rem;
  background: #fff3d6; color: #7a4e00; }
.outcome.vanished_early { color: var(--go); font-weight: 600; }
.outcome.gone_unobserved { color: var(--hold); }

.cats { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cats label { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); }
.cats small { display: block; color: var(--muted); }
.cats .cat-name { font-weight: 600; }
.cats .products { list-style: none; margin: 4px 0 6px 26px; padding: 0; display: grid; gap: 4px; }
.cats .products label { font-size: .9rem; }
.settings { display: grid; gap: 10px; }
.settings label { display: grid; gap: 4px; }
.saved { color: var(--go); font-size: .9rem; }
.events { list-style: none; margin: 0; padding: 0; font-size: .85rem; display: grid; gap: 4px; }
.events .mono { color: var(--muted); }

.remote { margin: 0; } /* in the main column, beside the side panels */

/* buying */
.buy-panel { display: grid; grid-template-columns: minmax(220px, 1fr) auto minmax(260px, 1fr); gap: 24px;
  align-items: center; margin: 20px 24px 0; padding: 18px 20px; border-radius: 10px;
  background: #fff7e8; border: 2px solid var(--hold); }
.buy-panel[hidden] { display: none; }
.buy-title { font-size: 1.3rem; font-weight: 800; margin: 4px 0; }
.buy-meta { color: var(--muted); font-size: .85rem; max-width: 60ch; }
.buy-captcha { height: 80px; image-rendering: pixelated; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.buy-form .row { display: flex; gap: 8px; margin-top: 6px; }
.buy-form input { font-family: var(--mono); font-size: 1.6rem; width: 9ch; letter-spacing: .12em; }
.buy-left { margin-top: 6px; color: var(--muted); font-size: .9rem; }
.pick { color: var(--ink); white-space: nowrap; }
.settings .switch { display: flex; gap: 8px; align-items: center; color: var(--ink); font-weight: 600; }
.usage { margin: 0; font-family: var(--mono); font-size: .85rem; }
.pstate.bought { color: var(--go); font-weight: 700; }
.pstate.failed, .pstate.not_ready { color: var(--stop); }
.pstate.captcha, .pstate.submitting { color: var(--hold); font-weight: 700; }
.remote iframe { width: 100%; aspect-ratio: 16 / 9; border: 1px solid var(--line); border-radius: 6px; background: #000; }

@media (max-width: 900px) {
  .band, .grid, .buy-panel { grid-template-columns: 1fr; }
  .band, .grid { padding: 16px; }
  .leads .title { max-width: 24ch; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
