/* ── Fonts (self-hosted via public/vendor) ───────────────────── */
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("/vendor/fonts/inter/files/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("/vendor/fonts/inter/files/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("/vendor/fonts/inter/files/inter-latin-600-normal.woff2") format("woff2"); }

/* ── Tokens ───────────────────────────────────────────────────── */
/* theme-init.js picks light/dark (saved choice, else the OS setting) and sets <html data-theme>; the top-bar toggle overrides it. */
/* Colour means something: structure (rail, tabs, selection, borders) is grey; the accent marks only what you act on or look up
   (issue keys, links, primary buttons, progress); ok/warn/err mark status. To re-colour the app, edit the three --accent* values
   in each theme below (keep text-on-accent ≥4.5:1 and accent on --paper/--sheet/--sel ≥4.5:1; --accent-bg is derived). */
:root {
  color-scheme: light;
  --paper:   #f5f6f8;   /* app background */
  --rail:    #fafbfc;   /* side rail */
  --sheet:   #ffffff;   /* documents and inputs */
  --sel:     #e7eaef;   /* selected row / nav item / tab (grey, never accent) */
  --ink:     #1b1f27;
  --ink-2:   #454c58;
  --ink-3:   #5e6672;
  --line:    #e3e6eb;
  --line-2:  #d0d5dc;
  --control-border: #868e9a;   /* ≥3:1 against the surface (WCAG 1.4.11) */
  --accent:  #1456d6;
  --accent-2:#0f43ad;          /* hover */
  --on-accent:#ffffff;
  --accent-bg: color-mix(in srgb, var(--accent) 8%, var(--sheet));
  --ok:      #177048;  --ok-bg:   #e4f3ec;
  --warn:    #945100;  --warn-bg: #fbf0dc;   /* saffron: needs attention */
  --err:     #b82f1c;  --err-bg:  #fbe7e3;
  --series-1:#2a78d6;  --series-2:#eb6834;   /* data-viz slots 1-2 (validated palette) */
  --focus:   #1456d6;
  --r-sm: 6px;    /* code, chips, bar ends */
  --r: 8px;       /* controls */
  --r-box: 12px;  /* containers */
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-family: var(--sans); font-size: 14px; color: var(--ink);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #22262d; --rail: #1b1e24; --sheet: #2b3038; --sel: #343b47; --ink: #e8ebf0; --ink-2: #b6bdc9; --ink-3: #a3acb9;
  --line: #3c424d; --line-2: #4a515e; --control-border: #7d8693; --accent: #86b0ff; --accent-2: #a9c8ff; --on-accent: #0a1a38;
  --accent-bg: color-mix(in srgb, var(--accent) 14%, var(--sheet));
  --ok: #5fcf97; --ok-bg: #1f3a2e; --warn: #f2b04a; --warn-bg: #3b2f17; --err: #ff8a78; --err-bg: #4a2420;
  --series-1: #3987e5; --series-2: #d95926; --focus: #86b0ff;
}

/* ── Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); line-height: 1.5; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--ink-3); }
.hidden, [hidden] { display: none !important; }   /* the hidden attribute must win over component display rules (.btn is inline-flex) */

