/* Ducky Pools Projects — phone / tablet / desktop, one responsive PWA.
   Brand: navy #2F3B69, blue #38B6FF, yellow #FBD420 (Nunito via Google Fonts
   when online, system stack otherwise so the shell works fully offline).
   Field rules: >=48px touch targets, high contrast for sunlight. */

:root {
  --navy: #2F3B69;
  --blue: #38B6FF;
  --yellow: #FBD420;
  --ink: #14181f;
  --paper: #ffffff;
  --wash: #eef1f6;
  --line: #c9d1de;
  --ok: #177245;
  --warn: #9a6a00;
  --bad: #b3261e;
  --radius: 14px;
  --tap: 48px;
}

* { box-sizing: border-box; }
/* NOTE: the `hidden`-attribute guard lives at the END of this file (see
   "hidden guard" there) so it wins under every cascade implementation. */
html, body { margin: 0; padding: 0; }
body {
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--wash);
}
button, input, select, textarea { font: inherit; }
button { min-height: var(--tap); }
img, video { max-width: 100%; }

.offline-banner {
  background: var(--yellow);
  color: var(--ink);
  padding: 10px 16px;
  font-weight: 700;
  text-align: center;
}

/* ---------- login ---------- */
.login-view { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 28px;
  width: min(420px, 100%);
  box-shadow: 0 8px 30px rgba(20, 24, 31, 0.15);
}
.brand { text-align: center; margin-bottom: 20px; }
.brand h1 { margin: 8px 0 2px; font-size: 1.5rem; color: var(--navy); }
.brand .tagline { margin: 0; color: #44507a; font-weight: 600; }
.brand-logo { width: 96px; height: 96px; object-fit: contain; }
.login-note { margin: 16px 0 0; color: #44507a; font-weight: 600; text-align: center; font-size: 0.95rem; }
.login-card label { display: block; font-weight: 700; margin: 14px 0 6px; }
.login-card select, .login-card input {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 2px solid var(--line); border-radius: 10px; background: var(--paper);
}
.error { color: var(--bad); font-weight: 700; min-height: 1.2em; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px;
  border-radius: 10px; border: 2px solid transparent;
  font-weight: 800; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-accent { background: var(--yellow); color: var(--ink); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-bad { background: var(--paper); color: var(--bad); border-color: var(--bad); }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn-big { width: 100%; margin-top: 18px; font-size: 1.1rem; }
.btn[disabled] { opacity: 0.55; cursor: default; }

/* ---------- shell layout ---------- */
.app-shell { min-height: 100dvh; }
.sidebar { display: none; }
.main { padding: 16px; padding-bottom: 96px; max-width: 1100px; margin: 0 auto; overscroll-behavior-y: none; }

/* Phone tab bar: up to 7 tabs — scrolls horizontally instead of breaking. */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--paper); border-top: 2px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-bar button {
  flex: 1 0 auto; min-width: 62px; background: none; border: none; padding: 10px 8px;
  font-weight: 800; font-size: 0.92rem; color: #44507a; position: relative; min-height: 56px;
  white-space: nowrap;
  /* Round 2 (R2-25): separated, ALL-CAPS tab items. */
  text-transform: uppercase; letter-spacing: 0.04em; border-right: 1px solid var(--line);
}
.tab-bar button:last-child { border-right: none; }
.tab-bar button[aria-current="page"] { color: var(--navy); box-shadow: inset 0 3px 0 var(--yellow); }
.badge {
  position: absolute; top: 6px; right: calc(50% - 26px);
  background: var(--bad); color: #fff; border-radius: 999px;
  min-width: 22px; height: 22px; line-height: 22px; font-size: 0.8rem; padding: 0 5px;
}

/* Tablet + desktop: sidebar layout, wider office-first canvas */
@media (min-width: 821px) {
  /* Phase-3 fix: minmax(0, 1fr), not plain 1fr — a plain 1fr track is
     minmax(AUTO, 1fr), so the widest content inside .main (calendar
     grid, projects table, reports) forced the column past the
     viewport on every 821–1279px-wide screen (landscape phones,
     iPads, Surface). .main also gets min-width: 0 below. */
  .app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
  .tab-bar { display: none; }
  .main { padding: 24px 28px 40px; margin: 0 auto; max-width: 1400px; width: 100%; min-width: 0; }
  .sidebar {
    display: flex; flex-direction: column; gap: 8px;
    background: var(--navy); color: #fff; padding: 20px 14px;
    position: sticky; top: 0; height: 100dvh;
  }
  .brand-side { display: flex; align-items: center; gap: 12px; text-align: left; margin-bottom: 18px; }
  .brand-side .brand-logo { width: 48px; height: 48px; background: #fff; border-radius: 12px; padding: 4px; }
  .brand-side strong { display: block; font-size: 1.05rem; }
  .brand-side span { color: var(--yellow); font-weight: 700; }
  /* Round 2 (R2-25): nav items are distinct blocks — own background,
     border, real spacing between them, ALL CAPS labels. */
  .main-nav { display: flex; flex-direction: column; gap: 10px; }
  .main-nav button {
    text-align: left; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.22); color: #dfe5f2;
    border-radius: 10px; padding: 12px 14px; font-weight: 800; cursor: pointer; position: relative;
    text-transform: uppercase; letter-spacing: 0.05em;
  }
  .main-nav button[aria-current="page"] { background: rgba(255, 255, 255, 0.16); color: #fff; border-color: rgba(255, 255, 255, 0.45); }
  .main-nav .badge { right: 12px; top: 12px; }
  .sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; color: #dfe5f2; }
  .sidebar-foot .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, 0.4); }
}

/* ---------- cards & content ---------- */
h2.view-title { color: var(--navy); margin: 4px 0 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  background: var(--paper); border-radius: var(--radius); padding: 16px;
  border: 2px solid var(--line);
}
.stat .num { font-size: 1.9rem; font-weight: 900; color: var(--navy); }
.stat .lbl { font-weight: 700; color: #44507a; }
.quick-links { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 4px; }

.card {
  background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius);
  margin-bottom: 14px; overflow: hidden;
}
.card-head {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: none; border: none; padding: 16px; text-align: left; cursor: pointer;
}
.card-head .job, .job { font-weight: 900; color: var(--navy); }
.card-head .ttl { font-weight: 700; }
.card-body { padding: 0 16px 16px; border-top: 1px dashed var(--line); }
.card-body-static { padding: 16px; }
.card-body dl, dl.detail-dl { display: grid; grid-template-columns: 110px 1fr; gap: 4px 12px; margin: 12px 0; }
.card-body dt, dl.detail-dl dt { font-weight: 800; color: #44507a; }
.card-body dd, dl.detail-dl dd { margin: 0; }
.pill {
  /* Note 9: flex centering keeps the label optically centered in the
     bubble even for long statuses like "Invoice Pending Approval". */
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  line-height: 1.3; vertical-align: middle;
  padding: 3px 10px; border-radius: 999px;
  background: var(--wash); border: 1.5px solid var(--line); font-weight: 800; font-size: 0.85rem;
}
.card-head > span:last-child { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pill.rail { background: #fdecea; border-color: var(--bad); color: var(--bad); }
.pill.rail-ok { background: #e6f4ec; border-color: var(--ok); color: var(--ok); }
.pill.rail-no { background: var(--wash); border-color: var(--line); color: #5a6580; }
.glance { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.glance .pill.on { background: #e6f4ec; border-color: var(--ok); color: var(--ok); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.eta-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.eta-row button { min-width: 56px; }
.eta-row button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.msg-preview {
  background: var(--wash); border-radius: 10px; padding: 12px; margin: 10px 0; font-style: italic;
}
.notif {
  background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px;
}
.notif.unread { border-color: var(--blue); }
.notif .t { font-weight: 800; }
.muted { color: #5a6580; }
form.stack label { display: block; font-weight: 700; margin: 12px 0 6px; }
form.stack input, form.stack select, form.stack textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 2px solid var(--line); border-radius: 10px; background: var(--paper);
}
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 84px; z-index: 40;
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 999px; font-weight: 800;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3); max-width: min(92vw, 520px); text-align: center;
}
@media (min-width: 821px) { .toast { bottom: 28px; } }

/* ---------- panels, forms, tables (office build) ---------- */
.panel {
  background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.panel h3 { color: var(--navy); margin: 4px 0 12px; }
.panel h4 { color: var(--navy); margin: 14px 0 8px; }
.panel label { display: block; font-weight: 700; margin: 10px 0 6px; }
.panel input, .panel select, .panel textarea,
.visit-controls input, .mini-form input, .mini-form select,
.attach-row input, .return-row input {
  min-height: var(--tap); padding: 10px 12px;
  border: 2px solid var(--line); border-radius: 10px; background: var(--paper);
}
.panel input, .panel select, .panel textarea { width: 100%; }
.panel input[type="checkbox"] { width: auto; min-height: 0; padding: 0; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 4px 14px; }
@media (min-width: 821px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .span2 { grid-column: span 2; }
}
.check-row { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.check-row .check { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; margin: 0; }
.check-row .check input { width: auto; min-height: 0; }

.table-wrap { overflow-x: auto; margin-bottom: 14px; }
.data-table { width: 100%; border-collapse: collapse; background: var(--paper); font-size: 0.98rem; }
.data-table th, .data-table td {
  text-align: left; padding: 10px 12px; border-bottom: 1.5px solid var(--line); vertical-align: top;
}
.data-table thead th { color: var(--navy); border-bottom: 2.5px solid var(--navy); white-space: nowrap; }
.data-table.compact th, .data-table.compact td { padding: 7px 9px; }
.num-cell { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.num-input { max-width: 130px; }
tr.over-threshold td, .over-threshold { background: #fff3cd; }
.data-table tr.over-threshold td { border-bottom-color: #e3c766; }
.tag-over {
  display: inline-block; background: var(--bad); color: #fff; border-radius: 999px;
  padding: 1px 8px; font-size: 0.78rem; font-weight: 900; vertical-align: middle;
}

/* Office projects: wide table on desktop, cards on phone. */
.projects-table-wrap { display: none; }
@media (min-width: 821px) {
  .projects-table-wrap { display: block; }
  .projects-cards { display: none; }
}

/* ---------- project detail ---------- */
.detail-head { margin-bottom: 14px; }
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 0; align-items: start; }
@media (min-width: 821px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr) 400px; gap: 14px; }
  .detail-grid .panel { margin-bottom: 14px; }
}
.visit-row { border-top: 1.5px dashed var(--line); padding: 12px 0; }
.visit-row:first-of-type { border-top: none; }
.visit-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-top: 8px; }
.visit-controls label { font-weight: 700; margin: 0; }
.visit-controls input { display: block; margin-top: 4px; }
.part-row {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
  border-top: 1.5px dashed var(--line); padding: 10px 0;
}
.part-row:first-of-type { border-top: none; }
.pill.pipe-needed { background: #fdecea; border-color: var(--bad); color: var(--bad); }
.pill.pipe-ordered { background: #fff3cd; border-color: #e3c766; color: var(--warn); }
.pill.pipe-available { background: #e6f4ec; border-color: var(--ok); color: var(--ok); }
.pill.pipe-picked_up { background: var(--wash); border-color: var(--line); color: #5a6580; }
.stub-note {
  background: #fff8d6; border: 1.5px solid #e3c766; border-radius: 10px;
  padding: 10px 12px; font-weight: 700; color: #6b5200; margin: 10px 0;
}
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.gallery-item { margin: 0; }
.gallery-item img, .gallery-item video { width: 100%; border-radius: 10px; border: 1.5px solid var(--line); display: block; }
.gallery-item figcaption { font-size: 0.82rem; color: #5a6580; font-weight: 700; margin-top: 4px; }
.thread { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.bubble { max-width: 85%; padding: 10px 12px; border-radius: 14px; background: var(--wash); border: 1.5px solid var(--line); }
.bubble.out { align-self: flex-end; background: #e8f4fd; border-color: var(--blue); }
.bubble.in { align-self: flex-start; }
.bubble .muted { font-size: 0.8rem; }
.audit-list { margin: 8px 0; padding-left: 20px; }
.audit-list li { margin-bottom: 4px; }
.invoice-actions { margin-top: 12px; }
.return-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-top: 10px; }
.return-row label { font-weight: 700; margin: 0; flex: 1; min-width: 200px; }
.return-row input { display: block; width: 100%; margin-top: 4px; }
.attach-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.plain-list { margin: 6px 0 12px; padding-left: 20px; }
.plain-list li { margin-bottom: 4px; }

/* ---------- admin ---------- */
.person-actions { min-width: 260px; }
.mini-form { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.mini-form input, .mini-form select { flex: 1; min-width: 110px; }
.session-group { margin-bottom: 14px; }
.session-row {
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between;
  border-top: 1.5px dashed var(--line); padding: 10px 0;
}

/* ---------- live dispatch: push card, updates pill, pull-to-refresh ---------- */
.push-card { border-color: var(--blue); }
.push-card h3 { color: var(--navy); margin: 4px 0 8px; }
.push-ios-hint { background: #fff8d6; border: 1.5px solid #e3c766; border-radius: 10px; padding: 10px 12px; font-weight: 700; color: #6b5200; }
.updates-pill {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 45;
  background: var(--navy); color: #fff; border: 2px solid var(--yellow); border-radius: 999px;
  padding: 10px 18px; font-weight: 800; min-height: var(--tap); cursor: pointer;
  box-shadow: 0 6px 24px rgba(0,0,0,0.3); max-width: 92vw;
}
.updates-pill[hidden] { display: none; }
.ptr-strip {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 44;
  background: var(--yellow); color: var(--ink); border-radius: 0 0 12px 12px;
  padding: 10px 18px; font-weight: 800; min-height: var(--tap);
  display: flex; align-items: center; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.ptr-strip[hidden] { display: none; }
.ptr-strip.ptr-ready { background: var(--navy); color: #fff; }
/* ---------- project detail: comms / call stub ---------- */
.comms-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.comms-head h3 { margin: 4px 0; }
.call-btn {
  min-height: 48px; min-width: 48px; padding: 12px 20px;
  background: var(--navy); color: #fff; font-size: 1.05rem;
}
.call-btn .call-icon { flex: 0 0 auto; }
.call-caption { margin: 6px 0 10px; font-size: 0.9rem; font-weight: 700; color: #5a6580; }
.call-stub[hidden] { display: none; }
.call-stub:focus { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- messages: sender labels + call log ---------- */
.bubble-sender { font-weight: 900; font-size: 0.85rem; color: var(--navy); margin-bottom: 4px; }
.bubble.out .bubble-sender { color: #1a4f7a; }
.bubble-body { white-space: pre-wrap; }
.call-log { margin: 6px 0 12px; padding-left: 20px; }
.call-log li { margin-bottom: 6px; }
.call-log-form { border-top: 1.5px dashed var(--line); margin-top: 12px; padding-top: 4px; }
.call-log-form select, .call-log-form input { min-height: var(--tap); }

/* ---------- review batch (Nov 15): copy buttons, helpers, calls, schedule ---------- */
/* Round 2 (R2-9): the copy icon is a small inline glyph now — no box, no
   border, no row-height effect; it sits on the text baseline. */
.copy-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; margin: -8px 0 -8px 4px; padding: 8px;
  box-sizing: content-box;
  background: transparent; border: none; border-radius: 6px;
  color: var(--navy); cursor: pointer; vertical-align: -4px; line-height: 0;
  /* Phase-3 fix: the glyph stays a 20px inline mark (R2-9), but the
     TAP AREA is now 36x36 via padding, with negative vertical margins
     so the hit area doesn't grow the line it sits on. */
}
.copy-btn:hover { background: var(--wash); }
.help-text { font-size: 0.88rem; margin: 4px 0 0; }
.view-intro { font-weight: 700; color: #44507a; margin: 0 0 12px; }
.call-card {
  border: 1.5px solid var(--line); border-left: 5px solid var(--blue, #38B6FF);
  border-radius: 10px; padding: 10px 12px; margin: 8px 0; background: #fbfcfe;
}
.transcript-wrap { margin-top: 6px; }
.transcript {
  white-space: pre-wrap; margin: 6px 0 0; padding: 10px 12px;
  background: var(--wash); border-radius: 10px; font-size: 0.95rem;
}
.sched-row {
  display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline;
  padding: 8px 0; border-top: 1.5px dashed var(--line);
}
/* Phase-3 fix: a long UNBREAKABLE string (a 60-char customer name, an
   email) inside a flex row could not shrink — flex items default to
   min-width:auto — and blew the whole page sideways on phones
   (measured +189px at 360px, +159px at 200% zoom). Children may now
   shrink and their text may break anywhere when it has to. */
.sched-row > *, .notif-row > *, .part-row > *, .session-row > *, .type-row > * { min-width: 0; }
.sched-row span, .sched-row a, .notif-row span, .bubble-body,
.card-body dd, dl.detail-dl dd, .card-head > span { overflow-wrap: anywhere; }
.seg-row { display: inline-flex; gap: 6px; margin-left: 10px; vertical-align: middle; }
.seg-row button {
  /* Phase-3 fix: 36px was below the ~44px touch guideline — these are
     the schedule Day/Week/Month controls a tech taps with wet hands. */
  min-height: 44px; padding: 4px 14px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff; font-weight: 800; color: var(--navy);
}
.seg-row button[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.pill.chip-overdue { background: #fdecea; border-color: var(--bad); color: var(--bad); }
.notif .actions { margin-top: 8px; }

/* ---------- round 2 (Nov 15): status colors, picker, calendar, visits,
   alerts, admin tiles ---------- */
/* Status color language (R2-8): one color per lifecycle stage, white or
   near-black text chosen per background for readability. */
/* Status palette (round 3, R3-5/R3-10): every pill carries WHITE text at
   WCAG contrast >= 4.5:1 against its background — ratios computed and
   verified numerically (see README round-3 notes). Invoice-pending is a
   deep raspberry — NOT purple (the old #7c3aed read as "mystery status")
   and not confusable with sent blue / accepted teal / waiting orange /
   cancelled dark red. */
.pill.st-draft { background: #5a6068; border-color: #5a6068; color: #fff; }
.pill.st-sent { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.pill.st-accepted { background: #0f766e; border-color: #0f766e; color: #fff; }
.pill.st-in-progress { background: #92400e; border-color: #92400e; color: #fff; }
.pill.st-waiting { background: #9a3412; border-color: #9a3412; color: #fff; }
.pill.st-completed { background: #166534; border-color: #166534; color: #fff; }
.pill.st-invoice-pending { background: #9d174d; border-color: #9d174d; color: #fff; }
.pill.st-approved { background: #14532d; border-color: #14532d; color: #fff; }
.pill.st-paid { background: #064e3b; border-color: #064e3b; color: #fff; }
.pill.st-cancelled { background: #991b1b; border-color: #991b1b; color: #fff; }

/* Type-ahead picker (R2-18): custom dropdown — renders on iOS, where
   <datalist> never shows. */
.picker-wrap { position: relative; }
.picker-list {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 30;
  background: #fff; border: 1.5px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(20, 24, 31, 0.18); overflow: hidden; margin-top: 4px;
}
.picker-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  width: 100%; text-align: left; background: #fff; border: none; border-bottom: 1px solid var(--line);
  padding: 10px 12px; min-height: 44px; cursor: pointer; font-weight: 700; color: var(--navy);
}
.picker-item:last-child { border-bottom: none; }
.picker-item:hover, .picker-item:focus { background: var(--wash); }
.picker-item .muted { font-weight: 400; font-size: 0.85rem; }
.picker-empty { padding: 10px 12px; color: #5a6580; }

/* Schedule calendar (R2-4). */
.cal-head { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-weight: 800; color: #44507a; text-align: center; font-size: 0.82rem; padding: 4px 0; }
.cal-cell { border: 1.5px solid var(--line); border-radius: 8px; min-height: 74px; padding: 4px; background: #fff; min-width: 0; }
.cal-cell.cal-empty { border: none; background: transparent; }
.cal-cell.cal-today { border-color: var(--navy); background: #fdf6d8; }
.cal-daynum { font-weight: 800; font-size: 0.85rem; color: var(--navy); }
.cal-chip {
  display: block; width: 100%; text-align: left; margin-top: 3px;
  background: #dbeafe; color: #1e3a8a; border: none; border-radius: 6px;
  padding: 3px 6px; font-size: 0.78rem; font-weight: 700; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-chip.cal-done { opacity: 0.55; }
.cal-more { font-size: 0.75rem; color: #5a6580; margin-top: 2px; }

/* Visit TIME strip + notes block (R2-10). */
.visit-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.visit-actions { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.visit-times {
  display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px;
  background: var(--wash); border-radius: 8px; padding: 8px 10px; font-size: 0.92rem;
}
.visit-notes { margin-top: 8px; }
.money-derived { font-weight: 800; font-size: 1.05rem; margin: 6px 0 0; }

/* Message delivery state on the bubble itself (R2-13). */
.not-sent { color: var(--bad); font-weight: 800; }
.sent-mark { color: var(--ok); font-weight: 700; }

/* Contractor logo (R2-6). */
.logo-preview { max-width: 260px; max-height: 110px; background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px; }
.logo-upload-label { cursor: pointer; }

/* Audit trail collapse (R2-17c) + invoice total row (R2-17b). */
.audit-wrap { margin-top: 10px; }
.data-table tr.total-row td { border-top: 2.5px solid var(--navy); font-size: 1.02rem; }

/* Admin tiles (R2-24). */
.tile-head {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: none; border: none; padding: 0; cursor: pointer; text-align: left;
}
.tile-head h3 { margin: 0; }
.tile-chev { font-size: 1.1rem; color: var(--navy); font-weight: 900; }
.tile-body { margin-top: 12px; }

/* Alerts: compact read rows + Cleared section (R2-22 decided). */
.notif-compact { padding: 8px 12px; }
.notif-row {
  display: flex; gap: 10px; align-items: baseline; width: 100%;
  background: none; border: none; padding: 4px 0; cursor: pointer; text-align: left;
}
.notif-row .t { font-weight: 800; }
.notif-chev { margin-left: auto; color: var(--navy); font-weight: 800; }
.cleared-head { margin-top: 18px; }
.issue-facts { font-weight: 700; color: #44507a; }


/* ================= ROUND 3 ================= */
/* Homepage stat tiles are buttons now (R3-1): centered, fully clickable. */
.stat { text-align: center; }
button.stat-btn {
  font: inherit; cursor: pointer; width: 100%;
}
button.stat-btn:hover { border-color: var(--navy); }
.stat .num, .stat .lbl { display: block; }

/* Target date + window (R3-6): the window sits UNDER the date. */
.target-window { display: block; font-size: 0.82rem; color: #44507a; font-weight: 700; }

/* Avatars (R3-9): initials disc with a per-person color. */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  color: #fff; font-weight: 900; font-size: 0.72rem; letter-spacing: 0.02em;
  background: #44507a; vertical-align: middle;
}
.avatar-lg { width: 44px; height: 44px; font-size: 1rem; }
.avatar-photo { object-fit: cover; }
.person-chip { display: inline-flex; align-items: center; gap: 7px; }
.assignee-line { margin: 6px 0 0; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid transparent;
  cursor: pointer; padding: 0; flex: none;
}
.swatch-on { border-color: var(--navy); box-shadow: 0 0 0 2px #fff inset; }
.avatar-pick { align-items: center; }

/* Thread (R3-16): newest first, capped height with internal scroll so the
   composer below stays reachable; call cards color-coded by direction. */
.thread { max-height: 480px; overflow-y: auto; padding-right: 4px; }
.call-card.call-in { border-left-color: #166534; background: #f4faf6; }
.call-card.call-out { border-left-color: #1d4ed8; background: #f5f8ff; }
.collapse-block { margin-top: 14px; border-top: 1.5px dashed var(--line); padding-top: 10px; }
.collapse-head {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: none; border: none; cursor: pointer; text-align: left;
  min-height: 56px; padding: 8px 4px; font: inherit; font-weight: 900; color: var(--navy);
  font-size: 1.05rem;
}

/* Large collapsible targets app-wide (R3-21): the chevron itself is big
   and the whole header is the tap target — no more hunting a tiny arrow. */
.tile-head { min-height: 56px; padding: 6px 4px; }
.tile-chev { font-size: 1.7rem; line-height: 1; padding: 6px 10px; }
.notif-chev { font-size: 1.3rem; }

/* Media lightbox (R3-15). */
.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(10, 14, 26, 0.96);
  display: flex; flex-direction: column;
}
.lb-bar {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  /* Phase-3: keep the lightbox controls clear of notches / home bars. */
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  color: #fff;
}
.lb-caption { font-weight: 800; }
.lb-stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 10px 10px max(10px, env(safe-area-inset-bottom)); }
.lb-stage img { max-width: 100%; max-height: 100%; transition: transform 0.15s ease; }
.lb-stage video { max-width: 100%; max-height: 100%; }
.gallery-item { cursor: zoom-in; }

/* Reports (R3-18): right-aligned money headers, month banding, tabs. */
.num-head { text-align: right; }
.data-table td.num-cell { text-align: right; }
.data-table tr.month-alt td { background: #f2f5fb; }
.pill.pill-live { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.seg { display: inline-flex; gap: 6px; margin: 0 0 12px; }
.seg-btn {
  min-height: 44px; padding: 6px 16px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff; font-weight: 800; color: var(--navy);
}
.seg-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Invoice sections (R3-10). */
.data-table tr.labor-section-row td {
  background: var(--wash); font-weight: 900; color: var(--navy);
  text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.05em;
}
.data-table tr.subtotal-row td { font-weight: 800; border-top: 1.5px solid var(--line); }
.labor-add { margin: 12px 0; padding: 10px 12px; border: 1.5px dashed var(--line); border-radius: 10px; }
.labor-add h4 { margin: 0 0 4px; }

/* Credential badges (R3-20b): one per credential. */
.pill.cred-rail-ok { background: #166534; border-color: #166534; color: #fff; }
.pill.cred-cpo { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.pill.cred-off { background: #e8ebf2; border-color: var(--line); color: #5a6580; }
.rate-masked { font-weight: 900; letter-spacing: 0.15em; }

/* Project type CRUD rows (R3-22). */
.type-row {
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center;
  padding: 10px 0; border-top: 1.5px dashed var(--line);
}
.type-row input[type="text"], .type-row > input { flex: 1; min-width: 180px; }

/* Picked-up parts section (R3-14b). */
.picked-up-details summary {
  cursor: pointer; font-weight: 900; color: var(--navy); font-size: 1.05rem;
  min-height: 48px; display: flex; align-items: center;
}

/* Full-width prominent button (R3-7). */
.btn-block { display: block; width: 100%; min-height: 52px; font-size: 1.02rem; }

/* Bigger checkboxes + radios app-wide (R3-7): ~24px box, label clickable. */
.panel input[type="checkbox"], .check input[type="checkbox"],
.panel input[type="radio"], .check input[type="radio"] {
  width: 24px; height: 24px; min-height: 24px; flex: none;
  accent-color: var(--navy); cursor: pointer;
}
.check { cursor: pointer; }
.cal-agenda { margin-top: 6px; }

/* ---------- hidden guard (LAST rules in the file, deliberately) ----------
   The app toggles views with the `hidden` attribute (26 places in app.js).
   An author `display` rule (e.g. .login-view's grid) silently overrides the
   UA stylesheet's [hidden] style, so the element stays on screen — this is
   the Nov 15, 2026 bug where sign-in succeeded but the login view never
   disappeared. These rules carry !important AND higher specificity AND the
   last position in the sheet, so `hidden` wins under every cascade. */
[hidden] { display: none !important; }
.login-view[hidden], .app-shell[hidden] { display: none !important; }
