:root {
  /* MsRenovationsPro brand system (reskin, replaces the old orange/navy set). */
  --maroon: #84002F;
  --maroon-mid: #A8003C;
  --maroon-deep: #5E0021;
  --maroon-soft: #C97595;
  --maroon-pale: #F5E6EB;
  --ink: #111017;
  --char: #2D2635;
  --cream: #F4F0EF;
  --paper: #FAFAF9;
  --muted: #706878;
  --muted-light: #9E95A2;
  --border: #E4DEE1;
  --card: #ffffff;
  --text: var(--ink);
  --text-dim: var(--muted);
  --danger: #B23A3A;
  --danger-bg: #FBEBEB;
  --ok: #3D7A55;
  --ok-bg: #E9F4ED;
  --warn: #9C6B1F;
  --warn-bg: #FBF1DE;
  --info: #33607D;
  --info-bg: #E8F1F6;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 12px rgba(17, 16, 23, 0.08);
  --shadow-lg: 0 16px 48px rgba(17, 16, 23, 0.14);
  --focus-ring: 0 0 0 3px rgba(168, 0, 60, 0.28);
  --sidebar-w: 232px;
  --sidebar-w-rail: 76px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

a { color: var(--maroon); text-decoration: none; }

h1, h2, h3, h4 { color: var(--ink); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.5rem; margin: 0 0 0.9rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 0.95rem; }

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 0.65rem 1.1rem;
  min-height: 44px;
  background: var(--maroon);
  color: #fff;
  font-weight: 600;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
button:hover:not(:disabled) { background: var(--maroon-mid); }
button:active:not(:disabled) { background: var(--maroon-deep); }
button.secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
button.secondary:hover:not(:disabled) { background: var(--cream); }
button.danger { background: var(--danger); }
button.danger:hover:not(:disabled) { background: #9c3131; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

input, select, textarea {
  font: inherit;
  padding: 0.6rem 0.7rem;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 5.5rem; }

label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-dim); margin: 0.6rem 0 0.3rem; text-transform: uppercase; letter-spacing: 0.03em; }

.field { margin-bottom: 0.5rem; }

/* Addendum 2026-09-23 item A: white shell, matching the report sheet — ink
   is now used only for text/icons (never a fill background) in the topbar,
   sidebar, and command header. Maroon stays the only accent color. */
.topbar {
  background: var(--card);
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .left { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.topbar .brand { font-weight: 700; letter-spacing: 0.01em; white-space: nowrap; color: var(--ink); }
.topbar .who { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 0.6rem; white-space: nowrap; }
.hamburger-btn {
  display: none;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.4rem;
  min-height: 40px;
  min-width: 40px;
  align-items: center;
  justify-content: center;
}
.hamburger-btn:hover { background: var(--paper); }

@media (max-width: 480px) {
  .topbar { padding: 0.7rem 0.8rem; }
  .topbar .brand { font-size: 0.9rem; }
  .topbar .who span { display: none; }
  .topbar .who button.link { padding: 0.3rem 0.5rem; font-size: 0.75rem; }
}
.topbar button.link {
  background: transparent;
  color: var(--ink);
  padding: 0.3rem 0.6rem;
  min-height: 36px;
  border: 1px solid var(--border);
}
.topbar button.link:hover { background: var(--paper); }

main {
  flex: 1;
  padding: 1.1rem;
  padding-bottom: 5.5rem;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}

/* ---- Ink sidebar (admin/pm) ---------------------------------------- */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--card);
  color: var(--muted);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 25;
  transition: transform 0.2s ease;
}
.sidebar .brand-block { padding: 1.3rem 1.4rem 1.1rem; border-bottom: 1px solid var(--border); }
.sidebar .brand-name { font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.sidebar .brand-sub { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 0.2rem; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 0.7rem 0.65rem; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.68rem 0.8rem;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
  min-height: 44px;
  border-left: 3px solid transparent;
}
.sidebar nav a svg { flex-shrink: 0; width: 20px; height: 20px; stroke: currentColor; }
.sidebar nav a:hover { background: var(--paper); color: var(--ink); }
.sidebar nav a.active {
  background: var(--maroon-pale);
  color: var(--maroon-deep);
  border-left-color: var(--maroon);
  font-weight: 600;
}
.sidebar .nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-backdrop { display: none; }

#app.with-sidebar main { margin-left: var(--sidebar-w); }

@media (max-width: 1023px) {
  :root { --sidebar-w: var(--sidebar-w-rail); }
  .sidebar .brand-sub, .sidebar .nav-label { display: none; }
  .sidebar .brand-block { padding: 1.1rem 0.6rem; text-align: center; }
  .sidebar nav a { justify-content: center; padding: 0.7rem 0.5rem; }
  .sidebar nav a svg { margin: 0; }
}

@media (max-width: 767px) {
  :root { --sidebar-w: 0px; }
  .hamburger-btn { display: inline-flex; }
  .sidebar {
    width: 260px;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar .brand-sub, .sidebar .nav-label { display: block; }
  .sidebar .brand-block { padding: 1.3rem 1.4rem 1.1rem; text-align: left; }
  .sidebar nav a { justify-content: flex-start; padding: 0.68rem 0.8rem; }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open ~ .sidebar-backdrop,
  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(17,16,23,0.45);
    z-index: 24;
  }
  #app.with-sidebar main { margin-left: 0; padding-bottom: 1.5rem; }
}

/* ---- Field bottom tab bar ------------------------------------------- */

.navbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--ink);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: var(--shadow-lg);
}
.navbar a {
  flex: 1;
  text-align: center;
  padding: 0.55rem 0.2rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: rgba(255,255,255,0.62);
  border-top: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-height: 52px;
  justify-content: center;
}
.navbar a svg { width: 22px; height: 22px; stroke: currentColor; }
.navbar a.active { color: #fff; border-top-color: var(--maroon-mid); }

#app.with-field-nav main { padding-bottom: 5.5rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  margin-bottom: 0.9rem;
  box-shadow: var(--shadow-sm);
}

