:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-2: #efece6;
  --ink: #1b2027;
  --ink-2: #444d58;
  --muted: #69727d;
  --line: #dedad2;
  --accent: #1d5fa8;
  --accent-ink: #ffffff;
  --go: #176b4d;
  --go-ink: #ffffff;
  --dark: #222a33;
  --dark-ink: #ffffff;
  --good: #1b7a4f;  --good-bg: #e3f2ea;
  --warn: #9a5800;  --warn-bg: #fbefd9;
  --bad: #b3352b;   --bad-bg: #fbe5e2;
  --info: #56606b;  --info-bg: #eceae5;
  --prog: #1d5fa8;  --prog-bg: #e2ecf8;
  --bar: #3b6fae;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 30, .06), 0 2px 8px rgba(20, 24, 30, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181d; --surface: #1d232a; --surface-2: #262d35; --ink: #eef1f4; --ink-2: #c3cad2; --muted: #9aa3ad; --line: #333b45;
    --accent: #6ea8ec; --accent-ink: #0d1520; --go: #3fb07f; --go-ink: #07160f; --dark: #e9edf1; --dark-ink: #14181d;
    --good: #5fcf98; --good-bg: #173326; --warn: #f0b45c; --warn-bg: #3a2c14; --bad: #f08a80; --bad-bg: #3d1e1b;
    --info: #b0b8c1; --info-bg: #2a3038; --prog: #8bbcf2; --prog-bg: #1d2e44; --bar: #7aa7dc;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
