/* MBOPC PMT -- utility styles, no framework.
 *
 * ---------------------------------------------------------------------------
 * ONE RULE: no colour is written anywhere below this token block. Every rule in
 * this file (and in report.css, and in the JS that draws the map, the S-curve
 * and the Gantt) reads a custom property, so the whole app re-themes from one
 * place and dark mode is a token swap rather than a second stylesheet.
 *
 * Themes are three-state:
 *   :root                                    light (MBOPC letterhead palette)
 *   @media (prefers-color-scheme: dark)      dark, unless the user pinned light
 *   :root[data-theme="dark"]                 dark, pinned by the user
 * A tiny inline script in <head> stamps data-theme on <html> before first paint
 * (see base.html), so there is no flash; the media query is the no-JS fallback.
 *
 * Brand rule: --gold is a RULE colour. It draws lines, underlines and hairlines
 * and it NEVER carries text -- 2.4:1 on white would fail every contrast bar.
 * RAG/status colours stay semantically red/amber/green and come from the
 * --bad / --warn / --ok families, never from the brand greens.
 * ------------------------------------------------------------------------- */

:root {
  /* ---- MBOPC brand (from the company letterhead) ---- */
  --brand: #4A5D2B;        /* wordmark green: links, primary buttons          */
  --brand-deep: #38471F;   /* header band, hover states                       */
  --brand-ink: #2B3717;    /* text on a sage fill                             */
  --brand-soft: #E7EDE0;   /* sage fill: table headers, chips                 */
  --brand-softer: #F2F6EC; /* sage wash: hovered rows, stripes                */
  --on-brand: #FFFFFF;     /* text on a solid brand fill                      */
  --on-bad: #FFFFFF;       /* text on a solid --bad fill (danger button)      */
  --on-ok: #FFFFFF;        /* text on a solid --ok fill (field save button)   */
  --on-warn: #FFFFFF;      /* text on a solid --warn fill (half-day chip)     */
  --paper: #FFFFFF;        /* NEVER themed: a QR must stay black-on-white     */
  --gold: #C9A227;         /* RULE colour only -- never text                  */
  --gold-soft: #F6EDCE;

  /* ---- Surfaces and ink ---- */
  --bg: #F4F5F1;
  --panel: #FFFFFF;
  --panel-sunken: #FAFBF7;  /* inset panels, hints, step boxes                */
  --ink: #1D2418;
  --muted: #5C6657;         /* 5.3:1 on white -- AA body text                 */
  --line: #DCE0D5;
  --line-strong: #C3CAB8;

  /* ---- Status families (text / fill / line) ---- */
  --warn: #7A5300;  --warn-bg: #FDF3DC;  --warn-line: #E3BE68;
  --bad:  #96261F;  --bad-bg:  #FBEAE8;  --bad-line:  #E4B4AF;
  --ok:   #1C6B3E;  --ok-bg:   #E3F1E7;  --ok-line:   #A9D3B9;
  --info: #1B5B9A;  --info-bg: #E5EFF9;  --info-line: #B4CDE8;
  --neutral-bg: #ECEFE7;

  /* ---- RAG solids (map dots, timeline fills -- must read at 11px) ---- */
  --rag-green: #1C6B3E;
  --rag-amber: #A8720A;
  --rag-red:   #96261F;
  --rag-none:  #8A9481;

  /* ---- Charts (read from getComputedStyle by scurve.js) ---- */
  --chart-planned: #5C6657;
  --chart-actual: #4A5D2B;
  --chart-actual-fill: rgba(74, 93, 43, 0.12);
  --chart-grid: #DCE0D5;
  --chart-text: #5C6657;

  /* ---- Topbar ---- */
  --top-bg: #38471F;
  --top-ink: #EDF2E4;
  --top-ink-strong: #FFFFFF;
  --top-hover: rgba(255, 255, 255, 0.14);
  --top-active: rgba(255, 255, 255, 0.20);
  --top-line: rgba(255, 255, 255, 0.16);

  /* ---- Focus / selection ---- */
  --focus: #4A5D2B;
  --focus-ring: rgba(74, 93, 43, 0.30);

  /* ---- Spacing scale (one scale, used everywhere) ---- */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;

  /* ---- Shell geometry ----
         One row of chrome across the top, one rail down the side. Both are
         tokens because the rail is positioned against the topbar's height and
         the content is offset by the rail's width -- three numbers that must
         never drift apart. */
  --topbar-h: 56px;
  --sidenav-w: 236px;
  --sidenav-rail-w: 60px;

  /* ---- Radius scale ---- */
  --r-sm: 4px;
  --r: 7px;
  --r-lg: 12px;
  --r-pill: 999px;

  /* ---- Elevation ---- */
  --shadow: 0 1px 2px rgba(29, 36, 24, 0.06), 0 1px 3px rgba(29, 36, 24, 0.05);
  --shadow-lg: 0 6px 18px rgba(29, 36, 24, 0.12);

  /* ---- Legacy aliases: older rules and any template that still names the
         first-generation tokens keep working. Do not add new uses. ---- */
  --surface: var(--panel);
  --border: var(--line);
  --text: var(--ink);
  --err: var(--bad);
  --accent: var(--gold);
  --brand-dark: var(--brand-deep);
  --radius: var(--r);
}

/* --------------------------------------------------------------- dark -- */
/* Deep green-tinted darks -- never pure black, which reads as a hole next to
 * the brand greens. Body text is >= 7:1 on the panel; every status text token
 * was checked against its own fill, not against the page background. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #8CB45C;
    --brand-deep: #A8C97C;
    --brand-ink: #D3E0C2;
    --brand-soft: #26301D;
    --brand-softer: #1F2719;
    --on-brand: #14180E;
    --on-bad: #2A100D;
    --on-ok: #0C1A11;
    --on-warn: #2A2210;
    --gold: #B8912E;
    --gold-soft: #3A3116;

    --bg: #12160F;
    --panel: #1B2117;
    --panel-sunken: #171D13;
    --ink: #E8EDE2;
    --muted: #A6B199;
    --line: #2E3727;
    --line-strong: #3E4A34;

    --warn: #E8C267;  --warn-bg: #2E2611;  --warn-line: #5C4A1C;
    --bad:  #F1A79E;  --bad-bg:  #331916;  --bad-line:  #6A302A;
    --ok:   #8FD6A8;  --ok-bg:   #152A1D;  --ok-line:   #2E5A3D;
    --info: #8FC3F0;  --info-bg: #12233A;  --info-line: #2C4E77;
    --neutral-bg: #232A1E;

    --rag-green: #4FA86D;
    --rag-amber: #D19A2E;
    --rag-red:   #D4655A;
    --rag-none:  #77836C;

    --chart-planned: #9AA88E;
    --chart-actual: #8CB45C;
    --chart-actual-fill: rgba(140, 180, 92, 0.16);
    --chart-grid: #2E3727;
    --chart-text: #A6B199;

    --top-bg: #1D2417;
    --top-ink: #D8E2CB;
    --top-ink-strong: #F2F7EA;
    --top-hover: rgba(255, 255, 255, 0.09);
    --top-active: rgba(255, 255, 255, 0.14);
    --top-line: rgba(255, 255, 255, 0.10);

    --focus: #A8C97C;
    --focus-ring: rgba(168, 201, 124, 0.35);

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.40), 0 1px 3px rgba(0, 0, 0, 0.30);
    --shadow-lg: 0 8px 22px rgba(0, 0, 0, 0.50);
  }
}

:root[data-theme="dark"] {
  --brand: #8CB45C;
  --brand-deep: #A8C97C;
  --brand-ink: #D3E0C2;
  --brand-soft: #26301D;
  --brand-softer: #1F2719;
  --on-brand: #14180E;
  --on-bad: #2A100D;
  --on-ok: #0C1A11;
  --on-warn: #2A2210;
  --gold: #B8912E;
  --gold-soft: #3A3116;

  --bg: #12160F;
  --panel: #1B2117;
  --panel-sunken: #171D13;
  --ink: #E8EDE2;
  --muted: #A6B199;
  --line: #2E3727;
  --line-strong: #3E4A34;

  --warn: #E8C267;  --warn-bg: #2E2611;  --warn-line: #5C4A1C;
  --bad:  #F1A79E;  --bad-bg:  #331916;  --bad-line:  #6A302A;
  --ok:   #8FD6A8;  --ok-bg:   #152A1D;  --ok-line:   #2E5A3D;
  --info: #8FC3F0;  --info-bg: #12233A;  --info-line: #2C4E77;
  --neutral-bg: #232A1E;

  --rag-green: #4FA86D;
  --rag-amber: #D19A2E;
  --rag-red:   #D4655A;
  --rag-none:  #77836C;

  --chart-planned: #9AA88E;
  --chart-actual: #8CB45C;
  --chart-actual-fill: rgba(140, 180, 92, 0.16);
  --chart-grid: #2E3727;
  --chart-text: #A6B199;

  --top-bg: #1D2417;
  --top-ink: #D8E2CB;
  --top-ink-strong: #F2F7EA;
  --top-hover: rgba(255, 255, 255, 0.09);
  --top-active: rgba(255, 255, 255, 0.14);
  --top-line: rgba(255, 255, 255, 0.10);

  --focus: #A8C97C;
  --focus-ring: rgba(168, 201, 124, 0.35);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.40), 0 1px 3px rgba(0, 0, 0, 0.30);
  --shadow-lg: 0 8px 22px rgba(0, 0, 0, 0.50);
}

/* ========================================================== base =========== */
* { box-sizing: border-box; }

/* The topbar is sticky, so an anchor jump has to stop short of it or the thing
   being jumped to lands underneath. Both halves are needed: scroll-padding
   covers the browser's own fragment navigation, scroll-margin covers the
   scrollIntoView() calls in wbs-jump.js and tabs.js. */
html { scroll-padding-top: calc(var(--topbar-h) + var(--s-3)); }
[id] { scroll-margin-top: calc(var(--topbar-h) + var(--s-3)); }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
body { min-height: 100vh; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* One visible, brand-coloured focus ring for everything keyboard-reachable. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.topbar :focus-visible { outline-color: var(--top-ink-strong); }

/* Colour transitions are a nicety; motion-sensitive users get none of it. */
@media (prefers-reduced-motion: no-preference) {
  body, .card, .stat, .btn, .badge, .topbar, input, select, textarea, .material-row {
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
  }
}

::selection { background: var(--brand-soft); color: var(--brand-ink); }

/* ================================================= shell: topbar + nav ====
 *
 * The header used to be a flex row with `flex-wrap: wrap` and fourteen links in
 * it. On a desktop window that produced a 240px-tall block of ragged rows --
 * the drawer's own stacking styles half-applying at a width they were never
 * meant for. The replacement has ONE code path per breakpoint and no wrapping
 * anywhere in the chrome:
 *
 *   below 1024px   a 56px topbar and an off-canvas drawer behind a hamburger
 *   1024px and up  the same topbar and a fixed rail, collapsible to icons
 *
 * The rail and the drawer are THE SAME ELEMENT (#primary-nav) rendered once.
 * Only its position changes, so there is no state in between the two and no
 * second markup path to fall out of step.
 * ------------------------------------------------------------------------- */

/* Keyboard users land here first; the rail is long and skipping it matters. */
.skip-link {
  position: absolute;
  left: var(--s-3);
  top: -80px;
  z-index: 100;
  padding: 9px 14px;
  border: 1px solid var(--brand);
  border-radius: var(--r-sm);
  background: var(--panel);
  color: var(--brand);
  font-weight: 600;
}
.skip-link:focus { top: 8px; text-decoration: none; }

/* ---------------------------------------------------------------- topbar -- */
.topbar {
  position: sticky;
  top: 0;
  /* Above the sidenav (45): the topbar is a stacking context, so its dropdown
   * panels can never rise above the rail unless the whole bar does. */
  z-index: 50;
  background: var(--top-bg);
  color: var(--top-ink);
  border-bottom: 2px solid var(--gold);
  box-shadow: var(--shadow);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  /* NEVER wraps. This one declaration is the whole fix for the four-row
     header -- everything in here either fits, truncates, or is hidden by a
     media query, and nothing is allowed to start a second row. */
  flex-wrap: nowrap;
  height: var(--topbar-h);
  padding: 0 var(--s-3);
  min-width: 0;
}
.topbar-spacer { flex: 1 1 auto; min-width: var(--s-2); }

/* The header lockup: the PNG's own wordmark is unreadable at nav size, so the
   mark carries the identity and the app name is set in live text beside it. */
/* FIXED, deliberately. The lockup is the identity and its text is a constant
   ("MBOPC PMT"), so it has no honest way to be narrower and nothing to gain
   from trying: letting it shrink only clips the mark, because the wordmark
   beside it is already `display: none` at the widths where the row is tight.
   The one control in this row that MUST shrink is the project switcher, whose
   label is a project name -- see the note above `.switcher-button`. */
.brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: 0 0 auto;
  color: var(--top-ink-strong);
  min-width: 0;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  height: 30px;
  width: auto;
  display: block;
  border-radius: var(--r-sm);
  flex: 0 0 auto;
}
.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2px;
  line-height: 1.15;
  white-space: nowrap;
  /* Belt to the braces above: if the app is ever renamed to something long,
     the wordmark ellipsises rather than pushing the row off the screen. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* One shape for every control in the topbar, so the row reads as one row. */
