/* I.V.E.Y. Core — customer application.
   Visual language: design-system/pages/core-app.md. A calm operational product:
   1px rules instead of shadow stacks, no gradients, no glass, no decorative colour.
   Status is always a word first and a tone second. */

:root {
  --paper: #f7f8fa; --surface: #ffffff; --ink: #141a24; --muted: #5b6675; --line: #e3e6eb;
  --accent: #2557d6; --ok: #1f7a4d; --warn: #b26a00; --danger: #b3261e; --focus: #ffb400;
  --ok-bg: #e8f3ed; --warn-bg: #fbf1e0; --danger-bg: #fbe9e8; --accent-bg: #e9eefb; --muted-bg: #eef0f4;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Inter", "Segoe UI", Roboto, sans-serif;
  --rail-w: 248px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1218; --surface: #151b24; --ink: #e6edf7; --muted: #98a3b3; --line: #242c37;
    --accent: #7fa8ff; --ok: #5fd39b; --warn: #e6ad55; --danger: #ff8a80;
    --ok-bg: #12251c; --warn-bg: #2a2013; --danger-bg: #2d1614; --accent-bg: #161f31; --muted-bg: #1b222c;
  }
}
[data-theme="light"] {
  --paper: #f7f8fa; --surface: #ffffff; --ink: #141a24; --muted: #5b6675; --line: #e3e6eb;
  --accent: #2557d6; --ok: #1f7a4d; --warn: #b26a00; --danger: #b3261e;
  --ok-bg: #e8f3ed; --warn-bg: #fbf1e0; --danger-bg: #fbe9e8; --accent-bg: #e9eefb; --muted-bg: #eef0f4;
}
[data-theme="dark"] {
  --paper: #0e1218; --surface: #151b24; --ink: #e6edf7; --muted: #98a3b3; --line: #242c37;
  --accent: #7fa8ff; --ok: #5fd39b; --warn: #e6ad55; --danger: #ff8a80;
  --ok-bg: #12251c; --warn-bg: #2a2013; --danger-bg: #2d1614; --accent-bg: #161f31; --muted-bg: #1b222c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.011em; line-height: 1.2; margin: 0; }
h1 { font-size: 24px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
code, .mono, .id { font-family: var(--mono); font-size: 0.92em; }
.id { color: var(--muted); word-break: break-all; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; z-index: 20; background: var(--surface); border: 1px solid var(--line); padding: 8px 12px; border-radius: 8px; }
.boot { padding: 48px 24px; color: var(--muted); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── frame ───────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
.rail {
  border-right: 1px solid var(--line); background: var(--surface); padding: 20px 16px 32px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 20px;
}
.wordmark { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--ink); }
.wordmark b { font-size: 15px; font-weight: 600; letter-spacing: 0.06em; }
.wordmark span { font-size: 11px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }

.switcher { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; gap: 6px; }
.switcher label { font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.switcher select { width: 100%; }
.switcher .plan-line { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 36px;
  padding: 7px 10px 7px 12px; color: var(--ink); text-decoration: none; border-radius: 8px;
  border-left: 2px solid transparent; font-size: 14px;
}
.nav a:hover { background: var(--muted-bg); }
.nav a[aria-current="page"] { border-left-color: var(--accent); background: var(--muted-bg); font-weight: 600; }
.nav .count { font: 12px var(--mono); color: var(--muted); }
.nav-group { font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); padding: 12px 12px 4px; }
.rail-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 6px; font-size: 13px; }
.rail-foot .who { color: var(--muted); font-size: 12px; word-break: break-all; }

.topbar { display: none; }

main { padding: 28px 28px 96px; min-width: 0; }
.col { max-width: 1120px; margin: 0 auto; display: grid; gap: 24px; }
.pagehead { display: grid; gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.pagehead .eyebrow { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.pagehead .row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pagehead .lede { color: var(--muted); max-width: 68ch; }
.pagehead .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── surfaces ────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.card > header { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card > header p { color: var(--muted); font-size: 13px; }
.card .body { padding: 16px; display: grid; gap: 14px; }
.card .body.tight { gap: 8px; }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: grid; gap: 16px; }
.note { border: 1px solid var(--line); border-left-width: 3px; border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--muted); background: var(--surface); }
.note.accent { border-left-color: var(--accent); }
.note.warn { border-left-color: var(--warn); }
.note.danger { border-left-color: var(--danger); color: var(--ink); background: var(--danger-bg); }

/* ── chips ───────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--muted-bg); color: var(--ink);
  font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
  max-width: 100%; white-space: normal; overflow-wrap: normal;
}
/* Chips stay on one line inside dense tables (the wrapper scrolls); in fact lists a long verdict
   token is allowed to break so it can never widen the page on a phone. */
td .chip { white-space: nowrap; }
.facts dd .chip, .pagehead .chip { overflow-wrap: anywhere; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--muted); }
.chip.ok { background: var(--ok-bg); border-color: var(--ok); } .chip.ok::before { background: var(--ok); }
.chip.warn { background: var(--warn-bg); border-color: var(--warn); } .chip.warn::before { background: var(--warn); }
.chip.danger { background: var(--danger-bg); border-color: var(--danger); } .chip.danger::before { background: var(--danger); }
.chip.accent { background: var(--accent-bg); border-color: var(--accent); } .chip.accent::before { background: var(--accent); }
.chip.draft { text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; }

/* ── tables ──────────────────────────────────────────────────────────── */
/* Grid items default to min-width:auto, which lets a wide table push the whole page sideways on a phone.
   Every grid child in this layout is allowed to shrink; wide tables scroll inside their own wrapper instead. */
.stack > *, .col > *, .split > *, .card > .body > *, .card > .body > * > * { min-width: 0; }
.tablewrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  position: sticky; top: 0; z-index: 1; text-align: left; font-size: 11px; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted); font-weight: 600; background: var(--surface);
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--muted-bg); }
.sub { display: block; color: var(--muted); font-size: 12px; }
td.num { text-align: right; font-family: var(--mono); }
td.actions { text-align: right; white-space: nowrap; }
/* Identifiers keep their shape inside a table (the wrapper scrolls) rather than collapsing to one glyph per line. */
td .id, td .mono { word-break: normal; white-space: nowrap; }

