/* ---------- Design tokens ----------
   Every colour lives here. data-theme = light | dark | system, data-cb = on | off (set on <html> by boot.js/app.js).
   Status colours are semantic (--ok / --bad / --pend); the colour-blind palette swaps them for Okabe-Ito blue/orange,
   and every status also carries an icon + text, so colour is never the only signal. */
:root {
  color-scheme: light;
  --bg: #EEF2F3; --card: #fff; --soft: #f4f6f8; --hover: #f8fafb; --input: #fff;
  --text: #1d2329; --muted: #66717c; --line: #e6eaee; --line-strong: #c8d2da;
  --accent: #E8601C; --accent-hover: #d4540f; --accent-soft: #fff6f0; --on-accent: #fff;
  --navy: #2F5D8A; --slate: #9DB3C8; --bar-text: #fff; --track: #f0f2f4; --sched-used: #8f9aa5;
  --today: #FBF1D3; --today-line: #eedfae;
  --sel-bg: #eaf1f8; --avatar-bg: #e3ebf3;
  --focus: #1f6fd1;
  --shadow: 0 1px 3px rgba(20,30,40,.08); --shadow-lg: 0 10px 40px rgba(0,0,0,.2);
  --overlay: rgba(40,50,60,.45); --tip-bg: #1d2329; --tip-text: #fff;
  --xls: #1f7a45; --pill: #eef0f2;
  /* status semantics */
  --ok: #1e7a49; --ok-bg: #e3f4ea;
  --bad: #b42318; --bad-bg: #fdecea;
  --warn: #a8530f; --warn-bg: #fdeee2;     /* "behind" */
  --pend: #475467; --pend-bg: #eef1f5;     /* submitted / pending */
  --hatch: rgba(255,255,255,.55);
  --danger: #b42318; --danger-hover: #912018; --on-danger: #fff;   /* destructive buttons (delete) */
}
:root[data-cb="on"] {
  --ok: #005a8e; --ok-bg: #e1effa;         /* Okabe-Ito blue */
  --bad: #a64200; --bad-bg: #fbe9dc;       /* Okabe-Ito vermillion, darkened for text contrast */
  --warn: #a64200; --warn-bg: #fbe9dc;
  --pend: #5b4a00; --pend-bg: #fbf4cc;     /* Okabe-Ito yellow family */
  --navy: #0072B2; --slate: #a9c7dd;
  --danger: #a64200; --danger-hover: #853500;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1419; --card: #182028; --soft: #212a33; --hover: #1e2730; --input: #121920;
  --text: #e4e9ee; --muted: #9ba7b3; --line: #2b3540; --line-strong: #3d4a57;
  --accent: #E8692A; --accent-hover: #f07d43; --accent-soft: #2e1e14; --on-accent: #fff;
  --navy: #3f73a8; --slate: #33495f; --bar-text: #fff; --track: #2a333d; --sched-used: #6f7c89;
  --today: #2f2a17; --today-line: #574a1f;
  --sel-bg: #1d2f42; --avatar-bg: #24384d;
  --focus: #7db4ff;
  --shadow: 0 1px 2px rgba(0,0,0,.5); --shadow-lg: 0 12px 40px rgba(0,0,0,.6);
  --overlay: rgba(0,0,0,.6); --tip-bg: #e4e9ee; --tip-text: #0f1419;
  --xls: #2b8f55; --pill: #26303a;
  --ok: #6fd39b; --ok-bg: #163324;
  --bad: #ff8a80; --bad-bg: #3d1b18;
  --warn: #f2a65e; --warn-bg: #3a2614;
  --pend: #c3ccd6; --pend-bg: #28313b;
  --hatch: rgba(255,255,255,.28);
  --danger: #c4392b; --danger-hover: #a93224; --on-danger: #fff;
}
:root[data-theme="dark"][data-cb="on"] {
  --ok: #7cc4f0; --ok-bg: #10293a; --bad: #f5b041; --bad-bg: #3a2a0c; --warn: #f5b041; --warn-bg: #3a2a0c;
  --pend: #f0e68c; --pend-bg: #2f2c12; --navy: #2f86c4; --slate: #2c4a62;
  --danger: #b04a00; --danger-hover: #943e00;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #0f1419; --card: #182028; --soft: #212a33; --hover: #1e2730; --input: #121920;
    --text: #e4e9ee; --muted: #9ba7b3; --line: #2b3540; --line-strong: #3d4a57;
    --accent: #E8692A; --accent-hover: #f07d43; --accent-soft: #2e1e14; --on-accent: #fff;
    --navy: #3f73a8; --slate: #33495f; --bar-text: #fff; --track: #2a333d; --sched-used: #6f7c89;
    --today: #2f2a17; --today-line: #574a1f;
    --sel-bg: #1d2f42; --avatar-bg: #24384d;
    --focus: #7db4ff;
    --shadow: 0 1px 2px rgba(0,0,0,.5); --shadow-lg: 0 12px 40px rgba(0,0,0,.6);
    --overlay: rgba(0,0,0,.6); --tip-bg: #e4e9ee; --tip-text: #0f1419;
    --xls: #2b8f55; --pill: #26303a;
    --ok: #6fd39b; --ok-bg: #163324;
    --bad: #ff8a80; --bad-bg: #3d1b18;
    --warn: #f2a65e; --warn-bg: #3a2614;
    --pend: #c3ccd6; --pend-bg: #28313b;
    --hatch: rgba(255,255,255,.28);
  --danger: #c4392b; --danger-hover: #a93224; --on-danger: #fff;
  }
  :root[data-theme="system"][data-cb="on"] {
    --ok: #7cc4f0; --ok-bg: #10293a; --bad: #f5b041; --bad-bg: #3a2a0c; --warn: #f5b041; --warn-bg: #3a2a0c;
    --pend: #f0e68c; --pend-bg: #2f2c12; --navy: #2f86c4; --slate: #2c4a62;
  --danger: #b04a00; --danger-hover: #943e00;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 14px; height: 14px; flex: none; vertical-align: -2px; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; }
.plain { list-style: none; margin: 0; padding: 0; }
.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;
}