.nav-toggle,
.nav-quick,
.switcher-button,
.projmenu-button,
.bell-menu > summary,
.avatar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 38px;
  min-width: 38px;
  padding: 0 10px;
  border: 1px solid var(--top-line);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--top-ink-strong);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  list-style: none;
}
.nav-toggle:hover,
.nav-quick:hover,
.switcher-button:hover,
.projmenu-button:hover,
.bell-menu > summary:hover,
.avatar-button:hover { background: var(--top-hover); text-decoration: none; }
.nav-toggle .nav-icon,
.nav-quick .nav-icon,
.projmenu-button .nav-icon,
.bell-menu > summary .nav-icon { flex: 0 0 auto; }

/* THE 433-448px HORIZONTAL OVERFLOW, AND WHERE IT ACTUALLY CAME FROM.
 *
 * Measured at 433px with the real markup, one change at a time:
 *
 *     as shipped ......................................  0px over
 *     wordmark shown (the old 420px cut) ..............  88px over
 *     switcher made rigid (its shrink removed) ........  81px over
 *     both .............................................182px over
 *
 * So the row is 88px short of the room it needs the moment the WORDMARK comes
 * back, and the fix is the breakpoint that hides it -- moved from 420px to
 * 600px, down at the bottom of this file. The project switcher was never the
 * culprit: `.menu.switcher` has been `flex: 0 1 auto` with a 62px floor and an
 * ellipsised label since it was written, and at 433px it was already sitting on
 * that floor with nothing left to give. Removing its shrink costs another 81px,
 * which is why it is worth saying here that it is load-bearing rather than
 * leaving somebody to discover that by deleting it.
 *
 * The band was 433-448px because both ends were handled by accident: at 420px
 * and below the wordmark is hidden and every control tightens, and by ~449px
 * there happened to be enough room for *this* project's name. A window between
 * two coincidences is not a fixed bug, so the fix is a real one: the six fixed
 * tap targets, their gaps and the row's padding come to ~290px on their own,
 * which leaves nothing for an 85px wordmark on any screen under 600px. */

/* ---- Dropdowns: <details>, so they work with the script dead ---- */
.menu { position: relative; flex: 0 0 auto; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  z-index: 60;
  width: max-content;
  min-width: 232px;
  max-width: min(320px, calc(100vw - 2 * var(--s-3)));
  padding: var(--s-2);
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
}
.menu-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s-2);
  margin-bottom: var(--s-1);
  border-bottom: 1px solid var(--line);
}
.menu-head strong { font-size: 14px; }
.menu-head .badge { align-self: flex-start; }
.menu-label {
  margin: var(--s-2) var(--s-2) var(--s-1);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.menu-note { padding: var(--s-1) var(--s-2) var(--s-2); margin: 0; }
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 40px;
  padding: 9px var(--s-2);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: 14px;
}
.menu-item:hover { background: var(--brand-softer); color: var(--brand-deep); text-decoration: none; }
.menu-item .nav-icon { flex: 0 0 auto; width: 18px; height: 18px; color: var(--muted); }
.menu-item:hover .nav-icon { color: var(--brand); }
/* The page you are already on, inside a dropdown. Same language as the rail's
   `.navlink.is-active`, one weight quieter -- a menu you had to open to see
   does not need to shout about where you are. */
.menu-item.is-current {
  background: var(--brand-softer);
  color: var(--brand-deep);
  font-weight: 600;
}
.menu-item.is-current .nav-icon { color: var(--brand); }
.menu-foot { margin-top: var(--s-1); border-top: 1px solid var(--line); border-radius: 0; }
.menu-logout { margin-top: var(--s-1); padding: var(--s-2); border-top: 1px solid var(--line); }
.menu-logout .btn { width: 100%; }

/* ---- Project switcher ----
   It names the project THIS PAGE is in. On a page that is not inside one it
   says so, rather than naming whichever project the session last remembered --
   the whole point of the context rule (see partials/_sidenav.html). */
/* The switcher is the ONE flexible item in the row: everything else is a tap
   target with a floor under it, so when the window is too narrow for all of
   them this is what gives. It still shows the first few characters of the
   project name rather than disappearing, which is the point of it being here. */
.menu.switcher { flex: 0 1 auto; min-width: 62px; }
.switcher-button {
  width: 100%;
  max-width: min(300px, 44vw);
  min-width: 0;
  justify-content: flex-start;
}
.switcher-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher-name.is-empty { color: var(--top-ink); font-weight: 600; }
.switcher-button .nav-icon { width: 16px; height: 16px; opacity: 0.75; }
.switcher-panel { left: 0; }
details[open] > .switcher-button { background: var(--top-active); }

/* ---- Project menu ----
   The switcher's twin: that one names the project, this one edits the project
   it names, so they sit side by side and share a shape. It is a fixed tap
   target -- the switcher is the only item in the row allowed to give -- and it
   drops its word before its icon when the window gets tight. */
.menu.projmenu { flex: 0 0 auto; }
.projmenu-label { display: none; }
.projmenu-panel { left: 0; }
details[open] > .projmenu-button { background: var(--top-active); }
/* The setup menu is the longest panel in the topbar (ten entries for the
   owner), so it is allowed to scroll rather than run off the bottom of a
   laptop screen. The handset rule below overrides this with its own ceiling. */
.projmenu-panel { max-height: calc(100vh - var(--topbar-h) - 32px); overflow-y: auto; }
@media (min-width: 900px) {
  .projmenu-label { display: inline; }
}

