/* ASG portal (behind the login). True black, one gold accent, big type, one
   question at a time for anything an admin has to decide. Mirrors the public
   site's typefaces (Archivo + JetBrains Mono). */

@font-face {
  font-family: "Archivo Var";
  src: url("/static/vendor/fonts/Archivo-Variable.ttf") format("truetype-variations");
  font-weight: 100 900; font-stretch: 62% 125%; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono Var";
  src: url("/static/vendor/fonts/JetBrainsMono-Variable.ttf") format("truetype-variations");
  font-weight: 100 800; font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #000000;
  --bg-raised: #0d0d0f;
  --bg-card: #121214;
  --text: #f4f6f9;
  --muted: #9aa3b0;
  --faint: #5a6270;
  --hair: rgba(244, 246, 249, 0.12);
  --hair-strong: rgba(244, 246, 249, 0.26);
  --accent: #d7a44a;
  --accent-dim: rgba(215, 164, 74, 0.55);
  --accent-soft: rgba(215, 164, 74, 0.13);
  --ok: #4fd07f;
  --ok-soft: rgba(79, 208, 127, 0.14);
  --warn: #e0b64a;
  --warn-soft: rgba(224, 182, 74, 0.14);
  --bad: #ef5a52;
  --bad-soft: rgba(239, 90, 82, 0.14);
  --font: "Archivo Var", "Archivo", "Segoe UI", -apple-system, sans-serif;
  --mono: "JetBrains Mono Var", "Cascadia Mono", ui-monospace, monospace;
  --radius: 10px;
  --radius-lg: 18px;
  --topbar: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { font-family: var(--font); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: #131006; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: 34px; line-height: 1.15; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--faint); }
.small { font-size: 13.5px; }
.hidden { display: none !important; }

/* ---- Top bar ------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar);
  display: flex; align-items: center; gap: 28px; padding: 0 clamp(18px, 3vw, 48px);
  background: rgba(0, 0, 0, 0.9); backdrop-filter: blur(14px); border-bottom: 1px solid var(--hair);
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-brand img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: #111; }
.topbar-brand .mono { color: var(--muted); }
.topbar-nav { display: flex; gap: 4px; margin-left: 12px; }
.topbar-nav a { padding: 9px 14px; border-radius: var(--radius); font-size: 15px; font-weight: 560; color: var(--muted); transition: color 0.15s, background 0.15s; }
.topbar-nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.topbar-nav a.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 14px; color: var(--muted); }
.topbar-user strong { color: var(--text); font-weight: 560; }
.topbar-user a:hover { color: var(--text); }
@media (max-width: 720px) {
  .topbar { gap: 10px; padding: 0 14px; }
  .topbar-brand .mono { display: none; }
  .topbar-nav { margin-left: 0; }
  .topbar-nav a { padding: 8px 8px; white-space: nowrap; }
  .topbar-user strong { display: none; }
  .topbar-user { gap: 10px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  h1 { font-size: 26px; }
}

/* ---- Page shell ------------------------------------------------------------ */
.page { width: min(1120px, 100% - 2 * clamp(18px, 3vw, 48px)); margin: 0 auto; padding: 40px 0 90px; }
.page.wide { width: min(1600px, 100% - 2 * clamp(18px, 3vw, 48px)); }
.page.narrow { width: min(760px, 100% - 2 * clamp(18px, 3vw, 48px)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 30px; }
.page-head .lead { color: var(--muted); margin-top: 8px; max-width: 64ch; font-size: 16px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.crumbs { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; font-size: 14px; color: var(--faint); }
.crumbs a:hover { color: var(--text); }
.crumbs > *:not(:first-child)::before { content: "/"; margin-right: 8px; color: var(--faint); }
.section { padding: 30px 0; border-top: 1px solid var(--hair); }
.section:first-of-type { border-top: 0; padding-top: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 30px; }

/* ---- Flash / notices ------------------------------------------------------------ */
.flash { display: flex; gap: 12px; align-items: flex-start; padding: 16px 20px; margin-bottom: 26px; border: 1px solid var(--hair-strong); border-left: 4px solid var(--accent); border-radius: var(--radius); font-size: 16px; background: var(--bg-raised); }
.flash.success { border-left-color: var(--ok); }
.flash.error { border-left-color: var(--bad); }
.notice { padding: 16px 18px; border: 1px dashed var(--hair-strong); border-radius: var(--radius); color: var(--muted); font-size: 15px; }
.notice.bad { border-color: var(--bad); color: var(--text); background: var(--bad-soft); border-style: solid; }
.notice.warn { border-color: var(--warn); }

/* ---- Buttons ------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: 12px;
  border: 1.5px solid var(--hair-strong); background: transparent; color: var(--text); font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.1s;
}
.btn:hover { border-color: var(--text); background: rgba(255, 255, 255, 0.04); }
.btn:active { transform: scale(0.985); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #131006; }
.btn.primary:hover { background: #e4b35d; border-color: #e4b35d; }
.btn.go { background: var(--ok); border-color: var(--ok); color: #05130a; letter-spacing: 0.08em; text-transform: uppercase; }
.btn.go:hover { background: #63e090; border-color: #63e090; }
.btn.stop { background: var(--bad); border-color: var(--bad); color: #fff; letter-spacing: 0.08em; text-transform: uppercase; }
.btn.stop:hover { background: #ff6e66; border-color: #ff6e66; }
.btn.danger { border-color: rgba(239, 90, 82, 0.55); color: #f5a49f; }
.btn.danger:hover { border-color: var(--bad); background: var(--bad-soft); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--hair-strong); }
.btn.sm { padding: 8px 13px; font-size: 13.5px; border-radius: 9px; }
.btn.lg { padding: 18px 30px; font-size: 18px; border-radius: 14px; }
.btn.xl { padding: 22px 34px; font-size: 20px; border-radius: 16px; min-width: 200px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.35; cursor: default; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ---- Forms ------------------------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 20px; }
.field label, .field .label { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.field .hint { font-size: 14px; color: var(--faint); }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], input[type="url"], input[type="search"], select, textarea {
  width: 100%; padding: 14px 16px; background: var(--bg-raised); border: 1.5px solid var(--hair-strong); border-radius: 12px;
  color: var(--text); font: inherit; font-size: 17px; transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 15px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 40px; }
input[type="file"] { color: var(--muted); font-size: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
.check { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--hair); font-size: 16px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.check .sub { color: var(--faint); font-size: 13.5px; margin-left: auto; }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin: 0; flex: 1 1 220px; }

/* ---- Wizard: one question per screen ---------------------------------------------- */
.wizard { max-width: 760px; margin: 0 auto; }
.wizard-progress { display: flex; gap: 6px; margin-bottom: 40px; }
.wizard-progress span { flex: 1; height: 4px; border-radius: 2px; background: var(--hair); }
.wizard-progress span.done { background: var(--accent); }
.wizard-progress span.now { background: var(--text); }
.wstep { display: none; animation: rise 0.25s ease; }
.wstep.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.wstep .q { font-size: clamp(28px, 4vw, 40px); font-weight: 600; line-height: 1.15; letter-spacing: -0.02em; margin-bottom: 10px; }
.wstep .q-sub { color: var(--muted); font-size: 18px; margin-bottom: 30px; }
.wstep input[type="text"], .wstep textarea, .wstep select { font-size: 22px; padding: 18px 20px; border-radius: 14px; }
.wstep textarea { min-height: 150px; }
.wizard-nav { display: flex; justify-content: space-between; gap: 14px; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--hair); }
.wizard-nav .spacer { flex: 1; }
.wizard-review dl { display: grid; grid-template-columns: max-content 1fr; gap: 12px 24px; margin: 0 0 20px; font-size: 17px; }
.wizard-review dt { color: var(--faint); }
.wizard-review dd { margin: 0; }
.wizard-review dd a { color: var(--accent); font-size: 14px; margin-left: 10px; }

/* Big selectable tiles (modules, yes/no, block types, file areas) */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile {
  display: flex; flex-direction: column; gap: 6px; padding: 22px 20px; border: 1.5px solid var(--hair-strong); border-radius: var(--radius-lg);
  background: var(--bg-card); cursor: pointer; font: inherit; color: var(--text); text-align: left; transition: border-color 0.15s, background 0.15s, transform 0.1s;
  position: relative;
}
.tile:hover { border-color: var(--text); }
.tile:active { transform: scale(0.99); }
.tile .t { font-size: 18px; font-weight: 600; line-height: 1.25; }
.tile .h { font-size: 14px; color: var(--muted); }
.tile input { position: absolute; opacity: 0; pointer-events: none; }
.tile.on, .tile:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.tile.on::after, .tile:has(input:checked)::after { content: "✓"; position: absolute; top: 14px; right: 16px; color: var(--accent); font-weight: 700; font-size: 18px; }
.tile.big { align-items: center; text-align: center; padding: 44px 24px; }
.tile.big .t { font-size: 24px; }
.tiles.two { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.tile.add { border-style: dashed; align-items: center; justify-content: center; text-align: center; color: var(--muted); background: transparent; min-height: 120px; }
.tile.add .plus { font-size: 40px; line-height: 1; color: var(--accent); }
.tile.add:hover { color: var(--text); background: var(--accent-soft); }

/* Logo picker */
.logo-pick { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.logo-pick .preview { width: 140px; height: 140px; border-radius: 50%; object-fit: cover; background: var(--bg-card); border: 1.5px dashed var(--hair-strong); display: grid; place-items: center; color: var(--faint); font-size: 14px; overflow: hidden; }
.logo-pick .preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Tables & lists ------------------------------------------------------------------ */
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--faint); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--hair-strong); }
.table td { padding: 14px 12px; border-bottom: 1px solid var(--hair); vertical-align: middle; }
.table tr:hover td { background: rgba(255, 255, 255, 0.025); }
.table .actions { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.empty { padding: 40px 0; text-align: center; color: var(--faint); font-size: 16px; }

/* ---- Cards ----------------------------------------------------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.card { display: block; padding: 24px; border: 1.5px solid var(--hair); border-radius: var(--radius-lg); background: var(--bg-card); transition: border-color 0.15s, transform 0.1s; }
a.card:hover { border-color: var(--hair-strong); }
a.card:active { transform: scale(0.99); }
.card-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.card-head img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: #111; }
.card-head .name { font-size: 20px; font-weight: 600; }
.card-stats { display: flex; gap: 22px; font-size: 13px; color: var(--muted); }
.card-stats strong { display: block; font-size: 22px; color: var(--text); font-weight: 600; }
.card.pending { border-color: rgba(239, 90, 82, 0.5); }

.company-card { display: flex; flex-direction: column; gap: 18px; }
.company-card .card-link { display: block; flex: 1; }
.company-card .card-link:hover .name { color: var(--accent); }
.btn.sp { border-color: var(--accent); color: var(--accent); font-weight: 700; letter-spacing: 0.02em; }
.btn.sp:hover { background: var(--accent); color: #131006; }
.sp-callout { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-top: 22px; padding: 18px 22px; border: 1.5px solid var(--accent-dim); border-radius: 14px; background: var(--accent-soft); }

/* ---- Pills / status ------------------------------------------------------------------------ */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; letter-spacing: 0.02em; border: 1px solid var(--hair-strong); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: rgba(79, 208, 127, 0.4); }
.pill.warn { color: var(--warn); border-color: rgba(224, 182, 74, 0.4); }
.pill.bad { color: var(--bad); border-color: rgba(239, 90, 82, 0.4); }
.pill.accent { color: var(--accent); border-color: var(--accent-dim); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }

/* ---- Tabs ---------------------------------------------------------------------------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--hair); margin-bottom: 30px; overflow-x: auto; }
.tabs a { padding: 12px 16px; font-size: 15px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { margin-left: 6px; font-family: var(--mono); font-size: 11px; color: var(--faint); }

/* ---- Matrix ---------------------------------------------------------------------------------- */
.matrix-wrap { display: inline-block; max-width: 100%; vertical-align: top; overflow: auto; border: 1px solid var(--hair); border-radius: var(--radius-lg); max-height: calc(100vh - var(--topbar) - 150px); background: var(--bg-raised); }
.matrix { border-collapse: separate; border-spacing: 0; font-size: 13px; width: auto; }
.matrix th, .matrix td { border-bottom: 1px solid var(--hair); border-right: 1px solid var(--hair); }
/* Diagonal module headers: a sticky opaque backdrop sits under the whole header strip
   (so rows never show through while scrolling). Header cells themselves are transparent;
   each one's band (the button) is skewed 45° about its bottom-left corner so its base
   sits on its own column and its top leans right. Cells stack with ASCENDING z-index so a
   label, which rises up-left out of its band, paints above the cells to its left, while
   the transparent cells let the bands leaning in from the left show through. Phantom
   bands fill the corner above the first two columns. */
.matrix-wrap { --head-h: 250px; --cell-w: 136px; --row-h: 92px; }
.matrix-wrap .head-backdrop { position: sticky; top: 0; left: 0; height: 0; z-index: 1; }
.matrix-wrap .head-backdrop::before { content: ""; position: absolute; left: 0; top: 0; width: 100%; height: var(--head-h); background: var(--bg-raised); }
.matrix thead th { position: sticky; top: 0; z-index: 3; background: transparent; padding: 0; height: var(--head-h); vertical-align: bottom; }
.matrix thead th.pilot-head { z-index: 90; left: 0; text-align: left; padding: 14px 18px; min-width: 250px; background: var(--bg-card); box-shadow: 1px 0 0 var(--hair); }
.matrix thead th.module-head { width: var(--cell-w); min-width: var(--cell-w); max-width: var(--cell-w); overflow: visible; background: transparent; pointer-events: none; z-index: calc(2 + var(--col, 0)); border-right: 0; }
.matrix thead th.gap { width: var(--head-h); min-width: var(--head-h); border: 0; background: transparent; padding: 0; z-index: 2; }
.matrix tbody td.gap { width: var(--head-h); min-width: var(--head-h); border: 0; background: transparent; padding: 0; }
.matrix .module-head button {
  all: unset; position: absolute; inset: 0; display: block; box-sizing: border-box; cursor: pointer; pointer-events: auto;
  border-left: 1px solid rgba(244, 246, 249, 0.42); background: linear-gradient(180deg, #19191c 0%, #111113 60%, #0c0c0e 100%);
  transform: skewX(-45deg); transform-origin: 0 100%; transition: background 0.15s;
}
.matrix .module-head button:hover { background: linear-gradient(180deg, #26262a 0%, #18181b 60%, #101012 100%); }
.matrix thead th:nth-child(2) button::before, .matrix thead th:nth-child(2) button::after, .matrix thead th:nth-child(3) button::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  border-left: 1px solid rgba(244, 246, 249, 0.42); background: linear-gradient(180deg, #19191c 0%, #111113 60%, #0c0c0e 100%);
}
.matrix thead th:nth-child(2) button::before { transform: translateX(calc(var(--cell-w) * -1)); }
.matrix thead th:nth-child(2) button::after, .matrix thead th:nth-child(3) button::after { transform: translateX(calc(var(--cell-w) * -2)); }
.matrix .module-head .label {
  /* A box as tall as the band is wide (cell-w · cos45), anchored at the band's bottom-RIGHT
     corner so it extends up-left across the band; text is centred inside it. */
  position: absolute; left: calc(var(--cell-w) - 6px); bottom: 4px; height: calc(var(--cell-w) * 0.66); width: calc(var(--head-h) * 0.98);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-box-pack: center; -webkit-line-clamp: 3; box-sizing: border-box; padding-left: 14px;
  overflow: hidden; white-space: normal; overflow-wrap: normal; word-break: keep-all; hyphens: none;
  transform: skewX(45deg) rotate(-45deg); transform-origin: left bottom; line-height: 1.08; font-weight: 600; font-size: 18px; color: var(--text); letter-spacing: -0.01em; text-align: left;
}
.matrix .module-head .num { font-family: var(--mono); font-size: 12px; color: var(--accent); display: inline; margin-right: 9px; letter-spacing: 0.08em; }
.matrix tbody th { position: sticky; left: 0; z-index: 2; background: var(--bg-raised); text-align: left; padding: 0; min-width: 250px; max-width: 330px; }
.matrix tbody th a { display: flex; align-items: center; gap: 12px; padding: 16px 18px; font-weight: 600; font-size: 16px; }
.matrix tbody th a:hover { background: rgba(255, 255, 255, 0.04); }
.matrix tbody th .tally { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.matrix td { padding: 5px; height: var(--row-h); }
.cell-wrap { position: relative; }
.cell { display: flex; flex-direction: column; justify-content: center; gap: 2px; height: calc(var(--row-h) - 10px); padding: 6px 10px; border-radius: 10px; border: 1.5px solid transparent; font-size: 12.5px; line-height: 1.25; color: var(--muted); cursor: pointer; text-align: left; width: 100%; background: transparent; font: inherit; overflow: hidden; }
.cell .l { font-family: var(--mono); font-size: clamp(8px, calc(var(--row-h) * 0.1), 11px); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); line-height: 1.2; white-space: nowrap; }
.cell .d { color: var(--text); font-size: clamp(11px, calc(var(--row-h) * 0.15), 16px); font-weight: 560; white-space: nowrap; line-height: 1.2; }
.cell.tone-current { border-color: rgba(79, 208, 127, 0.5); background: var(--ok-soft); }
.cell.tone-watch { border-color: rgba(224, 182, 74, 0.55); background: var(--warn-soft); }
.cell.tone-warning, .cell.tone-expired { border-color: rgba(239, 90, 82, 0.6); background: var(--bad-soft); }
.cell.tone-none { border-color: var(--hair-strong); }
.cell.tone-empty { border: 1.5px dashed var(--hair-strong); color: var(--faint); justify-content: center; align-items: center; }
.cell:hover { border-color: var(--text); }
.cell.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.cell .badge { font-size: 18px; }
.legend { display: flex; gap: 20px; flex-wrap: wrap; font-size: 14px; color: var(--muted); margin: 16px 0 0; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }

.matrix-cards { display: none; }
@media (max-width: 720px) {
  .matrix-wrap { display: none; }
  .matrix-cards { display: block; }
  .mcard { border-bottom: 1px solid var(--hair); }
  .mcard summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 18px 0; cursor: pointer; font-weight: 600; font-size: 18px; }
  .mcard summary::-webkit-details-marker { display: none; }
  .mcard summary .tally { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--faint); }
  .mcard ul { list-style: none; margin: 0; padding: 0 0 14px; }
  .mcard li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; font-size: 16px; border-top: 1px solid var(--hair); align-items: center; }
  .mcard li .sub { color: var(--faint); font-size: 13.5px; }
}

/* ---- Modal / popover ------------------------------------------------------------------------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { width: min(640px, 100%); background: var(--bg-raised); border: 1px solid var(--hair-strong); border-radius: 22px; padding: 36px; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7); max-height: 92vh; overflow: auto; }
.modal h2 { font-size: 30px; margin-bottom: 8px; letter-spacing: -0.02em; }
.modal .sub { color: var(--muted); margin-bottom: 26px; font-size: 17px; }
.choice-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin: 20px 0 26px; }
.choice { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 30px 18px; border: 1.5px solid var(--hair-strong); border-radius: var(--radius-lg); background: var(--bg-card); color: var(--text); font: inherit; font-size: 19px; font-weight: 600; cursor: pointer; transition: border-color 0.15s, background 0.15s, transform 0.1s; text-align: center; }
.choice:hover { border-color: var(--accent); background: var(--accent-soft); }
.choice:active { transform: scale(0.98); }
.choice .hint { font-size: 14px; color: var(--muted); font-weight: 400; }
.choice.big { padding: 54px 24px; font-size: 26px; }
.popover { position: absolute; z-index: 60; width: 320px; background: var(--bg-raised); border: 1px solid var(--hair-strong); border-radius: 16px; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); font-size: 15px; }
.popover dl { margin: 0 0 16px; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; }
.popover dt { color: var(--faint); font-size: 13.5px; }
.popover dd { margin: 0; }
.popover .title { font-weight: 600; font-size: 17px; margin-bottom: 12px; }

/* ---- Module view (chief pilot + builder preview) ---------------------------------------------- */
.module-view { max-width: 720px; margin: 0 auto; }
.module-view .kicker { margin-bottom: 10px; }
.module-view h1 { font-size: 36px; margin-bottom: 10px; }
.module-view .desc { color: var(--muted); font-size: 18px; margin-bottom: 10px; }
.module-view .validity { display: inline-flex; gap: 8px; align-items: center; color: var(--accent); font-size: 15px; margin-bottom: 36px; }
.block { padding: 26px 0; border-top: 1px solid var(--hair); }
.block .block-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--faint); margin-bottom: 10px; }
.block .block-body { white-space: pre-wrap; font-size: 17px; }
.block.reference .block-body { font-family: var(--mono); font-size: 15px; letter-spacing: 0.02em; color: var(--accent); }
.block.dropdown .opts { display: flex; flex-wrap: wrap; gap: 8px; }
.block.dropdown .opts span { padding: 6px 13px; border: 1px solid var(--hair-strong); border-radius: 999px; font-size: 14px; color: var(--muted); }
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--hair); font-size: 17px; }
.file-list li a.name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 560; }
.file-list li a.name:hover { color: var(--accent); }
.file-list li .meta { color: var(--faint); font-size: 13px; white-space: nowrap; }
.file-list .empty-files { color: var(--faint); font-size: 15px; padding: 12px 0; }
.dropbox { border: 1.5px dashed var(--hair-strong); border-radius: 14px; padding: 22px; text-align: center; color: var(--muted); font-size: 15px; margin-top: 14px; cursor: pointer; }
.dropbox.drag, .dropbox:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }

.block { animation: block-in 0.45s ease both; }
@keyframes block-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.callout-box { display: flex; gap: 14px; align-items: flex-start; padding: 18px 20px; border: 1.5px solid var(--accent-dim); border-radius: 14px; background: var(--accent-soft); }
.callout-box .callout-mark { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #131006; font-weight: 800; display: grid; place-items: center; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--hair); font-size: 17px; }
.checklist .tick { flex: none; width: 24px; height: 24px; border-radius: 6px; border: 1.5px solid var(--hair-strong); color: var(--accent); font-size: 13px; display: grid; place-items: center; margin-top: 2px; }
.figure { margin: 0; }
.figure img { display: block; width: 100%; border-radius: 14px; border: 1px solid var(--hair); }
.video { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; border: 1px solid var(--hair); background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.image-pick { display: flex; align-items: center; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.image-pick img { width: 200px; max-height: 140px; object-fit: cover; border-radius: 10px; border: 1px solid var(--hair); }
.image-pick .image-empty { width: 200px; height: 110px; border: 1.5px dashed var(--hair-strong); border-radius: 10px; display: grid; place-items: center; color: var(--faint); font-size: 14px; }

/* ---- Builder: the module card with dotted "+" boxes --------------------------------------- */
.builder-card { max-width: 720px; margin: 0 auto; padding: 40px clamp(20px, 4vw, 48px); border: 1.5px solid var(--hair-strong); border-radius: 26px; background: var(--bg-card); }
.builder-card .title-input { width: 100%; background: transparent; border: 0; border-bottom: 1.5px solid var(--hair); border-radius: 0; padding: 8px 0; font-size: 34px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
.builder-card .title-input:focus { border-bottom-color: var(--accent); outline: none; }
.builder-card .desc-input { width: 100%; background: transparent; border: 0; border-bottom: 1.5px solid var(--hair); border-radius: 0; padding: 8px 0; font-size: 18px; color: var(--muted); min-height: 0; resize: none; }
.builder-card .desc-input:focus { outline: none; border-bottom-color: var(--accent); color: var(--text); }
.bblock { position: relative; padding: 24px 0; border-top: 1px solid var(--hair); transition: background 0.2s; }
.bblock:hover { background: rgba(255, 255, 255, 0.015); }
.bblock.is-new { animation: block-new 0.55s cubic-bezier(0.2, 0.9, 0.25, 1.15) both; }
.bblock.is-leaving { animation: block-out 0.26s ease forwards; }
@keyframes block-new { from { opacity: 0; transform: translateY(18px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes block-out { to { opacity: 0; transform: translateX(24px); height: 0; padding: 0; } }
.builder-card { animation: card-in 0.5s ease both; }
@keyframes card-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.choice, .tile { transition: border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s; }
.choice:hover, .tile:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45); }
.modal { animation: modal-in 0.28s cubic-bezier(0.2, 0.9, 0.25, 1.1) both; }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(0.97); } to { opacity: 1; transform: none; } }
.add-box { transition: border-color 0.15s, background 0.15s, transform 0.15s; }
.add-box:hover .plus { transform: scale(1.15); transition: transform 0.2s; }
.bblock .kind { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--faint); margin-bottom: 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bblock .tools { margin-left: auto; display: flex; gap: 6px; }
.bblock .tools .btn { font-family: var(--font); letter-spacing: 0; text-transform: none; font-size: 13px; padding: 7px 12px; }
.bblock .tools .btn[disabled] { opacity: 0.25; }
.bblock input.blabel { background: transparent; border: 0; border-bottom: 1.5px solid var(--hair); border-radius: 0; padding: 6px 0; font-size: 20px; font-weight: 600; color: var(--text); }
.bblock input.blabel:focus { outline: none; border-bottom-color: var(--accent); }
.bblock textarea, .bblock input.bopts { margin-top: 10px; background: var(--bg-raised); font-size: 16px; }
.bblock .file-list { margin-top: 10px; }
.add-box { margin-top: 26px; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 30px; border: 2px dashed var(--hair-strong); border-radius: 18px; color: var(--muted); font-size: 18px; font-weight: 600; cursor: pointer; background: transparent; width: 100%; font-family: inherit; }
.add-box .plus { font-size: 34px; line-height: 1; color: var(--accent); }
.add-box:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.icon-btn { all: unset; cursor: pointer; padding: 6px 10px; border-radius: 8px; color: var(--faint); font-size: 13px; line-height: 1; }
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.preset-grid label { text-align: center; padding: 26px 12px; border: 1.5px solid var(--hair-strong); border-radius: var(--radius-lg); cursor: pointer; font-size: 22px; font-weight: 600; background: var(--bg-card); }
.preset-grid label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.preset-grid input { display: none; }

/* ---- Viewer ------------------------------------------------------------------------------------- */
.viewer-bar { display: flex; align-items: center; gap: 16px; padding: 14px clamp(18px, 3vw, 48px); border-bottom: 1px solid var(--hair); }
.viewer-bar .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.viewer-bar .sub { color: var(--faint); font-size: 13.5px; }
.viewer-bar .grow { flex: 1; min-width: 0; }
.viewer-body { height: calc(100vh - var(--topbar) - 64px); background: #0a0a0c; }
.viewer-body iframe, .viewer-body object { width: 100%; height: 100%; border: 0; }
.viewer-body img { max-width: 100%; max-height: 100%; display: block; margin: 0 auto; object-fit: contain; height: 100%; }
.viewer-body pre { margin: 0; padding: 24px; height: 100%; overflow: auto; font-family: var(--mono); font-size: 13px; color: var(--text); }
.viewer-fallback { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); font-size: 17px; }
.viewer-archive { padding: 20px clamp(18px, 3vw, 48px); border-top: 1px solid var(--hair); }

.viewer-docs { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px clamp(18px, 3vw, 48px); border-bottom: 1px solid var(--hair); background: var(--bg-raised); }
.viewer-docs .mono { margin-right: 6px; }
.viewer-body.with-docs { height: calc(100vh - var(--topbar) - 120px); }

/* ---- Login ------------------------------------------------------------------------------------- */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 30px; }
.login-card { width: min(420px, 100%); }
.login-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 40px; }
.login-card .brand img { width: 44px; height: 44px; }
.login-card h1 { font-size: 30px; margin-bottom: 8px; }
.login-card .sub { color: var(--muted); margin-bottom: 30px; font-size: 17px; }
.login-card .foot { margin-top: 28px; font-size: 14px; color: var(--faint); display: flex; justify-content: space-between; }

/* ---- Matrix zoom slider ------------------------------------------------------------------------ */
.zoom { display: flex; align-items: center; gap: 16px; margin: 14px 0 12px; color: var(--muted); }
.zoom svg { flex: none; color: var(--accent); }
.zoom input[type="range"] { -webkit-appearance: none; appearance: none; flex: 1 1 320px; max-width: 520px; height: 8px; border-radius: 4px; background: var(--hair-strong); outline: none; cursor: pointer; }
.zoom input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 34px; height: 34px; border-radius: 50%; background: var(--text); border: 4px solid var(--accent); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6); cursor: grab; }
.zoom input[type="range"]::-moz-range-thumb { width: 34px; height: 34px; border-radius: 50%; background: var(--text); border: 4px solid var(--accent); cursor: grab; }
.zoom input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; transform: scale(1.06); }
.matrix-wrap { zoom: var(--matrix-zoom, 1); }
.cp-full .zoom { margin: 0 0 14px; }

