/* ============================================================
   Daily Progress Tracking — "Nocturne" theme
   Whale Solution Sdn. Bhd.
   Dark, mobile-first app skin matching the approved Claude Design
   mockup: bottom tab bar, hero/stat cards, segmented progress bars,
   bottom sheets for logging progress and deciding approvals.
   ============================================================ */

:root {
  /* Earthy Minimal palette. Names are kept from the old theme so every
     existing screen picks up the new colours; roles are re-mapped:
       accent-900 = soft tint surface, accent-700 = strong (primary green),
       --sel-bg/--sel-fg = "selected" chips and solid buttons. */
  --bg: #F8F6EE; --bg-top: #F8F6EE; --surface: #FFFDF8; --surface-2: #F1EADB;
  --text: #2E3A2F; --text-soft: rgba(46, 58, 47, .74); --text-softer: rgba(46, 58, 47, .64);
  --divider: rgba(46, 58, 47, .15); --divider-strong: rgba(46, 58, 47, .3);

  --accent: #C96F4F;
  --accent-100: #F8F6EE; --accent-200: #2E3A2F; --accent-300: #2E3A2F;
  --accent-400: #566B48; --accent-500: #6B7F5B; --accent-600: #6B7F5B;
  --accent-700: #2E3A2F; --accent-800: #3B4A3D; --accent-900: #E6EBDD;
  --sel-bg: #2E3A2F; --sel-fg: #F8F6EE; --accent-tint: rgba(201, 111, 79, .13);

  --green: #3F6A3F; --green-soft: rgba(63, 106, 63, .12); --green-line: #7FA07F;
  --amber: #8A5A12; --amber-soft: rgba(138, 90, 18, .12); --amber-line: #C9A25B;
  --red: #A8382B; --red-soft: rgba(168, 56, 43, .1); --red-line: #C97A6E;
  --neutral-soft: rgba(46, 58, 47, .08); --neutral-fg: rgba(46, 58, 47, .78);
  --track: rgba(46, 58, 47, .11); --wash: rgba(46, 58, 47, .045); --shimmer: rgba(46, 58, 47, .07);
  --on-badge: #17211A; --scrim: rgba(20, 28, 21, .5);
  --rail: #2E3A2F; --rail-ink: #F8F6EE; --rail-soft: #B9C4B4; --rail-active: rgba(248, 246, 238, .12);

  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(46, 58, 47, .1);
  --shadow-md: 0 8px 24px rgba(46, 58, 47, .16);
  --shadow-lg: 0 -8px 40px rgba(46, 58, 47, .2);
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", "Inter", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", monospace;
  color-scheme: light;
}
/* Dark theme follows the phone/computer setting. Bright sunlight mode
   (data-sun) is always the light theme, made stronger. */
@media (prefers-color-scheme: dark) {
  :root:not([data-sun="1"]) {
    --bg: #182018; --bg-top: #182018; --surface: #212B22; --surface-2: #2A362B;
    --text: #F1EEE3; --text-soft: rgba(241, 238, 227, .72); --text-softer: rgba(241, 238, 227, .6);
    --divider: rgba(241, 238, 227, .14); --divider-strong: rgba(241, 238, 227, .28);
    --accent: #DB8062;
    --accent-100: #1D261E; --accent-200: #F1EEE3; --accent-300: #D9C9B2;
    --accent-400: #86A072; --accent-500: #86A072; --accent-600: #86A072;
    --accent-700: #D9C9B2; --accent-800: #3B4A3D; --accent-900: #2A382B;
    --sel-bg: #D9C9B2; --sel-fg: #1D261E; --accent-tint: rgba(219, 128, 98, .16);
    --green: #A9CC9C; --green-soft: rgba(169, 204, 156, .14); --green-line: #6F9A62;
    --amber: #E6C77E; --amber-soft: rgba(230, 199, 126, .13); --amber-line: #B98B3F;
    --red: #F0A08F; --red-soft: rgba(240, 160, 143, .13); --red-line: #B5665A;
    --neutral-soft: rgba(241, 238, 227, .1); --neutral-fg: rgba(241, 238, 227, .78);
    --track: rgba(241, 238, 227, .12); --wash: rgba(241, 238, 227, .05); --shimmer: rgba(241, 238, 227, .08);
    --on-badge: #17211A; --scrim: rgba(8, 12, 9, .62);
    --rail: #111912; --rail-ink: #F1EEE3; --rail-soft: #9FAE9F; --rail-active: rgba(241, 238, 227, .1);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow-md: 0 8px 24px rgba(0, 0, 0, .45); --shadow-lg: 0 -8px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-sun="1"] {
  --bg: #FFFDF8; --bg-top: #FFFDF8; --surface: #FFFFFF; --surface-2: #F1EADB;
  --text: #17211A; --text-soft: rgba(23, 33, 26, .84); --text-softer: rgba(23, 33, 26, .74);
  --divider: rgba(23, 33, 26, .38); --divider-strong: rgba(23, 33, 26, .55);
  --accent-400: #3F5231;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--f-body);
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
#app { min-height: 100vh; }
.mono { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
a { color: var(--accent-300); cursor: pointer; text-decoration: none; }
a:hover { color: var(--accent-200); }
p { margin: 0; }

button { font-family: inherit; color: inherit; -webkit-tap-highlight-color: transparent; transition: transform .1s ease, background .15s ease, border-color .15s ease; }
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input, select, textarea { font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.splash { display: flex; align-items: center; justify-content: center; min-height: 100vh; color: var(--text-soft); font-size: 14px; }
.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;
}
.row-label-sm { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--text-soft); }
.link-danger-sm { font-size: 11.5px; color: var(--red); }

/* ---------- Skeleton loaders (replace a bare "Loading…" label with a
   shape that mirrors the screen about to appear, and avoid layout jump) ---- */
.skel { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--radius-md); }
.skel::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--shimmer), transparent);
  animation: dptShimmer 1.4s ease-in-out infinite;
}
.skel-hero { height: 132px; border-radius: var(--radius-lg); }
.skel-tile { flex: 1; height: 66px; }
.skel-tile-big { height: 84px; }
.skel-chip { flex: none; width: 74px; height: 36px; border-radius: 999px; }
.skel-card { height: 78px; }
.skel-card-lg { height: 140px; }
.skel-row-sm { height: 58px; }
@keyframes dptShimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
  .skel::after { animation: none; }
  .stagger > * { animation: none; }
  .sheet, .sheet-scrim, .toast { animation: none; }
}

/* ---------- App shell ---------- */
.app-shell {
  max-width: 480px; margin: 0 auto; min-height: 100vh;
  display: flex; flex-direction: column; position: relative;
  background: var(--bg);
}
.app-shell.wide { max-width: 760px; }