/* ---- User menu ---- */
.avatar-button { padding: 0 3px; border-color: transparent; }
details[open] > .avatar-button { border-color: var(--top-line); background: var(--top-active); }
.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-pill);
  background: var(--top-active);
  color: var(--top-ink-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.usermenu-panel, .bell-panel { right: 0; }
.usermenu-panel .nav-who { word-break: break-word; }

/* ---- Theme switch: Auto / Light / Dark, inside the user menu ---- */
.theme-switch {
  display: flex;
  margin: 0 var(--s-2) var(--s-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.theme-switch button {
  flex: 1 1 0;
  border: 0;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 8px;
  min-height: 34px;
  cursor: pointer;
  line-height: 1;
}
.theme-switch button + button { border-left: 1px solid var(--line); }
.theme-switch button:hover { background: var(--brand-softer); color: var(--brand-deep); }
.theme-switch button[aria-pressed="true"] {
  background: var(--brand-soft);
  color: var(--brand-ink);
  box-shadow: inset 0 -2px 0 var(--gold);
}

/* ---- The one-tap Field link (phones only; the rail carries it otherwise) -- */
.nav-quick-label { display: none; }
/* Its fold-away twin inside the user menu, shown only below 360px where the
   topbar copy is hidden. One of the two is on screen at any width, never both
   and never neither. */
.usermenu-field { display: none; }

/* ================================================= shell: the navigation ==
   Below 1024px: an off-canvas drawer. It is a light surface sliding OVER the
   page rather than a second dark band, because it is the same list the rail
   shows and the two must not read as different components. */
.shell { display: block; }
.shell-main { min-width: 0; }

.sidenav {
  position: fixed;
  top: var(--topbar-h);
  bottom: 0;
  left: 0;
  z-index: 45;
  width: min(288px, 86vw);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  color: var(--ink);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateX(-100%);
  visibility: hidden;
}
body.nav-open .sidenav { transform: none; visibility: visible; }
@media (prefers-reduced-motion: no-preference) {
  .sidenav { transition: transform 0.2s ease, visibility 0s linear 0.2s; }
  body.nav-open .sidenav { transition: transform 0.2s ease, visibility 0s; }
}
.nav-scrim {
  display: none;
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  z-index: 44;
  background: rgba(0, 0, 0, 0.45);
}
body.nav-open .nav-scrim { display: block; }
body.nav-open { overflow: hidden; }

.sidenav-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s-3) var(--s-2) var(--s-4);
}

/* Which contract this rail belongs to. The switcher answers the same question
   at the top of the window; on a wide screen the eye is already down here. */
.sidenav-context {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0 0 var(--s-3);
  padding: 0 var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.sidenav-context-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.sidenav-context-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.navgroup { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
/* A group is only rendered when at least one of its entries survives the role
   gate, so this heading never appears over an empty list. */
.navgroup-label {
  margin: var(--s-4) var(--s-2) var(--s-1);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.navlink {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  border-left: 3px solid transparent;
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.navlink:hover { background: var(--brand-softer); color: var(--brand-deep); text-decoration: none; }
.navlink .nav-icon { flex: 0 0 auto; color: var(--muted); }
.navlink:hover .nav-icon { color: var(--brand); }
.navlink.is-active {
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 700;
  border-left-color: var(--brand);
}
.navlink.is-active .nav-icon { color: var(--brand); }
.nav-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.navlink .nav-count { margin-left: var(--s-1); }

.sidenav-collapse {
  display: none;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 11px var(--s-3);
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.sidenav-collapse:hover { background: var(--brand-softer); color: var(--brand-deep); }
.sidenav-collapse .nav-icon { flex: 0 0 auto; }

/* ---------------------------------------------------- desktop: the rail --
   ONE breakpoint. Above it the drawer's transform, scrim and hamburger are all
   switched off together and the same element becomes a permanent rail; there is
   no width at which half of each applies. */
@media (min-width: 1024px) {
  :root { --topbar-h: 60px; }

  .nav-toggle, .nav-quick { display: none; }
  .nav-scrim { display: none !important; }
  body.nav-open { overflow: visible; }

  .sidenav {
    width: var(--sidenav-w);
    transform: none;
    visibility: visible;
    transition: none;
    box-shadow: none;
  }
  .sidenav-collapse { display: flex; }
  .shell-main { margin-left: var(--sidenav-w); }

  /* Collapsed to icons. The state is stamped on <html> by the head script
     before first paint, so a rail that was left collapsed never flashes wide.
     Every label stays in the DOM -- hidden from the eye, not from a reader. */
  :root[data-sidenav="rail"] .sidenav { width: var(--sidenav-rail-w); }
  :root[data-sidenav="rail"] .shell-main { margin-left: var(--sidenav-rail-w); }
  :root[data-sidenav="rail"] .sidenav-scroll { padding-left: 6px; padding-right: 6px; }
  :root[data-sidenav="rail"] .sidenav-context { display: none; }
  :root[data-sidenav="rail"] .nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  /* The heading becomes the hairline it always was semantically: a break
     between two kinds of work. Its text is clipped, not removed. */
  :root[data-sidenav="rail"] .navgroup-label {
    height: 1px;
    margin: var(--s-3) 8px var(--s-2);
    padding: 0;
    font-size: 0;
    line-height: 0;
    overflow: hidden;
    background: var(--line);
  }
  :root[data-sidenav="rail"] .navlink {
    position: relative;
    justify-content: center;
    gap: 0;
    padding: 8px 0;
    border-left-width: 0;
  }
  :root[data-sidenav="rail"] .navlink.is-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: var(--brand);
  }
  :root[data-sidenav="rail"] .navlink .nav-count {
    position: absolute;
    top: 2px;
    right: 3px;
    margin: 0;
    padding: 0 5px;
    font-size: 10px;
  }
  :root[data-sidenav="rail"] .sidenav-collapse { justify-content: center; padding: 11px 0; }
  :root[data-sidenav="rail"] .sidenav-collapse .nav-icon { transform: scaleX(-1); }
}

/* On a handset a dropdown is pinned to the viewport rather than to the button
   that opened it: the button can sit anywhere along a 320px topbar, and a panel
   anchored to it hangs off whichever edge it happens to be nearest. */
@media (max-width: 560px) {
  .menu-panel {
    position: fixed;
    left: var(--s-2);
    right: var(--s-2);
    top: calc(var(--topbar-h) + 6px);
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: calc(100vh - var(--topbar-h) - 24px);
    overflow-y: auto;
  }
  .bell-panel { width: auto; max-width: none; max-height: calc(100vh - var(--topbar-h) - 24px); }
}

/* Handsets and small tablets: the lockup gives up its WORDMARK before anything
   else in the row is allowed to shrink below a 36px tap target. The mark itself
   stays, and it is what carries the identity.

   **600px rather than the 420px this used to be, and that IS the fix for the
   433-448px overflow** -- see the measurements beside `.switcher-button` above.
   Six 38px controls, their gaps and the row's padding come to ~290px on their
   own, so below 600px the wordmark was spending eighty-five pixels the row did
   not have, and the project switcher (already shrinking, already ellipsised)
   was sitting on its 62px floor with nothing left to give. Between the two, the
   switcher is the one worth keeping: it says which contract is open, and the
   mark beside it already says whose app this is. */
@media (max-width: 600px) {
  .brand-name { display: none; }
}
@media (max-width: 420px) {
  .topbar-inner { gap: 6px; padding: 0 var(--s-2); }
  .brand-logo { height: 26px; }
  .switcher-button { max-width: 40vw; padding: 0 6px; gap: 2px; }
  .nav-toggle, .nav-quick, .projmenu-button, .bell-menu > summary {
    padding: 0 7px;
    min-width: 36px;
  }
  .avatar-button { min-width: 34px; }
  .avatar { width: 28px; height: 28px; font-size: 11px; }
}

/* ---- 320px: the real floor -----------------------------------------------
 * The owner's ruling is that the app is inclusive of every device, and the
 * smallest one anybody still hands a foreman is a 320px screen (iPhone SE 1st
 * gen, the cheap Androids that go to site). Measured on the real markup with
 * the bell carrying a two-digit count, the row wanted 370px inside a 304px
 * content box -- 65px over, and the page scrolled sideways on every screen in
 * the app because the topbar is the shell:
 *
 *     nav-toggle 36 + brand 32 + switcher 62 + projmenu 36 + spacer 8
 *     + Field 36 + bell 75 + avatar 36, with seven 6px gaps ......... 370px
 *
 * Two changes pay for it, and neither of them grows the navigation or drops a
 * control the row cannot do without:
 *
 *   * the bell's count moves ON TOP of its icon instead of beside it
 *     (`.bell-button .nav-count` down in the bell section) ......... -39px
 *   * the Field link folds into the user menu below 360px ......... -42px
 *   * the gaps and the row's padding give a pixel each (below) ..... -14px
 *
 * which leaves
 *
 *     nav-toggle 36 + brand 32 + switcher 62 + projmenu 36 + spacer 8
 *     + bell 36 + avatar 36, with six 5px gaps ..................... 276px
 *
 * inside the 308px a 320px screen has once the row's padding is paid -- and
 * the switcher, the one item allowed to give, takes the 32px of slack back as
 * a longer project name. Verified in a browser, not by arithmetic: 46 pages x
 * 20 widths from 320 to 1440 x both themes, zero horizontal overflow.
 *
 * The three that stay are the three a phone cannot work without: the drawer
 * toggle (the only route to the sections), the switcher (which contract am I
 * looking at) and the bell (the only thing that says something is wrong). The
 * fold is the SAME control at every width below the breakpoint -- Field is
 * gone from 359px down, not shuffled about -- because a row that reorders
 * itself as the window narrows is a row nobody can learn. */
@media (max-width: 359px) {
  .nav-quick { display: none; }
  .usermenu-field { display: flex; }
  /* Tap targets stay at 36 x 38px here rather than tightening further: the
     row already fits, and shaving a touch target to buy space it does not
     need is how a small screen becomes an unusable one. Only the dead space
     gives. */
  .topbar-inner { gap: 5px; padding: 0 6px; }
}
@media (min-width: 560px) {
  .nav-quick-label { display: inline; }
}

/* ---- The /projects switcher page (not the topbar dropdown) ---- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--s-3);
}
.project-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-2);
}
.project-card-head h2 { margin: 0; font-size: 18px; }

/* ========================================================== layout ======== */
.container { max-width: 1200px; margin: 0 auto; padding: var(--s-5) var(--s-4) 64px; }

/* Site-wide footer: identity plus the Terms link, quiet enough to ignore.
   Hidden in print -- a report carries its own footer. */
.appfoot {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--s-4) var(--s-5);
  border-top: 1px solid var(--line);
}
.appfoot p { margin: var(--s-3) 0 0; }
.appfoot a { color: var(--muted); }
.appfoot a:hover { color: var(--brand); }

/* The Terms of Use document: a reading column, not a dashboard. */
.legal-page .card { max-width: 46em; }
.legal-doc h1 { font-size: 22px; margin: 0 0 2px; }
.legal-doc h2 { font-size: 15px; margin: var(--s-5) 0 var(--s-2); color: var(--brand); }
.legal-doc p { max-width: 42em; line-height: 1.65; }
.legal-head { border-bottom: 2px solid var(--gold); padding-bottom: var(--s-3); margin-bottom: var(--s-4); }
.legal-org { margin: 0; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--brand); font-size: 12px; }
.legal-meta { color: var(--muted); font-size: 13px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
  margin-bottom: var(--s-4);
}
h1 { font-size: 22px; margin: 0 0 var(--s-1); line-height: 1.25; }
h2 { font-size: 17px; margin: 0 0 10px; line-height: 1.3; }
h3 { font-size: 15px; margin: 0 0 var(--s-2); line-height: 1.35; }
.subtitle { color: var(--muted); font-size: 14px; margin: 0; }

/* ========================================================== page tabs ===== */
/* Progressive disclosure on the station and facility pages. Every pane stays in
   the document -- see static/js/tabs.js for why that is not negotiable -- so
   this is purely a matter of which one is showing. Sticky under the topbar,
   because on a long pane the way back to the other three must not be a scroll. */
.page-tabs {
  display: flex;
  gap: 2px;
  position: sticky;
  top: var(--topbar-h);
  z-index: 25;
  margin: 0 0 var(--s-4);
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.page-tabs::-webkit-scrollbar { display: none; }
.page-tabs [role="tab"] {
  flex: 1 1 auto;
  min-height: 40px;
  padding: 8px 14px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.page-tabs [role="tab"]:hover { background: var(--brand-softer); color: var(--brand-deep); }
.page-tabs [role="tab"][aria-selected="true"] {
  background: var(--brand-soft);
  color: var(--brand-ink);
  box-shadow: inset 0 -2px 0 var(--gold);
}
.tabpane[hidden] { display: none; }

/* ========================================================== cards ========= */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s-4);
  margin-bottom: var(--s-4);
  box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.card-narrow { max-width: 460px; margin-left: auto; margin-right: auto; }

/* A card that folds. The heading stays a heading -- it is still the thing you
   read to know what is inside -- and the disclosure triangle is the only thing
   the <summary> adds to it. */
.section > summary {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  flex-wrap: wrap;
  cursor: pointer;
  list-style: none;
  border-radius: var(--r-sm);
  padding: 2px;
  margin: -2px;
}
.section > summary::-webkit-details-marker { display: none; }
.section > summary::before {
  content: "\25B8";
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}
.section[open] > summary::before { content: "\25BE"; }
.section > summary:hover { background: var(--brand-softer); }
.section > summary h2 { margin: 0; }
.section-body { margin-top: var(--s-3); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-3); }
.kv { margin: 0; }
.kv dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.kv dd { margin: 2px 0 10px; font-size: 15px; }

/* ---- Login: the brand moment ---- */
/* A column, not a row: the flash block is a sibling of the card and would
   otherwise sit beside it instead of above it. */
.auth-page {
  min-height: calc(100vh - var(--topbar-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: var(--s-6);
  background:
    radial-gradient(120% 90% at 50% -10%, var(--brand-softer) 0%, transparent 62%);
}
.auth-page .flashes { width: 100%; max-width: 420px; }
.auth-card {
  width: 100%;
  max-width: 420px;
  margin: 0;
  padding: var(--s-5);
  border-top: 3px solid var(--gold);
  box-shadow: var(--shadow-lg);
}
.auth-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--s-4);
  text-align: center;
}
.auth-mark img { width: 132px; height: auto; border-radius: var(--r-sm); display: block; }
.auth-mark h1 { font-size: 20px; margin: 0; }
.auth-mark .subtitle { font-size: 13px; }

/* ========================================================== tables ======== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* A table wider than the card scrolls inside the card, never the page. */
  max-width: 100%;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  background: var(--brand-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--brand-ink);
  white-space: nowrap;
  font-weight: 700;
  border-bottom: 1px solid var(--line-strong);
}
tbody tr:hover { background: var(--brand-softer); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: var(--s-5); text-align: center; color: var(--muted); }
tbody td.empty { background: var(--panel-sunken); }

/* ========================================================== badges ======== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  background: var(--neutral-bg);
  color: var(--muted);
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge.planned,
.badge.not_started { background: var(--neutral-bg); color: var(--muted); }
.badge.mobilization { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge.ongoing,
.badge.in_progress { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.badge.suspended { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.badge.completed,
.badge.done { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.badge.turned_over { background: var(--brand-soft); color: var(--brand-ink); border-color: var(--line-strong); }
.badge.role { background: var(--brand-soft); color: var(--brand-ink); border-color: var(--line-strong); }
.badge.danger { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }

/* RAG stays semantically red / amber / green -- never the brand greens. */
.badge.rag-green { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.badge.rag-amber { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge.rag-red { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.nav-count { margin-left: 4px; }

/* ========================================================== progress ====== */
.bar {
  background: var(--neutral-bg);
  border-radius: var(--r-pill);
  height: 8px;
  min-width: 70px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: var(--r-pill); }

/* ========================================================== forms ========= */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: var(--s-1); color: var(--ink); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="week"], input[type="month"], input[type="search"],
input[type="file"], select, textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--panel);
  font: inherit;
  color: var(--ink);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.85; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
  border-color: var(--focus);
}
textarea { min-height: 90px; resize: vertical; }
select[multiple] { min-height: 150px; }
/* The UA paints its own chrome for these two; in dark mode both would come out
   as a light plate inside a dark panel unless they are told otherwise. */
option:checked, option:hover { background: var(--brand-soft); color: var(--brand-ink); }
input[type="file"] { padding: 6px 8px; }
input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--brand-softer);
  color: var(--brand);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--brand-soft); }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: var(--s-1); }
.field .error { font-size: 12px; color: var(--bad); margin-top: var(--s-1); font-weight: 600; }
.check { display: flex; align-items: center; gap: var(--s-2); }
.check input { width: auto; accent-color: var(--brand); }
.check label { margin: 0; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 14px; }
.actions { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; margin-top: var(--s-2); }

/* Dark mode: the browser's own widget chrome has to be told. */
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}

/* ========================================================== buttons ======= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  min-height: 38px;
  border-radius: var(--r-sm);
  border: 1px solid var(--brand);
  background: var(--brand);
  color: var(--on-brand);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
}
.btn:hover { background: var(--brand-deep); border-color: var(--brand-deep); text-decoration: none; color: var(--on-brand); }
.btn.secondary { background: var(--panel); color: var(--brand); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--brand-softer); color: var(--brand-deep); border-color: var(--brand); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--on-bad); }
.btn.danger:hover { background: var(--bad); border-color: var(--bad); filter: brightness(0.9); }
.btn.small { padding: 5px 9px; min-height: 30px; font-size: 13px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.inline-form { display: inline; }


/* ========================================================== filters ======= */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin-bottom: 0; min-width: 160px; flex: 1 1 160px; }