.card h2, .card h3 { margin-top: 0; }

.grid { display: grid; gap: 0.9rem; }
@media (min-width: 640px) {
  .grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat .num { font-size: 1.7rem; font-weight: 700; color: var(--ink); }
.stat .label { font-size: 0.76rem; color: var(--text-dim); margin-top: 0.15rem; }
a.stat:hover { box-shadow: var(--shadow-lg); }

.chip {
  display: inline-block;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--cream);
  color: var(--text-dim);
}
.chip.status-planning { background: #EDEAF0; color: var(--char); }
.chip.status-scheduled { background: var(--info-bg); color: var(--info); }
.chip.status-active { background: var(--ok-bg); color: var(--ok); }
.chip.status-waiting { background: var(--warn-bg); color: var(--warn); }
.chip.status-punch_list { background: var(--maroon-pale); color: var(--maroon-deep); }
.chip.status-complete { background: #E5E3F4; color: #4B3F87; }
.chip.status-closed { background: #E9E9EA; color: #5B5760; }

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }

.muted { color: var(--text-dim); font-size: 0.85rem; }

.banner { border-radius: var(--radius); padding: 0.75rem 0.95rem; margin-bottom: 0.9rem; font-size: 0.9rem; }
.error-banner { background: var(--danger-bg); color: var(--danger); border: 1px solid #EBC9C9; border-radius: var(--radius); padding: 0.75rem 0.95rem; margin-bottom: 0.9rem; }
.ok-banner { background: var(--ok-bg); color: var(--ok); border: 1px solid #C7E4D0; border-radius: var(--radius); padding: 0.75rem 0.95rem; margin-bottom: 0.9rem; }
.info-banner { background: var(--info-bg); color: var(--info); border: 1px solid #C6DCE7; border-radius: var(--radius); padding: 0.75rem 0.95rem; margin-bottom: 0.9rem; }

/* ---- Toasts (top, dismissible) --------------------------------------- */
.toast-stack {
  position: fixed;
  top: 0.8rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(420px, calc(100vw - 1.6rem));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
}
.toast.toast-danger { background: var(--danger); }
.toast.toast-ok { background: var(--ok); }
.toast .toast-close { background: transparent; border: none; color: inherit; opacity: 0.8; padding: 0 0.2rem; min-height: auto; }
.toast .toast-close:hover { opacity: 1; background: transparent; }

.tabs {
  display: flex;
  overflow-x: auto;
  gap: 0.4rem;
  margin: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}
.tabs a {
  padding: 0.55rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--maroon); border-bottom-color: var(--maroon); font-weight: 700; }

.command-header {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  margin-bottom: 0.6rem;
  box-shadow: var(--shadow-sm);
}
.command-header .job-name { font-size: 1.3rem; font-weight: 700; margin: 0 0 0.2rem; color: var(--ink); }
.command-header .job-sub { color: var(--muted); font-size: 0.85rem; }
.command-header dl {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem 1rem;
  margin: 0.8rem 0 0;
  font-size: 0.85rem;
}
.command-header dt { color: var(--muted); }
.command-header dd { margin: 0; font-weight: 600; color: var(--ink); }

.enroll-link-box {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  word-break: break-all;
}

.project-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 0.8rem;
  box-shadow: var(--shadow-sm);
}
.project-card .name { font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.project-card .addr { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.2rem; }
a.project-card:hover { box-shadow: var(--shadow-lg); }

.loading {
  padding: 2rem 0;
  text-align: center;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  border-top-color: var(--maroon);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 2.2rem 1rem;
  color: var(--text-dim);
}
.empty-state .empty-hint { font-size: 0.85rem; margin-top: 0.3rem; }

/* Loop 7: derived task progress bars — Command Center header + per-phase on the Tasks tab. */
.progress-bar {
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
  height: 0.5rem;
  overflow: hidden;
  margin-top: 0.3rem;
}
.progress-bar .fill { background: var(--maroon-mid); height: 100%; border-radius: 999px; }
.progress-bar.on-card { background: var(--border); }
.phase-row { margin-bottom: 0.7rem; }
.phase-row .phase-label { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 0.2rem; }

/* Loop 8: photo gallery grid. */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.5rem; }
.photo-grid .thumb { display: block; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--border); border: 1px solid var(--border); }
.photo-grid .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-lightbox { position: fixed; inset: 0; background: rgba(17,16,23,0.9); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.photo-lightbox img { max-width: 100%; max-height: 80vh; border-radius: var(--radius); }
.photo-lightbox .close { position: absolute; top: 1rem; right: 1rem; }

/* Loop 8: big field-friendly add-photo button. */
.add-photo-btn { width: 100%; font-size: 1rem; padding: 1rem; margin-bottom: 0.9rem; }

/* ---- Field clock: sticky status card --------------------------------- */
.clock-status-card {
  position: sticky;
  top: 0.7rem;
  z-index: 15;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-lg);
}
.clock-status-card.clocked-in { background: linear-gradient(135deg, var(--maroon-deep), var(--ink)); }
.clock-status-card .clock-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.75; font-weight: 700; }
.clock-status-card .clock-project { font-size: 1.05rem; font-weight: 700; margin-top: 0.2rem; }
.clock-status-card .clock-timer { font-size: 2.1rem; font-weight: 700; margin: 0.4rem 0; font-variant-numeric: tabular-nums; }
.clock-status-card .clock-big-btn { width: 100%; min-height: 56px; font-size: 1.05rem; margin-top: 0.5rem; }
.clock-status-card .clock-big-btn.out { background: var(--danger); }
.clock-status-card .clock-big-btn.out:hover { background: #9c3131; }
.clock-in-btn-big { width: 100%; min-height: 52px; font-size: 1rem; margin-top: 0.6rem; }

/* ---- Employee contact actions ---------------------------------------- */
.contact-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.contact-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  min-height: 38px;
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--cream);
  color: var(--char);
  border: 1px solid var(--border);
}
.contact-btn:hover { background: var(--maroon-pale); color: var(--maroon-deep); }
.contact-btn svg { width: 15px; height: 15px; stroke: currentColor; flex-shrink: 0; }
.contact-btn.whatsapp:hover { background: #E4F5E9; color: #1f7a3d; }
.contact-btn.call:hover { background: var(--maroon-pale); color: var(--maroon-deep); }

/* ---- Dashboard "Needs attention" / "Working now" deep links ---------- */
.attention-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.3rem;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
}
.attention-link:hover, .attention-link:focus-visible { background: var(--maroon-pale); color: var(--maroon-deep); text-decoration: underline; }
.attention-link .chevron-affordance { width: 15px; height: 15px; color: var(--muted-light); flex-shrink: 0; }
.attention-link:hover .chevron-affordance, .attention-link:focus-visible .chevron-affordance { color: var(--maroon-deep); }