.app-header {
  padding: max(18px, env(safe-area-inset-top)) 16px 12px; flex: none;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 10px;
  background: var(--bg); border-bottom: 1px solid var(--divider); position: relative; z-index: 5;
}
.app-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-header-kicker { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-400); }
.app-header-title { font-size: 20px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 36px; height: 36px; flex: none; border-radius: var(--radius-sm);
  border: 1px solid var(--divider); background: transparent; color: var(--text);
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.avatar-btn {
  width: 38px; height: 38px; flex: none; border-radius: 999px;
  border: 1px solid var(--accent-700); background: var(--accent-900); color: var(--accent-200);
  font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; padding: 0;
}

.app-content {
  flex: 1; overflow-y: auto; padding: 14px 16px 24px;
  display: flex; flex-direction: column; gap: 12px;
}
.app-shell.has-tabbar .app-content { padding-bottom: 96px; }

.toast {
  position: sticky; top: 0; z-index: 20; margin: -2px -2px 4px;
  padding: 11px 14px; border-radius: var(--radius-md);
  background: var(--sel-bg); border: 1px solid var(--sel-bg); color: var(--sel-fg);
  font-size: 12.5px; box-shadow: var(--shadow-md); animation: dptFade .18s ease;
}

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: 480px; z-index: 15;
  padding: 8px 8px max(14px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--divider);
  display: flex; align-items: flex-end; gap: 4px;
}
.tabbar-item {
  flex: 1; position: relative; min-height: 52px; border: 0; background: transparent;
  border-radius: var(--radius-sm); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; color: var(--text-soft); padding: 4px 2px;
}
.tabbar-item svg { flex: none; }
.tabbar-item span.tabbar-label { font-size: 10.5px; letter-spacing: .02em; }
.tabbar-item.active { color: var(--accent-200); }
.tabbar-item.active::after {
  content: ''; position: absolute; bottom: -2px; width: 20px; height: 2px; border-radius: 2px; background: var(--accent);
}
/* The assistant engineer carries nine tabs. On a 360px phone the row was 18px wider than the screen and
   the last one was clipped, so below 380px the gaps and padding give that back. */
@media (max-width: 380px) {
  .tabbar { padding-left: 4px; padding-right: 4px; gap: 1px; }
  .tabbar-item { padding-left: 0; padding-right: 0; }
  .tabbar-item span.tabbar-label { font-size: 9.5px; }
}
.tabbar-badge {
  position: absolute; top: 2px; right: calc(50% - 22px); min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 999px; background: var(--accent); color: var(--on-badge); font-size: 10.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Cards & stat tiles ---------- */
.card {
  padding: 14px; border-radius: var(--radius-md); background: var(--surface);
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 8px;
}
.card.bordered { border: 1px solid var(--divider); box-shadow: none; }
.card.tap { cursor: pointer; text-align: left; width: 100%; border: 1px solid var(--divider); background: var(--surface); }
.card.tap:active { transform: scale(.99); }

.hero-card {
  padding: 16px; border-radius: var(--radius-lg); background: linear-gradient(180deg, var(--accent-900), var(--surface));
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 12px;
}
.hero-kicker { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-300); }
.hero-title { font-size: 22px; font-weight: 600; line-height: 1.18; letter-spacing: -.015em; }
.hero-sub { font-size: 13px; color: var(--text-soft); line-height: 1.45; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 16px; border-radius: var(--radius-md);
  border: 1px solid var(--divider); background: transparent; color: var(--text);
  font-size: 14.5px; font-weight: 600; cursor: pointer;
}
.btn.block { width: 100%; }
.btn.flex { flex: 1; }
.btn.sm { min-height: 40px; font-size: 13px; padding: 0 12px; }
.btn.accent { border-color: var(--accent); background: transparent; color: var(--accent-200); }
.btn.accent:hover:not(:disabled) { background: var(--accent-tint); }
.btn.solid { border-color: var(--sel-bg); background: var(--sel-bg); color: var(--sel-fg); box-shadow: inset 0 -3px 0 var(--accent); }
.btn.ok { border-color: var(--green-line); background: var(--green-soft); color: var(--green); }
.btn.warn { border-color: var(--amber-line); background: transparent; color: var(--amber); }
.btn.bad { border-color: var(--red-line); background: transparent; color: var(--red); }
.btn.ghost { border: none; color: var(--accent-300); min-height: 36px; padding: 0 4px; }
.btn.dashed { border-style: dashed; color: var(--text-soft); }
.link-btn { background: none; border: 0; color: var(--accent-300); font-size: 13px; padding: 4px 0; cursor: pointer; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* Mobile default: a plain stacked column, same spacing as before this
   wrapper existed. The desktop @media block below turns it into a grid. */
.card-grid { display: flex; flex-direction: column; gap: 12px; }
.stat-row { display: flex; gap: 10px; }
.stat-tile { flex: 1; padding: 12px 12px; border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 3px; }
.stat-tile.big { padding: 14px; }
.stat-val { font-size: 22px; font-weight: 600; line-height: 1; }
.stat-tile.big .stat-val { font-size: 27px; }
.stat-label { font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--text-soft); }
.stat-sub { font-size: 11.5px; color: var(--text-softer); }

/* ---------- Worklist / list cards ---------- */
.wl-card { display: flex; flex-direction: column; gap: 9px; padding: 13px 14px; }
.wl-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wl-id { font-size: 15px; font-weight: 600; }
.chip { font-size: 11px; padding: 3px 9px; border-radius: 6px; white-space: nowrap; }
.wl-sub { font-size: 12.5px; color: var(--text-soft); }
.seg-track { display: flex; gap: 3px; height: 6px; }
.seg { flex: 1; border-radius: 3px; background: var(--track); overflow: hidden; display: block; }
.seg > i { display: block; height: 100%; background: var(--accent-500); }
.wl-stageline { font-size: 11.5px; color: var(--text-softer); }

.filter-row { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; }
.filter-chip {
  flex: none; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--divider);
  background: transparent; color: var(--text-soft); font-size: 12.5px; min-height: 36px;
}
.filter-chip.active { border-color: var(--sel-bg); background: var(--sel-bg); color: var(--sel-fg); }

/* ---------- Detail screen ---------- */
.detail-head { padding: 13px 14px; border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 8px; }
.detail-pct { display: flex; align-items: flex-end; gap: 8px; }
.detail-pct-num { font-size: 30px; font-weight: 600; line-height: 1; }
.detail-pct-of { font-size: 12px; color: var(--text-softer); padding-bottom: 3px; }

.component-block { border-radius: var(--radius-md); border: 1px solid var(--divider); background: var(--surface); overflow: hidden; }
.component-head { padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; border-bottom: 1px solid var(--divider); }
.component-title { font-size: 14.5px; font-weight: 600; }
.component-sub { font-size: 11.5px; color: var(--text-soft); }
.component-stages { padding: 8px; display: flex; flex-direction: column; gap: 6px; }