/* ========================================================== flash ========= */
.flashes { margin-bottom: 14px; }
.flash {
  padding: 10px var(--s-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  background: var(--neutral-bg);
  color: var(--ink);
  margin-bottom: var(--s-2);
  font-size: 14px;
}
.flash.success { background: var(--ok-bg); border-color: var(--ok-line); border-left-color: var(--ok); color: var(--ok); }
.flash.error { background: var(--bad-bg); border-color: var(--bad-line); border-left-color: var(--bad); color: var(--bad); }
.flash.warning { background: var(--warn-bg); border-color: var(--warn-line); border-left-color: var(--warn); color: var(--warn); }
.flash.info { background: var(--info-bg); border-color: var(--info-line); border-left-color: var(--info); color: var(--info); }

/* ========================================================== empty states == */
.placeholder-panel {
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
  padding: var(--s-5) var(--s-4);
  text-align: center;
  color: var(--muted);
  background: var(--panel-sunken);
  font-size: 14px;
}

/* ========================================================== feed ========== */
.progress-form { border-bottom: 1px solid var(--line); padding-bottom: var(--s-2); margin-bottom: var(--s-3); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed-item {
  border-left: 3px solid var(--line-strong);
  padding: var(--s-2) 0 var(--s-2) var(--s-3);
  margin-bottom: var(--s-2);
}
.feed-item.progress { border-left-color: var(--ok); }
.feed-item.correction { border-left-color: var(--bad); background: var(--bad-bg); }
.feed-item.note { border-left-color: var(--brand); }
.feed-item.empty { border-left-color: transparent; color: var(--muted); font-size: 14px; }
.feed-item.is-live { animation: feed-in 0.6s ease-out; }
@keyframes feed-in { from { background: var(--gold-soft); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) {
  .feed-item.is-live { animation: none; }
}
.feed-head { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.feed-pct { font-variant-numeric: tabular-nums; font-weight: 700; }
.feed-meta { margin-top: 2px; }
.feed-note { margin-top: var(--s-1); white-space: pre-wrap; }
.struck { text-decoration: line-through; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ========================================================== stats ========= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: var(--s-3) 14px;
}
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-value { font-size: 24px; font-weight: 700; margin: var(--s-1) 0 6px; font-variant-numeric: tabular-nums; }
.stat-value.is-danger { color: var(--bad); }
.stat-unit { font-size: 14px; font-weight: 500; color: var(--muted); }
.stat-rags { display: flex; gap: 5px; flex-wrap: wrap; font-size: 12px; font-weight: 600; }
.stat-sub { font-size: 12px; }
.stat-sub.ahead { color: var(--ok); }
.stat-sub.behind { color: var(--bad); }

/* ========================================================== map =========== */
.map-layout { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(220px, 1fr); gap: 14px; }
.map {
  height: 460px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  /* Leaflet stacks its panes and controls up to z-index 1000 INSIDE the map.
   * isolation caps all of that at this element's own level, so the topbar's
   * dropdown panels (the Manage menu) can never be covered by map controls. */
  isolation: isolate;
  position: relative;
  z-index: 0;
}
.map-tall { height: 560px; }
/* leaflet.css is linked from head_extra, i.e. AFTER this file, so every override
   below carries one extra class (:root / .leaflet-container) to win the tie.
   Without it Leaflet's own `background: #fff` repaints the controls white in
   dark mode and the near-white label text vanishes into them. */
:root .leaflet-container { font: inherit; background: var(--panel-sunken); }
.map-popup { min-width: 200px; }
.map-popup-kv { margin: 6px 0; display: grid; grid-template-columns: auto 1fr; gap: 1px var(--s-2); }
.map-popup-kv dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; }
.map-popup-kv dd { margin: 0; font-size: 13px; }

/* Leaflet chrome follows the theme. The STREET tiles are inverted in dark mode
   (see .osm-tiles below); the satellite layer is imagery and stays untouched. */
:root .leaflet-popup-content-wrapper,
:root .leaflet-popup-tip {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
:root .leaflet-popup-content-wrapper { border-radius: var(--r); border: 1px solid var(--line); }
:root .leaflet-popup-content a { color: var(--brand); }
:root .leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
:root .leaflet-container a.leaflet-popup-close-button:hover { color: var(--ink); background: transparent; }
:root .leaflet-bar a,
:root .leaflet-bar a:hover,
:root .leaflet-control-layers,
:root .leaflet-control-layers-expanded,
:root .leaflet-tooltip {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line-strong);
}
:root .leaflet-bar a:hover { background: var(--brand-softer); }
:root .leaflet-bar a.leaflet-disabled { background: var(--panel-sunken); color: var(--muted); }
:root .leaflet-control-layers-toggle,
:root .leaflet-control-layers label,
:root .leaflet-control-layers-list { color: var(--ink); }
:root .leaflet-control-layers-separator { border-top-color: var(--line); }
/* Leaflet scopes this one as `.leaflet-container .leaflet-control-attribution`,
   so the override needs three classes rather than two. */
:root .leaflet-container .leaflet-control-attribution {
  background: var(--panel);
  color: var(--muted);
}
:root .leaflet-container .leaflet-control-attribution a { color: var(--brand); }
:root .leaflet-tooltip { border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
:root .leaflet-tooltip-top::before { border-top-color: var(--line-strong); }
:root .leaflet-tooltip-bottom::before { border-bottom-color: var(--line-strong); }
:root .leaflet-tooltip-left::before { border-left-color: var(--line-strong); }
:root .leaflet-tooltip-right::before { border-right-color: var(--line-strong); }

/* Dark street tiles. Scoped to the OSM layer's own class so Esri imagery -- the
   Satellite layer -- is never touched: inverted aerial photography is unusable. */
:root[data-theme="dark"] .leaflet-tile-pane .osm-tiles {
  filter: invert(1) hue-rotate(180deg) brightness(0.94) contrast(0.92) saturate(0.72);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .leaflet-tile-pane .osm-tiles {
    filter: invert(1) hue-rotate(180deg) brightness(0.94) contrast(0.92) saturate(0.72);
  }
}

.unmapped-panel {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s-3);
  background: var(--panel-sunken);
  overflow: auto;
  max-height: 460px;
}
.unmapped-list { list-style: none; margin: var(--s-2) 0 0; padding: 0; }
.unmapped-list li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.map-legend { display: grid; grid-template-columns: auto 1fr; gap: 2px var(--s-2); margin: 14px 0 0; align-items: center; }
.map-legend dt { margin: 0; }
.map-legend dd { margin: 0; font-size: 12px; color: var(--muted); }
.dot {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 2px solid var(--panel);
  box-shadow: 0 0 0 1px var(--line-strong);
}
.dot.rag-green { background: var(--rag-green); }
.dot.rag-amber { background: var(--rag-amber); }
.dot.rag-red { background: var(--rag-red); }
.dot.rag-none { background: var(--rag-none); }

.geotag-form { margin-top: 14px; }

/* -- Geotag proposals -----------------------------------------------------
 * The pending-approval block that sits under the Coordinates row of a site or
 * facility page, plus the two-pin legend above the placement map. Warn colours
 * throughout, from the same --warn family the amber RAG badge uses: a proposal
 * is a question nobody has answered, not a failure.
 * ------------------------------------------------------------------------- */
.geo-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0 0 8px; }
.geo-key {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  margin-right: 2px;
  vertical-align: -1px;
}
.geo-key-official { border: 2px solid var(--rag-green); background: var(--ok-bg); }
.geo-key-proposed { border: 2px dashed var(--rag-amber); background: var(--warn-bg); }

.geo-proposal {
  /* The row it sits in is .mono, which is right for a coordinate pair and wrong
     for a sentence. Step back out to the page font for the prose. */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--warn-line);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: var(--warn-bg);
}
.geo-proposal-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.geo-proposal-who { font-size: 13px; color: var(--warn); }
.geo-proposal-note { margin: 6px 0 0; color: var(--warn); }
.geo-proposal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 8px;
}
.geo-proposal-decide { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: 1 1 auto; }
/* The reason takes its own line and the two verdicts share the next one. The
   block lives in a narrow key/value column on every page that shows it, so
   letting the box share a line would push one button below the other -- two
   verdicts at different heights read as a hierarchy they do not have. */
.geo-proposal-decide input[type="text"] { flex: 1 1 100%; min-width: 0; font-size: 13px; padding: 5px 8px; }
.geo-proposal-decide .btn { flex: 0 0 auto; }

/* ========================================================== timeline ====== */
.timeline-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; max-width: 100%; }
.timeline { min-width: 860px; }
.tl-row { display: grid; grid-template-columns: 190px minmax(0, 1fr); align-items: center; gap: 10px; }
.tl-row:hover { background: var(--brand-softer); }
.tl-axis {
  border-bottom: 1px solid var(--line);
  padding-bottom: var(--s-1);
  margin-bottom: 6px;
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
}
.tl-axis .tl-track { height: 18px; }
.tl-tick {
  position: absolute;
  top: 0;
  font-size: 11px;
  color: var(--muted);
  border-left: 1px solid var(--line);
  padding-left: 3px;
  white-space: nowrap;
  height: 100%;
}
.tl-tick.is-year { border-left-color: var(--line-strong); color: var(--ink); font-weight: 600; }

.tl-label { display: flex; align-items: baseline; gap: 6px; padding: 3px 0 3px 2px; overflow: hidden; color: var(--ink); }
.tl-label:hover { text-decoration: none; color: var(--brand); }
.tl-code { font-weight: 600; font-size: 13px; white-space: nowrap; }
.tl-pct { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.tl-track { position: relative; height: 20px; }
.tl-bar {
  position: absolute;
  top: 4px;
  height: 12px;
  background: var(--neutral-bg);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  overflow: hidden;
}
.tl-fill { display: block; height: 100%; background: var(--rag-none); }
.tl-fill.rag-green { background: var(--rag-green); }
.tl-fill.rag-amber { background: var(--rag-amber); }
.tl-fill.rag-red { background: var(--rag-red); }
.tl-fill.rag-none { background: var(--rag-none); }
.tl-nobar { position: absolute; left: 0; top: 3px; }
.tl-today { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dashed var(--bad); pointer-events: none; }
.tl-row.is-live .tl-bar { box-shadow: 0 0 0 2px var(--gold); }
.tl-fill { transition: width 0.4s ease-out; }
@media (prefers-reduced-motion: reduce) { .tl-fill { transition: none; } }

.tl-group { border-top: 1px solid var(--line); }
.tl-group[open] { padding-bottom: 6px; }
.tl-group-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  cursor: pointer;
  padding: 7px 2px;
  list-style: none;
}
.tl-group-head::-webkit-details-marker { display: none; }
.tl-group-head::before { content: "\25B8"; color: var(--muted); font-size: 11px; }
.tl-group[open] > .tl-group-head::before { content: "\25BE"; }
.tl-group-head:hover { background: var(--brand-softer); }
.tl-group-name { font-weight: 600; font-size: 14px; }
.timeline-empty { border: 1px dashed var(--line-strong); border-radius: var(--r); background: var(--panel-sunken); }
.timeline-empty p { margin: var(--s-1) 0; }
.timeline-foot { margin: var(--s-2) 0 0; }

/* ========================================================== charts ======== */
.chart-wrap { position: relative; height: 320px; }
/* A canvas with no chart on it yet is 300 CSS px wide -- that is the HTML
   default, not a choice -- which is wider than the card holding it on a 320px
   screen. Chart.js resizes it to its container the moment it runs, but that is
   after the first paint and never at all when the vendor bundle has not
   arrived, so the element carries its own ceiling rather than trusting a script
   to save the layout. */
.chart-wrap > canvas { max-width: 100%; }
.gantt-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.gantt-toolbar .btn.active {
  background: var(--brand);
  color: var(--on-brand);
  border-color: var(--brand);
}
.gantt-hint { flex: 1 1 240px; }
.gantt-chart { overflow-x: auto; max-width: 100%; }
.gantt-container { max-height: 560px; }