/* ---- Area map / phasing board ----------------------------------------- */
.area-map-wrap { overflow-x: auto; }
.area-map-legend { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 0.7rem; font-size: 0.78rem; color: var(--text-dim); }
/* Ring-dot style (Task 2): a filled circle with a visible stroke ring —
   color is never the only signal, every legend entry also carries text. */
.area-map-legend .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 0.35rem; vertical-align: middle; box-sizing: border-box; }
.area-block { cursor: pointer; }
.area-block:focus-visible { outline: 2px solid var(--maroon-mid); outline-offset: 2px; }

/* Tower elevations: side by side on desktop (scrolls horizontally past 3
   towers, MAX_TOWERS is 6), stacked full-width on mobile. */
.tower-row { display: flex; gap: 1.1rem; align-items: flex-end; overflow-x: auto; padding-bottom: 0.25rem; }
.tower-elevation { flex: 0 0 auto; width: 190px; }
.tower-elevation h4 { margin: 0 0 0.35rem; font-size: 0.82rem; text-align: center; color: var(--ink); }
@media (max-width: 640px) {
  .tower-row { flex-direction: column; overflow-x: visible; align-items: stretch; }
  .tower-elevation { width: 100%; }
}

@media (min-width: 800px) {
  #app.with-field-nav .navbar { top: 0; bottom: auto; left: 0; right: auto; width: 200px; height: 100vh; flex-direction: column; border-top: none; border-right: 1px solid rgba(255,255,255,0.08); padding-top: 1rem; box-shadow: none; }
  #app.with-field-nav .navbar a { flex-direction: row; text-align: left; padding: 0.7rem 1.2rem; border-top: none; border-left: 2px solid transparent; justify-content: flex-start; }
  #app.with-field-nav .navbar a.active { border-left-color: var(--maroon-mid); border-top-color: transparent; }
  #app.with-field-nav main { margin-left: 200px; max-width: 900px; }
}