/* ── forms ───────────────────────────────────────────────────────────── */
form { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; }
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.field > legend { font-size: 13px; font-weight: 600; padding: 0; }
.field > label { font-size: 13px; font-weight: 600; }
.hint { font-size: 12px; color: var(--muted); }
.field .bad { font-size: 12px; color: var(--danger); }
hr { border: 0; border-top: 1px solid var(--line); margin: 2px 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; min-height: 40px; width: 100%;
}
textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; }
.checks { display: grid; gap: 6px; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; min-height: 32px; }
.check input { width: 16px; height: 16px; margin-top: 3px; flex: none; }
.formrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.formactions { display: flex; justify-content: flex-end; gap: 8px; align-items: center; flex-wrap: wrap; }
.formactions .left { margin-right: auto; color: var(--muted); font-size: 13px; }

button, .btn {
  font: inherit; font-weight: 600; font-size: 14px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; min-height: 40px;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:hover, .btn:hover { background: var(--muted-bg); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
[data-theme="dark"] button.primary, [data-theme="dark"] .btn.primary { color: #0e1218; }
@media (prefers-color-scheme: dark) { button.primary, .btn.primary { color: #0e1218; } }
button.primary:hover, .btn.primary:hover { filter: brightness(1.06); }
button.danger { border-color: var(--danger); color: var(--danger); }
button.danger:hover { background: var(--danger-bg); }
button.quiet { border-color: transparent; background: none; color: var(--accent); padding: 6px 8px; }
button.quiet:hover { background: var(--muted-bg); }
button.small, .btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
button[disabled] { opacity: 0.55; cursor: not-allowed; }
button[aria-busy="true"]::after { content: "…"; }

/* ── definition rows (facts) ─────────────────────────────────────────── */
.facts { display: grid; gap: 0; }
.facts .fact { display: grid; grid-template-columns: minmax(0, 11ch) minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.facts .fact:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.facts.wide .fact { grid-template-columns: minmax(0, 18ch) minmax(0, 1fr); }

/* ── ETA receipt ─────────────────────────────────────────────────────── */
.eta { display: grid; gap: 10px; }
.eta .headline { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.eta .headline small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.etatrack { position: relative; height: 34px; margin-top: 4px; }
.etatrack .rule { position: absolute; top: 12px; left: 0; right: 0; height: 2px; background: var(--line); }
.etatrack .span { position: absolute; top: 12px; height: 2px; background: var(--accent); left: var(--a); right: var(--b); }
.etatrack .tick { position: absolute; top: 6px; width: 2px; height: 14px; background: var(--muted); left: var(--x); }
.etatrack .tick.p50 { background: var(--accent); height: 20px; top: 3px; width: 3px; }
.etatrack .lab { position: absolute; top: 22px; font: 11px var(--mono); color: var(--muted); transform: translateX(-50%); left: var(--x); white-space: nowrap; }
.etatrack .lab.p50 { color: var(--accent); font-weight: 700; }
.etatrack .lab.min { transform: none; }        /* keep the endpoints inside the track instead of half-clipped */
.etatrack .lab.max { transform: translateX(-100%); }
.waves { display: grid; gap: 4px; font-size: 13px; }
.waves .wave { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dotted var(--line); }
.waves .wave:last-child { border-bottom: 0; }
.waves .wave span { color: var(--muted); font-family: var(--mono); font-size: 12px; }

/* ── stage timeline ──────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 22px; display: grid; gap: 0; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.stage { position: relative; padding: 10px 0 10px 4px; border-bottom: 1px solid var(--line); animation: fadein 160ms ease-out; }
.stage:last-child { border-bottom: 0; }
.stage::before { content: ""; position: absolute; left: -21px; top: 15px; width: 9px; height: 9px; background: var(--surface); border: 2px solid var(--muted); border-radius: 2px; }
.stage.done::before { background: var(--ok); border-color: var(--ok); }
.stage.now::before { background: var(--accent); border-color: var(--accent); }
.stage.bad::before { background: var(--danger); border-color: var(--danger); }
.stage .name { font-weight: 600; font-size: 14px; }
.stage .meta { color: var(--muted); font-size: 12px; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.stage .receipt { margin-top: 6px; font: 12px var(--mono); color: var(--muted); overflow-wrap: anywhere; }
@keyframes fadein { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ── skeletons / states ──────────────────────────────────────────────── */
.skel { display: grid; gap: 10px; }
.skel .bar { height: 13px; border-radius: 4px; background: var(--muted-bg); border: 1px solid var(--line); }
.skel .bar.w40 { width: 40%; } .skel .bar.w60 { width: 60%; } .skel .bar.w85 { width: 85%; }
.empty { padding: 28px 16px; text-align: left; display: grid; gap: 12px; justify-items: start; color: var(--muted); }
.empty strong { color: var(--ink); font-weight: 600; }
.errorpanel { border: 1px solid var(--danger); border-left-width: 3px; border-radius: 8px; padding: 14px 16px; background: var(--danger-bg); display: grid; gap: 8px; }
.errorpanel .code { font: 12px var(--mono); font-weight: 700; letter-spacing: 0.04em; }
.errorpanel .rid { font: 12px var(--mono); color: var(--muted); }
.errorpanel .msg { color: var(--ink); }

/* ── auth pages ──────────────────────────────────────────────────────── */
.solo { display: block; padding: 0; }
.solo main { padding: 56px 24px 96px; }
.solo .col { max-width: 460px; }
.solo.wide .col { max-width: 900px; }
.brandline { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; color: var(--ink); text-decoration: none; }
.brandline b { letter-spacing: 0.06em; }
.brandline span { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.altlinks { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; }

/* ── landing ─────────────────────────────────────────────────────────── */
.masthead { display: grid; gap: 14px; border-bottom: 1px solid var(--line); padding-bottom: 28px; }
.masthead h1 { font-size: 34px; max-width: 18ch; letter-spacing: -0.02em; }
.masthead p { max-width: 60ch; color: var(--muted); font-size: 16px; }
.spinelist { display: grid; gap: 0; counter-reset: s; }
.spinelist li { list-style: none; display: grid; grid-template-columns: 3ch minmax(0, 22ch) minmax(0, 1fr); gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.spinelist li::before { counter-increment: s; content: counter(s, decimal-leading-zero); font: 12px var(--mono); color: var(--muted); }
.spinelist strong { font-weight: 600; }
.spinelist span { color: var(--muted); font-size: 14px; }

/* ── sparks ──────────────────────────────────────────────────────────── */
.ledger { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.ledger .cell { padding: 14px 16px; border-right: 1px solid var(--line); display: grid; gap: 4px; }
.ledger .cell:last-child { border-right: 0; }
.ledger .cell dt { font-size: 12px; color: var(--muted); }
.ledger .cell dd { margin: 0; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ledger .cell dd.small { font-size: 15px; font-weight: 500; }

/* ── one-time secret ─────────────────────────────────────────────────── */
.secret { border: 1px solid var(--warn); border-radius: 12px; padding: 16px; background: var(--warn-bg); display: grid; gap: 10px; }
.secret .value { font: 18px var(--mono); font-weight: 700; letter-spacing: 0.14em; word-break: break-all; }
.cmd { background: var(--muted-bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: 12.5px var(--mono); overflow-x: auto; white-space: pre; }

/* ── motion / responsive ─────────────────────────────────────────────── */
.fade { animation: fadein 140ms ease-out; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
    position: sticky; top: 0; z-index: 10;
  }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); display: none; }
  .app[data-rail="open"] .rail { display: flex; }
  main { padding: 20px 16px 80px; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .masthead h1 { font-size: 27px; }
  .spinelist li { grid-template-columns: 3ch minmax(0, 1fr); }
  .spinelist li span { grid-column: 2; }
  button, .btn, input:not([type="checkbox"]), select, textarea { min-height: 44px; }
  .check { min-height: 44px; align-items: center; }
  .check input { width: 20px; height: 20px; min-height: 0; margin-top: 0; }
  .facts.wide .fact { grid-template-columns: minmax(0, 10ch) minmax(0, 1fr); }
}

/* PRELAUNCH lock — the non-operational state must read as deliberate, not broken */
.note.prelaunch { padding: 18px 20px; display: grid; gap: 8px; }
.note.prelaunch .eyebrow { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); font-weight: 600; margin: 0; }
.note.prelaunch .hint { color: var(--muted); font-size: 13px; margin: 0; }