/* ---- billing milestones: a lane above the chart, on its own axis ----------
   A billing threshold is a PERCENTAGE and the Gantt's axis is a DATE, so the
   marker gets a 0-100 rail of its own rather than a projected vertical line
   pretending to be a date. See the header of static/js/gantt.js.

   CALM, per the standing doctrine: no fill, no colour and no weight until the
   work is actually near the threshold. A station with four milestones on it is
   four quiet rows, not four alarms. The lane is `hidden` until gantt.js has
   something to put in it, so a client -- whose payload carries no milestones at
   all -- sees no empty container and no heading.

   These rules live in app.css rather than in finance.css because the station
   page is drawn for every staff role and none of them loads the money
   stylesheet; the AMOUNT is what finance.css would have been protecting, and
   the amount is stripped on the server before it reaches this markup. */
.gantt-milestones { margin: 0 0 var(--s-3); }
.gm-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--s-2);
}
@media (min-width: 720px) {
  .gm-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.gm-item {
  padding: var(--s-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--panel-sunken);
}
/* A contract-wide milestone appears on EVERY station's lane, so it is drawn
   back a step: same shape, dashed edge, muted label. It is context for the
   station rather than a fact about it. */
.gm-item.is-project { border-style: dashed; }
.gm-item.is-project .gm-label { color: var(--muted); }

.gm-head { display: flex; flex-wrap: wrap; gap: var(--s-1); align-items: baseline; }
.gm-label { font-weight: 600; font-size: 13px; }
.gm-scope { font-size: 12px; color: var(--muted); }
.gm-amount {
  margin-left: auto;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.gm-rail {
  position: relative;
  display: block;
  height: 6px;
  margin: var(--s-1) 0 4px;
  border-radius: 3px;
  background: var(--line);
}
.gm-done { display: block; height: 100%; border-radius: 3px; background: var(--brand); }
/* The flag needs one ring of the card's own background around it, or a REACHED
   milestone -- whose green fill runs right past the threshold -- hides its own
   marker in the fill. Two greens a shade apart at 2px wide is not a marker. */
.gm-flag {
  position: absolute;
  top: -4px;
  width: 3px;
  height: 14px;
  margin-left: -1.5px;
  border-radius: 1px;
  background: var(--muted);
  box-shadow: 0 0 0 1.5px var(--panel-sunken);
}
.gm-flag.is-nearing { background: var(--warn); }
.gm-flag.is-reached { background: var(--ok); }
.gm-foot { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- the dashboard's income strip ----------------------------------------
   One row, three figures, a link. Rendered only for a reader who may see money
   (the route hands the template None otherwise), so there is no "hidden" state
   here and nothing to grey out.

   Deliberately no chart, no bar and no fourth figure: the dashboard's question
   is whether the programme is on track, and this is a line of context beside
   it rather than a second dashboard. Everything behind it is one click away on
   the Finance page's Billings tab. */
.income-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  justify-content: space-between;
}
.income-figures {
  display: grid;
  gap: var(--s-2);
  margin: var(--s-2) 0 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.income-figures dt { font-size: 12px; color: var(--muted); }
.income-figures dd {
  margin: 2px 0 0;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 479px) {
  /* Three money figures side by side at 375px is three truncated numbers.
     One per row, full width, readable. */
  .income-figures { grid-template-columns: 1fr; gap: var(--s-1); }
  .income-figures div { display: flex; justify-content: space-between; align-items: baseline; }
  .income-figures dd { margin-top: 0; font-size: 16px; }
}

/* ---- Frappe Gantt: its own --g-* tokens, re-pointed at ours.
       Defined on .gantt-container (not :root) so these beat the vendor file's
       own html[data-theme=dark] block, which is loaded after app.css. ---- */
.gantt-container {
  --g-arrow-color: var(--muted);
  --g-bar-color: var(--neutral-bg);
  --g-bar-border: var(--line-strong);
  --g-tick-color-thick: var(--line-strong);
  --g-tick-color: var(--line);
  --g-actions-background: var(--brand-soft);
  --g-border-color: var(--line);
  --g-text-muted: var(--muted);
  --g-text-light: var(--on-brand);
  --g-text-dark: var(--ink);
  --g-progress-color: var(--brand);
  --g-handle-color: var(--brand-deep);
  --g-weekend-label-color: var(--neutral-bg);
  --g-expected-progress: var(--line-strong);
  --g-header-background: var(--panel);
  --g-row-color: var(--panel);
  --g-row-border-color: var(--line);
  --g-today-highlight: var(--gold);
  --g-popup-actions: var(--brand-soft);
  --g-weekend-highlight-color: var(--panel-sunken);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
/* Bar fill by task status -- same semantics as the badges. */
.gantt-container .bar-not_started .bar-progress { fill: var(--rag-none); }
.gantt-container .bar-in_progress .bar-progress { fill: var(--brand); }
.gantt-container .bar-done .bar-progress { fill: var(--ok); }
.gantt-container .bar-label,
.gantt-container .bar-label.big { fill: var(--ink); }
/* --g-today-highlight paints the vertical "today" line, its ball AND the date
   chip in the header. Gold is right for the first two and forbidden under the
   chip -- gold never carries text -- so the chip is re-paired with the brand. */
/* Two class names deep on purpose: frappe-gantt.css is linked after app.css,
   so a single-class override would lose the cascade tie. */
.gantt-container .lower-text.current-date-highlight,
.gantt-container .current-date-highlight {
  background: var(--brand);
  color: var(--on-brand);
}
.gantt-container .popup-wrapper { border: 1px solid var(--line); }
.gantt-container .popup-wrapper .title,
.gantt-container .popup-wrapper .subtitle { color: var(--ink); }
.gantt-container .popup-wrapper .details { color: var(--muted); }

/* ========================================================== misc ========== */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
/* A single unbroken token (a CSV header line, a key) has no break opportunity
   of its own and would push the whole page sideways on a phone. */
.code-line {
  background: var(--panel-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--s-2) 10px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Spacing utilities on the one scale -- these replaced the scattered inline
   `style="margin-top:14px"` attributes so nothing sets geometry off-scale. */
.mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mb-1 { margin-bottom: var(--s-1); }
.auth-foot { margin-top: var(--s-4); }
.qr-hint { margin-bottom: var(--s-1); }
.qr-form { margin-top: var(--s-4); }
/* WBS editor: narrow numeric cells, sized here rather than per-element. */
.col-seq { width: 90px; }
.col-weight { width: 110px; }
.col-days { width: 120px; }
.col-seq input, .col-weight input, .col-days input { width: 100%; min-width: 70px; }
.row-error { background: var(--bad-bg); }
.row-error:hover { background: var(--bad-bg); }
.row-skip { background: var(--warn-bg); }
.row-skip:hover { background: var(--warn-bg); }
.qr {
  display: block;
  margin: var(--s-3) auto;
  width: 200px;
  height: 200px;
  image-rendering: pixelated;
  background: var(--paper);   /* black-on-white or it will not scan */
  padding: 6px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
}
.secret-key {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  background: var(--panel-sunken);
  border: 1px solid var(--line);
  padding: var(--s-2) 10px;
  border-radius: var(--r-sm);
  word-break: break-all;
  text-align: center;
  font-size: 14px;
}
.htmx-request .htmx-indicator { visibility: visible; }
.htmx-indicator { visibility: hidden; color: var(--muted); font-size: 13px; }

/* ========================================================== install ======= */
/* Deliberately slim: one line of chrome above the page, not a hero. Ships
   hidden -- static/js/install.js decides whether this browser sees it at all. */
.install-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 10px var(--s-3);
  margin-bottom: 14px;
}
.install-card[hidden], .install-steps[hidden], [data-install-guide][hidden] { display: none; }
.install-row { display: flex; align-items: center; gap: 10px; }
.install-icon { border-radius: var(--r-sm); flex: 0 0 auto; }
.install-text { flex: 1 1 auto; min-width: 0; }
.install-text strong { display: block; font-size: 14px; }
.install-text p { margin: 2px 0 0; }
.install-dismiss {
  flex: 0 0 auto;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  min-width: 32px;
  min-height: 32px;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.install-dismiss:hover { background: var(--neutral-bg); color: var(--ink); }

/* ============================================================= push ======= */
/* The opt-in reuses the install card's shape on the field home screen (they
   read as one idea) and gets a plain card of its own on /me/notifications.
   Every state is written by static/js/push.js into data-push-state; the colour
   is the only thing that varies, and only to separate "on" from "blocked". */
.push-card { border-left-color: var(--accent, var(--gold)); }
.push-card[hidden], .push-panel [data-push][hidden] { display: none; }
.push-panel { margin-bottom: 14px; }
.push-panel h2 { margin: 0 0 6px; font-size: 15px; }
.push-panel .actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.push-panel[data-push-state="on"] { border-left: 3px solid var(--ok, var(--gold)); }
.push-panel[data-push-state="blocked"],
.push-panel[data-push-state="unsupported"],
.push-panel[data-push-state="unconfigured"] { border-left: 3px solid var(--line); }
.install-steps {
  margin-top: 10px;
  padding: 10px var(--s-3);
  background: var(--panel-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.install-steps p { margin: 0 0 6px; }
.install-steps ol { margin: 0 0 6px; padding-left: 20px; font-size: 13px; }
.install-steps li { margin-bottom: 5px; }
.install-glyph { vertical-align: -2px; }

/* ========================================================== field zone ==== */
/* Mobile-first: single column, 48px touch targets, nothing that needs a mouse.
   These styles are additive -- the office pages never load a .field-shell. */
.field-shell { max-width: 620px; margin: 0 auto; }

.field-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: var(--s-2) var(--s-3);
  margin-bottom: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  position: sticky;
  /* Under the topbar, not under the top of the window: the topbar is sticky
     too, and a bar pinned to 0 would slide behind it. */
  top: calc(var(--topbar-h) + var(--s-2));
  z-index: 20;
}
.net-dot { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.net-dot::before {
  content: "";
  width: 10px; height: 10px;
  border-radius: var(--r-pill);
  background: var(--muted);
  flex: 0 0 auto;
}
.net-dot[data-state="online"] { color: var(--ok); }
.net-dot[data-state="online"]::before { background: var(--ok); }
.net-dot[data-state="offline"] { color: var(--bad); }
.net-dot[data-state="offline"]::before { background: var(--bad); }
.field-outbox-link { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }

.field-sync-state { min-height: 18px; margin: 0 0 10px; color: var(--muted); }
.field-sync-state[data-state="error"], .field-sync-state[data-state="auth"] { color: var(--bad); }
.field-sync-state[data-state="offline"] { color: var(--warn); }
.field-sync-state[data-state="done"] { color: var(--ok); }

.field-site-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.field-site-head h2 { margin-bottom: 2px; }
.field-site-progress { display: flex; align-items: center; gap: 10px; margin: 10px 0 var(--s-3); }
.field-site-progress .bar { flex: 1 1 auto; }
.field-actions { display: grid; gap: var(--s-2); }

/* EU-12: the field home -- one row per site, expanding on tap to its actions.
   The row is a <summary>, so it opens with no script at all, and it is 48px
   tall for the same glove reason as .btn.big. Long names WRAP, never clip. */
.field-site-search { margin-bottom: var(--s-3); }
.field-site-search input { width: 100%; box-sizing: border-box; }
.field-group-head { font-size: 15px; margin: var(--s-4) 0 var(--s-2); color: var(--muted); }
.field-site-list { list-style: none; margin: 0 0 var(--s-3); padding: 0; }
.field-site {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  margin-bottom: var(--s-2);
}
.field-site-row {
  /* Line one: fold mark, code, percent, upload chip. Line two: name and port. */
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: var(--s-2);
  row-gap: 2px;
  min-height: 48px;
  padding: var(--s-2) var(--s-3);
  cursor: pointer;
  list-style: none;
  box-sizing: border-box;
}
.field-site-row::-webkit-details-marker { display: none; }
.field-site-row::before {
  content: "\25B8";
  color: var(--muted);
  font-size: 14px;
  flex: 0 0 auto;
}
details[open] > .field-site-row::before { content: "\25BE"; }
.field-site-code { min-width: 0; overflow-wrap: anywhere; }
.field-site-name {
  grid-column: 2 / -1;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  color: var(--muted);
}
.field-site-pct { font-variant-numeric: tabular-nums; color: var(--muted); }
.field-site-body { padding: 0 var(--s-3) var(--s-3); }
.field-site-body .bar { margin-bottom: var(--s-3); }
.field-site.is-last { border-color: var(--brand); }
/* The upload chip shows only on a site with unsent or refused entries. `.badge`
   states display:inline-block, which beats the UA's [hidden], so say it here. */
.field-site-row .badge[hidden] { display: none; }
/* The one upload line above the list: quiet when clean, amber when not. */
.field-upload-summary { margin: 0 0 var(--s-3); min-height: 1.4em; }
.field-upload-summary.is-dirty { color: var(--warn); font-weight: 600; }
.field-help-line { margin: var(--s-3) 0; }

/* Big touch targets: 48px is the smallest comfortable tap area with gloves on. */
.btn.big { padding: 14px var(--s-4); font-size: 16px; min-height: 48px; }
.btn.primary-save { background: var(--ok); border-color: var(--ok); color: var(--on-ok); }
.btn.primary-save:hover { background: var(--ok); border-color: var(--ok); filter: brightness(0.92); }
/* `output` is named alongside `input` in all three of these because the percent
   readout stopped being a control at EU-03 -- it is an <output> now
   (app/templates/field/progress.html) -- and an element-scoped rule would have
   dropped it out of the 48px glove standard on the day it changed tag. */
.field-form input.big, .field-form select.big, .field-form output.big { min-height: 48px; font-size: 16px; }
.field-form input.num, .field-form output.num { text-align: center; font-variant-numeric: tabular-nums; }
/* An <output> is inline by default and inherits none of the input chrome, so
   min-height alone would neither hold the box open nor make it read as the
   figure between the two step buttons. */
.field-form output.big {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--panel);
  color: var(--ink);
  font-weight: 600;
}
.label-like { display: block; font-size: 13px; font-weight: 600; margin-bottom: var(--s-1); color: var(--ink); }


.stepper { display: flex; gap: var(--s-2); align-items: stretch; }
.stepper .step { min-width: 68px; min-height: 48px; font-size: 17px; }
.stepper input, .stepper output { flex: 1 1 auto; }
/* RENDER-1: `margin: 10px 0 0`, never `margin-top` alone. The UA sheet gives a
   range input 2px of horizontal margin, and 100% width plus that margin is 4px
   wider than its container -- measured on the handset progress screen at every
   width, in both themes. */
/* TT-1: the THUMB is the thing a gloved hand grabs, so it gets the 48px glove
   floor as a HIT AREA, not as a bigger picture. The drawn disc stays 24px; the
   other 24px is a transparent border (background-clip keeps the paint inside
   it), which the browser still counts as the thumb for a touch. The input box
   is 48px tall for the same reason -- in Chromium and Firefox a touch anywhere
   on it grabs the thumb; in WebKit only the thumb itself does, hence both.
   Margin stays the RENDER-1 shorthand (every side stated, no UA remainder).
   --fill is the thumb's position, set by field.js, painting the track left of
   it the way accent-color used to. */
input[type="range"] {
  width: 100%;
  margin: 10px 0 0;
  height: 48px;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  accent-color: var(--brand);
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--brand) var(--fill, 0%), var(--line-strong) var(--fill, 0%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  margin-top: -21px;
  border: 12px solid transparent;
  border-radius: 50%;
  background: var(--brand);
  background-clip: padding-box;
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line-strong); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--brand); }
input[type="range"]::-moz-range-thumb {
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  border: 12px solid transparent;
  border-radius: 50%;
  background: var(--brand);
  background-clip: padding-box;
}
input[type="range"]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* TT-1: a 48px HIT AREA around a control whose drawn size stays as it is (the
   Back link on the field progress screen). The pseudo-element is invisible,
   centred on the control and never smaller than it, so a gloved tap a few
   pixels outside the button still lands on the button. */
.hit-48 { position: relative; }
.hit-48::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: max(100%, 48px);
  height: max(100%, 48px);
  transform: translate(-50%, -50%);
}

/* EU-08: the one question a lowering asks. A panel in the flow, not a modal,
   so it cannot strand a phone behind an overlay; its buttons are the glove
   size and share one line, wrapping below ~300px rather than shrinking. */
.lower-confirm {
  margin: 10px 0;
  padding: var(--s-3);
  border: 1px solid var(--warn-line);
  border-left: 4px solid var(--warn);
  border-radius: var(--r-sm);
  background: var(--warn-bg);
}
.lower-confirm .lower-q { margin: 0 0 var(--s-2); font-size: 17px; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.lower-confirm label { display: block; font-size: 13px; font-weight: 600; margin-bottom: var(--s-1); color: var(--ink); }
.lower-confirm textarea { width: 100%; min-height: 72px; font-size: 16px; }
/* The "say what was wrong" refusal sits outside any `.field`, so the generic
   `.field .error` colour never reached it and it read as body text. */
.lower-confirm .error { margin: var(--s-2) 0 0; color: var(--bad); font-weight: 600; }
.lower-confirm .actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-2); }
.lower-confirm .actions .btn { flex: 1 1 120px; }
/* `.actions` states display:flex, which beats the UA's [hidden]; the Save row
   steps aside while the question is open, so say so explicitly. */
.lower-confirm[hidden], .field-form .actions[hidden] { display: none; }

.file-btn { display: block; }
/* BIAS-09: "Take photo" and "Choose photo" side by side, each still a full
   44px+ target. They wrap onto their own lines under ~320px rather than
   shrinking below the thumb size the field zone is built around. */
.photo-buttons { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.photo-buttons .file-btn { flex: 1 1 140px; text-align: center; }
.gps-line { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.gps-line[data-state="ok"] { color: var(--ok); }
.gps-line[data-state="denied"], .gps-line[data-state="unavailable"] { color: var(--warn); }

.photo-staging { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.photo-staging li {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  align-items: center;
  width: 104px;
}
.photo-staging img {
  width: 104px; height: 104px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
}

.field-flash {
  padding: 10px var(--s-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  background: var(--neutral-bg);
  color: var(--ink);
  font-size: 14px;
  margin: 10px 0;
}
.field-flash.success { background: var(--ok-bg); border-color: var(--ok-line); border-left-color: var(--ok); color: var(--ok); }
.field-flash.error { background: var(--bad-bg); border-color: var(--bad-line); border-left-color: var(--bad); color: var(--bad); }
.field-flash.warning { background: var(--warn-bg); border-color: var(--warn-line); border-left-color: var(--warn); color: var(--warn); }

/* ---- the attendance register -------------------------------------------
   Job number one, on a phone, with gloves on. Every control here is at least
   48px tall for the same reason .btn.big is, and the three status buttons are
   a segmented row rather than a <select> because a picker that needs two taps
   and a scroll is a picker somebody fills in from memory at 18:00.

   Lives in app.css rather than in a page stylesheet because the field zone's
   offline shell is app.css -- a separate file would be one the service worker
   never pre-caches, and the register must draw with no signal. */
.att-daybanner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  min-height: 48px;
  padding: 10px var(--s-3);
  margin-top: var(--s-2);
  text-align: left;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  background: var(--neutral-bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.att-daybanner:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.att-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.att-row {
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.att-row.is-present { border-left-color: var(--ok); }
.att-row.is-half { border-left-color: var(--warn); }
.att-row.is-absent { border-left-color: var(--bad); }
.att-who { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--s-2); }

.att-status { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-1); }
.att-btn {
  min-height: 48px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  background: var(--neutral-bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.att-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.att-btn.is-present[aria-pressed="true"] {
  background: var(--ok); border-color: var(--ok); color: var(--on-ok);
}
.att-btn.is-half[aria-pressed="true"] {
  background: var(--warn); border-color: var(--warn); color: var(--on-warn);
}
.att-btn.is-absent[aria-pressed="true"] {
  background: var(--bad); border-color: var(--bad); color: var(--on-bad);
}

.att-reason, .att-ot { margin-top: var(--s-2); display: grid; gap: var(--s-1); }
/* An explicit `display` beats the UA's `[hidden] { display: none }`, so the
   two progressive blocks have to opt back out by name -- otherwise a row that
   is Present still shows the absence-reason picker. */
.att-reason[hidden], .att-ot[hidden], .att-reason [hidden] { display: none; }
.att-reason select, .att-reason input[type="text"] { width: 100%; min-height: 48px; font-size: 16px; }
.att-ot input.num { min-height: 48px; font-size: 16px; }
.att-note { margin: var(--s-1) 0 0; }
.att-note:empty { display: none; }

.att-foot { margin-top: var(--s-3); }
.att-tally { font-weight: 600; margin: 0 0 var(--s-2); }
.att-foot .btn.big { width: 100%; }

/* The unit page's headcount line -- office side, but the token set is shared. */
.att-headcount { font-variant-numeric: tabular-nums; }

/* The daily-rate cell on the assignments board and in the tree console. Two
   narrow inputs and a button; it wraps to a stack on a phone rather than
   pushing the table sideways. */
.rate-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.rate-form input { min-width: 0; width: 8rem; font-variant-numeric: tabular-nums; }
.rate-form input[name="rate_source"] { width: 9rem; }

.outbox-actions { margin-bottom: var(--s-3); }
.outbox-item.rejected { border-left-color: var(--bad); background: var(--bad-bg); }
.outbox-item.pending, .outbox-item.syncing { border-left-color: var(--warn); }
.outbox-item.accepted, .outbox-item.duplicate { border-left-color: var(--ok); }

/* Photo thumbnails in the office progress feed -- never filtered, in any theme. */
.feed-photos { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: var(--s-2) 0 0; padding: 0; }
.feed-photos img {
  width: 72px; height: 72px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
}

/* ========================================================== materials ===== */
.materials-readiness {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.materials-readiness .stat-value { font-size: 24px; font-weight: 700; margin-right: 6px; }
.materials-table td { vertical-align: top; }
.materials-history td { padding-top: 0; }
.materials-history details summary { cursor: pointer; color: var(--brand); }
.materials-forms { gap: 18px; align-items: start; }
.materials-form h3 { margin: 0 0 var(--s-2); font-size: 15px; }
.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.doc-list li { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: baseline; }

/* Field materials screen: one big tappable row per kit line. */
.material-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 10px; }
.material-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.material-head {
  width: 100%;
  min-height: 56px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px var(--s-3);
  justify-content: space-between;
  align-items: center;
  padding: var(--s-3) 14px;
  background: none;
  border: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.material-head[aria-expanded="true"] { background: var(--brand-soft); color: var(--brand-ink); }
.material-name { font-weight: 600; }
.material-figures { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.material-body { padding: var(--s-1) 14px var(--s-4); border-top: 1px solid var(--line); }
.material-body hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-4) 0; }
.inspect-toggle { display: flex; gap: var(--s-4); }
.inspect-toggle label { display: flex; align-items: center; gap: 6px; min-height: 44px; }

/* ========================================================== weather ======= */
/* Three bands, deliberately NOT the RAG palette: schedule health and weather
   are different questions and must not be mistaken for each other at a glance.
   Weather chips are outlined, RAG chips are solid. */
.badge.weather-severe { background: var(--bad-bg); color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad-line); }
.badge.weather-rough  { background: var(--warn-bg); color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn-line); }
.badge.weather-fair   { background: var(--ok-bg); color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok-line); }

.weather-now {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  flex-wrap: wrap;
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--line);
}
.weather-glyph { font-size: 40px; line-height: 1; flex: 0 0 auto; }
.weather-now-main { flex: 1 1 160px; min-width: 0; }
.weather-condition { font-weight: 600; display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.weather-temp { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.weather-outlook { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
/* Three labelled figures side by side. The dt/dd pairs are in source order, so
   the grid MUST flow down-then-across -- with the default row flow the second
   label lands under the first value and every figure reads against the wrong
   caption. Two explicit rows, filled column by column. */
.weather-figures {
  display: grid;
  grid-template-columns: repeat(3, minmax(84px, auto));
  grid-template-rows: auto auto;
  grid-auto-flow: column;
  gap: 2px 18px;
  margin: 0;
  flex: 0 1 auto;
}
.weather-figures dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.weather-figures dd { margin: 0; font-size: 15px; font-variant-numeric: tabular-nums; }

.weather-days {
  list-style: none;
  margin: var(--s-3) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: var(--s-2);
}
.weather-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--s-2) var(--s-1);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--panel-sunken);
  text-align: center;
}
.weather-day.is-today { background: var(--brand-softer); border-color: var(--line-strong); }
.weather-day-name { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.weather-day-glyph { font-size: 22px; line-height: 1.1; }
.weather-day-text { line-height: 1.25; }
.weather-day-temp { font-variant-numeric: tabular-nums; font-weight: 600; }
.weather-day-rain { color: var(--brand); }
.weather-asof { margin: 10px 0 0; }

.weather-table td { vertical-align: middle; }
.weather-table td .small.muted { display: block; }
.weather-row.is-worst { background: var(--bad-bg); }
.weather-row.is-worst.weather-fair { background: var(--ok-bg); }
.weather-row.is-worst td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.weather-row.is-worst.weather-rough td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.weather-row.is-worst.weather-fair td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.weather-more { margin: 10px 0 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ========================================================== chips ========= */
/* One assigned person: engineers on the assignments board and the site page's
   Team card, crew in both places too. The remove button is a form, so the chip
   is a flex row rather than a plain pill. */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--brand-softer);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 100%;
}
/* A removable chip tucks its × into the right padding. Browsers without :has()
   simply keep the symmetrical pill -- nothing breaks. */
.chip:has(.chip-x) { padding-right: 5px; }
.chip-sub { font-weight: 500; color: var(--muted); }
.chip.is-inactive { background: var(--neutral-bg); color: var(--muted); border-style: dashed; }
/* Advisory only -- "nobody is answerable for this station yet". It never blocks
   anything, so it stays a chip in the amber family rather than a flash. */
.chip.warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: var(--warn-line);
  border-style: dashed;
  font-weight: 600;
}
.chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.chip-x:hover { background: var(--bad-bg); color: var(--bad); }
.chip-add { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.chip-add select { flex: 1 1 140px; min-width: 120px; font-size: 13px; padding: 5px 8px; }
.chip-add .btn { flex: 0 0 auto; }

/* ---- Assignments board ---- */
.worker-add { border-bottom: 1px solid var(--line); padding-bottom: var(--s-2); margin-bottom: var(--s-3); }
.assignments-table td { vertical-align: top; }
.assignments-table td:first-child { white-space: nowrap; }
/* The row the site page sent us to. Gold is a rule here, never the text. */
.assignment-row.is-focus { background: var(--brand-softer); }
.assignment-row.is-focus td:first-child { box-shadow: inset 3px 0 0 var(--gold); }

/* ---- Site page: Team card ---- */
.team-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); flex-wrap: wrap; }
.team-head h2 { margin-bottom: var(--s-2); }
.team-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  margin: 0 0 6px;
}

/* ---- Site page: a WBS row is a shortcut to the progress form ---- */
.wbs-row { cursor: pointer; }
.wbs-row:hover { background: var(--brand-softer); }
.wbs-task-link { font-weight: 600; }
.wbs-chevron { color: var(--muted); margin-left: 5px; font-weight: 400; }
.wbs-row:hover .wbs-chevron { color: var(--brand); }

/* ================================================== collaboration ========= */
/* Checkpoints, action items, comment threads and the notifications bell.
 * No colour below is written literally -- every one is a token, so the whole
 * package themes with the rest of the app (see the rule at the top of this
 * file). Status colour is carried by the existing --ok / --warn / --bad
 * families, never by the brand greens: a hold point is red because it is a
 * refusal, not because it is important. */

/* ---- Checkpoint library and per-site states ---- */
.cp-row, .cp-state {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s-3);
  margin-bottom: var(--s-3);
  background: var(--panel-sunken);
}
.cp-row.is-inactive { opacity: 0.62; }
/* The one visual shout in the package: an unsigned hold point gets a red rule
 * down its left edge, because it is the thing that will stop the crew. */