/* ---- Progress Report sheet (PROGRESS-REPORT-SPEC.md) ------------------- */
.progress-sheet { padding: 1.4rem; }
/* The app-wide `input, select, textarea { min-height: 44px; padding: 0.6rem
   0.7rem; }` (touch-target sizing for ordinary forms elsewhere in the app)
   was still binding on every field in this sheet that didn't happen to
   already override both properties — the actual cause of oversized table
   rows on screen and, worse, a second printed page (spec review: rows were
   ~91px tall for a single line of text because the DROP cell's two stacked
   `<input>`s each carried a 44px floor). A dense printed sheet is not a
   touch-target form; strip both properties from every field in it, once,
   here — individual classes below only need to set what makes THEM
   different (font size, alignment, color), not re-fight this floor. */
/* :where() carries zero specificity, so every more-specific .pr-* rule
   below (e.g. .pr-meta-value's own padding) still wins the cascade — this
   only needs to beat the UNQUALIFIED app-wide `input/select/textarea` rule,
   never anything declared for this sheet specifically. */
:where(.progress-sheet) input,
:where(.progress-sheet) select,
:where(.progress-sheet) textarea {
  min-height: 0;
  padding: 0;
}
/* dualField (views/progress-report.js): every editable value in this sheet
   renders BOTH the real control (screen only) and a plain-text mirror
   (print only). `.pr-dual` is the wrapper — `display:contents` so it never
   adds a box of its own and every call site can keep treating it as a
   single node. On screen the mirror is hidden; the print media query below
   flips that. */
.pr-dual { display: contents; }
/* `!important`: the mirror always shares a class with its real control
   (e.g. `pr-cell-textarea print-value`), and that shared class also sets
   `display:block` for the real control's own layout — without `!important`
   here, source order let that later rule win and the mirror rendered
   VISIBLY DUPLICATED next to the real field on screen (caught in review:
   every value appeared twice, e.g. two "09/15/2026" under DATE). */