/* ── Shell ────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); height: 100vh; }
.rail { background: var(--rail); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { padding: 18px 18px 14px; font-family: var(--sans); font-size: 21px; font-weight: 600; letter-spacing: -.01em; }
.brand small { display: block; font-family: var(--sans); font-size: 12px; font-weight: 400; color: var(--ink-3); letter-spacing: 0; }
.space-btn { margin: 0 12px 10px; padding: 8px 10px; display: flex; align-items: center; gap: 8px; text-align: left; background: var(--sheet); border: 1px solid var(--control-border); border-radius: var(--r-box); cursor: pointer; }
.space-btn:hover { border-color: var(--ink-3); }
.space-btn .k { font-weight: 600; }
.space-btn .n { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { flex: 1; overflow-y: auto; padding: 4px 8px; display: flex; flex-direction: column; gap: 1px; }
.nav-group { margin: 14px 10px 4px; font-size: 12px; color: var(--ink-3); }
.nav a, .nav button { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 0; background: none; border-radius: var(--r); color: var(--ink-2); text-decoration: none; cursor: pointer; width: 100%; text-align: left; }
.nav a:hover { background: var(--sel); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--sel); color: var(--ink); font-weight: 600; }
.nav a[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.nav i { font-size: 17px; }
.status { padding: 12px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
/* status dot */
.dot.ok { background: var(--ok); } .dot.err { background: var(--err); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: baseline; gap: 14px; padding: 14px 28px; border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 18px; font-weight: 600; }
.topbar-tools { margin-left: auto; align-self: center; display: flex; align-items: center; gap: 8px; }
.quiet-select { width: auto; border-color: transparent; background: transparent; cursor: pointer; }
.env-list { margin: 0 0 16px; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--r-box); overflow: hidden; }
.env-list li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.env-list li:last-child { border-bottom: 0; }
.env-list i { color: var(--ok); font-size: 16px; }
.env-list .v { margin-left: auto; color: var(--ink-3); font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.topbar p { color: var(--ink-3); font-size: 13px; }
.content { flex: 1; overflow-y: auto; padding: 24px 28px 48px; }
.page { max-width: 1280px; margin: 0 auto; }

@media (max-width: 860px) {
  .app { grid-template-columns: 56px minmax(0, 1fr); }
  .brand small, .nav-group, .space-btn > span, .nav span, .status span { display: none; }
  .brand { padding: 14px 4px; font-size: 12px; text-align: center; }
  .space-btn { margin: 0 6px 8px; justify-content: center; padding: 8px 0; }
  .nav a { justify-content: center; padding: 10px 0; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
}

/* ── Primitives ───────────────────────────────────────────────── */
a.btn { text-decoration: none; color: inherit; }
a.btn.primary { color: var(--on-accent); }
.btn { min-height: 32px; display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border: 1px solid var(--control-border); background: var(--sheet); border-radius: var(--r); cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--ink-3); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 500; }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); }
.btn.danger { color: var(--err); }
.btn.quiet { border-color: transparent; background: none; color: var(--ink-2); }
.btn.busy::before { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }
@media (forced-colors: active) { .btn.primary, .seg button[aria-pressed="true"], .tpl-grid button[aria-pressed="true"], .nav a[aria-current="page"] { border: 2px solid ButtonText; } }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.hint { font-size: 12px; color: var(--ink-3); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; background: var(--sheet); border: 1px solid var(--control-border); border-radius: var(--r);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
input:disabled { background: var(--paper); color: var(--ink-3); }

.panel { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-box); overflow: hidden; }
.panel { margin-bottom: 16px; overflow: hidden; }
.cols-2 > .panel, .workspace > .panel, .review > .panel, .panel-b .panel { margin-bottom: 0; }
.cols-2 { margin-bottom: 16px; }
.panel-b > .cols-2:last-child { margin-bottom: 0; }
.panel-h { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-h h2 { font-size: 14px; font-weight: 600; flex: 1; }
.panel-b { padding: 16px; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 1000px) { .cols-2 { grid-template-columns: 1fr; } }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--paper); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok, .badge.warn, .badge.err { background: var(--sheet); }   /* status = coloured text on a neutral chip, no tinted blobs */
.badge.ok { color: var(--ok); border-color: currentColor; }
.badge.warn { color: var(--warn); border-color: currentColor; }
.badge.err { color: var(--err); border-color: currentColor; }
.badge.accent { background: var(--sel); color: var(--ink); border-color: transparent; }

.empty { padding: 36px 20px; text-align: center; color: var(--ink-3); }
.empty i { display: block; font-size: 28px; margin-bottom: 8px; }
.empty strong { display: block; color: var(--ink-2); font-weight: 500; margin-bottom: 4px; }
.error-box { padding: 10px 12px; background: var(--err-bg); color: var(--err); border-radius: var(--r); font-size: 13px; }

#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { padding: 9px 14px; background: var(--ink); color: var(--paper); border-radius: var(--r-box); font-size: 13px; max-width: 420px; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.toast.err { background: var(--err-bg); color: var(--err); border: 1px solid currentColor; }