.cp-state.is-blocking.pending { border-left: 3px solid var(--bad); }
.cp-state.passed { border-left: 3px solid var(--ok); }
.cp-state.skipped { border-left: 3px solid var(--warn); }
.cp-head { display: flex; align-items: baseline; gap: var(--s-2); flex-wrap: wrap; }
.cp-code { color: var(--muted); font-size: 12px; letter-spacing: 0.3px; }
.cp-meta, .cp-reason { margin: var(--s-1) 0 0; }
.cp-list { list-style: none; margin: 0; padding: 0; }
.cp-items { margin: var(--s-2) 0 0; padding-left: var(--s-5); }
.cp-items li { margin-bottom: 3px; }
.cp-alert {
  border: 1px solid var(--bad-line);
  background: var(--bad-bg);
  color: var(--bad);
  border-radius: var(--r);
  padding: var(--s-2) var(--s-3);
  margin-bottom: var(--s-3);
}

/* ---- Guidance, and the footer that always follows it ---- */
.cp-guidance {
  border-left: 3px solid var(--gold);
  background: var(--panel);
  padding: var(--s-2) var(--s-3);
  margin: var(--s-3) 0;
  border-radius: 0 var(--r) var(--r) 0;
}
.cp-guidance p { margin: 0 0 var(--s-2); }
.cp-guidance p:last-child { margin-bottom: 0; }
.cp-footer { color: var(--muted); font-style: italic; }