.print-value { display: none !important; }
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.8rem;
  margin-bottom: 0.8rem;
}
.progress-header-left { min-width: 140px; }
.progress-company { font-weight: 800; font-size: 1.05rem; color: var(--ink); }
.progress-header-center { text-align: center; flex: 1; min-width: 220px; }
.pr-title { font-size: 1.6rem; font-weight: 800; text-align: center; border: none; background: transparent; width: 100%; letter-spacing: 0.02em; }
.pr-display-name { font-size: 1.2rem; font-weight: 700; text-align: center; border: none; background: transparent; width: 100%; color: var(--ink); }
.pr-subtitle { font-size: 0.85rem; letter-spacing: 0.12em; text-transform: uppercase; text-align: center; border: none; background: transparent; width: 100%; color: var(--muted); }
.progress-header-right { font-size: 0.82rem; display: flex; flex-direction: column; gap: 0.5rem; min-width: 190px; align-items: flex-end; }
/* Stacked label-over-value (spec review item 6): DATE / REPORT # / PREPARED
   BY now read as one consistent block instead of a big form input sitting
   next to a bare label. Value fields are borderless until hover/focus, so
   the sheet still reads as a printed document, not a form, while staying
   editable in place. */
.pr-meta-block { text-align: right; }
.pr-meta-label { display: block; font-weight: 700; font-size: 0.68rem; letter-spacing: 0.05em; text-transform: uppercase; opacity: 0.6; margin: 0; }
.pr-meta-value {
  display: block;
  border: 1px solid transparent;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  text-align: right;
  width: auto;
  max-width: 170px;
}
.pr-meta-value:hover, .pr-meta-value:focus { border-color: var(--border); background: var(--cream); }
.pr-meta-static { cursor: default; }
.pr-meta-static:hover { border-color: transparent; background: transparent; }

.progress-mid-row { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: 1rem; }
.progress-elevation { flex: 2; min-width: 280px; }
.pr-legend-card { flex: 1; min-width: 220px; padding: 0; overflow: hidden; }
.pr-legend-title { background: var(--maroon); color: #fff; padding: 0.5rem 0.8rem; font-weight: 700; font-size: 0.85rem; letter-spacing: 0.04em; }
/* Addendum item B: each legend row is now a BUTTON that arms a paint
   brush (aria-pressed reflects the armed state) — reset the app's default
   button chrome (min-height, background, border-radius) back to a plain
   row so it still reads as a legend, not a form control. */
.pr-legend-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.8rem;
  font-size: 0.82rem;
  width: 100%;
  min-height: auto;
  background: transparent;
  color: var(--text);
  font-weight: 400;
  border: none;
  border-radius: 0;
  text-align: left;
}
.pr-legend-row:hover:not(:disabled) { background: var(--paper); }
.pr-legend-row.armed { background: var(--maroon-pale); font-weight: 700; }
.pr-legend-row.armed .pr-dot { outline: 2px solid var(--maroon); outline-offset: 1px; }
.pr-brush-hint { padding: 0 0.8rem 0.6rem; margin: 0; font-size: 0.72rem; }
.pr-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.pr-floors-row { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.5rem; font-size: 0.78rem; flex-wrap: wrap; }
.pr-floors-row label { margin: 0; }
.pr-floors-input { width: 70px; }
.pr-elevation-label { width: 160px; }

/* table-layout:fixed + the colgroup (JS) percentages are what keep the
   table from ever growing past the card edge — spec review item 2: the old
   content-driven auto layout let the move/Remove buttons hang outside the
   card at 1440px. */