.stage-btn {
  text-align: left; width: 100%; padding: 10px 11px; border-radius: var(--radius-md);
  border: 1px solid var(--divider); background: transparent;
  display: flex; align-items: center; gap: 11px;
}
.stage-btn.actionable { border-color: var(--accent-700); background: var(--accent-900); }
.stage-dot {
  width: 26px; height: 26px; flex: none; border-radius: 999px; border: 1px solid var(--divider);
  background: transparent; color: var(--text-soft); font-size: 10.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.stage-dot.done { border-color: var(--green-line); background: var(--green-soft); color: var(--green); }
.stage-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.stage-body-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.stage-name { font-size: 13.5px; font-weight: 500; }
.stage-meta { font-size: 11.5px; color: var(--text-soft); }
.stage-bar { display: block; height: 5px; border-radius: 3px; background: var(--track); overflow: hidden; }
.stage-bar > i { display: block; height: 100%; background: var(--accent-500); }
.stage-chev { flex: none; color: var(--text-softer); }

.final-block { border-radius: var(--radius-md); border: 1px solid var(--accent-700); background: var(--accent-900); padding: 13px 14px; display: flex; flex-direction: column; gap: 10px; }
.additional-btn { text-align: left; padding: 10px 11px; border-radius: var(--radius-md); border: 1px solid var(--divider); background: var(--surface); display: flex; align-items: center; gap: 10px; width: 100%; }
.check-box { width: 22px; height: 22px; flex: none; border-radius: 6px; border: 1px solid var(--divider); background: transparent; display: flex; align-items: center; justify-content: center; }
.check-box.done { border-color: var(--green-line); background: var(--green-soft); }

.history-row { padding: 10px 12px; border-radius: var(--radius-md); background: var(--surface); display: flex; align-items: center; gap: 10px; }
.history-dot { width: 7px; height: 7px; border-radius: 999px; flex: none; }

/* ---------- Queue (supervisor) ---------- */
.queue-card { border-radius: var(--radius-md); border: 1px solid var(--divider); background: var(--surface); padding: 13px 14px; display: flex; flex-direction: column; gap: 11px; }
.queue-who { display: flex; align-items: center; gap: 10px; }
.queue-avatar { width: 32px; height: 32px; flex: none; border-radius: 999px; background: var(--accent-900); border: 1px solid var(--accent-700); color: var(--accent-200); font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.queue-body { padding: 11px 12px; border-radius: var(--radius-md); background: var(--wash); display: flex; flex-direction: column; gap: 5px; }
.queue-qty { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; }
.queue-qty-num { font-size: 23px; font-weight: 600; }

/* ---------- People / profile ---------- */
.person-row { padding: 12px 14px; border-radius: var(--radius-md); background: var(--surface); display: flex; align-items: center; gap: 11px; }
.person-avatar { width: 34px; height: 34px; flex: none; border-radius: 999px; background: var(--accent-900); border: 1px solid var(--accent-700); color: var(--accent-200); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.pin-req-banner { padding: 13px 14px; border-radius: var(--radius-md); border: 1px solid var(--amber-line); background: var(--amber-soft); display: flex; flex-direction: column; gap: 10px; }

.profile-row {
  min-height: 48px; text-align: left; padding: 0 14px; border-radius: var(--radius-md);
  border: 1px solid var(--divider); background: transparent; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
}

/* Desktop-only brand copy (see the @media(min-width:900px) block below
   for the two-pane layout that shows these) - hidden on the compact
   mobile login where there isn't room for them. */
.field-label { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-soft); }
.text-input {
  width: 100%; min-height: 52px; padding: 8px 14px; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius-md);
  caret-color: var(--accent);
}
.text-input:hover { border-color: var(--divider-strong); }

/* ---------- Bottom sheets ---------- */
.sheet-scrim {
  position: fixed; inset: 0; z-index: 60; background: var(--scrim);
  display: flex; align-items: flex-end; justify-content: center; animation: dptFade .18s ease;
}
.sheet {
  width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg);
  padding: 16px 16px max(24px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px;
  animation: dptSheet .28s cubic-bezier(.22, 1, .36, 1);
}
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sheet-kicker { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-300); }
.sheet-title { font-size: 19px; font-weight: 600; margin-top: 3px; }
.field-group { display: flex; flex-direction: column; gap: 7px; }
.field-caption { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-softer); }
.chip-row { display: flex; gap: 7px; flex-wrap: wrap; }
.pick-chip {
  padding: 9px 13px; min-height: 42px; border-radius: var(--radius-md); border: 1px solid var(--divider);
  background: transparent; color: var(--text-soft); font-size: 13px;
}
.pick-chip.selected { border-color: var(--sel-bg); background: var(--sel-bg); color: var(--sel-fg); }
.stage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.stage-pick {
  padding: 10px 11px; min-height: 52px; text-align: left; border-radius: var(--radius-md);
  border: 1px solid var(--divider); background: transparent; color: var(--text);
  display: flex; flex-direction: column; gap: 2px;
}
.stage-pick.selected { border-color: var(--sel-bg); background: var(--sel-bg); color: var(--sel-fg); }
.stage-pick-note { font-size: 10.5px; color: var(--text-softer); }
.stage-pick.selected .stage-pick-note, .pick-chip.selected small, .filter-chip.active small { color: var(--sel-fg); opacity: .8; }
.stepper-row { display: flex; align-items: center; gap: 10px; }
.stepper-btn { width: 56px; height: 60px; border-radius: var(--radius-md); border: 1px solid var(--divider); background: transparent; font-size: 26px; color: var(--text); }
.stepper-btn.sm { width: 42px; height: 42px; font-size: 18px; }
.stepper-display { flex: 1; height: 60px; border-radius: var(--radius-md); border: 1px solid var(--accent-700); background: var(--accent-900); display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.stepper-num { font-size: 30px; font-weight: 600; color: var(--text); }
.stepper-unit { font-size: 13px; color: var(--accent-300); }
.stepper-input { border: none; background: transparent; outline: none; text-align: right; width: 4.5ch; padding: 0; -moz-appearance: textfield; }
.stepper-input::-webkit-outer-spin-button, .stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-input:focus { color: var(--text); }
.quick-row { display: flex; gap: 7px; }
.quick-btn { flex: 1; min-height: 40px; border-radius: var(--radius-md); border: 1px solid var(--divider); background: transparent; font-size: 12.5px; color: var(--text-soft); }
.inline-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 12px; border-radius: var(--radius-md); border: 1px solid var(--divider); }
.mini-row { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px; }

/* ---------- Bars / crew ---------- */
.bar-block { padding: 14px; border-radius: var(--radius-md); background: var(--surface); display: flex; flex-direction: column; gap: 12px; }
.bar-item { display: flex; flex-direction: column; gap: 5px; }
.bar-item-top { display: flex; justify-content: space-between; font-size: 12.5px; }
.bar-track2 { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar-track2 > i { display: block; height: 100%; border-radius: 4px; background: var(--accent-500); }

/* ---------- Date nav (Stats screen — pick a past day's report) ---------- */
.date-nav { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); }
.date-nav-arrow { flex: none; width: 34px; height: 34px; border-radius: 999px; border: 1px solid var(--divider); background: transparent; color: var(--text); display: flex; align-items: center; justify-content: center; }
.date-nav-arrow:disabled { opacity: .35; }
.date-nav-mid { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; }
.date-nav-mid { border: 1px solid var(--divider); border-radius: var(--radius-md); min-height: 40px; padding: 0 10px; }
.date-nav-open { flex: 1; min-height: 40px; border: none; background: transparent; color: var(--text); font-size: 13.5px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; padding: 0 6px; }
.date-nav-hint { font-size: 11px; font-weight: 400; color: var(--text-softer); }
/* The real date field lies invisibly over the whole middle of the nav and IS the tap target. It used to
   be pointer-events:none, with the button under it calling showPicker() instead - but showPicker() does
   not exist on older mobile browsers and the fallback, a synthetic click on a hidden input, is not a
   trusted gesture, so on a phone nothing opened. Tapping the field itself always opens the native
   picker. The button underneath stays for the keyboard. */
.date-nav-input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: none; background: transparent; color: transparent;
  -webkit-appearance: none; appearance: none; cursor: pointer;
  font-size: 16px;            /* stops iOS zooming the page when the field is tapped */
}
.date-nav-input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.date-nav-mid:focus-within { border-color: var(--accent-400); }

/* ---------- Donut chart (scope: coated vs remaining) ---------- */
.donut-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut-svg { flex: none; }
.donut-legend { flex: 1; min-width: 140px; display: flex; flex-direction: column; gap: 8px; }
.donut-legend-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.donut-dot { width: 9px; height: 9px; border-radius: 999px; flex: none; }