/* ---- The sign-off checklist ---- */
/* EU-25: the head carries "Verify all", the counter sits beside the button and
   the gap line carries the server's own refusal sentence. All three wrap, so
   at 320px they stack rather than push the card sideways. */
.cp-check-head {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--s-2);
}
.cp-check-head .small { flex: 1 1 180px; min-width: 0; }
.cp-counter { flex: 0 1 auto; min-width: 0; }
.cp-counter.warn { color: var(--warn, #9a6b00); }
.cp-counter.ok { color: var(--muted); }
.cp-gap { margin: var(--s-2) 0 0; }
/* --panel-sunken, not an invented name: it is defined in all three theme
   blocks (light, prefers-dark, [data-theme=dark]), so the highlight is a real
   colour in both themes rather than the transparent an undefined var falls
   back to. */
.cp-check-item.cp-unanswered { background: var(--panel-sunken); }
.cp-check-item.cp-unanswered .cp-check-text { font-weight: 600; }
/* The refusal that is ABOUT this item, under the note box it is asking for. */
.cp-item-error { margin: var(--s-2) 0 0; }
.cp-check { list-style: none; margin: 0 0 var(--s-4); padding: 0; }
.cp-check-item {
  border-bottom: 1px solid var(--line);
  padding: var(--s-2) 0;
}
.cp-check-item:last-child { border-bottom: 0; }
.cp-check-text { margin: 0 0 var(--s-2); }
.cp-check-controls { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
/* 44px targets: this list is ticked on a phone, at a pit edge, in gloves. */
.cp-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 var(--s-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--panel);
  cursor: pointer;
}
.cp-radio:hover { border-color: var(--line-strong); }
.cp-note { flex: 1 1 200px; min-width: 160px; }

/* ---- Action items ---- */
.action-list { list-style: none; margin: 0; padding: 0; }
.action-item {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s-3);
  margin-bottom: var(--s-2);
  background: var(--panel-sunken);
}
.action-item.is-overdue { border-left: 3px solid var(--bad); }
.action-item.done, .action-item.cancelled { opacity: 0.66; }
.action-head { display: flex; align-items: baseline; gap: var(--s-2); flex-wrap: wrap; }
.action-meta, .action-details { margin: var(--s-1) 0 0; }
.action-buttons { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-top: var(--s-2); }

/* ---- the inline disclosure control ----
   ONE home for these declarations. The <summary> IS the control, so it wears
   the link's look rather than nesting a button a click on the summary would
   have to forward to. It was written twice -- here as `.task-assign > summary`
   and in requirements.css as `.req-toggle` -- declaration for declaration, and
   both files load on sites/detail.html. It lives here because app.css is the
   only stylesheet every page carries: .req-toggle is worn by the finance tabs
   and by the site-task card, which also renders on the fabrication facility
   page, and neither of those loads requirements.css. */
.req-toggle {
  display: inline-block;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  color: var(--brand);
  padding: 2px 0;
}
.req-toggle::-webkit-details-marker { display: none; }
.req-toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* TSK-1: the assignment form is not what the progress tab is opened for, so it
   is one line until somebody wants it. Its summary wears .req-toggle; only
   what is the task card's own is below. */
.task-assign > summary:hover { text-decoration: underline; }
.task-assign[open] > summary { margin-bottom: var(--s-2); }
.task-assign > .progress-form { margin-top: var(--s-2); }
.action-list + .task-assign { margin-top: var(--s-2); }

/* ---- Comment threads ---- */
.thread-mount { margin-top: var(--s-2); }
.thread {
  margin-top: var(--s-2);
  border-top: 1px solid var(--line);
  padding-top: var(--s-2);
}
.thread-head { display: flex; justify-content: space-between; gap: var(--s-2); }
.thread-list { list-style: none; margin: var(--s-2) 0; padding: 0; }
.thread-item {
  border-left: 2px solid var(--line-strong);
  padding: 0 0 var(--s-2) var(--s-3);
  margin-bottom: var(--s-2);
}
.thread-meta { display: flex; gap: var(--s-2); align-items: baseline; }
/* Comments are typed by people, not machines: keep their line breaks. */
.thread-body { margin: 3px 0 0; white-space: pre-wrap; }

/* ---- The bell ----
   The button's shape and the panel's frame come from the shared topbar rules
   at the head of this file (.bell-menu > summary, .menu-panel); only the two
   things that are the bell's own live here. It sits at the RIGHT of the row
   now, beside the user menu, so the panel is right-anchored -- see
   `.usermenu-panel, .bell-panel { right: 0 }` up there. */
.bell { position: relative; flex: 0 0 auto; }
/* THE COUNT OVERLAPS THE BELL, it does not sit beside it.
   In the flow the badge cost the topbar 39px -- more than a whole tap target --
   and 39px is most of the 65px by which the row used to run off a 320px screen.
   Lifted out of the flow the bell is a 36px button whatever the number says,
   which is what lets an iPhone SE carry the same six controls a laptop does.
   The count itself is never the only telling: the summary's aria-label spells
   out the alert/notification split for a screen reader, so shrinking the glyph
   costs nothing a reader depends on. */
.bell-button { position: relative; }
.bell-button .nav-count {
  position: absolute;
  /* INSIDE the button's box, not hanging off its corner: at 320px the gap to
     the avatar beside it is 6px, and a badge that overhangs would eat it. */
  top: 2px;
  right: 2px;
  margin: 0;
  padding: 0 4px;
  min-width: 16px;
  font-size: 10px;
  line-height: 15px;
  text-align: center;
  /* On the dark topbar band the badge needs an edge of its own or it reads as
     a smudge on the icon; the ring is the band colour, not a border colour. */
  border-color: var(--top-bg);
  box-shadow: 0 0 0 1px var(--top-bg);
}
.bell-panel {
  width: min(340px, calc(100vw - 2 * var(--s-3)));
  max-width: min(340px, calc(100vw - 2 * var(--s-3)));
  max-height: min(60vh, 460px);
  overflow-y: auto;
  padding: var(--s-3);
}
details[open] > .bell-button { background: var(--top-active); }
.bell-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
}
.bell-list { list-style: none; margin: 0; padding: 0; }
.bell-item { border-bottom: 1px solid var(--line); }
.bell-item:last-child { border-bottom: 0; }
.bell-item.is-unread { background: var(--brand-softer); }
.bell-link {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: var(--s-2);
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.bell-link:hover { background: var(--neutral-bg); }
.bell-title { display: block; font-weight: 600; }
.bell-body { display: block; }
.bell-clear { margin-top: var(--s-2); text-align: right; }

/* ---- Notifications page ---- */
.notice-list { list-style: none; margin: 0; padding: 0; }
.notice-item {
  border-bottom: 1px solid var(--line);
  padding: var(--s-3) 0;
}
.notice-item:last-child { border-bottom: 0; }
.notice-item.is-unread { border-left: 3px solid var(--brand); padding-left: var(--s-3); }
.notice-head { display: flex; align-items: baseline; gap: var(--s-2); flex-wrap: wrap; }
.notice-meta { margin-top: var(--s-1); }

/* ---- Field zone: read-only checkpoints and tasks ---- */
.field-task-list, .field-cp-list { list-style: none; margin: 0; padding: 0; }
.field-task, .field-cp {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s-3);
  margin-bottom: var(--s-2);
  background: var(--panel-sunken);
}
.field-task.is-overdue { border-left: 3px solid var(--bad); }
.field-cp.pending { border-left: 3px solid var(--warn); }
.field-cp.passed { border-left: 3px solid var(--ok); }
/* Signed is not released: a hold point waiting on the PM's ratification, or one
   he refused, keeps the amber rule the green one would have contradicted. Last,
   so it wins over .passed whatever the order of the classes in the markup. */