body.noscroll { overflow: hidden; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .9rem; color: var(--ink-2); margin-top: 1rem; }
p { margin: 0 0 .8em; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.logo { width: 22px; height: 22px; border-radius: 50%; background: var(--go); position: relative; flex: none; }
.logo::after { content: ""; position: absolute; left: 10px; top: 5px; width: 2px; height: 7px; background: #fff; box-shadow: 2px 6px 0 0 transparent; transform-origin: bottom; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; flex: none; }
.lang button { border: 0; background: transparent; padding: 6px 12px; min-height: 44px; cursor: pointer; font-size: .9rem; }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--bg); font-weight: 600; }
.demo-bar { background: var(--surface-2); color: var(--ink-2); font-size: .85rem; padding: 6px 16px; text-align: center; }
.demo-bar.warn { background: var(--warn-bg); color: var(--warn); }
.whobar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 16px; font-size: .9rem; color: var(--ink-2); max-width: 1100px; margin: 0 auto; }
.link { border: 0; background: none; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 10px 4px; min-height: 44px; font-size: inherit; }
.demo-bar .link { padding: 4px; min-height: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { padding: 16px; margin: 0 auto; }
.wrap.narrow { max-width: 520px; }
.wrap.wide { max-width: 1100px; padding-bottom: 96px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.lead { font-size: 1.1rem; color: var(--ink-2); }
.hint { margin-top: 16px; font-size: .9rem; color: var(--ink-2); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.error { color: var(--bad); font-weight: 600; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; margin-top: 12px; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2, .grid3 { display: grid; gap: 12px; grid-template-columns: 1fr; }
.grid2 > *, .grid3 > * { min-width: 0; }
.field input[type=datetime-local] { min-width: 0; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid3 { grid-template-columns: 1fr 1fr 1fr; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; box-shadow: var(--shadow); }
.card.inactive, li.inactive { opacity: .55; }
.card.inactive { background: var(--surface-2); }
.section { margin-top: 24px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.small { min-height: 44px; padding: 4px 14px; font-size: .9rem; }
.btn.big { min-height: 52px; font-size: 1.05rem; }
.btn.huge { width: 100%; min-height: 72px; font-size: 1.35rem; border-radius: 16px; margin-top: 12px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.go { background: var(--go); color: var(--go-ink); border-color: transparent; }
.btn.dark { background: var(--dark); color: var(--dark-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.danger-solid { background: var(--bad); color: #fff; border-color: transparent; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--ink-2); border: 0; padding: 0; margin: 0; }
.field legend { padding: 0; margin-bottom: 6px; }
.field input, .field select, .field textarea, .inline input {
  min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-size: 1rem; width: 100%;
}
.inline { display: flex; gap: 8px; margin: 12px 0; }
.inline input { flex: 1; min-width: 0; }
@media (max-width: 420px) { .inline { flex-direction: column; } .inline .btn { align-self: flex-start; } }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; margin: 16px 0; }
.seg button { flex: 1; border: 0; background: transparent; min-height: 44px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.namegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.namebtn { min-height: 60px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; font-weight: 600; cursor: pointer; display: flex; flex-direction: column; justify-content: center; }
.namebtn small { font-weight: 400; color: var(--accent); font-size: .78rem; }

.pin { text-align: center; }
.pin .back { display: block; text-align: left; margin-bottom: 8px; }
.dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0; }
.dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink-2); }
.dot.on { background: var(--ink); border-color: var(--ink); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; margin: 16px auto 0; }
.key { min-height: 64px; font-size: 1.5rem; font-weight: 600; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.key.ok { background: var(--go); color: var(--go-ink); border-color: transparent; font-size: 1.15rem; }
.key:active { transform: scale(.97); }

.status .eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; font-weight: 700; margin-bottom: 4px; }
.status.on { border-left: 6px solid var(--go); }
.status.on .eyebrow { color: var(--go); }
.status.off .eyebrow { color: var(--muted); }
.sitelist { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px; }
.sitebtn { text-align: left; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-height: 64px; }
.sitebtn span { color: var(--muted); font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; color: var(--ink); }
.chip[aria-pressed="true"], .chip:has(input:checked) { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip[aria-pressed="true"]::before { content: "✓"; }
.chip input { width: 18px; height: 18px; margin: 0; accent-color: var(--go); }
.done .big-ico { width: 64px; height: 64px; border-radius: 50%; margin: 4px auto 12px; display: grid; place-items: center; font-size: 2rem; background: var(--good-bg); color: var(--good); }
.daylist { list-style: none; padding: 0; margin: 8px 0 0; }
.daylist li { display: grid; grid-template-columns: 6.5em 1fr auto; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: .92rem; align-items: baseline; }

.notice { display: flex; gap: 10px; padding: 12px; border-radius: 12px; margin: 12px 0; font-size: .95rem; }
.notice .ico { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .85rem; }
.notice.warn { background: var(--warn-bg); }
.notice.warn .ico { background: var(--warn); color: var(--surface); }
.notice.bad { background: var(--bad-bg); }
.notice.bad .ico { background: var(--bad); color: var(--surface); }
.notice .row { margin-top: 8px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; text-align: center; padding: 14px 4px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .92rem; border-top: 3px solid transparent; }
.tabs a[aria-current="page"] { color: var(--ink); border-top-color: var(--accent); }
@media (min-width: 900px) {
  .tabs { position: sticky; top: 57px; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); justify-content: center; }
  .tabs a { flex: 0 0 auto; padding: 12px 24px; border-top: 0; border-bottom: 3px solid transparent; }
  .tabs a[aria-current="page"] { border-bottom-color: var(--accent); }
  .wrap.wide { padding-bottom: 32px; }
}

.reporthead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.daynav { display: flex; align-items: center; gap: 6px; }
.daynav .btn.ghost { min-width: 44px; font-size: 1.3rem; }
.daynav h1 { margin: 0 4px; font-size: 1.25rem; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0 0 16px; }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tiles > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.tiles dt { font-size: .82rem; color: var(--muted); }
.tiles dd { margin: 2px 0 0; font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tiles .attn { border-color: var(--warn); background: var(--warn-bg); }
.tiles .attn dd { color: var(--warn); }
.sitegrid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .sitegrid { grid-template-columns: 1fr 1fr; } .sitegrid .card { margin: 0; } }
.site header { margin-bottom: 8px; }
.site header h3 { margin-bottom: 2px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--info-bg); color: var(--info); white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.progress { background: var(--prog-bg); color: var(--prog); }
.pill.ms, .people .pill { white-space: normal; }
.people li > span.row { flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 10px; }
.stats dt { font-size: .78rem; color: var(--muted); }
.stats dd { margin: 0; font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.meter { display: block; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter > * { display: block; height: 100%; border-radius: 999px; background: var(--good); }
.meter.warn > * { background: var(--warn); }
.meter.bad > * { background: var(--bad); }
.site .row.between { margin-top: 6px; }
details { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.crew { list-style: none; padding: 0; margin: 4px 0 0; }
.crew li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.crew li > div { display: flex; flex-direction: column; min-width: 0; }
.crew .times { text-align: right; font-size: .85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.readylist, .mslist, .simplelist { list-style: none; padding: 0; margin: 8px 0 0; }
.readylist li, .mslist li, .simplelist li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.readylist li > div, .people li > div { display: flex; flex-direction: column; gap: 2px; }
.ready { border-left: 6px solid var(--warn); }

.hbars { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 10px; }
.hbars li { display: grid; grid-template-columns: minmax(7em, 34%) 1fr 3.5em; gap: 10px; align-items: center; font-size: .9rem; }
.hbars .lbl { overflow: hidden; text-overflow: ellipsis; }
.hbars .bar { height: 18px; background: transparent; }
.hbars .bar > span { display: block; height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbars .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

#sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.scrim { position: absolute; inset: 0; background: rgba(10, 12, 16, .45); }
.sheet { position: relative; background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { #sheet { align-items: center; } .sheet { border-radius: 18px; } }
#toast { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); width: max-content; text-align: center; background: var(--dark); color: var(--dark-ink); padding: 12px 18px; border-radius: 12px; z-index: 30; max-width: calc(100% - 32px); box-shadow: 0 4px 16px rgba(0,0,0,.2); font-weight: 600; }

@media print {
  .top, .demo-bar, .whobar, .tabs, .btn, .reporthead .row, #toast, #sheet { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
  details { display: block; }
  details > *:not(summary) { display: block !important; }
  .wrap.wide { padding: 0; }
}