/* ── Space picker (dialog) ────────────────────────────────────── */
dialog { border: 1px solid var(--control-border); border-radius: var(--r-box); padding: 0; width: min(520px, 92vw); background: var(--sheet); color: var(--ink); overflow: hidden; }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.space-list { max-height: 55vh; overflow-y: auto; }
.space-list button { display: flex; gap: 12px; width: 100%; padding: 10px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.space-list button:hover, .space-list button[aria-current="true"] { background: var(--sel); }
.space-list .k { font-weight: 600; min-width: 64px; }

/* ── Issue rows ───────────────────────────────────────────────── */
.issue-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 8px 10px; border-bottom: 1px solid var(--line); }
button.issue-row { width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); font: inherit; color: inherit; cursor: pointer; }
button.issue-row[aria-current="true"] { background: var(--sel); }
.issue-row .key { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.list-scroll.pick-list .issue-row { cursor: pointer; grid-template-columns: 22px 76px minmax(0, 1fr); align-items: center; }
.pick-list .issue-row:hover { background: var(--paper); }

/* ── The sheet: generated / reviewed documents ────────────────── */
.workspace { display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1100px) { .workspace { grid-template-columns: 1fr; } }
.sheet-wrap { display: grid; grid-template-columns: 168px minmax(0, 1fr); background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-box); min-height: 360px; overflow: hidden; }
@media (max-width: 700px) { .sheet-wrap { grid-template-columns: 1fr; } .spine { border-right: 0 !important; border-bottom: 1px solid var(--line); } }
.spine { border-right: 1px solid var(--line); padding: 18px 14px; font-size: 12px; }
.spine h3 { font-size: 12px; font-weight: 500; color: var(--ink-3); margin-bottom: 10px; }
.spine ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.spine li { display: grid; grid-template-columns: 16px 1fr; gap: 6px; color: var(--ink-2); line-height: 1.3; }
.spine li i { font-size: 15px; }
.spine li.ok i { color: var(--ok); } .spine li.warn i { color: var(--warn); } .spine li.err i { color: var(--err); } .spine li.idle i { color: var(--line-2); }
.sheet-main { padding: 22px 28px 26px; min-width: 0; }
.sheet-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.sheet-tools input { flex: 1 1 100%; font-family: var(--sans); font-size: 16px; font-weight: 600; }

.doc { font-family: var(--sans); font-size: 15px; line-height: 1.65; max-width: 72ch; overflow-wrap: anywhere; }
.doc h1, .doc h2, .doc h3 { font-family: var(--sans); font-weight: 600; margin: 1.5em 0 .4em; line-height: 1.3; }
.doc h2 { font-size: 14px; color: var(--ink-2); padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.doc h1 { font-size: 20px; } .doc h3 { font-size: 15px; }
.doc > :first-child { margin-top: 0; }
.doc p { margin: .6em 0; }
.doc ul, .doc ol { padding-left: 1.3em; margin: .5em 0; }
.doc code { font-family: var(--mono); font-size: .85em; background: var(--paper); padding: 1px 5px; border-radius: var(--r-sm); }
.doc pre { background: var(--paper); padding: 10px 12px; border-radius: var(--r); overflow-x: auto; }
.doc table { border-collapse: collapse; } .doc th, .doc td { border: 1px solid var(--line); padding: 4px 8px; }
.doc blockquote { margin: .6em 0; padding-left: 12px; border-left: 3px solid var(--warn); color: var(--ink-2); }
.verdict { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r); margin-bottom: 16px; font-weight: 500; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); } .verdict.warn { background: var(--warn-bg); color: var(--warn); } .verdict.err { background: var(--err-bg); color: var(--err); }

/* ── Choosers ─────────────────────────────────────────────────── */
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.seg button { padding: 6px 12px; background: var(--sheet); border: 1px solid var(--control-border); border-radius: var(--r); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--sel); border-color: var(--ink-2); font-weight: 600; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 8px; }
.tpl-grid button { text-align: left; padding: 8px 10px; background: var(--sheet); border: 1px solid var(--control-border); border-radius: var(--r); cursor: pointer; }
.tpl-grid button[aria-pressed="true"] { border-color: var(--ink-2); background: var(--sel); }
.drop { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px dashed var(--control-border); border-radius: var(--r); cursor: pointer; color: var(--ink-2); }
.drop:hover { border-color: var(--ink-3); }
.drop img { max-height: 64px; border-radius: var(--r-sm); }