.field-cp.is-held { border-left: 3px solid var(--warn); }
/* The chip and the code are built as adjacent nodes by field.js, so the gap
   has to come from here rather than from a space in the markup. */
.field-cp .badge { margin-right: var(--s-2); }

/* ---- EU-10: hold points, named where the engineer is ---- */
/* The Progress tab's one-line-per-hold-point list, and the chip on the stage
   row a hold point blocks. Both wrap rather than scroll at 320px. */
.hold-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.hold-list li { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-2); align-items: baseline; overflow-wrap: anywhere; }
.hold-chip { margin-left: var(--s-1); text-decoration: none; white-space: nowrap; }
.gate-link { color: inherit; text-decoration: underline; }
/* The warning before Save: said, not blocking. Same weight as the photo rule. */
.gate-warn {
  margin: var(--s-2) 0 0;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--bad-line);
  border-left: 4px solid var(--bad);
  border-radius: var(--r-sm);
  background: var(--bad-bg);
  color: var(--bad);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.gate-warn a { color: inherit; }
.gate-warn[hidden] { display: none; }
/* The field sign-off: a panel in the flow (never a modal), glove-size answers
   that share a line and wrap below ~300px rather than shrinking. */
.field-cp .signoff-open { display: block; width: 100%; margin-top: var(--s-2); }
/* In the button's place while a pass awaits the PM: one line, wraps at 320. */
.field-cp .cp-awaiting-pm { margin: var(--s-2) 0 0; overflow-wrap: anywhere; }
.signoff-panel {
  margin: var(--s-3) 0 0;
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--r-sm);
  background: var(--panel-sunken);
}
.signoff-panel[hidden] { display: none; }
.signoff-title { margin: 0 0 var(--s-2); font-size: 17px; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.signoff-items { list-style: none; margin: 0 0 var(--s-3); padding: 0; display: grid; gap: var(--s-3); }
.signoff-text { display: block; margin-bottom: var(--s-1); overflow-wrap: anywhere; }
.signoff-choices { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.signoff-choices .btn { flex: 1 1 110px; }
.signoff-choices .btn[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.signoff-note { width: 100%; margin-top: var(--s-2); min-height: 48px; font-size: 16px; }
.signoff-note[hidden] { display: none; }
.signoff-panel .actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.signoff-panel .actions .btn { flex: 1 1 120px; }
.signoff-panel .error { color: var(--bad); font-weight: 600; }

/* ========================================================== a11y utils ==== */
.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;
}
.mb-0 { margin-bottom: 0; }

/* ========================================================== responsive ==== */
@media (max-width: 900px) {
  .map-layout { grid-template-columns: 1fr; }
  .unmapped-panel { max-height: none; }
}

@media (max-width: 640px) {
  .container { padding: 14px var(--s-3) 48px; }
  th, td { padding: var(--s-2) 7px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .btn { width: 100%; }
  .actions .btn { width: auto; flex: 1 1 auto; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s-2); }
  .stat-value { font-size: 20px; }
  .map { height: 320px; }
  .map-tall { height: 400px; }
  .tl-row { grid-template-columns: 130px minmax(0, 1fr); gap: 6px; }
  .chart-wrap { height: 260px; }
  .gantt-toolbar .btn { width: auto; }
  .unmapped-list .btn { width: auto; }
  .materials-forms { grid-template-columns: 1fr; }
  /* Chips and their pickers stay inline on a phone; only real page buttons
     go full width (see .btn above). */
  .chip-add .btn, .team-head .btn { width: auto; }
  /* .btn goes full width on a phone; the two verdicts share their line instead,
     which keeps them side by side and still gives each a big tap target. */
  .geo-proposal-decide { width: 100%; }
  .geo-proposal-decide .btn { width: auto; flex: 1 1 auto; }
  .geo-proposal-actions .btn { width: auto; }
  .assignments-table td:first-child { white-space: normal; }
  .weather-figures { grid-template-columns: repeat(3, 1fr); flex: 1 1 100%; }
  .weather-days { grid-template-columns: repeat(2, 1fr); }
  .auth-page { padding-top: var(--s-4); min-height: 0; }
  .auth-card { padding: var(--s-4); }
  /* Icon + wording on one line, a full-width tap target underneath. */
  .install-row { flex-wrap: wrap; }
  .install-text { flex: 1 1 140px; }
  .install-dismiss { order: 2; align-self: flex-start; }
  .install-row .btn { width: 100%; flex: 1 1 100%; order: 3; }
}

/* ================================================== facilities ============ */
/* The Sorsogon plant and everything it does: stock, fabrication orders,
   shipments, and the incoming strip on a station's own page. Colours come from
   the same status families as everything else -- fabrication and shipment
   statuses map onto neutral / info / ok / muted so they read at a glance
   without inventing a fifth palette. */

/* A facility is a different KIND of thing, so it gets the brand chip rather
   than a status colour -- it is not "good" or "bad", it is elsewhere. */
.badge.facility {
  background: var(--brand-soft);
  color: var(--brand-ink);
  border-color: var(--line-strong);
}
.facility-mark { color: var(--brand); margin-right: var(--s-1); }

.badge.fab-draft,
.badge.ship-packed { background: var(--neutral-bg); color: var(--muted); }
.badge.fab-in_progress,
.badge.ship-in_transit {
  background: var(--info-bg); color: var(--info); border-color: var(--info-line);
}
.badge.fab-completed,
.badge.ship-received {
  background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line);
}
.badge.fab-cancelled,
.badge.ship-cancelled {
  background: var(--neutral-bg); color: var(--muted); text-decoration: line-through;
}
.badge.kind-receipt { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.badge.kind-production {
  background: var(--info-bg); color: var(--info); border-color: var(--info-line);
}
.badge.kind-shipment_out {
  background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line);
}
.badge.kind-correction { background: var(--neutral-bg); color: var(--muted); }
/* Raw bar a fabrication order ate. Sage rather than the shipment amber: both
   took stock off the shelf, but one left the yard and one is still here in a
   different shape, and a stock sheet has to be able to tell them apart. */
.badge.kind-consumption {
  background: var(--brand-soft); color: var(--brand-ink); border-color: var(--line-strong);
}

/* ---- Inventory ---- */
.inventory-table td.num { font-variant-numeric: tabular-nums; }
.inventory-table tr.is-negative { background: var(--bad-bg); }
.inventory-table tr.is-negative strong { color: var(--bad); }
.movement-feed { max-height: 26em; overflow-y: auto; }

/* ---- Sites list: grouping and facility rows ---- */
.tree-branch { color: var(--muted); margin-right: var(--s-1); }
tr.is-child td:first-child { padding-left: var(--s-5); }
.tl-row.is-child .tl-label { padding-left: var(--s-3); }
tr.is-facility { background: var(--brand-softer); }

/* ---- The map's factory marker: a shape, not a colour (see map.js) ---- */
.facility-marker {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  background: var(--brand);
  color: var(--on-brand);
  border: 2px solid var(--panel);
  box-shadow: var(--shadow);
  font-size: 15px;
  line-height: 1;
}

/* ---- Incoming shipments, on a station's page ---- */
.incoming-card { border-left: 3px solid var(--info-line); }
.incoming-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-3); }
.incoming {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s-3);
  background: var(--panel-sunken);
}
.incoming.is-late { border-color: var(--warn-line); background: var(--warn-bg); }
.incoming-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2);
  margin-bottom: var(--s-2);
}
tr.is-discrepant { background: var(--bad-bg); }

/* ---- The line editor shared by the order and shipment forms ---- */
.line-editor { width: 100%; }
.line-editor select,
.line-editor input { width: 100%; }
.line-editor td { vertical-align: top; }

/* ---- Field zone: receiving a load off the truck ---- */
.field-shipments { margin-bottom: var(--s-4); }
.shipment-list, .shipment-lines { list-style: none; margin: 0; padding: 0; }
.shipment-list { display: grid; gap: var(--s-3); }
.shipment-row {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s-3);
  background: var(--panel-sunken);
}
.shipment-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2);
  margin-bottom: var(--s-2);
}
.shipment-lines { display: grid; gap: var(--s-2); }
.shipment-lines label {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--s-2);
}
/* Big enough to hit with a thumb in gloves -- the whole point of the zone. */
.shipment-lines input {
  grid-column: 2;
  width: 7em;
  min-height: 44px;
  font-size: 17px;
  text-align: right;
}
.shipment-lines .small { grid-column: 1 / -1; }

@media (max-width: 640px) {
  .line-editor, .line-editor thead, .line-editor tbody,
  .line-editor tr, .line-editor td, .line-editor th { display: block; width: 100%; }
  /* The column headers go with the table layout, so each cell grows its own --
     an unlabelled box on a phone is worse than a slightly taller form. */
  .line-editor thead { display: none; }
  .line-editor td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: var(--s-1);
  }
  .line-editor td.num { text-align: left; }
  .line-editor tr {
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: var(--s-2);
    margin-bottom: var(--s-2);
  }
  .incoming-head, .shipment-head { flex-direction: column; align-items: flex-start; }
}

/* ========================================================== print ========= */
/* Paper is always light, whatever the screen is set to. report.css pins the
   same tokens for the compiled reports -- both are needed because a user can
   print any page, not only /reports/view. */
@media print {
  :root,
  :root[data-theme="dark"],
  :root[data-theme="light"] {
    --bg: #FFFFFF;
    --panel: #FFFFFF;
    --panel-sunken: #FFFFFF;
    --ink: #000000;
    --muted: #444444;
    --line: #BBBBBB;
    --line-strong: #999999;
    --brand: #38471F;
    --brand-deep: #2B3717;
    --brand-ink: #2B3717;
    --brand-soft: #EEEEEE;
    --brand-softer: #FFFFFF;
    --on-brand: #FFFFFF;
    --on-bad: #FFFFFF;
    --on-ok: #FFFFFF;
    --on-warn: #FFFFFF;
    --paper: #FFFFFF;
    --gold: #C9A227;
    --neutral-bg: #EEEEEE;
    --warn: #7A5300;  --warn-bg: #FDF3DC;  --warn-line: #E3BE68;
    --bad:  #96261F;  --bad-bg:  #FBEAE8;  --bad-line:  #E4B4AF;
    --ok:   #1C6B3E;  --ok-bg:   #E3F1E7;  --ok-line:   #A9D3B9;
    --info: #1B5B9A;  --info-bg: #E5EFF9;  --info-line: #B4CDE8;
    --rag-green: #1C6B3E;
    --rag-amber: #A8720A;
    --rag-red: #96261F;
    --rag-none: #8A9481;
    --shadow: none;
    --shadow-lg: none;
    color-scheme: light;
  }
  html, body { background: var(--panel); color: var(--ink); }
  .topbar, .appfoot, .filters, .gantt-toolbar, .actions,
  .sidenav, .nav-scrim, .skip-link, .page-tabs { display: none; }
  /* Paper has no rail to make room for, and every tab pane is already in the
     document -- printing a tabbed page prints the whole of it. */
  .shell-main { margin-left: 0 !important; }
  .tabpane[hidden] { display: block !important; }
  .timeline-scroll { overflow: visible; }
  .tl-group { break-inside: avoid; }
  .card { box-shadow: none; break-inside: avoid; }
  /* Never invert street tiles onto paper. */
  .leaflet-tile-pane .osm-tiles { filter: none !important; }
}
