/* Energetic Desk. Brand: teal #118692, blue #14599f, navy #0b1b2e. Archivo for headings, Inter for text. */
@font-face { font-family: 'Archivo'; font-weight: 600; font-display: swap; src: url('/fonts/archivo-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-weight: 700; font-display: swap; src: url('/fonts/archivo-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap; src: url('/fonts/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-display: swap; src: url('/fonts/inter-latin-600-normal.woff2') format('woff2'); }

:root {
  --teal: #118692;
  --teal-strong: #0d6d77;
  --blue: #14599f;
  --navy: #0b1b2e;
  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-2: #eaf0f3;
  --text: #0b1b2e;
  --muted: #55657a;
  --line: #d6dee5;
  --ok: #18794e;
  --warn: #9a5b00;
  --err: #b42318;
  --focus: #14599f;
  --radius: 12px;
  --tabbar-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --teal: #3fb7c3;
    --teal-strong: #5cc8d2;
    --blue: #6aa6e6;
    --navy: #171512;
    --bg: #1d1b18;
    --surface: #272522;
    --surface-2: #32302c;
    --text: #ece9e3;
    --muted: #a6a29a;
    --line: #3f3c37;
    --ok: #34a06d;
    --warn: #d9a441;
    --err: #f0675e;
    --focus: #8cc2ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: Archivo, Inter, system-ui, sans-serif; line-height: 1.2; }
a { color: var(--blue); }
code { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.break { word-break: break-all; display: block; padding: 8px; background: var(--surface-2); border-radius: 8px; margin: 8px 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.boot { display: grid; place-items: center; min-height: 100vh; font-family: Archivo, sans-serif; font-weight: 700; color: var(--muted); }

/* ---------- Shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-family: Archivo, sans-serif; font-weight: 700; }
.brand img { border-radius: 6px; background: #fff; }
.net { font-size: 13px; background: var(--warn); color: #fff; padding: 2px 10px; border-radius: 999px; }
.top-right { display: flex; align-items: center; gap: 6px; }
.net-alert { border: 0; font: inherit; font-size: 13px; background: var(--err); min-height: 32px; cursor: pointer; }
/* Dark, 28 Oct 2026 (R40): the ground colour is the text of every filled control; the bar has a hairline. */
@media (prefers-color-scheme: dark) {
  .net, .net-alert { color: var(--bg); }
  .topbar { border-bottom: 1px solid var(--line); }
}
main { max-width: 760px; margin: 0 auto; padding: 0 16px calc(var(--tabbar-h) + var(--safe-b) + 24px); }
main:focus { outline: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; min-height: 44px; }
.tabbar a[aria-current] { color: var(--teal); }
.tab-icon { font-size: 20px; line-height: 1; }

.page-title { font-size: 26px; margin: 18px 0 12px; }
h2 { font-size: 17px; margin: 24px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.loading, .empty { padding: 48px 0; text-align: center; color: var(--muted); }
.empty-line { color: var(--muted); margin: 4px 0 12px; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: 600 15px/1 Inter, system-ui, sans-serif; text-decoration: none; cursor: pointer;
}
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-primary { color: var(--bg); } }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--err); border-color: var(--err); }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: inherit; font-size: 18px; cursor: pointer; text-decoration: none; flex: none; }
.icon-btn.call { background: var(--teal); color: #fff; }
@media (prefers-color-scheme: dark) { .icon-btn.call { color: var(--bg); } } /* A74: as .btn-primary */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: 16px/1.4 Inter, system-ui, sans-serif;
}
textarea { resize: vertical; }
input.num { width: 90px; }
.field { display: block; margin: 0 0 14px; }
.field-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.field-hint { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0 0 14px; }
legend { font-weight: 600; font-size: 14px; padding: 0 4px; }

.searchbar { display: flex; gap: 8px; margin-bottom: 10px; }
.searchbar input { flex: 1; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.chip-btn { flex: none; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: 600 14px Inter, sans-serif; white-space: nowrap; }
.chip-btn[aria-pressed='true'] { background: var(--navy); border-color: var(--navy); color: #fff; }
@media (prefers-color-scheme: dark) { .chip-btn[aria-pressed='true'] { background: var(--teal); color: var(--bg); border-color: var(--teal); } }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text); margin-left: 4px; vertical-align: 1px; }
.chip-warn, .result-pending { background: #fff2d6; color: #7a4a00; }
.result-pass { background: #d9f2e4; color: #0f5a37; }
.result-fail { background: #fde2df; color: #8a1c12; }
.stage-0 { background: #fde2df; color: #8a1c12; }
.stage-1 { background: #e3eefa; color: #14599f; }
.stage-2 { background: #d8f1f3; color: #0d6d77; }
.stage-3 { background: #ece4fb; color: #5b3a9c; }
.stage-4 { background: #d9f2e4; color: #0f5a37; }
.stage-9 { background: var(--surface-2); color: var(--muted); }
/* Dark pills: tints, not the light fills (R40). .stage-9 stays on the tokens. */
@media (prefers-color-scheme: dark) {
  .stage-0, .result-fail { background: #4a2320; color: #ffa399; }
  .stage-1 { background: #1f2e42; color: #a9cbf2; }
  .stage-2 { background: #163639; color: #8fd9df; }
  .stage-3 { background: #312a46; color: #cbb8f0; }
  .stage-4, .result-pass { background: #17352a; color: #8fdcb1; }
  .chip-warn, .result-pending { background: #3e2f14; color: #f2c66d; }
}

/* ---------- Lists and cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; }
.card textarea, .card input { margin: 6px 0; }
.list { list-style: none; margin: 0 0 12px; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); min-height: 56px; }
.list > li:first-child { border-top: 0; }
.list > li > a:not(.icon-btn), .list > li > div, .row-button { flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.row-button { text-align: left; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.row-main { overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 14px; color: var(--muted); }
.nav-list .row-main { font-weight: 600; }
.plain { margin: 0; padding-left: 18px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.stats a { display: flex; flex-direction: column; padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: inherit; text-decoration: none; }
.stats strong { font: 700 26px/1.1 Archivo, sans-serif; color: var(--teal); }
.stats span { font-size: 13px; color: var(--muted); }

.alert { display: block; padding: 12px 14px; border-radius: var(--radius); margin: 0 0 10px; text-decoration: none; font-weight: 600; }
.alert-err { background: #fde2df; color: #8a1c12; }
@media (prefers-color-scheme: dark) { .alert-err { background: #4a2320; color: #ffa399; } } /* the bundle's; not in the R40 brief */
.alert a { color: inherit; text-decoration: underline; }

.lead-head { margin: -4px 0 4px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 8px; }
.facts dt { color: var(--muted); font-size: 14px; text-transform: capitalize; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
blockquote { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--teal); background: var(--surface-2); border-radius: 0 8px 8px 0; white-space: pre-wrap; }
.timeline { list-style: none; padding: 0 0 0 14px; margin: 0; border-left: 2px solid var(--line); }
.timeline li { margin: 0 0 12px; position: relative; white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline li::before { content: ''; position: absolute; left: -20px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.timeline .act-stage::before { background: var(--teal); }
.timeline .act-system::before, .timeline .act-escalation::before { background: var(--warn); }

/* ---------- Week view ---------- */
.weeknav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.week { display: grid; gap: 8px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.day.is-today { border-color: var(--teal); box-shadow: inset 4px 0 0 var(--teal); }
.day-head { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.visit { padding: 6px 0; border-top: 1px solid var(--line); }
.visit:first-of-type { border-top: 0; }
.visit a { color: inherit; text-decoration: none; }
@media (min-width: 900px) { .week { grid-template-columns: repeat(7, 1fr); } main { max-width: 1100px; } }

/* ---------- Proposal builder ---------- */
.boq-line { display: grid; grid-template-columns: 1fr 70px 60px 90px 44px; gap: 6px; margin-bottom: 6px; }
.boq-line input { width: 100%; padding: 8px; }
@media (max-width: 420px) { .boq-line { grid-template-columns: 1fr 1fr 1fr 44px; } .boq-line .boq-item { grid-column: 1 / -1; } }
.preview { white-space: pre-wrap; background: var(--surface-2); padding: 10px; border-radius: 8px; font: 14px/1.45 Inter, sans-serif; }

/* ---------- Sheets and toasts ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; background: rgb(0 0 0 / 0); display: flex; align-items: flex-end; justify-content: center; transition: background 0.2s; }
.sheet-wrap.open { background: rgb(0 0 0 / 0.45); }
.sheet { width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; background: var(--bg); border-radius: 16px 16px 0 0; padding: 0 16px calc(16px + var(--safe-b)); transform: translateY(100%); transition: transform 0.2s ease-out; }
.sheet-wrap.open .sheet { transform: none; }
.sheet-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; background: var(--bg); padding: 12px 0 8px; }
.sheet-head h2 { margin: 0; }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-wrap, .toast { transition: none; } }

/* A74: --hint-h is the install hint's height plus a gap while it is shown (app.ts), so the toast clears it. */
.toast { white-space: pre-line; position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px + var(--hint-h, 0px)); z-index: 40; transform: translate(-50%, 20px); opacity: 0; transition: 0.25s; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px; background: var(--navy); color: #fff; font-weight: 600; font-size: 15px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.25); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-ok { background: var(--ok); }
.toast-err { background: var(--err); }
@media (prefers-color-scheme: dark) {
  .toast { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
  .toast-ok { background: var(--ok); color: var(--bg); border-color: var(--ok); }
  .toast-err { background: var(--err); color: var(--bg); border-color: var(--err); }
}

.install-hint { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px); z-index: 20; display: flex; align-items: center; gap: 8px; padding: 10px 6px 10px 14px; border-radius: 12px; background: var(--navy); color: #fff; font-size: 14px; }
.install-hint span { flex: 1; }
@media (prefers-color-scheme: dark) { .install-hint { border: 1px solid var(--line); } }

/* ---------- Sign-in ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(var(--safe-t) + 24px) 16px 24px; background: var(--navy); color: #fff; }
.auth h1 { margin: 12px 0 20px; font-size: 24px; }
.auth-logo { border-radius: 14px; background: #fff; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); color: var(--text); border-radius: 16px; padding: 20px; }
.auth-card .btn { width: 100%; margin-top: 8px; }
.code-input { font: 600 28px/1 ui-monospace, Menlo, monospace; letter-spacing: 0.4em; text-align: center; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 16px 0; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--teal); }
.pin-dots span.on { background: var(--teal); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-key { min-height: 56px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: 600 22px Inter, sans-serif; cursor: pointer; }