/* Visible focus for keyboard users everywhere. */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--card); color: var(--text);
  padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg);
}
.skip:focus { top: 12px; }

/* Header */
.top { background: var(--card); border-bottom: 1px solid var(--line); padding: 0 24px; }
.top-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 8px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* Logo: two images, one per theme, following data-theme (system = prefers-color-scheme), not just the OS setting. */
.logo { display: block; height: 30px; width: auto; flex: none; }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .logo-light { display: none; }
  :root[data-theme="system"] .logo-dark { display: block; }
}
.brand-name { font-size: 18px; font-weight: 600; white-space: nowrap; }
.pill-grey { background: var(--pill); color: var(--muted); font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.top-right { display: flex; align-items: center; gap: 16px; min-width: 0; }
.asof { color: var(--muted); font-size: 12px; white-space: nowrap; }
.asof b { color: var(--text); }
.user { display: flex; align-items: center; gap: 8px; }
.user .who { text-align: right; line-height: 1.2; }
.user .who .nm { font-weight: 600; font-size: 13px; }
.user .who .rl { font-size: 11px; color: var(--muted); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; min-width: 36px;
  background: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; color: var(--text);
}
.icon-btn:hover { background: var(--soft); }
.icon-btn svg { width: 16px; height: 16px; flex: none; }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs a {
  padding: 10px 12px; color: var(--muted); text-decoration: none;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.count {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px; border-radius: 999px; font-size: 11px;
  background: var(--accent); color: var(--on-accent); text-align: center; font-weight: 600;
}

.wrap { max-width: 1320px; margin: 0 auto; padding: 24px 24px 60px; }
.wrap:focus { outline: none; }
.wrap[aria-busy="true"] { cursor: progress; }
.busy-bar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 90; overflow: hidden; pointer-events: none; }
.busy-bar::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 30%; background: var(--accent);
  animation: busy 1s ease-in-out infinite;
}
@keyframes busy { from { left: -30%; } to { left: 100%; } }
.loading::before {
  content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px;
  border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s 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: none !important; }
}
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px 0 18px; }
.page-head h1 { font-size: 24px; margin: 0; }
.page-head .spacer { flex: 1; }
.card { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card + .card, .stack > * + * { margin-top: 16px; }
h2 { font-size: 16px; margin: 0 0 4px; }
h3 { font-size: 14px; margin: 0; }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .big { font-size: 15px; color: var(--text); font-weight: 600; margin-bottom: 4px; }
.state-err { border-left: 4px solid var(--bad); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px;
  border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 7px 14px; font-weight: 500;
  color: var(--text); text-decoration: none;
}
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: .5; }
.btn:disabled:hover { background: var(--card); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled:hover { background: var(--accent); }
.btn-ok { color: var(--ok); border-color: currentColor; }
.btn-bad { color: var(--bad); border-color: currentColor; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); font-weight: 600; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-danger:disabled:hover { background: var(--danger); }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; min-height: 48px; }
.link { background: none; border: 0; padding: 0; color: var(--navy); text-decoration: underline; }
:root[data-theme="dark"] .link { color: #8fbbe8; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Status chips: always icon + text. */
.status, .chip-st {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  font-weight: 600; white-space: nowrap; line-height: 16px;
}
.status svg, .chip-st svg { width: 11px; height: 11px; flex: none; }
.status.behind { background: var(--warn-bg); color: var(--warn); }
.status.on_track { background: var(--ok-bg); color: var(--ok); }
.chip-st.ok { background: var(--ok-bg); color: var(--ok); }
.chip-st.bad { background: var(--bad-bg); color: var(--bad); }
.chip-st.pend { background: var(--pend-bg); color: var(--pend); }
.chip-st.off { background: var(--pill); color: var(--muted); }

/* Gantt */
.gantt-scroll { overflow-x: auto; border-radius: 12px 12px 0 0; }
.gantt { display: grid; position: relative; }
.g-cell { border-bottom: 1px solid var(--line); min-height: 34px; }
.g-month { font-size: 12px; font-weight: 600; padding: 10px 6px 4px; white-space: nowrap; border-bottom: 0; min-height: 0; }
.g-dayh { font-size: 11px; color: var(--muted); text-align: center; padding: 8px 0; background: var(--soft); }
.g-dayh.today { font-weight: 700; color: var(--text); }
.g-left {
  position: sticky; left: 0; z-index: 3; background: var(--card); padding: 10px 14px; border-right: 1px solid var(--line);
}
.g-left.head { background: var(--soft); font-size: 11px; color: var(--muted); display: flex; align-items: center; }
.g-left.blank { border-bottom: 0; }
button.g-row-left {
  display: block; width: 100%; text-align: left; border-top: 0; border-left: 0; border-radius: 0; cursor: pointer;
}
.g-row-left:hover { background: var(--hover); }
.g-row-left:focus-visible { outline-offset: -3px; border-radius: 0; }
.g-row-left .t { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.g-row-left .n { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-day { min-height: 62px; }
.today { background: var(--today); }
.wk { border-left: 1px solid var(--line); }
.g-bar {
  z-index: 2; align-self: center; height: 30px; margin: 0 2px; border-radius: 5px; background: var(--slate);
  position: relative; overflow: hidden; cursor: pointer;
}
/* Behind: hatched remainder + warning marker, so it reads without colour. */
.g-bar.behind {
  background-image: repeating-linear-gradient(135deg, transparent 0 5px, var(--hatch) 5px 8px);
  box-shadow: inset 0 0 0 2px var(--warn);
}
.g-bar .done { position: absolute; inset: 0 auto 0 0; background: var(--navy); }
.g-bar .lbl {
  position: relative; display: inline-flex; align-items: center; gap: 5px; color: var(--bar-text); font-size: 12px;
  font-weight: 500; padding: 0 10px; line-height: 30px; white-space: nowrap; text-shadow: 0 1px 1px rgba(0,0,0,.35);
}
.g-bar .flag {
  display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%;
  background: var(--warn); color: var(--card); font-size: 11px; font-weight: 800; text-shadow: none;
}
.legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 12px 16px; font-size: 12px; color: var(--muted); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.sw.done { background: var(--navy); }
.sw.rest { background: var(--slate); }
.sw.today { background: var(--today); border: 1px solid var(--today-line); }
.sw.behind {
  width: 16px; background: var(--slate); box-shadow: inset 0 0 0 1.5px var(--warn);
  background-image: repeating-linear-gradient(135deg, transparent 0 3px, var(--hatch) 3px 5px);
}
.tip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--tip-bg); color: var(--tip-text); font-size: 12px;
  padding: 6px 10px; border-radius: 6px; white-space: nowrap;
}
.tip.multi { white-space: pre-line; max-width: min(320px, calc(100vw - 16px)); line-height: 1.45; }

/* Small "i" button next to a label that shows a tooltip on hover and keyboard focus. */
.info-btn {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: -3px;
  margin-left: 4px; padding: 1px; appearance: none; -webkit-appearance: none;
  background: transparent; border: 0; border-radius: 50%; box-shadow: none;
  color: var(--muted); cursor: help; line-height: 0;
}
.info-btn:hover, .info-btn:focus, .info-btn:active { background: transparent; }
.info-btn svg { width: 16px; height: 16px; flex: none; }
.info-btn:hover, .info-btn:focus-visible { color: var(--accent); }
.info-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-radius: 50%; }

