/* TenderCapture: one stylesheet, mobile first, no external fonts or hosts (the CSP allows style-src 'self' only).
   Colours live in tokens on :root; the dark palette swaps the tokens and nothing else.
   Every class below is shown on /styleguide. Tap targets are 44px (--tap). */
:root {
  color-scheme: light dark;
  --bg: #f4f6f8; --surface: #ffffff; --text: #15191f; --muted: #4a5565;
  --line: #d5dbe3; --line-strong: #6b7686; --track: #dfe5ec; --chip: #e8ecf1;
  --accent: #0a5aa8; --on-accent: #ffffff; --danger: #a6261c; --on-danger: #ffffff;
  --ok: #14683c; --ok-bg: #e3f4ea; --warn: #7a4a00; --warn-bg: #fdf0d5;
  --bad: #a6261c; --bad-bg: #fbe5e3; --info: #0a5aa8; --info-bg: #e1edf9;
  --tap: 44px; --nav-h: 56px; --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1218; --surface: #171d26; --text: #e8ecf1; --muted: #a0abb9;
    --line: #2c3542; --line-strong: #7a8697; --track: #2a3441; --chip: #263040;
    --accent: #7ab8ff; --on-accent: #07111d; --danger: #ff9189; --on-danger: #2b0a07;
    --ok: #6fdca0; --ok-bg: #12301f; --warn: #f2c46b; --warn-bg: #3a2b0b;
    --bad: #ff9a92; --bad-bg: #3d1613; --info: #8fc4ff; --info-bg: #14283f;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 1rem/1.5 var(--font);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 1rem);
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); text-underline-offset: 2px; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: .5rem 0 1rem; }
h2 { font-size: 1.2rem; line-height: 1.3; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1.05rem; line-height: 1.3; margin: 1rem 0 .5rem; }
p, li { max-width: 70ch; }
.muted { color: var(--muted); }
pre { overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
header.top {
  position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; column-gap: .75rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top, 0px) max(1rem, env(safe-area-inset-right, 0px)) 0 max(1rem, env(safe-area-inset-left, 0px));
}
.brand { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 700; color: var(--text); text-decoration: none; }
.who { margin-left: auto; min-width: 0; font-size: .85rem; color: var(--muted); text-align: right; overflow-wrap: anywhere; }
form.inline { display: inline; margin: 0; }
button.link {
  min-height: var(--tap); padding: 0 .5rem; background: none; border: 0; border-radius: 0; color: var(--accent);
  font: inherit; font-weight: 400; text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}

/* Page body: single column */
main {
  max-width: 60rem; margin: 0 auto; padding: 1rem max(1rem, env(safe-area-inset-right, 0px)) 1rem max(1rem, env(safe-area-inset-left, 0px));
}
.stack > * + * { margin-top: 1rem; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .75rem 0; border-bottom: 1px solid var(--line); min-height: var(--tap); }

/* Bottom navigation: five items, always reachable by thumb */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav a {
  display: flex; align-items: center; justify-content: center; min-height: var(--nav-h); padding: 0 .25rem;
  border-top: 3px solid transparent; color: var(--muted); font-size: .8rem; text-align: center; text-decoration: none;
}
.bottom-nav a.on { color: var(--accent); border-top-color: var(--accent); font-weight: 700; }

/* Buttons */
button, .button, input[type="submit"] {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 1.1rem;
  background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent); border-radius: var(--radius);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.danger, .button.danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
button:disabled, .button[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* Forms: 16px text so phones do not zoom, 44px high */
label { display: block; font-weight: 600; }
input, select, textarea {
  display: block; width: 100%; min-height: var(--tap); margin-top: .25rem; padding: .6rem .75rem;
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius); font: inherit;
}
input[type="hidden"] { display: none; }
textarea { min-height: 7rem; }
label.check { display: flex; align-items: center; gap: .75rem; min-height: var(--tap); font-weight: 400; }
input[type="checkbox"], input[type="radio"] { width: 1.4rem; height: 1.4rem; min-height: 0; margin: 0; accent-color: var(--accent); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem 1rem 1rem; }
legend { padding: 0 .5rem; font-weight: 600; }

/* Flash messages */
.flash, .error {
  margin: 1rem 0; padding: .75rem 1rem; border-left: 5px solid var(--info); border-radius: var(--radius);
  background: var(--info-bg); color: var(--info);
}
.flash.ok { border-left-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.flash.warn { border-left-color: var(--warn); background: var(--warn-bg); color: var(--warn); }
.flash.error, .error { border-left-color: var(--bad); background: var(--bad-bg); color: var(--bad); }

/* Status chips */
.chip {
  display: inline-flex; align-items: center; min-height: 1.75rem; padding: 0 .7rem; border-radius: 999px;
  background: var(--chip); color: var(--text); font-size: .8rem; font-weight: 600; text-decoration: none; white-space: nowrap;
}
a.chip, button.chip { min-height: var(--tap); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); }