/* ---------- Productivity bar (actual vs target m²/painter) ---------- */
.prod-chart { display: flex; flex-direction: column; gap: 8px; }
.prod-chart-top { display: flex; align-items: baseline; gap: 8px; }
.prod-bar-track { position: relative; height: 14px; border-radius: 7px; background: var(--track); overflow: visible; }
.prod-bar-fill { height: 100%; border-radius: 7px; transition: width .2s ease; }
.prod-bar-tick { position: absolute; top: -3px; bottom: -3px; width: 3px; border-radius: 2px; background: var(--text); box-shadow: 0 0 0 1px var(--bg); }

/* ---------- Productivity cards (confirmed actual vs target, with a
   separate pending-approval badge so confirmed and pending are never
   blended into one number) ---------- */
.prod-card-grid { display: flex; gap: 10px; }
.prod-card {
  flex: 1; min-width: 0; padding: 13px; border-radius: var(--radius-md);
  background: var(--surface); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 9px;
}
.prod-card-head { display: flex; flex-direction: column; gap: 2px; }
.prod-card-title { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--text-soft); }
.prod-card-target { font-size: 11px; color: var(--text-softer); }
.prod-card-val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 5px; }
.prod-card-unit { font-size: 11px; font-weight: 500; color: var(--text-soft); }
.pending-badge {
  display: inline-flex; align-items: center; gap: 5px; align-self: flex-start;
  font-size: 11px; font-weight: 600; padding: 4px 8px 4px 6px; border-radius: 999px;
  background: var(--amber-soft); color: var(--amber); border: 1px solid var(--amber-line);
}

/* ---------- Daily report screen (chrome-free, built to screenshot) ------- */
.report-screen {
  max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative;
  background: var(--bg); padding: max(18px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.report-close { position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px; }
.report-header { display: flex; flex-direction: column; gap: 3px; padding-right: 44px; }
.report-title { font-size: 23px; font-weight: 700; letter-spacing: -.01em; }
.report-wl-group { display: flex; flex-direction: column; gap: 10px; }
.report-wl-id { font-size: 13px; font-weight: 700; color: var(--accent-300); }
.report-stage-group { display: flex; flex-direction: column; gap: 6px; }
.report-stage-label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-soft); }

/* ---------- Forms / modals (PE admin) ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-hint { font-size: 11px; color: var(--text-softer); }
.error-box { border: 1px solid var(--red-line); background: var(--red-soft); color: var(--red); border-radius: var(--radius-md); padding: 9px 12px; font-size: 12.5px; }
.modal-scrim.center { position: fixed; inset: 0; z-index: 70; background: var(--scrim); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-center { width: min(440px, 100%); max-height: 88vh; overflow-y: auto; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.row-gap { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; gap: 8px; flex-wrap: wrap; }
.component-row { border: 1px solid var(--divider); border-radius: var(--radius-sm); padding: 10px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--divider); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-softer); padding: 9px 10px; border-bottom: 1px solid var(--divider); background: var(--surface-2); }
td { padding: 9px 10px; border-bottom: 1px solid var(--divider); }
tr:last-child td { border-bottom: none; }
.empty-state { text-align: center; color: var(--text-softer); font-size: 13.5px; padding: 48px 20px; }

/* Progressive disclosure for dense, secondary content (e.g. the PE report's
   raw per-entry log) — collapsed by default so the screen leads with the
   summarized team report, not a long flat table. */
.details-block { border-radius: var(--radius-md); border: 1px solid var(--divider); background: var(--surface); padding: 2px; }
.details-block summary {
  cursor: pointer; list-style: none; padding: 12px 12px; display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; font-weight: 600; color: var(--text-soft);
}
.details-block summary::-webkit-details-marker { display: none; }
.details-block .details-chev { transition: transform .15s ease; color: var(--text-softer); }
.details-block[open] .details-chev { transform: rotate(90deg); }
.details-block > .table-wrap, .details-block > button { margin: 0 10px 10px; }
.details-block[open] > .table-wrap { margin-top: 4px; }

/* ---------- Animations ---------- */
@keyframes dptUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes dptSheet { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes dptFade { from { opacity: 0; } to { opacity: 1; } }
.stagger > * { animation: dptUp .28s cubic-bezier(.22, 1, .36, 1) both; }
.stagger > *:nth-child(2) { animation-delay: .03s; }
.stagger > *:nth-child(3) { animation-delay: .06s; }
.stagger > *:nth-child(4) { animation-delay: .09s; }
.stagger > *:nth-child(5) { animation-delay: .12s; }
/* Already on screen before this re-render (see renderApp): no entrance animation, so a tap does not blink. */
.stagger.settled > * { animation: none; }
.sheet.settled, .sheet-scrim.settled { animation: none; }
.toast.settled { animation: none; }

@media (min-width: 620px) {
  body { padding: 24px 0; }
  .app-shell { min-height: calc(100vh - 48px); border-radius: 22px; overflow: hidden; box-shadow: 0 30px 80px rgba(46,58,47,.25); border: 1px solid var(--divider); }
  .tabbar { position: absolute; }
}

/* ============================================================
   Desktop layout — a genuinely different shell, not a scaled-up
   phone screen: a fixed left sidebar replaces the bottom tab bar,
   and content uses the freed-up width instead of sitting in a
   narrow centered card. Below 900px (phones/small tablets) nothing
   here applies — that's the "mobile view" above, unchanged.
   ============================================================ */
@media (min-width: 900px) {
  body { padding: 0; }
  .app-shell {
    max-width: none; width: 100%; min-height: 100vh;
    border-radius: 0; box-shadow: none; border: none;
  }
  .app-shell.wide { max-width: none; }

  /* Sidebar nav (same buttons/markup as the mobile tab bar — just
     repositioned and restyled, so no app.js changes are needed).
     Auto-hide rail: collapsed to icon-only width by default (position:
     fixed already, so it overlays rather than pushing content) and
     slides out to full width on hover or keyboard focus — the same
     drawer pattern used for the drawing screen's Tools/BOM panels. */
  .app-shell.has-tabbar .tabbar {
    position: fixed; left: 0; top: 0; bottom: auto; transform: none;
    width: 64px; max-width: 64px; height: 100vh; overflow: hidden; z-index: 50;
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    gap: 2px; padding: 22px 12px; background: var(--rail);
    border-top: none; border-right: none;
    transition: width .2s ease, box-shadow .2s ease;
  }
  .app-shell.has-tabbar .tabbar:hover,
  .app-shell.has-tabbar .tabbar:focus-within {
    width: 232px; max-width: 232px; box-shadow: 6px 0 28px rgba(0, 0, 0, .3);
  }
  .app-shell.has-tabbar .tabbar-item {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    min-height: 44px; padding: 0 12px; border-radius: var(--radius-md);
  }
  .app-shell.has-tabbar .tabbar-item span.tabbar-label {
    font-size: 13.5px; white-space: nowrap; opacity: 1; transition: opacity .12s ease;
  }
  .app-shell.has-tabbar .tabbar-item.active::after { display: none; }
  .app-shell.has-tabbar .tabbar-badge { position: static; margin-left: auto; white-space: nowrap; }
  /* Collapsed state: hide the label/brand text (it has no room to sit in
     a 64px rail) rather than letting it wrap or overflow, so what's left
     is a clean icon rail; hovering fades it back in as the rail widens. */
  .app-shell.has-tabbar .tabbar:not(:hover):not(:focus-within) .tabbar-item span.tabbar-label,
  .app-shell.has-tabbar .tabbar:not(:hover):not(:focus-within)::before {
    opacity: 0;
  }

  /* Header + content move right to clear the collapsed rail and fill
     the rest of the screen edge-to-edge - same full-bleed approach as
     the drawing screen's desktop layout, so a wide monitor isn't left
     with a narrow column and dead space down the right side. The rail
     overlays content when hovered open, rather than pushing it, so this
     margin never needs to change with hover state. */
  .app-shell.has-tabbar .app-header,
  .app-shell.has-tabbar .app-content {
    margin-left: 64px; max-width: none;
  }
  .app-shell.has-tabbar .app-header { padding: 28px 32px 16px; }
  .app-shell.has-tabbar .app-content { padding: 6px 32px 40px; }
  .app-shell.has-tabbar .app-header-title { font-size: 23px; }

  /* More columns now that there's room for the self-contained grids
     (stat tiles, bar charts); everything else stays a single,
     comfortably wide column rather than being forced into a grid
     that would scramble screens meant to be read top-to-bottom
     (worklist detail, drawing forms, step-by-step sheets). */
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .stat-row { flex-wrap: wrap; }

  /* Card lists (worklists, drawings, approval queue) reflow into a
     multi-column grid instead of one full-width column per card, so
     the freed-up width is used for more cards visible at once rather
     than just wider individual cards. Wraps whatever the JS renderer
     produced for that list - see .card-grid usages in app.js. */
  .card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; align-items: start; }
  .card-grid > .card { margin: 0; }

  /* Sheets/modals stay centered floating panels (that pattern works
     fine at any width) but get a little more breathing room. */
  .sheet { max-width: 560px; border-radius: 18px; margin-bottom: 5vh; align-self: center; }
  .sheet-scrim { align-items: center; }

}