.progress-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 0.78rem; margin-bottom: 0.8rem; }
.progress-table th { background: var(--maroon); color: #fff; padding: 0.4rem 0.5rem; text-align: left; font-size: 0.7rem; letter-spacing: 0.03em; overflow-wrap: normal; word-break: normal; }
.progress-table td { border: 1px solid var(--border); padding: 0.3rem 0.4rem; vertical-align: top; overflow: hidden; }
.pr-drop-cell { text-align: center; }
.pr-drop-label { width: 100%; border: none; background: transparent; font-weight: 800; font-size: 0.95rem; text-align: center; }
.pr-width-wrap { display: flex; align-items: center; gap: 0.2rem; justify-content: center; font-size: 0.72rem; }
.pr-width-input {
  width: 32px;
  border: none;
  background: transparent;
  text-align: right;
  padding: 0;
  -moz-appearance: textfield;
  appearance: textfield;
}
.pr-width-input::-webkit-inner-spin-button, .pr-width-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
/* overflow-wrap/word-break NORMAL (spec review item 2): text wraps only at
   word boundaries, never mid-word ("Waterproofin g 1"). A line longer than
   the box just grows the textarea taller (autosize, JS) instead of
   breaking a word in half. */
.pr-cell-textarea, .pr-cell-input {
  width: 100%;
  /* Overrides the app-wide `textarea { min-height: 5.5rem }` (app.css:90,
     sized for the app's normal multi-line note fields) — this module's
     textareas must be able to shrink to ONE short line, not sit floored at
     88px regardless of value (the actual cause of the "way too tall"
     bullet/cell boxes found in review). */
  min-height: 0;
  border: none;
  background: transparent;
  font-size: 0.78rem;
  resize: none;
  overflow: hidden;
  overflow-wrap: normal;
  word-break: normal;
  white-space: pre-wrap;
  font-family: inherit;
  line-height: 1.35;
  display: block;
  /* Native auto-grow to content, evaluated by whichever layout pass is
     actually running (screen edit OR the real print/PDF layout) — a JS
     scrollHeight approach was tried first and shipped a real bug: it runs
     in the SCREEN viewport's layout context, a different width than the
     paginated print layout, so it could under-measure a line that only
     wraps once print's narrower columns are actually applied, silently
     dropping the wrapped text under `overflow:hidden`. Supported in the
     Chromium this app's users and this repo's own print verification both
     run (Chrome 123+); rows="1" (JS) still floors the minimum size in
     every browser. */
  field-sizing: content;
}
.pr-status-cell-wrap { vertical-align: top; }
.pr-status-cell { display: flex; align-items: center; gap: 0.4rem; }
/* Addendum item B: compact floor summary under the status, only rendered
   when floor overrides make it differ from the drop's own status. */
.pr-floor-summary { margin-top: 0.2rem; font-size: 0.7rem; line-height: 1.3; }
.pr-status-select {
  border: none;
  background: transparent;
  font-size: 0.78rem;
  color: var(--ink);
  flex: 1;
  min-width: 0;
}
.pr-row-actions { display: flex; flex-direction: column; gap: 0.15rem; align-items: stretch; }
.pr-icon-btn {
  padding: 0.1rem 0.3rem;
  min-height: 22px;
  min-width: 22px;
  font-size: 0.72rem;
  line-height: 1;
}
.pr-row-selected { outline: 2px solid var(--maroon-mid); outline-offset: -2px; }

/* Addendum item C: visible saved state + a brief highlight on the field
   that just saved, so autosave-on-blur reads as trustworthy rather than a
   silent assumption. */
.pr-save-indicator { font-size: 0.8rem; color: var(--muted); min-width: 4.5rem; }
.pr-save-indicator.saving { color: var(--muted); }
.pr-save-indicator.saved { color: var(--ok); font-weight: 600; }
.pr-flash-saved { animation: pr-flash 0.9s ease-out; }
@keyframes pr-flash {
  0% { background-color: var(--ok-bg); }
  100% { background-color: transparent; }
}

.pr-bullet-list { list-style: none; margin: 0; padding: 0; }
.pr-bullet-list li { display: flex; align-items: flex-start; gap: 0.3rem; padding: 0.15rem 0; }
.pr-bullet-list li::before { content: "•"; color: var(--maroon); font-weight: 700; line-height: 1.5; }
.pr-bullet-input {
  flex: 1;
  min-height: 0; /* overrides the app-wide textarea min-height, see .pr-cell-textarea comment */
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-family: inherit;
  resize: none;
  overflow: hidden;
  overflow-wrap: normal;
  word-break: normal;
  white-space: pre-wrap;
  line-height: 1.4;
  padding: 0;
  field-sizing: content; /* see .pr-cell-textarea comment */
}
.pr-bullet-remove { min-height: auto; padding: 0 0.4rem; align-self: flex-start; }
.pr-notes-card h4 { margin-top: 0; }

.progress-elevation .pr-drop-block { cursor: pointer; }
.progress-elevation .pr-drop-block:focus-visible { outline: 2px solid var(--maroon-mid); outline-offset: 2px; }

/* Addendum item B: the floor-by-floor grid (drop columns x floor rows) and
   its click targets — cells, the drop-number row, and the floor-number
   column, all keyboard-reachable (role=grid/gridcell, roving tabindex, JS). */
.pr-floor-cell, .pr-drop-number, .pr-floor-number { cursor: pointer; touch-action: none; }
.pr-floor-cell:focus-visible, .pr-drop-number:focus-visible, .pr-floor-number:focus-visible {
  outline: 2px solid var(--maroon-mid);
  outline-offset: -1px;
}

/* The armed-brush hint on the legend + the popover for the "no brush
   armed" click path (public/views/progress-report.js: openPopover). */
.pr-floor-popover {
  position: fixed;
  z-index: 60;
  width: 220px;
  max-height: 320px;
  overflow-y: auto;
  padding: 0.6rem;
  box-shadow: var(--shadow-lg);
}
.pr-popover-title { font-weight: 700; font-size: 0.82rem; margin-bottom: 0.4rem; color: var(--ink); }
.pr-popover-list { display: flex; flex-direction: column; gap: 0.15rem; margin-bottom: 0.4rem; }
.pr-popover-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-height: auto;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  border: 1px solid transparent;
  text-align: left;
  padding: 0.35rem 0.5rem;
}
.pr-popover-status:hover { background: var(--paper); border-color: var(--border); }

