/* PURPOSE:      The Command Center look (ADR 0011, direction 8) for every screen: tokens,
 *               layout, and the few components the screens share. Low-vision mode (direction
 *               10) is the same tokens at a larger scale and higher contrast.
 * DEPENDS ON:   Manrope from Google Fonts, with system fallbacks.
 * USED BY:      site/src/index.html and every screen in site/src/js/screens/.
 * LAST AUDITED: 2026-10-28
 */

/* Layout: one phone-width column of cards over a cool ground, a sticky header with the company
   and person, and a tab bar at the bottom. Wider screens get a centered column. */

/* `hidden` always hides, whatever display a component's class sets. */
[hidden] { display: none !important; }
:root {
  --ground: #F4F6F9; --surface: #FFFFFF; --border: #E5E7EB; --text: #111827; --muted: #4B5563;
  --accent: #0E7490; --accent-ink: #FFFFFF; --accent-tint: #E2F1F5;
  --warn: #B45309; --warn-tint: #FBEFE2; --good: #047857; --good-tint: #E3F2EC; --bad: #B42318; --bad-tint: #FDECEA;
  --focus: #0E7490;
  --font-ui: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num: "Manrope", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --scale: 1; --radius: 12px; --radius-sm: 10px; --touch: 44px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0F1416; --surface: #172024; --border: #26323A; --text: #E6EDF0; --muted: #9AAAB2;
    --accent: #4FD1C5; --accent-ink: #0F1416; --accent-tint: #123033;
    --warn: #F5A25D; --warn-tint: #3A2817; --good: #5FD49A; --good-tint: #123227; --bad: #FF8A80; --bad-tint: #3A1714;
    --focus: #4FD1C5; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0F1416; --surface: #172024; --border: #26323A; --text: #E6EDF0; --muted: #9AAAB2;
  --accent: #4FD1C5; --accent-ink: #0F1416; --accent-tint: #123033;
  --warn: #F5A25D; --warn-tint: #3A2817; --good: #5FD49A; --good-tint: #123227; --bad: #FF8A80; --bad-tint: #3A1714;
  --focus: #4FD1C5; color-scheme: dark;
}
/* Low-vision mode: bigger type and targets, borders and muted text pushed toward full contrast. */
:root[data-display="large"] { --scale: 1.25; --touch: 56px; --muted: var(--text); --border: var(--text); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--text);
  font: 400 calc(15px * var(--scale)) / 1.45 var(--font-ui);
  -webkit-text-size-adjust: 100%;
}
.app { min-height: 100%; display: flex; flex-direction: column; }
.column {
  width: 100%; max-width: 760px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { font-size: calc(26px * var(--scale)); font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: calc(16px * var(--scale)); font-weight: 700; }
h3 { font-size: calc(15px * var(--scale)); font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: calc(13px * var(--scale)); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* Header: company and person, sticky under the phone's status bar. */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--ground);
  border-bottom: 1px solid var(--border);
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--ground); }
.topbar .column { padding-block: 10px; display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.who { display: flex; flex-direction: column; min-width: 0; }
.who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-button {
  min-height: var(--touch); padding: 0 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; display: inline-flex; align-items: center; gap: 6px;
}

main { flex: 1; padding-block: 18px 24px; display: flex; flex-direction: column; gap: 16px; }
main:focus { outline: none; }
.screen-head { display: flex; flex-direction: column; gap: 2px; }
.back { align-self: flex-start; }

/* Cards and grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile .label { font-size: calc(12px * var(--scale)); font-weight: 700; color: var(--muted); }
.tile .figure { font-size: calc(22px * var(--scale)); font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile .note { font-size: calc(12px * var(--scale)); color: var(--muted); }
.warn { color: var(--warn); }
.good { color: var(--good); }
.bad { color: var(--bad); }
@media (min-width: 620px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* Progress bars */
.bar { height: 10px; border-radius: 5px; background: var(--border); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 5px; background: var(--accent); }
.bar.over > span { background: var(--bad); }
.job-progress { display: flex; flex-direction: column; gap: 4px; }
.budget-row { padding: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.total-row { border-top: 2px solid var(--text); padding-top: 8px; font-weight: 800; }
.nowrap { white-space: nowrap; }
.row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.row > :first-child { min-width: 0; overflow-wrap: anywhere; }

/* Lists of tappable rows */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; }
.list-button {
  width: 100%; min-height: calc(64px * var(--scale)); padding: 10px 0; border: 0; background: none; color: inherit;
  font: inherit; text-align: left; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.list-button .stack { display: flex; flex-direction: column; min-width: 0; }
.list-button .stack > * { overflow-wrap: anywhere; }
.list-button .end { flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px; font-weight: 700; white-space: nowrap; }
.chevron { flex-shrink: 0; color: var(--muted); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: calc(12px * var(--scale)); font-weight: 700; }
.badge.good { background: var(--good-tint); color: var(--good); }
.badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.info { background: var(--accent-tint); color: var(--accent); }
.badge.bad { background: var(--bad-tint); color: var(--bad); }

/* Buttons */
.button {
  min-height: var(--touch); padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button.danger { color: var(--bad); }
.button:disabled { opacity: 0.55; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions .button { flex: 1 1 140px; }
.link-button { min-height: var(--touch); padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }

/* Disclosure: a summary that opens more detail, such as the full WIP schedule. */
details > summary { min-height: var(--touch); display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--accent); cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; width: 7px; height: 7px; margin-left: 2px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 0.15s; }
details[open] > summary::before { transform: rotate(45deg); }
details[open] > summary { margin-bottom: 6px; }

/* Messages */
.notice { padding: 12px 14px; border-radius: var(--radius-sm); display: flex; gap: 10px; align-items: flex-start; }
.notice.info { background: var(--accent-tint); }
.notice.warn { background: var(--warn-tint); }
.notice.bad { background: var(--bad-tint); }
.notice.good { background: var(--good-tint); }

/* Tables: scroll inside their own box, never the page. */
.table-wrap { overflow-x: auto; margin-inline: -14px; padding-inline: 14px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
caption { text-align: left; font-weight: 700; padding-bottom: 6px; }
th, td { padding: 8px 6px; border-top: 1px solid var(--border); text-align: left; vertical-align: top; }
thead th { border-top: 0; font-size: calc(12px * var(--scale)); color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
td.amount, th.amount { text-align: right; white-space: nowrap; }
tr.total td { font-weight: 800; border-top: 2px solid var(--text); }
tr.subtotal td { font-weight: 700; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: calc(13px * var(--scale)); font-weight: 700; }
input, select, textarea {
  min-height: calc(48px * var(--scale)); padding: 0 12px; border: 1px solid var(--muted); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: max(16px, calc(15px * var(--scale))); min-width: 0; width: 100%;
}
textarea { padding: 10px 12px; min-height: 88px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.segmented { display: flex; gap: 6px; flex-wrap: wrap; }
.segmented .button[aria-pressed="true"] { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }

/* Bottom tabs */
.tabbar { position: sticky; bottom: 0; z-index: 5; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabbar .column { display: grid; grid-template-columns: repeat(var(--tabs, 5), minmax(0, 1fr)); padding-block: 0; }
.tab {
  min-height: calc(60px * var(--scale)); border: 0; background: none; color: var(--muted); font: inherit;
  font-size: calc(12px * var(--scale)); font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; position: relative;
}
.tab[aria-current="page"] { color: var(--accent); font-weight: 800; }
.tab .count { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: #FFFFFF; font-size: 11px; line-height: 18px; font-weight: 800; }

/* Starting screen */
.splash { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 32px max(16px, env(safe-area-inset-left, 0px)); text-align: center; }
.splash .bar { width: min(320px, 80%); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