/* ---- Chief pilot: the matrix is the whole screen --------------------------------------------- */
.cp-full { padding: 22px clamp(14px, 2vw, 32px) 30px; }
.cp-full .flash { margin-bottom: 16px; }
.cp-full-head { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 16px; }
.cp-full-head h1 { font-size: 28px; }
.cp-full-head .legend { margin: 0; }
.matrix-wrap.cp-matrix { display: block; width: 100%; max-height: calc(100vh - var(--topbar) - 130px); }
.cp-matrix .matrix { min-width: 100%; }
.cp-matrix .matrix tbody th a { font-size: 17px; padding: 18px; }
.cp-matrix .cell.tone-empty .l { font-size: 10px; }
.close-x {
  position: fixed; top: calc(var(--topbar) + 18px); right: clamp(18px, 3vw, 48px); z-index: 30;
  display: inline-flex; align-items: center; gap: 12px; padding: 14px 22px 14px 18px; border-radius: 999px;
  background: var(--text); color: #000; font-size: 17px; font-weight: 700; letter-spacing: 0.04em; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.close-x .x { font-size: 22px; line-height: 1; }
.close-x:hover { background: var(--accent); }
@media (max-width: 720px) { .close-x { top: auto; bottom: 18px; right: 18px; } }

.welcome { position: fixed; inset: 0; z-index: 200; background: #000; display: grid; place-items: center; overflow: hidden; animation: welcome-in 0.4s ease both; }
.wl-scene { position: relative; width: 520px; height: 520px; }
.wl-scene > span { position: absolute; left: 50%; top: 50%; border-radius: 50%; transform: translate(-50%, -50%); }
.wl-ring { border: 1.5px solid var(--accent); opacity: 0; animation: wl-pulse 2.4s ease-out infinite; }
.wl-ring.r1 { width: 160px; height: 160px; }
.wl-ring.r2 { width: 160px; height: 160px; animation-delay: 0.8s; }
.wl-ring.r3 { width: 160px; height: 160px; animation-delay: 1.6s; }
.wl-arc { border: 2px solid transparent; border-top-color: var(--accent); border-right-color: rgba(215, 164, 74, 0.35); }
.wl-arc.a1 { width: 300px; height: 300px; animation: wl-spin 2.2s linear infinite; }
.wl-arc.a2 { width: 380px; height: 380px; border-top-color: rgba(244, 246, 249, 0.6); border-right-color: transparent; animation: wl-spin 3.4s linear infinite reverse; }
.wl-arc.a3 { width: 220px; height: 220px; border-top-color: rgba(215, 164, 74, 0.55); animation: wl-spin 1.5s linear infinite; }
.wl-sweep { width: 380px; height: 380px; background: conic-gradient(from 0deg, rgba(215, 164, 74, 0.28), rgba(215, 164, 74, 0) 70deg); animation: wl-spin 2.6s linear infinite; }
.wl-core { width: 14px; height: 14px; background: var(--accent); box-shadow: 0 0 30px 6px rgba(215, 164, 74, 0.45); animation: wl-core 1.3s ease-in-out infinite alternate; }
.wl-tick { width: 2px; height: 18px; background: rgba(244, 246, 249, 0.55); border-radius: 1px; transform-origin: 50% 50%; }
.wl-tick.t1 { transform: translate(-50%, -50%) rotate(0deg) translateY(-190px); }
.wl-tick.t2 { transform: translate(-50%, -50%) rotate(90deg) translateY(-190px); }
.wl-tick.t3 { transform: translate(-50%, -50%) rotate(180deg) translateY(-190px); }
.wl-tick.t4 { transform: translate(-50%, -50%) rotate(270deg) translateY(-190px); }
.wl-wipe { position: absolute; inset: 0; background: linear-gradient(115deg, #000 0%, #000 35%, var(--accent) 50%, #000 65%, #000 100%); background-size: 300% 100%; background-position: 100% 0; opacity: 0; pointer-events: none; }
.welcome.is-wiping .wl-wipe { opacity: 1; animation: wl-wipe 0.7s cubic-bezier(0.7, 0, 0.2, 1) forwards; }
.welcome.is-wiping .wl-scene { animation: wl-out 0.5s ease forwards; }
@keyframes welcome-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes wl-pulse { 0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0; } 20% { opacity: 0.9; } 100% { transform: translate(-50%, -50%) scale(3.1); opacity: 0; } }
@keyframes wl-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes wl-core { from { transform: translate(-50%, -50%) scale(0.8); } to { transform: translate(-50%, -50%) scale(1.3); } }
@keyframes wl-out { to { opacity: 0; transform: scale(0.85); } }
@keyframes wl-wipe { from { background-position: 100% 0; } to { background-position: 0% 0; } }

/* ---- Progress / misc ---------------------------------------------------------------------------- */
.progress { height: 4px; background: var(--hair); border-radius: 2px; overflow: hidden; margin-top: 14px; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.log-row .when { font-family: var(--mono); font-size: 11px; color: var(--faint); white-space: nowrap; }
.log-row .who { color: var(--muted); white-space: nowrap; }
.log-row .act { font-family: var(--mono); font-size: 10.5px; color: var(--accent); white-space: nowrap; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 22px 0; color: var(--faint); font-size: 14px; }