/* ── Review ───────────────────────────────────────────────────── */
.review { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1100px) { .review { grid-template-columns: 1fr; } }
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.filters .wide { grid-column: 1 / -1; }
.list-scroll { max-height: 62vh; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-box); }
.list-scroll .issue-row { cursor: pointer; grid-template-columns: 70px minmax(0, 1fr); }
.list-scroll .issue-row .meta { grid-column: 2; display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--ink-3); }
.list-scroll .issue-row:hover { background: var(--paper); }
.list-scroll .issue-row[aria-current="true"] { background: var(--sel); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { padding: 8px 14px; border: 0; background: none; border-bottom: 2px solid transparent; cursor: pointer; color: var(--ink-2); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.chat { display: flex; flex-direction: column; gap: 12px; max-height: 52vh; overflow-y: auto; padding-bottom: 8px; }
.msg { max-width: 88%; padding: 9px 13px; border-radius: var(--r); background: var(--paper); }
.msg.user { align-self: flex-end; background: var(--sel); }
.msg .doc { font-family: var(--sans); font-size: 14px; }
.chat-input { display: flex; gap: 8px; margin-top: 12px; }
.chat-input textarea { min-height: 44px; }

/* ── Sprint ───────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--r-box); background: var(--sheet); margin-bottom: 16px; overflow: hidden; }
.kpi { padding: 14px 16px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: 0; }
.kpi b { display: block; font-size: 26px; font-weight: 600; line-height: 1.1; }
.kpi span { font-size: 13px; color: var(--ink-2); }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 44px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .track { height: 12px; background: var(--paper); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.bar-row .fill { height: 100%; border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--series-1); }
.bar-row .v { text-align: right; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.vel-row { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px; align-items: center; margin-bottom: 10px; font-size: 13px; }
.vel-pair { display: flex; flex-direction: column; gap: 2px; }
.vel-pair .track { display: flex; align-items: center; gap: 8px; }
.vel-pair .fill { height: 10px; border-radius: 0 var(--r-sm) var(--r-sm) 0; min-width: 2px; }
.vel-pair .fill.s1 { background: var(--series-1); } .vel-pair .fill.s2 { background: var(--series-2); }
.vel-pair b { font-weight: 500; font-variant-numeric: tabular-nums; font-size: 12px; }

/* ── Story map ────────────────────────────────────────────────── */
.cover { display: grid; grid-template-columns: 260px minmax(0, 1fr) 48px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.cover .track { height: 10px; background: var(--paper); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.cover .fill { height: 100%; background: var(--accent); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.map { width: 100%; border-collapse: collapse; }
.map th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.map td { vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.chip { display: block; margin-bottom: 4px; }
.chip .key { font-family: var(--mono); font-size: 12px; color: var(--accent); margin-right: 6px; }

/* ── Testbook ─────────────────────────────────────────────────── */
.steps { display: flex; gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.step { flex: 1; padding: 10px 14px; border-bottom: 3px solid var(--line); color: var(--ink-3); }
.step.active { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.step.done { border-color: var(--ok); color: var(--ink-2); }
.cov-row { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cov-axes { display: flex; flex-direction: column; gap: 4px; }
.axis { flex: 1; text-align: center; padding: 2px 4px; border-radius: var(--r-sm); font-size: 12px; }
.axis.ok { background: var(--ok-bg); color: var(--ok); } .axis.partial { background: var(--warn-bg); color: var(--warn); } .axis.missing { background: var(--err-bg); color: var(--err); }
.col-row { display: grid; grid-template-columns: 1fr 180px 1fr; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.sheet-tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }

/* ── Settings ─────────────────────────────────────────────────── */
.section-edit { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; gap: 6px; margin-bottom: 6px; }
.type-card { border: 1px solid var(--line); border-radius: var(--r-box); padding: 14px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }

@media print { .rail, .topbar, .sheet-tools, #toasts { display: none !important; } .app { display: block; height: auto; } .content { overflow: visible; } }

/* ── Accessibility ────────────────────────────────────────────── */
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; padding: 8px 14px; background: var(--accent); color: var(--on-accent); border-radius: var(--r); text-decoration: none; }
.skip:focus { top: 8px; }
h1:focus { outline: none; }
.sheet-tools input, input, select, textarea { min-height: 34px; }

/* ── Issue type mapping wizard ────────────────────────────────── */
.wiz-rows { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.wiz-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.wiz-row:last-child { border-bottom: 0; }
.wiz-pick { display: flex; flex-direction: column; gap: 6px; }
.wiz-naming { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin: 0 0 16px; }
.wiz-naming legend { padding: 0 6px; font-weight: 500; }
.radio { display: flex; gap: 10px; align-items: flex-start; padding: 4px 0; cursor: pointer; }
.radio input { width: auto; min-height: 0; margin-top: 3px; }
.notice { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--accent-bg); border-radius: var(--r); margin-bottom: 14px; }
.notice span { flex: 1; }
@media (max-width: 700px) { .wiz-row { grid-template-columns: 1fr; } }
input[type=radio], input[type=checkbox] { accent-color: var(--accent); }

/* ── Narrow screens (zoomed in or phones) ─────────────────────── */
.topbar { flex-wrap: wrap; row-gap: 6px; }
.topbar h1, .topbar p { min-width: 0; overflow-wrap: anywhere; }
.quiet-select { max-width: 9rem; }
@media (max-width: 520px) {
  #theme-btn span { display: none; }
  .topbar { padding-left: 12px; padding-right: 12px; }
  .panel-h { flex-wrap: wrap; }
  .row { flex-wrap: wrap; }
}
.cols-2 > *, .workspace > *, .review > * { min-width: 0; }
.panel-h h2 { min-width: 0; overflow-wrap: anywhere; }
.tabs { flex-wrap: wrap; }
.steps { flex-wrap: wrap; }
.step { min-width: 0; }
select, input[type=text], input[type=email], input[type=password], input[type=number], textarea { max-width: 100%; }
@media (max-width: 520px) {
  .cover { grid-template-columns: minmax(0, 1fr) 44px; }
  .cover > span { grid-column: 1 / -1; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
}

/* ── Account block (rail, hosted mode): pinned under the scrolling nav, above the status line ── */
.account { display: flex; flex-direction: column; align-items: stretch; gap: 2px; padding: 8px 8px 8px 10px; border-top: 1px solid var(--line); }
.account-id { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 4px; border-radius: var(--r); color: var(--ink); text-decoration: none; }
.account-id:hover { background: var(--sel); }
.avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--sel); display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.account-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.account-text strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-text small { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-out { flex: none; justify-content: flex-start; }
@media (max-width: 860px) {
  .account { align-items: center; padding: 8px 4px; gap: 4px; }
  .account-text, .account-out span { display: none; }
  .account-id { justify-content: center; flex: none; }
  .account-out { min-width: 44px; min-height: 44px; justify-content: center; padding: 0; }
}

/* ── Sign-in view ─────────────────────────────────────────────── */
.login { display: none; }
body[data-view="login"] .app, body[data-view="login"] #space-dialog, body[data-view="login"] .skip { display: none; }
/* Until /api/me answers we do not know whether to show the app or the sign-in: show neither (no flash of an empty dashboard). */
body[data-view="loading"] .app, body[data-view="loading"] #space-dialog, body[data-view="loading"] .skip, body[data-view="loading"] .login { display: none; }
body[data-view="login"] .login { display: grid; min-height: 100vh; place-items: center; padding: 24px 16px; }
.login-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px 28px 24px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-box); }
.login-tools { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin: -8px -10px 0 0; }
.login-card h1 { font-size: 24px; font-weight: 600; letter-spacing: -.01em; }
.login-lead { font-size: 15px; }
.login-message { padding: 10px 12px; background: var(--sel); border-radius: var(--r); font-size: 13px; }
.login-message:empty { display: none; }
.login-methods { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.login-btn, .login-sso-wrap > .btn { width: 100%; min-height: 44px; border-radius: var(--r-box); justify-content: flex-start; padding: 10px 14px; }
.login-btn .badge { margin-left: auto; }
.login-sso { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.login-sso label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.login-sso .row { flex-wrap: nowrap; align-items: stretch; }
.login-sso .btn.primary { min-width: 44px; justify-content: center; }
.logo { flex: none; width: 18px; height: 18px; background: center / contain no-repeat; }
.logo-google { background-image: url(/img/google.svg); }
.logo-microsoft { background-image: url(/img/microsoft.svg); }
.login-btn.google, .login-btn.microsoft { background: var(--sel); border-color: var(--sel); color: var(--ink); font-weight: 500; }
.login-btn.google:hover:not(:disabled), .login-btn.microsoft:hover:not(:disabled) { border-color: var(--ink-3); }
.login-sso-wrap > .sso-toggle { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 500; }
.login-sso-wrap > .sso-toggle:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
.login-sso input { flex: 1; min-width: 0; }

/* ── Settings → Account ───────────────────────────────────────── */
.methods { list-style: none; margin: 8px 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-box); overflow: hidden; }
.method { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.method:last-child { border-bottom: 0; }

.wiz-copy { max-width: 460px; margin-bottom: 16px; }

/* ── Demo mode: always visible while sample data is on ───────── */
.demo-banner { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 6px 28px; background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid var(--line); font-size: 13px; }
.demo-banner a { color: inherit; }
.demo-banner .btn { margin-left: auto; min-height: 28px; padding: 3px 10px; background: var(--sheet); color: var(--ink); }
.demo-list { list-style: none; margin: 0; padding: 0; }
.demo-item { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.demo-item:last-child { border-bottom: 0; }
.demo-item .hint { margin: 2px 0 10px; }
@media (max-width: 520px) { .demo-banner { padding-left: 12px; padding-right: 12px; } }
.login-person { display: flex; flex-direction: column; min-width: 0; text-align: left; line-height: 1.3; }
.login-person .muted { font-size: 12px; overflow-wrap: anywhere; }
.login-btn .badge { flex: none; }