/* Cards (the inbox). data-swipe-left / data-swipe-right name the action; app.js adds the gesture. */
.cards { display: grid; gap: .75rem; }
.card {
  position: relative; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transform: translateX(var(--dx, 0px)); transition: transform .2s ease, box-shadow .2s ease;
}
.card[data-swipe-left], .card[data-swipe-right] { touch-action: pan-y; }
.card.swiping { transition: none; user-select: none; -webkit-user-select: none; }
.card.swipe-right { box-shadow: inset 8px 0 0 var(--ok); }
.card.swipe-left { box-shadow: inset -8px 0 0 var(--bad); }
.card.armed.swipe-right { box-shadow: inset 20px 0 0 var(--ok); }
.card.armed.swipe-left { box-shadow: inset -20px 0 0 var(--bad); }
.card h3 { margin: 0 0 .25rem; }
.card h3 a { display: flex; align-items: center; min-height: var(--tap); color: var(--text); }
.card .meta { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; color: var(--muted); font-size: .9rem; }
.card .actions, .actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.actions > form { display: flex; flex: 1 1 100%; flex-wrap: wrap; gap: .5rem; margin: 0; }
.actions button, .actions .button { flex: 1 1 7rem; }

/* Inline confirmation (app.js, for buttons with data-confirm; never window.confirm) */
.confirm {
  flex: 1 1 100%; margin-top: .75rem; padding: .75rem 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); border-radius: var(--radius);
}
.confirm p { flex: 1 1 100%; margin: 0; font-weight: 600; }
.confirm button { flex: 1 1 7rem; }

/* Score components: one bar per component, value on the right */
.score { display: grid; gap: .25rem; }
.score-row { display: grid; grid-template-columns: minmax(5.5rem, 35%) 1fr 3rem; align-items: center; gap: .75rem; min-height: 2rem; }
.score-val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.score-total { font-size: 1.2rem; font-weight: 700; }
progress.bar { appearance: none; -webkit-appearance: none; width: 100%; height: .75rem; border: 0; border-radius: 999px; overflow: hidden; background: var(--track); color: var(--accent); }
progress.bar::-webkit-progress-bar { background: var(--track); }
progress.bar::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress.bar::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
progress.bar.ok::-webkit-progress-value { background: var(--ok); }
progress.bar.ok::-moz-progress-bar { background: var(--ok); }
progress.bar.warn::-webkit-progress-value { background: var(--warn); }
progress.bar.warn::-moz-progress-bar { background: var(--warn); }
progress.bar.bad::-webkit-progress-value { background: var(--bad); }
progress.bar.bad::-moz-progress-bar { background: var(--bad); }

/* Tables scroll sideways inside their own container, never the page */
.table-wrap, .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table-wrap table, .table-scroll table { width: 100%; min-width: 34rem; border-collapse: collapse; }
th, td { padding: .6rem .75rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .8rem; font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

/* Requirement split: one column per firm, stacked on phones */
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.col { min-width: 0; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.col h3 { margin-top: 0; }
@media (min-width: 48rem) {
  .split { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Calendar: on phones the month view is its list (.cal-agenda); the grid shows from 40rem up */
@media (max-width: 39.99rem) {
  .cal-grid { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
}

/* evidence-first writing (src/web/pages/writing.js) */
.draft-view { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; }
.draft-view mark.uncited { background: var(--warn-bg); color: var(--warn); text-decoration: underline wavy; }
.draft-view mark.bad-ref { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.innsyn-text { font-family: inherit; }

/* passkeys and offline reading (src/web/pages/passkeys.js, src/web/static/passkey.js, app.js, sw.js; P20) */
.passkey-box [hidden] { display: none; }
.passkey-status:empty { display: none; }
.passkey-status { color: var(--muted); }
.offline-banner, .offline-queue, .offline-results { margin: 0 0 1rem; padding: .5rem .75rem; border-left: 4px solid var(--info); background: var(--info-bg); color: var(--info); border-radius: var(--radius); }
.offline-banner { border-left-color: var(--warn); background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.offline-results { white-space: pre-line; }
/* footer line on every page: data attribution, /sources, /privacy (P24) */
.site-foot { max-width: 60rem; margin: 0 auto; padding: 0 1rem 1rem; color: var(--muted); font-size: .8rem; text-align: center; }
.site-foot a { color: inherit; }
/* threaded comments on the tender page: replies indented under their top comment (P26, D.3) */
.list.replies { margin: .5rem 0 0 1rem; padding-left: .75rem; border-left: 2px solid var(--line); }
.list.replies li:last-child { border-bottom: 0; }