/* ============================================================
   Sign-in screen — "Earthy Minimal" palette (step 1 of the redesign)
   primary #2E3A2F · secondary #6B7F5B · tertiary #D9C9B2 ·
   accent #C96F4F · background #F8F6EE
   Scoped to .lg so the rest of the app keeps its current theme
   until each screen is redesigned.
   ============================================================ */
.lg {
  --bg: #F8F6EE; --ink: #2E3A2F; --ink-soft: #55645A; --line: #D9C9B2; --line-soft: #EBE3D2;
  --primary: #2E3A2F; --on-primary: #F8F6EE; --secondary: #6B7F5B; --accent: #C96F4F;
  --field: #FFFFFF; --danger: #A8382B; --danger-bg: #F6E3DC;
  --panel: #2E3A2F; --panel-ink: #F8F6EE; --panel-soft: #B9C4B4; --key: #F1ECDD; --key-press: #E4DAC3; --focus: #C96F4F;
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", monospace;
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  background: var(--bg); color: var(--ink); font: 400 16px/1.5 var(--f-body); color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  .lg {
    --bg: #192019; --ink: #F1EEE3; --ink-soft: #AFBBAF; --line: #3B4A3D; --line-soft: #2C382E;
    --primary: #D9C9B2; --on-primary: #1D261E; --secondary: #86A072; --accent: #DB8062;
    --field: #172018; --danger: #F0A08F; --danger-bg: #3A2521;
    --panel: #121A13; --panel-ink: #F1EEE3; --panel-soft: #9FAE9F; --key: #2A362B; --key-press: #354436; --focus: #DB8062;
    color-scheme: dark;
  }
}
.lg *, .lg *::before, .lg *::after { box-sizing: border-box; }
.lg button { font-family: inherit; }
.lg :focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.lg-panel { background: var(--panel); color: var(--panel-ink); padding: clamp(28px, 5vw, 64px); display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.lg-logo { display: inline-flex; background: #fff; border-radius: 14px; padding: 8px 12px; }
.lg-logo img { display: block; width: 117px; height: auto; max-width: 100%; }
.lg-pitch h1 { font: 700 clamp(30px, 3.6vw, 52px)/1.04 var(--f-display); letter-spacing: -.02em; margin: 0 0 16px; max-width: 14ch; text-wrap: balance; }
.lg-pipe { width: 100%; height: auto; display: block; }
.lg-pipe text { font-family: var(--f-mono); font-size: 12.5px; fill: var(--panel-soft); }
.lg-pipe .code { font-weight: 500; fill: var(--panel-ink); }

.lg-main { display: flex; align-items: center; justify-content: center; padding: clamp(24px, 5vw, 64px) 16px; }
.lg-card { width: 100%; max-width: 420px; }
.lg-card h2 { font: 700 30px/1.15 var(--f-display); letter-spacing: -.015em; margin: 0 0 6px; }
.lg-sub { margin: 0 0 24px; color: var(--ink-soft); }
.lg-lbl { display: block; font: 600 13px/1.2 var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 8px; }
.lg-field { margin-bottom: 20px; }
.lg-text { width: 100%; height: 52px; padding: 0 16px; font: 500 17px/1 var(--f-body); color: var(--ink); background: var(--field); border: 1.5px solid var(--line); border-radius: 10px; caret-color: var(--accent); }
.lg-text::placeholder { color: color-mix(in srgb, var(--ink-soft) 70%, transparent); }
.lg-text:focus-visible { border-color: var(--ink); outline-offset: 0; }
.lg-pinwrap { position: relative; }
.lg-pin { font-family: var(--f-mono); font-size: 22px; letter-spacing: .34em; padding-right: 64px; }
.lg-eye { position: absolute; right: 6px; top: 6px; height: 40px; min-width: 52px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-soft); font: 600 13px/1 var(--f-body); cursor: pointer; }
.lg-eye:hover { background: var(--line-soft); color: var(--ink); }
.lg-ticks { display: flex; gap: 6px; margin-top: 10px; }
.lg-tick { width: 22px; height: 5px; border-radius: 3px; background: var(--line-soft); border: 1px solid var(--line); }
.lg-tick.min { border-color: color-mix(in srgb, var(--ink-soft) 55%, var(--line)); }
.lg-tick.on { background: var(--secondary); border-color: var(--secondary); }
.lg-hint { display: block; margin: 6px 0 0; font-size: 13px; color: var(--ink-soft); }

.lg-kptoggle { margin: 0 0 12px; }
.lg-link { background: none; border: 0; padding: 4px 0; color: var(--ink); font: 500 14px/1.2 var(--f-body); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 4px; cursor: pointer; }
.lg-keypad { display: none; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.lg-keypad.open { display: grid; }
.lg-key { height: 58px; border: 0; border-radius: 12px; background: var(--key); color: var(--ink); font: 500 24px/1 var(--f-mono); cursor: pointer; touch-action: manipulation; transition: background .12s; }
.lg-key:hover, .lg-key:active { background: var(--key-press); }
.lg-key.util { font: 600 13px/1 var(--f-body); letter-spacing: .04em; color: var(--ink-soft); }

.lg-btn { width: 100%; height: 56px; border: 0; border-radius: 12px; background: var(--primary); color: var(--on-primary); font: 600 17px/1 var(--f-body); cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 -4px 0 color-mix(in srgb, var(--accent) 90%, transparent); }
.lg-btn:hover:not(:disabled) { filter: brightness(1.08); }
.lg-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.lg-note { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; margin-bottom: 20px; font-size: 15px; background: var(--danger-bg); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
.lg-note svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.lg-note strong { font-weight: 600; }
.lg-help { margin: 22px 0 0; font-size: 14.5px; color: var(--ink-soft); }
.lg-help b { color: var(--ink); font-weight: 600; }

@media (max-width: 860px) {
  .lg { grid-template-columns: 1fr; }
  .lg-panel { padding: 20px 16px 22px; gap: 16px; }
  .lg-logo img { width: 84px; }
  .lg-logo { padding: 6px 10px; border-radius: 12px; }
  .lg-pitch h1 { font-size: 26px; max-width: none; margin-bottom: 8px; }
  .lg-pipe text { font-size: 15.5px; }
  .lg-main { align-items: flex-start; padding-top: 24px; padding-bottom: 32px; }
  .lg-keypad { display: grid; }
  .lg-kptoggle { display: none; }
}
@media (max-width: 420px) {
  .lg-card h2 { font-size: 26px; }
  .lg-key { height: 54px; }
}
@media (prefers-reduced-motion: reduce) { .lg-key { transition: none; } }


/* ============================================================
   Shell — step 2 of the redesign: fonts, tab bar (phone), rail (desktop)
   ============================================================ */
h1, h2, h3, .app-header-title, .hero-title, .stat-val, .wl-id { font-family: var(--f-display); }
.mono, .stepper-num, .tabbar-badge { font-family: var(--f-mono); }

/* Phone: bottom tabs */
.tabbar-item { color: var(--text-soft); }
.tabbar-item.active { color: var(--text); font-weight: 600; }
.tabbar-item.active::after { background: var(--accent); width: 26px; height: 3px; bottom: -8px; }
.avatar-btn { background: var(--accent-900); border-color: var(--divider-strong); color: var(--text); }
.rail-brand { display: none; }

/* Desktop: dark green rail with the accent marking the current page */
@media (min-width: 900px) {
  .app-shell.has-tabbar .tabbar-item { color: var(--rail-soft); flex: none; }
  .app-shell.has-tabbar .tabbar-item:hover { color: var(--rail-ink); }
  .app-shell.has-tabbar .tabbar-item.active { background: var(--rail-active); color: var(--rail-ink); box-shadow: inset 3px 0 0 var(--accent); }
  .app-shell.has-tabbar .tabbar-badge { background: var(--accent); color: var(--on-badge); }
  .app-shell.has-tabbar .tabbar .rail-brand { display: flex; align-items: center; padding: 0 0 18px 0; min-height: 66px; }
  .rail-mark { width: 32px; height: 32px; flex: none; margin-left: 2px; }
  .rail-logo { display: none; }
  .app-shell.has-tabbar .tabbar:hover .rail-mark,
  .app-shell.has-tabbar .tabbar:focus-within .rail-mark { display: none; }
  .app-shell.has-tabbar .tabbar:hover .rail-logo,
  .app-shell.has-tabbar .tabbar:focus-within .rail-logo { display: inline-flex; }
  .rail-logo img { width: 96px; }
  .rail-logo { padding: 6px 10px; border-radius: 12px; }
}
/* Wide screens: keep the rail open (except on the drawing screen, which needs the width) */
@media (min-width: 1200px) {
  .app-shell.has-tabbar:not(.screen-drawing) .tabbar { width: 232px; max-width: 232px; }
  .app-shell.has-tabbar:not(.screen-drawing) .tabbar .tabbar-item span.tabbar-label { opacity: 1 !important; }
  .app-shell.has-tabbar:not(.screen-drawing) .tabbar .rail-mark { display: none; }
  .app-shell.has-tabbar:not(.screen-drawing) .tabbar .rail-logo { display: inline-flex; }
  .app-shell.has-tabbar:not(.screen-drawing) .app-header,
  .app-shell.has-tabbar:not(.screen-drawing) .app-content { margin-left: 232px; }
}


/* ============================================================
   Today (step 3): crew headcount + category productivity
   ============================================================ */
.crew-panel { gap: 14px; }
.crew-head { display: flex; flex-direction: column; gap: 2px; }
.crew-head h2 { font-size: 19px; }
.crew-sub { font-size: 13px; color: var(--text-soft); }
.crew-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.crew-item { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.crew-label { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-soft); }
.crew-stepper { display: flex; align-items: stretch; border: 1.5px solid var(--divider-strong); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); }
.crew-btn { width: 46px; min-height: 46px; flex: none; border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--text); cursor: pointer; }
.crew-btn:hover { background: var(--neutral-soft); }
.crew-num { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; text-align: center; font-size: 20px; font-weight: 500; color: var(--text); -moz-appearance: textfield; }
.crew-num::-webkit-outer-spin-button, .crew-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.crew-num:focus { outline: 0; background: var(--accent-tint); }
.prod-card-note { font-size: 12.5px; color: var(--text-soft); margin-top: -2px; }
@media (max-width: 640px) {
  .crew-row { grid-template-columns: 1fr; gap: 12px; }
  .crew-item { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
  .crew-label { flex: 1; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); font-weight: 500; }
  .crew-stepper { width: 160px; flex: none; }
}


/* ============================================================
   Trends (step 4)
   ============================================================ */
.trend-controls { display: flex; flex-direction: column; gap: 10px; }
.trend-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.trend-crew { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trend-card { gap: 12px; }
.trend-card.busy { opacity: .55; transition: opacity .15s; }
.trend-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.trend-range { font-size: 13px; color: var(--text-soft); text-align: center; flex: 1; }
.trend-chart { width: 100%; max-width: 820px; height: auto; display: block; margin: 0 auto; }
.trend-chart text { font-family: var(--f-mono); font-size: 11px; fill: var(--text-soft); }
.trend-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-soft); }
.trend-legend i { display: inline-block; width: 16px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.trend-legend i.dash { height: 0; border-top: 2px dashed; background: none; }
.trend-table summary { cursor: pointer; font-size: 13.5px; color: var(--text); padding: 6px 0; }
.trend-note { font-size: 12.5px; color: var(--text-soft); line-height: 1.55; max-width: 70ch; }


/* ============================================================
   Overview + Report (step 5)
   ============================================================ */
.scope-card { gap: 10px; }
.scope-row { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; }
.scope-pct { font-family: var(--f-display); font-size: 52px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.scope-txt { font-size: 14px; line-height: 1.5; padding-bottom: 4px; }
.scope-bar { height: 12px; border-radius: 6px; }
.scope-bar > i { border-radius: 6px; }
@media (max-width: 640px) { .scope-pct { font-size: 42px; } }


/* ============================================================
   People + Drawings (step 6)
   ============================================================ */
.people-card, .pin-card { gap: 12px; }
.people-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.people-head h2 { font-size: 19px; }
.people-list { display: flex; flex-direction: column; }
.people-list .person-row, .people-list .pin-row { background: transparent; border-radius: 0; border-top: 1px solid var(--divider); padding: 12px 2px; }
.people-list .person-row:first-child, .people-list .pin-row:first-child { border-top: 0; }
.pin-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.people-name { font-size: 14.5px; font-weight: 600; }
.people-sub { font-size: 12.5px; color: var(--text-soft); }
.person-row.off .people-name, .person-row.off .person-avatar { opacity: .55; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill.on { background: var(--green-soft); color: var(--green); }
.status-pill.off { background: var(--neutral-soft); color: var(--neutral-fg); }
.pin-card { border: 1px solid var(--amber-line); background: var(--amber-soft); }
.banner-note { padding: 12px 14px; border-radius: var(--radius-md); background: var(--amber-soft); color: var(--amber); font-size: 14px; }
.dw-remark { font-size: 12.5px; color: var(--red); }
@media (max-width: 640px) {
  .person-row { flex-wrap: wrap; row-gap: 8px; }
  .person-row .grow { flex: 1 1 60%; }
}
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- Pipe size hint next to an IWL number ---------- */
.wl-id-group { display: inline-flex; align-items: center; gap: 7px; flex-wrap: wrap; min-width: 0; }
.pipe-hint { font-family: var(--f-mono); font-size: 11.5px; font-weight: 500; line-height: 1; padding: 4px 7px; border-radius: 6px; background: var(--sel-bg); color: var(--sel-fg); white-space: nowrap; }
.pipe-hint.more { background: transparent; color: var(--text-soft); border: 1px dashed var(--divider-strong); padding: 3px 6px; }
.pipe-hint.none { background: var(--accent-tint); color: var(--accent); font-family: var(--f-body, inherit); font-weight: 500; }

/* ---------- Share report button (Report screen) ---------- */
.share-report-btn { width: 100%; padding: 12px 14px; border-radius: var(--radius-md); background: var(--green); color: var(--surface); font-weight: 600; font-size: 14px; border: 0; }
.share-report-btn:disabled { opacity: .6; }

/* ---------- Worklists screen: search, select mode, assign, bulk bar ---------- */
.wl-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.wl-tools .text-input { flex: 1; min-width: 0; }
.filter-chip.warn { border-color: var(--red); color: var(--red); font-weight: 700; }
.load-strip { display: flex; gap: 6px; margin: 4px 0 10px; overflow-x: auto; }
.load-strip div { flex: 1 0 84px; background: var(--surface); border-radius: var(--radius-md); padding: 6px 9px; box-shadow: var(--shadow-sm); }
.load-strip b { display: block; font-size: 17px; }
.load-strip span { font-size: 10.5px; color: var(--text-soft); }
.wl-pill { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 11.5px; font-weight: 700; }
.wl-pill.un { background: var(--red-soft); color: var(--red); }
.wl-pill.as { background: var(--green-soft); color: var(--green); }
.wl-menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; font-size: 20px; line-height: 1; color: var(--text-soft); }
.wl-menu-btn:hover { background: var(--neutral-soft); }
.wl-check { width: 20px; height: 20px; border: 2px solid var(--divider-strong); border-radius: 6px; flex: none; position: relative; }
.wl-check.on { background: var(--green); border-color: var(--green); }
.wl-check.on::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px; border: solid var(--surface); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.wl-card.selected { outline: 2px solid var(--green); }
.bulk-bar { position: sticky; bottom: 0; z-index: 30; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; margin-top: 12px; background: var(--ink, #2E3A2F); color: var(--surface, #fff); border-radius: var(--radius-md); }
.assign-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border: 1px solid var(--divider); border-radius: var(--radius-md); background: var(--surface); text-align: left; min-height: 48px; }
.assign-row span { font-size: 12px; color: var(--text-soft); }
.assign-row.selected { border-color: var(--accent-700); background: var(--accent-900); }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 8px 2px; }

/* ---------- Worklist screen: sheets of one drawing ---------- */
.sheet-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 14px 2px 4px; padding: 8px 12px; border-radius: var(--radius-md); background: var(--surface-2); }
.sheet-name { font-weight: 700; font-size: 14px; }
.sheet-pct { font-size: 12px; color: var(--text-soft); }

/* ---------- Log all sheet ---------- */
.batch-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; }
.batch-row { gap: 6px; }
.batch-row.off { opacity: .65; }
.batch-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.batch-name { font-weight: 600; font-size: 13.5px; }