/* Modal */
.overlay {
  position: fixed; inset: 0; background: var(--overlay); z-index: 20; display: flex;
  align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto;
}
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 560px; padding: 24px; box-shadow: var(--shadow-lg); }
.modal h2 { font-size: 20px; display: flex; align-items: center; gap: 10px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.tile { background: var(--soft); border-radius: 8px; padding: 10px 12px; }
.tile .k { font-size: 11px; color: var(--muted); }
.tile .v { font-weight: 700; font-size: 15px; }
.prog { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; margin: 6px 0; font-size: 13px; }
.track { height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; }
.track > div { height: 100%; border-radius: 99px; }
.list { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; }
.list > div { padding: 9px 12px; border-top: 1px solid var(--line); display: flex; gap: 20px; }
.list > div:first-child { border-top: 0; }
.sect { font-size: 13px; color: var(--muted); margin-top: 16px; }
.drop {
  border: 2px dashed var(--line-strong); border-radius: 12px; padding: 34px 16px; text-align: center; margin-top: 16px;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .big { font-weight: 600; font-size: 15px; }
.drop .row { display: flex; gap: 10px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.chip { display: flex; align-items: center; gap: 10px; background: var(--soft); border-radius: 8px; padding: 10px 12px; margin: 14px 0; }
.xls { background: var(--xls); color: #fff; font-size: 10px; font-weight: 700; border-radius: 5px; padding: 6px 5px; }
.chip .grow { flex: 1; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.field label, .field .label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.field input, .field select, .field textarea, select.input, input.input {
  width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--input); color: var(--text);
}
.field input[aria-invalid="true"], .field select[aria-invalid="true"], input.input[aria-invalid="true"] { border-color: var(--bad); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
/* Not found in the work order file: goes back to normal once filled in; a validation error takes over from the hint. */
.field.missing input:invalid:not([aria-invalid="true"]) { border-color: var(--warn); background: var(--warn-bg); }
.field.missing .hint { color: var(--warn); font-weight: 500; }
.field.missing input:valid + .hint, .field.missing input[aria-invalid="true"] + .hint { display: none; }
.field .ferr { font-size: 12px; color: var(--bad); margin-top: 4px; font-weight: 500; }
.req { color: var(--bad); }
.err, .ok, .info, .warn {
  display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin-top: 10px; padding: 8px 10px; border-radius: 8px;
}
.err { color: var(--bad); background: var(--bad-bg); }
.ok { color: var(--ok); background: var(--ok-bg); }
.info { color: var(--pend); background: var(--pend-bg); }
.warn { color: var(--warn); background: var(--warn-bg); }
.warn ul { margin: 0; padding-left: 16px; }
.warn li + li { margin-top: 2px; }
.read-notes { margin: -4px 0 14px; }
.err svg, .ok svg, .info svg, .warn svg { width: 14px; height: 14px; flex: none; margin-top: 2px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 32px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--navy); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.seg label { position: relative; display: flex; align-items: center; gap: 6px; padding: 8px 14px; cursor: pointer; min-height: 40px; border-left: 1px solid var(--line-strong); }
.seg label:first-child { border-left: 0; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label:has(input:checked) { background: var(--sel-bg); font-weight: 600; box-shadow: inset 0 -2px 0 var(--navy); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 36px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .tr {
  width: 40px; height: 22px; border-radius: 999px; background: var(--line-strong); position: relative; flex: none; transition: background .15s;
}
.switch .tr::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.switch input:checked + .tr { background: var(--navy); }
.switch input:checked + .tr::after { left: 21px; }
.switch input:focus-visible + .tr { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch .st { font-size: 12px; color: var(--muted); min-width: 22px; }

/* Tables */
.tbl-wrap { overflow: auto; max-height: 70vh; border-radius: 0 0 12px 12px; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl th, .tbl td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl thead th {
  position: sticky; top: 0; z-index: 1; background: var(--soft); font-size: 11px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
}
.tbl tbody tr:hover td { background: var(--hover); }
.tbl tr.hl td { background: var(--accent-soft); }
.tbl tr.sub td { background: var(--soft); }
.tbl td.num, .tbl th.num { text-align: right; }
.tbl .cb { width: 36px; }
.tbl .cb input { width: 18px; height: 18px; accent-color: var(--navy); margin: 0; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px 18px 12px; }
.card-head .spacer { flex: 1; }
.reason-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.reason-row .field { flex: 1; min-width: 200px; margin: 0; }
.results { padding: 0 18px 12px; }
.results ul { list-style: none; margin: 6px 0 0; padding: 0; }
.results li { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }
.results li svg { width: 14px; height: 14px; flex: none; margin-top: 2px; }
.results li.ok-r { color: var(--ok); }
.results li.bad-r { color: var(--bad); }
.results li.warn-r { color: var(--warn); }
.results li .txt { color: var(--text); }
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.subtabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; color: var(--muted); min-height: 44px; white-space: nowrap;
}
.subtabs button[aria-selected="true"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.mchips { display: flex; flex-wrap: wrap; gap: 6px; }
.mchips label {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 4px 10px; font-size: 12px; cursor: pointer; min-height: 30px;
}
.mchips label:has(input:checked) { background: var(--sel-bg); border-color: var(--navy); }
.mchips input { width: 15px; height: 15px; margin: 0; accent-color: var(--navy); }

/* Daily task list */
.daypill { display: flex; align-items: center; background: var(--card); border-radius: 999px; box-shadow: var(--shadow); }
.daypill button { background: none; border: 0; min-width: 40px; min-height: 36px; color: var(--muted); font-size: 18px; border-radius: 999px; }
.daypill button:hover { color: var(--text); }
.daypill span { font-weight: 600; padding: 0 4px; white-space: nowrap; }
.tasks { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.crew .person { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: grab; }
.crew .person:hover { background: var(--soft); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--avatar-bg); color: var(--navy); flex: none;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px;
}
:root[data-theme="dark"] .avatar { color: #b9d3ee; }
.pmeta { flex: 1; min-width: 0; }
.pmeta .nm { font-weight: 600; }
.pmeta .rl { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.wo-card { padding: 16px; transition: box-shadow .1s; }
.wo-card + .wo-card { margin-top: 0; }
.wo-card.over { box-shadow: 0 0 0 2px var(--accent); }
.wo-head { display: flex; justify-content: space-between; gap: 10px; }
.wo-head .nm { color: var(--muted); font-weight: 400; }
.wo-head .right { color: var(--muted); font-size: 12px; white-space: nowrap; }
.asg { background: var(--soft); border-radius: 10px; padding: 10px; margin-top: 10px; }
.asg-top { display: flex; align-items: center; gap: 8px; }
.x { background: none; border: 0; color: var(--muted); font-size: 18px; min-width: 32px; min-height: 32px; border-radius: 6px; line-height: 1; }
.x:hover { color: var(--text); background: var(--soft); }
.add-btn { width: 100%; margin-top: 10px; }
.picker { border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; max-height: 240px; overflow-y: auto; }
.picker button {
  display: flex; width: 100%; justify-content: space-between; align-items: center; background: var(--card); border: 0;
  border-top: 1px solid var(--line); padding: 8px 10px; min-height: 40px; text-align: left;
}
.picker button:first-child { border-top: 0; }
.picker button:hover { background: var(--soft); }

/* Time entries */
.te { display: grid; grid-template-columns: 380px 1fr; gap: 24px; align-items: start; }
.radio-card {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  margin-bottom: 8px; cursor: pointer; background: var(--card); min-height: 52px;
}
.radio-card.sel { border: 2px solid var(--navy); background: var(--sel-bg); padding: 9px 11px; }
.radio-card:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.radio-card input { accent-color: var(--navy); width: 18px; height: 18px; margin: 0; }
.radio-card .grow { flex: 1; min-width: 0; }
.radio-card .asgd { font-size: 11px; color: var(--muted); white-space: nowrap; }
.radio-card .lead-note { font-size: 12px; color: var(--text); margin-top: 2px; font-style: italic; }
.bigstep {
  display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 10px; padding: 8px;
}
.bigstep button { width: 52px; height: 44px; border: 0; border-radius: 8px; background: var(--soft); font-size: 18px; }
.bigstep button:hover { background: var(--line); }
.mb { margin-bottom: 14px; }
.mt { margin-top: 14px; }
.lbl { font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.wo-log { padding: 16px 18px; margin-bottom: 14px; }
.wo-log + .wo-log { margin-top: 0; }
.wo-log .hd { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.wo-log .tot b { font-size: 22px; }
.wo-log .tbl { margin-top: 8px; }
.wo-log .tbl th, .wo-log .tbl td { padding: 7px 8px; }
.wo-log .tbl thead th { position: static; background: none; border-bottom: 1px solid var(--line); }
.ppl { list-style: none; margin: 0; padding: 0; }
.ppl li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.ppl li:first-child { border-top: 0; }

/* Worker view (crew) */
.phone { max-width: 480px; margin: 0 auto; }
.me { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.me .avatar { width: 40px; height: 40px; font-size: 15px; }
.entry { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.entry:first-child { border-top: 0; padding-top: 0; }
.entry .h { font-weight: 700; text-align: right; }
.entry .meta { font-size: 12px; color: var(--muted); }
.entry .why { grid-column: 1 / -1; font-size: 13px; color: var(--bad); background: var(--bad-bg); padding: 6px 8px; border-radius: 6px; }
.entry .acts { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sum { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.sum .tile { flex: 1; min-width: 120px; }

/* Login */
.auth { max-width: 400px; margin: 6vh auto 0; }
.auth .card { padding: 28px; }
.auth h1 { font-size: 22px; margin: 0 0 4px; }
.auth .field { margin-top: 14px; }
.auth .alt { margin-top: 18px; text-align: center; font-size: 13px; color: var(--muted); }
body.signed-out .tabs, body.signed-out .asof { display: none; }

/* Toasts */
.toasts {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column;
  gap: 8px; align-items: center; width: min(560px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; background: var(--tip-bg); color: var(--tip-text);
  padding: 10px 12px 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); width: 100%; font-size: 13px;
}
.toast.bad { background: var(--bad-bg); color: var(--bad); border: 1px solid currentColor; }
.toast svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.toast .grow { flex: 1; }
.toast button { background: none; border: 0; color: inherit; font-size: 18px; line-height: 1; min-width: 28px; min-height: 28px; opacity: .8; }

@media (max-width: 1000px) {
  .wo-grid { grid-template-columns: minmax(0, 1fr); }
  .te { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .top { padding: 0 16px; }
  .wrap { padding: 16px 16px 48px; }
  .asof, .pill-grey, .user .who, .icon-btn .t { display: none; }
  .brand-name { font-size: 16px; }
  .tasks { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .form-grid { grid-template-columns: 1fr; }
  .prog { grid-template-columns: 1fr; gap: 4px; }
  .modal { padding: 18px; }
  .page-head h1 { font-size: 20px; }
  .tbl-wrap { max-height: none; }
}
/* Touch screens: every control at least 44px tall/wide. */
@media (pointer: coarse) {
  .btn, .btn-sm, .icon-btn, .field input, .field select, select.input, input.input, .tabs a { min-height: 44px; }
  .icon-btn, .x, .daypill button { min-width: 44px; min-height: 44px; }
  .check, .switch, .mchips label { min-height: 44px; }
  .tbl .cb input, .check input { width: 22px; height: 22px; }
}

/* Schedule detail panel */
.sched { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.sched.has-panel { grid-template-columns: minmax(0, 1fr) 380px; }
.sched > .card + .card { margin-top: 0; }
.wo-panel { padding: 20px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.wo-panel h2 { font-size: 20px; display: flex; align-items: center; gap: 10px; margin: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.wo-panel .x { font-size: 22px; }
.wo-panel .tiles { gap: 8px; }
.wo-panel .prog { grid-template-columns: 1fr; gap: 4px; }
/* Delete WO: secondary button at the panel bottom, then an in-place confirm step. */
.wo-del { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.wo-del.confirm { border: 1px solid var(--bad); background: var(--bad-bg); border-radius: 10px; padding: 12px 14px; }
.wo-del.confirm h3 { color: var(--bad); }
.wo-del.confirm p { margin: 8px 0; font-size: 13px; }
.wo-del.confirm .btn-row { margin-top: 12px; }
.g-row-left.sel { background: var(--sel-bg); box-shadow: inset 3px 0 0 var(--navy); }
.g-bar.sel { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--accent); }
.g-bar.behind.sel { box-shadow: inset 0 0 0 2px var(--warn), 0 0 0 2px var(--card), 0 0 0 4px var(--accent); }
@media (max-width: 720px) {
  .sched.has-panel { grid-template-columns: minmax(0, 1fr); }
  .wo-panel { position: static; max-height: none; }
}
/* Admin > History */
.audit-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 12px; align-items: end; padding: 0 18px 14px; border-bottom: 1px solid var(--line); }
.audit-filters .field { margin: 0; }
.audit-what { min-width: 240px; overflow-wrap: anywhere; }
.audit-details summary { margin-top: 4px; color: var(--muted); font-size: 12px; cursor: pointer; }
.audit-details ul { margin: 6px 0 0; padding: 8px 10px; list-style: none; border-radius: 8px; background: var(--soft); font-size: 12px; overflow-wrap: anywhere; }
.audit-details li + li { margin-top: 4px; }
/* Admin > Events */
.ev-filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; padding: 0 18px 14px; border-bottom: 1px solid var(--line); }
.ev-filters .field { margin: 0; min-width: 120px; }
.ev-table { min-width: 860px; }
.ev-table td { vertical-align: top; }
.ev-activity { overflow-wrap: anywhere; max-width: 24ch; }
.ev-payload { display: block; max-width: 48ch; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11.5px; color: var(--muted); }

/* ---------- Daily Task List + WO edit (2026-11-06) ---------- */
.wrap:has(> .tasks) { max-width: none; }   /* this tab only: 7 work orders x 24 people need the width */
/* Crew: stays in view, scrolls on its own. */
.crew { position: sticky; top: 16px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.crew-list { flex: 1; min-height: 0; overflow-y: auto; }
.crew-list:focus-visible { outline-offset: -2px; }
.pline { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.pline .nm { flex: 0 1 auto; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pline .rl { flex: 1 1 0; min-width: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crew .free { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin-top: 2px; font-size: 12px; color: var(--muted); }
.ot-badge {
  display: inline-flex; align-items: center; gap: 4px; flex: none; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600;
  white-space: nowrap; background: var(--warn-bg); color: var(--warn);
}
.ot-badge svg { width: 11px; height: 11px; }
/* Work order card */
.wo-head { align-items: flex-start; }
.wo-head .ttl { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.wo-head .right { line-height: 30px; }
.wo-out { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; font-weight: 500; color: var(--warn); }
/* Assignment: name on row 1; hours and a wide note on row 2. */
.asg-edit { display: flex; align-items: flex-start; gap: 10px; margin-top: 8px; }
.asg-hours { display: flex; align-items: center; gap: 4px; flex: none; color: var(--muted); font-size: 13px; }
.asg-hours input {
  width: 68px; min-height: 36px; padding: 6px 4px 6px 8px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--input); color: var(--text); font-weight: 600;
}
.asg-hours input[aria-invalid="true"] { border-color: var(--bad); }
.asg .note {
  flex: 1; min-width: 0; width: 100%; min-height: 52px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--input); color: var(--text); font-size: 13px; line-height: 1.35; resize: vertical;
}
.asg .note:hover { border-color: var(--line-strong); }
.asg-err { font-size: 12px; font-weight: 500; color: var(--bad); margin-top: 4px; }
.asg-err:empty { display: none; }
/* Schedule panel + edit dialog */
/* Gantt bar that runs past the edge of the window: square edge + a ‹ or › marker, so it reads without colour. */
.g-bar.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; }
.g-bar.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; }
.g-bar.cont-l .lbl { padding-left: 26px; }
.g-bar.cont-r .lbl { padding-right: 26px; }
.g-cont {
  position: absolute; top: 7px; width: 16px; height: 16px; border-radius: 50%; background: var(--card); color: var(--text);
  font-size: 14px; font-weight: 700; line-height: 14px; text-align: center;
}
.g-cont.l { left: 5px; }
.g-cont.r { right: 5px; }
.tile.span2 { grid-column: span 2; }
.wo-baseline { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.wo-baseline b { color: var(--text); font-weight: 600; }
.wo-edit-row { margin-bottom: 4px; }
#wo-edit-form { margin-top: 16px; }
@media (max-width: 720px) {
  .crew { position: static; max-height: none; }
  .crew-list { max-height: 45vh; }
}
@media (max-width: 720px), (pointer: coarse) {
  .asg-hours input, .asg .note { min-height: 44px; font-size: 16px; }   /* 16px: iOS doesn't zoom in on focus */
  .asg .x { min-width: 44px; min-height: 44px; }
}

/* ---------- Time Entries + worker view (2026-11-06) ---------- */
/* Day control: ‹ date ›. The date input lies invisibly over the label, so a tap opens the native picker. */
.daybar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.daypick { display: flex; align-items: center; background: var(--card); border-radius: 999px; box-shadow: var(--shadow); }
.daypick button { background: none; border: 0; min-width: 44px; min-height: 44px; color: var(--muted); font-size: 20px; border-radius: 999px; }
.daypick button:hover:not(:disabled) { color: var(--text); }
.daypick button:disabled { opacity: .35; }
.daypick-date { position: relative; display: block; padding: 4px 6px; font-weight: 600; white-space: nowrap; cursor: pointer; border-radius: 8px; }
.daypick-date span { border-bottom: 1px dashed var(--line-strong); }
.daypick-date:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.daypick-date input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.daypick-date input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; cursor: pointer; }

/* Log form hours: type the number, or use − / + beside it */
.bigstep { gap: 8px; }
.bigstep input {
  flex: 1; min-width: 0; min-height: 44px; padding: 0; text-align: center; font-size: 24px; font-weight: 700;
  border: 1px solid transparent; background: transparent; appearance: textfield; -moz-appearance: textfield;
}
.bigstep input::-webkit-inner-spin-button, .bigstep input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Entry actions and inline forms (crew view and Hours by crew) */
.entry > .sheet, .entry > .edited { grid-column: 1 / -1; }
.entry-form { grid-column: 1 / -1; background: var(--soft); border-radius: 8px; padding: 10px; }
.entry-edit { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.entry-edit .field { margin: 0; }
.entry-edit .field input { width: 96px; }
.entry-edit .field.grow { flex: 1; min-width: 180px; }
.entry-edit .field.grow select { width: 100%; }

/* Lead: Hours by crew */
.te > * { min-width: 0; }
.crew-day { padding: 14px 18px; }
.crew-day + .crew-day { margin-top: 12px; }
.crew-day-hd { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 10px; }
.crew-day-hd .tot { white-space: nowrap; }
.crew-day .nothing { padding-top: 8px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.crew-day .entry + .nothing { margin-top: 8px; }
.te-others { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; border-radius: 10px; background: var(--pend-bg); }
.te-others svg { width: 14px; height: 14px; flex: none; color: var(--pend); }
.te-results { margin-bottom: 12px; }
.te-results .results { padding-top: 12px; }
.ts-files { max-width: 680px; }

/* Crew: My tasks and Needs your attention */
.task-plan { font-weight: 700; margin-top: 6px; }
.task-note { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.task-card .btn-block { margin-top: 12px; }
.attn h2 { display: flex; align-items: center; gap: 8px; }
.attn h2 svg { width: 16px; height: 16px; flex: none; color: var(--warn); }
.attn li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.attn li:first-child { border-top: 0; }
.attn li .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.phone .btn-sm { min-height: 44px; }

@media (max-width: 1000px) {
  .te.by-crew .te-log { order: 2; } /* the crew list comes first on narrow screens; the form follows it */
}
@media (max-width: 720px) {
  .daypick-date input, .entry-form .field input, .entry-form .field select { font-size: 16px; } /* iOS zooms in on smaller inputs */
}