@media (max-width: 640px) {
  .progress-mid-row { flex-direction: column; }
  .progress-header { flex-direction: column; }
  .progress-table { display: block; overflow-x: auto; }
}

/* Print / Save as PDF: sheet only, landscape letter, no nav/edit chrome.
   .no-print covers every control that must never appear on the printed
   sheet (buttons, the floors/elevation-label mini-form, row move/remove,
   and, since the second PM review pass, the real <input>/<select> form
   controls themselves — dualField's print mirror (`.print-value`, JS)
   takes over as plain text). */
@media print {
  @page { size: letter landscape; margin: 0.3in; }

  /* PM review (second pass), root cause of three symptoms at once: this
     app's shell (sidebar, topbar) previously stayed in NORMAL LAYOUT FLOW
     under print (only `visibility:hidden`, which hides paint but keeps the
     box and its width/margin side effects). At the sidebar breakpoint,
     `main` still carried `margin-left:232px` and `max-width:1080px`, so
     `.progress-sheet`'s `position:absolute; width:100%` resolved against a
     containing block that was narrower than, and offset from, the actual
     page box. Measured directly (not eyeballed): the sheet rendered with
     `left: -196px` and the table's right edge stopped ~0.9in short of the
     page's right margin — this is what PM review saw as "elevation renders
     tiny", "table stops short of the page's right edge", and the grey
     backdrop showing through the empty ~40% at the bottom (the app's
     `--paper` body background, #FAFAF9, showing wherever the undersized
     sheet didn't cover). Fix: remove the shell from LAYOUT entirely in
     print (`display:none`, not just invisible), and reset every ancestor
     that could constrain width back to auto/none, so `.progress-sheet` has
     a clean, predictable initial containing block matching the real page
     content box. */
  .topbar, .sidebar, .sidebar-backdrop, .navbar { display: none !important; }
  /* The Progress tab is nested inside the ordinary project-detail page shell
     (public/views/projects.js: the "All projects" breadcrumb, the project
     command-header card, and the tab bar) — none of those carry `.no-print`
     because they belong to a different view file. `visibility:hidden` hid
     their PAINT but not their LAYOUT BOX, so they still reserved ~260px of
     vertical space above the sheet on every printed page (found by walking
     `main`'s children directly: breadcrumb 16px + command-header 221px +
     tabs 37px, all `visibility:hidden` but still taking up room) — that gap
     is why the sheet's content overflowed to a second page even though its
     own measured height fit the budget. */
  main > a:first-child, .command-header, .tabs { display: none !important; }
  html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; }
  #app { display: block !important; min-height: 0 !important; }
  #app.with-sidebar main, #app.with-field-nav main, main {
    margin: 0 !important;
    max-width: none !important;
    width: 100% !important;
    padding: 0 !important;
  }

  body * { visibility: hidden; }
  .progress-sheet, .progress-sheet * { visibility: visible; }
  .progress-sheet {
    width: 100%;
    margin: 0;
    padding: 0.04in 0.12in;
    box-shadow: none;
    border: none;
    background: #fff;
  }
  .no-print, .no-print * { display: none !important; }

  /* ---- Fill the page (PM review: "scale to fill one page, do not just
     shrink to fit") — sizes below are chosen against the real usable
     print area (11in x 8.5in landscape minus 0.3in margins = 10.4in x
     7.9in), not against the old, incorrectly-narrow layout. ---- */
  .progress-header { padding-bottom: 0.02in; margin-bottom: 0.03in; }
  .pr-title, .print-value.pr-title { font-size: 15pt; }
  .pr-display-name, .print-value.pr-display-name { font-size: 11pt; }
  .pr-subtitle, .print-value.pr-subtitle { font-size: 7.5pt; }
  .progress-header-right, .progress-company { font-size: 8pt; }
  .pr-meta-value, .print-value.pr-meta-value { font-size: 9pt; }
  .pr-meta-label { font-size: 6.5pt; }

  /* Elevation takes the left ~54% of the sheet at its OWN real height (no
     artificial max-height crushing it to a sliver) — width:100% of that
     54%-wide column, height follows the SVG's own aspect ratio. A generous
     safety cap only stops a pathological many-floor building from ever
     pushing past the page; it is far above what any real floor count in
     this app's own cap (60, see buildElevationSvg) needs at this width. */
  .progress-mid-row { margin-bottom: 0.03in; gap: 0.15in; align-items: stretch; flex-wrap: nowrap; }
  /* min-width:0 overrides the base rule's implicit min-content floor (a
     flex item's default min-width is "auto", i.e. its own content's
     min-content size — an unbreakable long status name like "Engineering
     Investigation" could otherwise force this item wider than its 54%
     share and trigger flex-wrap, pushing the legend onto its own full-width
     row below instead of sitting beside the elevation). */
  .progress-elevation { flex: 0 0 54%; min-width: 0; }
  .pr-legend-card { flex: 1 1 auto; min-width: 0; }
  .progress-elevation svg { width: 100%; height: auto; max-height: 4.2in; display: block; margin: 0 auto; }
  .pr-floors-row { display: none; } /* no-print already hides it; belt and suspenders */

  .pr-legend-card > div > div:last-child { display: grid; grid-template-columns: repeat(2, 1fr); }
  .pr-legend-card { font-size: 8.5pt; }
  .pr-legend-title { padding: 0.05in 0.1in; font-size: 9.5pt; }
  .pr-legend-row { padding: 0.025in 0.1in; gap: 0.07in; }
  .pr-dot { width: 9px; height: 9px; }

  .progress-table { font-size: 7.2pt; margin-bottom: 0.02in; }
  .progress-table th { padding: 0.02in 0.05in; font-size: 6.8pt; line-height: 1.05; }
  .progress-table td { padding: 0.015in 0.05in; }
  .pr-cell-textarea, .pr-cell-input, .pr-status-select, .print-value.pr-cell-textarea { font-size: 7.2pt; line-height: 1.15; }
  .pr-width-wrap, .print-value.pr-width-input { font-size: 7pt; }
  .pr-drop-label, .print-value.pr-drop-label { font-size: 9pt; }
  .pr-status-print-label { font-weight: 700; color: var(--ink); }
  .pr-floor-summary { font-size: 6.2pt; margin-top: 0.01in; }

  .pr-notes-card { padding: 0.04in 0.1in; margin-bottom: 0; }
  .pr-notes-card h4 { font-size: 8.5pt; margin: 0 0 0.015in; }
  .pr-bullet-list li { padding: 0.005in 0; }
  .pr-bullet-input, .print-value.pr-bullet-input { font-size: 7.2pt; line-height: 1.15; }
  .progress-sheet .grid.cols-2 { gap: 0.15in; }

  /* ---- No form chrome on paper (PM review item 3) ---- */
  /* .no-print already removes the real <select>/<input type=date> entirely
     (dualField, JS) — these are belt and suspenders for anything that
     somehow still renders a native control in print. */
  select, input { appearance: none; -webkit-appearance: none; }
  input[type="date"]::-webkit-calendar-picker-indicator { display: none; }

  /* ---- Print mirror layout (dualField, JS) ---- */
  .print-value {
    display: block !important;
    white-space: pre-wrap;
    overflow-wrap: normal;
    word-break: normal;
  }
  .print-value.pr-meta-value { text-align: right; }
  .print-value.pr-drop-label { text-align: center; font-weight: 800; }
  .print-value.pr-width-input { display: inline !important; }
}