/* Workload strip cards filter the list by workleader */
.load-strip .load-card { flex: 1 0 84px; text-align: left; border: 0; background: var(--surface); border-radius: var(--radius-md); padding: 6px 9px; box-shadow: var(--shadow-sm); cursor: pointer; min-height: 44px; color: inherit; }
.load-strip .load-card b { display: block; font-size: 17px; }
.load-strip .load-card span { font-size: 10.5px; color: var(--text-soft); }
.load-strip .load-card.on { outline: 2px solid var(--green); }
.load-strip .load-card.clear { flex: 0 0 auto; }

/* ---------- Log today: every open stage on every IWL, one keypad ---------- */
.day-list { display: flex; flex-direction: column; gap: 6px; max-height: 30vh; overflow-y: auto; flex-shrink: 0; }
.day-group { position: sticky; top: 0; z-index: 1; padding: 4px 0; background: var(--surface); }
.day-badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 6px; background: var(--accent); color: var(--accent-100); font-family: var(--f-mono); font-size: 13px; font-weight: 700; flex: none; }
.day-badge.sm { font-size: 11px; padding: 1px 6px; }
.day-item { border: 1px solid var(--divider); border-radius: var(--radius-md); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.day-item-top { display: flex; align-items: center; gap: 8px; }
.day-name { font-weight: 600; font-size: 13.5px; }
.day-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.day-chip { min-height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--divider-strong); background: transparent; color: var(--text); font: inherit; font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.day-chip.has { background: var(--green-soft); color: var(--green); border-color: var(--green-line); }
.day-chip.on { background: var(--sel-bg); color: var(--sel-fg); border-color: var(--sel-bg); }
.day-pad { display: flex; flex-direction: column; gap: 7px; border-top: 1px solid var(--divider); padding-top: 8px; }
.day-meters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.day-meter { background: var(--surface-2); border-radius: 10px; padding: 5px 10px; display: flex; flex-direction: column; font-size: 11px; color: var(--text-soft); }
.day-meter b { font-size: 15px; color: var(--text); }
.day-meter b.good { color: var(--green); }
.day-meter b.low { color: var(--red); }
.day-cur { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13.5px; font-weight: 600; }
.day-cur small { color: var(--text-soft); font-weight: 400; flex: none; }
.day-num { text-align: center; font-family: var(--f-mono); font-size: 32px; font-weight: 600; }
.day-num small { font-size: 15px; color: var(--text-soft); }
.day-num.over { color: var(--red); }
.day-fracs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.day-keys { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.day-key { min-height: 44px; border-radius: 12px; border: none; background: var(--surface-2); color: var(--text); font-family: var(--f-mono); font-size: 20px; font-weight: 600; cursor: pointer; }
.day-key:disabled { opacity: .3; }
.day-error { white-space: pre-line; }

/* ---------- Coat tick: one worklist, pick the coat, tick what is done ---------- */
/* not ".lg": that is the login page class (full-screen height) */
.day-badge.big { font-size: 18px; padding: 3px 10px; border-radius: 8px; margin-bottom: 4px; }
.coat-tabs { display: flex; gap: 6px; }
.coat-tab { flex: 1; min-height: 52px; border-radius: 12px; border: 1px solid var(--divider-strong); background: transparent; color: var(--text); font: inherit; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer; }
.coat-tab b { font-size: 14px; }
.coat-tab small { font-size: 10.5px; color: var(--text-soft); }
.coat-tab.on { background: var(--sel-bg); color: var(--sel-fg); border-color: var(--sel-bg); }
.coat-tab.on small { color: inherit; }
.coat-list { display: flex; flex-direction: column; gap: 8px; max-height: 30vh; overflow-y: auto; flex-shrink: 0; }
.coat-item { border: 1px solid var(--divider); border-radius: var(--radius-md); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.coat-item.on { border-color: var(--green-line); }
.coat-row { display: flex; align-items: center; gap: 12px; min-height: 44px; background: transparent; border: none; color: var(--text); font: inherit; text-align: left; padding: 0; cursor: pointer; }
.coat-box { width: 32px; height: 32px; border-radius: 8px; border: 2px solid var(--divider-strong); display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; flex: none; }
.coat-item.on .coat-box { background: var(--green); border-color: var(--green); color: var(--surface); }
.coat-name { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.coat-name b { font-size: 14.5px; }
.coat-name small { font-size: 12px; color: var(--text-soft); }
.coat-qty { font-size: 15px; font-weight: 600; }
.coat-part { display: flex; align-items: center; gap: 8px; padding-left: 44px; font-size: 12px; color: var(--text-soft); }
.coat-part span { flex: 1; }
.coat-step, .coat-amt { min-width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--divider-strong); background: transparent; color: var(--text); font: inherit; font-size: 18px; cursor: pointer; }
.coat-amt { padding: 0 10px; font-size: 14px; }
.coat-amt.over { color: var(--red); border-color: var(--red-line); }
.detail-log { display: flex; flex-direction: column; gap: 8px; }
/* Tall sheet (coat tick): the item list takes whatever the header and footer leave, so a
   long worklist shows several items at once instead of a fixed 30% strip. */
.sheet.tall { height: 96vh; height: 96dvh; max-height: 96vh; max-height: 96dvh; gap: 10px; }
.sheet.tall > .sheet-head { margin: 0; padding: 0; background: none; align-items: center; }
.sheet.tall .coat-list { flex: 1 1 auto; min-height: 140px; max-height: none; }
.coat-head-l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.coat-head-l .sheet-title { margin: 0; font-size: 17px; }
.coat-head-l .day-badge.big { margin: 0; }
.coat-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--text-soft); }
/* Log today with the keypad hidden: the list takes the room the keypad used */
.day-list.roomy { max-height: 60vh; }
.day-kpbar { display: flex; justify-content: flex-end; }
/* Log today: search and the review step */
.day-search { display: flex; flex-direction: column; gap: 4px; }
.day-count { font-size: 12px; color: var(--text-soft); }
.rv-list { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.sheet.tall .rv-list { flex: 1 1 auto; min-height: 140px; }
.rv-group { border: 1px solid var(--divider); border-radius: var(--radius-md); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.rv-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--text-soft); }
.rv-row { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--divider); padding-top: 8px; }
.rv-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rv-main b { font-size: 14px; }
.rv-main small { font-size: 12px; color: var(--text-soft); }
.rv-x { width: 44px; height: 44px; flex: none; border-radius: 12px; border: 1px solid var(--red-line); background: transparent; color: var(--red); font-size: 18px; cursor: pointer; }
.rv-amt { display: flex; align-items: center; gap: 8px; }
.rv-warn { font-size: 12px; color: var(--red); }
.rv-note { font-size: 13px; color: var(--text-soft); }
/* New worklist: how to add the items */
.new-ways { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.new-way { min-height: 64px; border-radius: 12px; border: 1px solid var(--divider-strong); background: transparent; color: var(--text); font: inherit; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding: 8px 10px; text-align: left; cursor: pointer; }
.new-way b { font-size: 13.5px; }
.new-way small { font-size: 11px; color: var(--text-soft); }
.new-way.on { background: var(--sel-bg); color: var(--sel-fg); border-color: var(--sel-bg); }
.new-way.on small { color: inherit; }
.new-way:disabled { opacity: .55; cursor: default; }
.new-panel { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--divider); border-radius: var(--radius-md); padding: 10px; }
.copy-results { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.copy-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 48px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--divider); background: var(--surface-2); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.copy-row span { font-size: 12px; color: var(--text-soft); }
.tap-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tap-chip { min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--divider-strong); background: transparent; color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.tap-chip.on { background: var(--sel-bg); color: var(--sel-fg); border-color: var(--sel-bg); }
.new-est { border: 1px solid var(--divider); border-radius: var(--radius-md); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; background: var(--surface-2); }
@media (max-width: 480px) { .new-ways { grid-template-columns: 1fr; } }
/* New worklist: paste from Excel */
.paste-box { font-family: var(--f-mono); font-size: 12px; white-space: pre; min-height: 140px; resize: vertical; }
.paste-list { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.paste-row { display: flex; gap: 8px; align-items: flex-start; border-radius: 10px; padding: 8px 10px; border: 1px solid var(--divider); }
.paste-row.ask { border-color: var(--amber-line); background: var(--amber-soft); }
.paste-row.skip { border-style: dashed; opacity: .75; }
.paste-mark { width: 24px; height: 24px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.paste-mark.ok { background: var(--green-soft); color: var(--green); }
.paste-mark.ask { background: var(--amber); color: var(--surface); }
.paste-mark.skip { background: var(--neutral-soft); color: var(--neutral-fg); }
.paste-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.paste-main b { font-size: 13px; }
.paste-main small { font-size: 11px; color: var(--text-soft); overflow-wrap: anywhere; }
.tap-chip.bad { border-color: var(--red-line); color: var(--red); }

/* Drawing scans (migration 0030): the drawing card, the "view drawing" link in sheets, and the full-screen viewer. */
.scan-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.scan-card-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.scan-link { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; }
.scan-viewer { position: fixed; inset: 0; z-index: 90; background: var(--bg); display: flex; flex-direction: column; }
.scan-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: max(8px, env(safe-area-inset-top)) 10px 8px; border-bottom: 1px solid var(--divider); background: var(--surface); }
.scan-title { display: flex; flex-direction: column; min-width: 0; }
.scan-title span { font-size: 12px; color: var(--text-soft); }
.scan-tools { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.scan-tools .icon-btn { font-size: 20px; line-height: 1; }
.scan-tools .icon-btn[disabled] { opacity: .35; }
.scan-pageno { font-size: 12px; min-width: 44px; text-align: center; }
.scan-stage { flex: 1; overflow: auto; background: var(--surface-2); -webkit-overflow-scrolling: touch; }
.scan-img { display: block; max-width: none; height: auto; background: #fff; }
.scan-loading { padding: 24px; text-align: center; color: var(--text-soft); font-size: 13px; }
.scan-note { padding: 8px 12px max(8px, env(safe-area-inset-bottom)); font-size: 11.5px; color: var(--text-soft); background: var(--surface); border-top: 1px solid var(--divider); }

/* Pinned drawing on the log sheets: page at normal size, stays at the top while the form scrolls; 3x lens on touch / hover. */
.pin-draw { position: sticky; top: 0; z-index: 3; background: var(--surface-2); border: 1px solid var(--divider); border-radius: var(--radius-md); overflow: hidden; flex: none; }
.pin-head { display: flex; align-items: center; gap: 2px; padding: 4px 4px 4px 10px; }
.pin-head .icon-btn { font-size: 20px; line-height: 1; }
.pin-head .icon-btn[disabled] { opacity: .35; }
.pin-title { flex: 1; min-width: 0; font-size: 12px; font-weight: 600; }
.pin-stage { display: flex; justify-content: center; background: var(--surface); border-top: 1px solid var(--divider); touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.pin-img { display: block; max-width: 100%; max-height: 38vh; max-height: 38dvh; height: auto; pointer-events: none; background: #fff; }
.pin-hint { font-size: 10.5px; color: var(--text-softer); padding: 3px 10px 5px; background: var(--surface); }
.pin-msg { padding: 14px 12px; font-size: 12.5px; color: var(--text-soft); background: var(--surface); }
.pin-lens { position: fixed; z-index: 95; display: none; border-radius: 50%; border: 3px solid #fff; background-color: #fff; background-repeat: no-repeat; box-shadow: 0 6px 18px rgba(20, 28, 21, .35), 0 0 0 1px rgba(46, 58, 47, .35); pointer-events: none; }
.pin-lens.on { display: block; }
