/* UDS Validation — Apple-inspired restyle (apple-design skill, 2026-08-14).
 * Neutral palette on #f5f5f7, white cards with soft layered shadows, system
 * font stack, pill buttons, glass top bar, 8px spacing grid, 300ms eased
 * transitions. Deliberately light-mode only: the app lives on tablets in
 * bright clinical rooms, and several templates carry inline light-tone
 * styles. Class names are a contract with the templates — do not rename. */
:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73; /* 4.5:1 on white — muted text is load-bearing here */
  --rule: #d2d2d7;
  --hairline: rgba(0, 0, 0, 0.08);
  --blue: #0071e3;
  --blue-d: #0060c0;
  --green: #248a3d;
  --red: #d70015;
  --amber: #91600a;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-lift: 0 12px 32px rgba(0, 0, 0, 0.10);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-6: 24px;
  --space-8: 32px;
}
* { box-sizing: border-box; }
body { margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Segoe UI", Roboto, sans-serif;
  font-size: 16px; line-height: 1.55; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; }
main { max-width: 1080px; margin: 0 auto; padding: var(--space-6) var(--space-4) var(--space-8); }

/* ---- glass top bar -------------------------------------------------- */
.topbar { position: sticky; top: 0; z-index: 100;
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-3) var(--space-6);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--hairline); }
.topbar .brand { color: var(--ink); text-decoration: none; font-weight: 700;
  font-size: 17px; letter-spacing: -0.01em; }
.topbar .brand span { color: var(--blue); font-weight: 600; }
.topbar nav { display: flex; align-items: center; gap: var(--space-4); }
.topbar .who { font-size: 14px; color: var(--ink); }
.topbar .who em { color: var(--muted); font-style: normal; font-size: 12.5px;
  margin-left: 4px; }
.topbar .backbtn { width: 44px; height: 44px; min-height: 44px; padding: 0;
  border-radius: 50%; border: 1px solid var(--rule); background: #fff;
  color: var(--blue); font-size: 18px; line-height: 1; display: inline-flex;
  align-items: center; justify-content: center; flex: 0 0 auto; }
.topbar .backbtn:hover { transform: none; box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.topbar .navlink { color: var(--blue); text-decoration: none; font-weight: 600;
  font-size: 15px; }
.topbar .navlink:hover { text-decoration: underline; }
.topbar button.ghost { background: transparent; color: var(--ink);
  border: 1px solid var(--rule); min-height: 36px; padding: 6px 16px; }
.topbar button.ghost:hover { background: rgba(0, 0, 0, 0.05); transform: none;
  box-shadow: none; }

/* ---- type ----------------------------------------------------------- */
h1 { font-size: clamp(1.55rem, 1.2rem + 1.4vw, 2.1rem); font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.15; margin: 0; }
h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
h3 { margin-top: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.page-head { display: flex; justify-content: space-between; align-items: center;
  margin: var(--space-3) 0 var(--space-6); gap: var(--space-3); flex-wrap: wrap; }
.muted { color: var(--muted); }
.error { color: var(--red); font-weight: 600; }

/* ---- cards ---------------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--hairline);
  border-radius: 18px; padding: var(--space-6); margin-bottom: var(--space-4);
  box-shadow: var(--shadow-card); }
.card.narrow { max-width: 420px; margin: 64px auto; }

/* ---- forms ---------------------------------------------------------- */
label { display: block; margin: var(--space-3) 0; font-weight: 600;
  font-size: 14px; color: var(--ink); }
input, select, textarea { width: 100%; padding: 11px 14px; margin-top: 6px;
  border: 1px solid var(--rule); border-radius: 12px; font: inherit;
  background: #fff; color: var(--ink); min-height: 44px;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease); }
textarea { min-height: 88px; }
input:focus, select:focus, textarea:focus { outline: none;
  border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15); }
input[readonly], input:disabled, select:disabled, textarea:disabled {
  background: var(--bg); color: var(--muted); }
input[type="radio"], input[type="checkbox"] { width: auto; min-height: 0;
  margin: 0 8px 0 0; accent-color: var(--blue); }
.role-check { display: inline-flex; align-items: center; gap: 6px;
  font-weight: 500; margin: 0; white-space: nowrap; }

/* ---- buttons -------------------------------------------------------- */
button, .button { display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 22px; border-radius: 980px;
  border: 1px solid var(--rule); background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; font-size: 15px; text-decoration: none;
  cursor: pointer; min-height: 44px;
  transition: transform 300ms var(--ease), box-shadow 300ms var(--ease),
    background 300ms var(--ease); }
button:hover, .button:hover { transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08); }
button:active, .button:active { transform: translateY(0); }
button.primary, .button.primary { background: var(--blue); border-color: var(--blue);
  color: #fff; }
.button.sm { min-height: 34px; padding: 4px 14px; font-size: 13.5px; }
/* fingers get the app's own 44px rule even on the small variants (T8) */
@media (pointer: coarse) {
  .button.sm { min-height: 44px; }
  .topbar .backbtn { width: 44px; height: 44px; }
}

/* format-trap fields: a pattern mismatch shows immediately (T10). Autosave
   still stores the raw text — the red border is the nudge, not a gate. */
input[pattern]:invalid { border-color: var(--red);
  background: rgba(215, 0, 21, 0.04); }

/* Finish-check highlighting: fields the _missing.html banner points at */
label.miss { color: var(--red); }
label.miss input, label.miss select, label.miss textarea {
  border-color: var(--red); background: rgba(215, 0, 21, 0.04); }
tr.miss td { background: rgba(215, 0, 21, 0.05); }
form.miss button { outline: 2px solid var(--red); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important;
    animation: none !important; }
}
button.primary:hover, .button.primary:hover {
  box-shadow: 0 8px 24px rgba(0, 113, 227, 0.30); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important;
  box-shadow: none !important; }
button.danger { background: var(--red); border-color: var(--red); color: #fff; }
button.danger:hover { box-shadow: 0 8px 24px rgba(215, 0, 21, 0.28); }
button.armed { background: #7d000c; border-color: #7d000c; color: #fff;
  animation: arm-pulse 0.4s var(--ease); }
@keyframes arm-pulse { from { transform: scale(1.05); } to { transform: scale(1); } }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---- tables --------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 12px 14px;
  border-bottom: 1px solid var(--hairline); }
th { font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); }
tr:last-child td { border-bottom: none; }
tr.row-fail td { background: rgba(215, 0, 21, 0.06); }

/* ---- badges & chips ------------------------------------------------- */
.badge { display: inline-block; padding: 4px 12px; border-radius: 980px;
  font-size: 13px; font-weight: 600; vertical-align: middle;
  letter-spacing: -0.01em; }
.s-DRAFT { background: rgba(0, 0, 0, 0.06); color: #515154; }
.s-ON_SITE { background: rgba(0, 113, 227, 0.12); color: var(--blue-d); }
.s-CANCELLED { background: rgba(0, 0, 0, 0.08); color: var(--muted); }
.s-FAILED { background: rgba(215, 0, 21, 0.14); color: var(--red); }
.s-AWAITING_BI { background: rgba(255, 159, 10, 0.16); color: var(--amber); }
.s-QA_REVIEW { background: rgba(175, 82, 222, 0.14); color: #7d3c98; }
.s-ISSUED { background: rgba(48, 209, 88, 0.16); color: var(--green); }
.chip { display: inline-block; padding: 4px 12px; border-radius: 980px;
  font-size: 13px; font-weight: 600; }
.chip-pass { background: rgba(48, 209, 88, 0.16); color: var(--green); }
.chip-warn { background: rgba(255, 159, 10, 0.16); color: var(--amber); }
.chip-fail { background: rgba(215, 0, 21, 0.10); color: var(--red); }

.state-group { margin-bottom: var(--space-6); }
.state-group h2 small { color: var(--muted); font-weight: 400; margin-left: 8px; }

/* ---- fact grid ------------------------------------------------------ */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4); margin: 0; }
.facts dt { font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); }
.facts dd { margin: 3px 0 0; font-weight: 600; letter-spacing: -0.01em; }

/* ---- status board --------------------------------------------------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-3); margin-bottom: var(--space-6); align-items: start; }
.kcol { background: rgba(0, 0, 0, 0.025); border: 1px solid var(--hairline);
  border-radius: 16px; padding: 10px; min-height: 88px; }
.kcol-head { display: flex; justify-content: space-between; align-items: center;
  padding: 2px 4px 8px; }
.kcard { display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
  color: var(--ink); font-size: 13.5px;
  min-height: 82px; line-height: 1.35;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
  transition: transform 300ms var(--ease), box-shadow 300ms var(--ease); }
.kcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.kmain { display: flex; flex-direction: column; gap: 3px; flex: 1;
  text-decoration: none; color: var(--ink); }
.kaction { margin-top: 8px; text-align: center; }
.kcard .kline { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* practice names wrap to two lines — one-line ellipsis made similar names
   identical (UX audit M3) */
.kcard strong { font-size: 14px; letter-spacing: -0.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; }
.kfoot { display: flex; justify-content: space-between; align-items: baseline;
  gap: 6px; margin-top: auto; }
.kage { color: var(--muted); font-size: 12px; font-weight: 600;
  background: rgba(0, 0, 0, 0.05); border-radius: 999px; padding: 1px 8px; }
.kdue { color: var(--amber); font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.kready { color: var(--green); font-weight: 600; }
.klate { color: var(--red); font-weight: 700; }
.ksent { color: var(--red); font-weight: 600; }
.card.sentback { border-color: rgba(215, 0, 21, 0.35);
  background: rgba(215, 0, 21, 0.03); }
.card.sentback h3 { color: var(--red); }

/* ---- hub ------------------------------------------------------------- */
.hub-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4); }
.hubcard { display: block; padding: 26px 24px; background: var(--card);
  border: 1px solid var(--hairline); border-radius: 18px;
  text-decoration: none; color: var(--ink); box-shadow: var(--shadow-card);
  transition: transform 300ms var(--ease), box-shadow 300ms var(--ease); }
.hubcard:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.hubcard h3 { margin: 0 0 6px; font-size: 20px; letter-spacing: -0.02em; }
.hubcard p { margin: 0 0 14px; font-size: 14px; }
.hubstats { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- loaners --------------------------------------------------------- */
.loaner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--space-3); }
.loanercard { display: flex; flex-direction: column; gap: 4px;
  padding: 14px 16px; background: var(--card);
  border: 1px solid var(--hairline); border-radius: 12px;
  text-decoration: none; color: var(--ink); font-size: 13.5px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
  transition: transform 300ms var(--ease), box-shadow 300ms var(--ease); }
.loanercard:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.loanercard.l-overdue { border-color: rgba(215, 0, 21, 0.4); }
.lchip { font-size: 12.5px; font-weight: 600; margin-top: 4px; }
.lc-ok { color: var(--green); }
.lc-out { color: var(--amber); }
.lc-bad { color: var(--red); }
.lc-mut { color: var(--muted); }

/* ---- hub personal dashboard ("your day") ----------------------------- */
.myday { margin-bottom: var(--space-5); }
.myday-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.myday-stat { display: inline-flex; align-items: baseline; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--hairline); border-radius: 999px;
  text-decoration: none; color: var(--muted); font-size: 13.5px;
  font-weight: 500; background: rgba(0, 0, 0, 0.02); }
.myday-stat strong { color: var(--ink); font-size: 16px; }
.myday-stat:hover { border-color: var(--blue); color: var(--ink); }
.myday-list .notif-item { font-size: 14px; }

/* ---- leads / sales --------------------------------------------------- */
.leadcard { display: flex; flex-direction: column; gap: 3px;
  background: var(--card); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
  text-decoration: none; color: var(--ink); font-size: 13.5px; }
.leadcard:active { background: rgba(0, 0, 0, 0.03); }
.leadcard.l-recent { border-left: 4px solid var(--green); }
.leadcard.l-cust { opacity: 0.55; }
.leadcard strong { font-size: 14.5px; letter-spacing: -0.01em; }
.lead-meta { display: flex; gap: 12px; font-size: 12.5px; color: var(--muted);
  font-weight: 600; }
.lead-legend { white-space: nowrap; }
.lead-dot { display: inline-block; width: 10px; height: 10px;
  border-radius: 50%; vertical-align: middle; }
.ld-green { background: var(--green); }
.ld-grey { background: rgba(0, 0, 0, 0.25); }
.lead-hide { display: inline-flex; align-items: center; gap: 6px;
  font-weight: 500; margin: 0; white-space: nowrap; }

/* ---- admin shell: fixed sidebar tabs -------------------------------- */
.admin-shell { display: grid; grid-template-columns: 190px minmax(0, 1fr);
  gap: var(--space-5); align-items: start; }
.admin-nav { position: sticky; top: 78px; display: flex;
  flex-direction: column; gap: 4px; background: var(--card);
  border: 1px solid var(--hairline); border-radius: 14px; padding: 8px; }
.admin-nav a { padding: 10px 14px; border-radius: 9px; text-decoration: none;
  color: var(--ink); font-weight: 600; font-size: 14px; }
.admin-nav a:hover { background: rgba(0, 0, 0, 0.05); }
.admin-nav a.on { background: var(--blue); color: #fff; }
.admin-nav .admin-nav-hub { color: var(--muted); font-weight: 500;
  margin-top: 8px; border-top: 1px solid var(--hairline);
  border-radius: 0 0 9px 9px; }
@media (max-width: 760px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav { position: static; flex-direction: row; overflow-x: auto;
    padding: 6px; }
  .admin-nav a { white-space: nowrap; }
  .admin-nav .admin-nav-hub { margin-top: 0; border-top: none; }
}

/* activity-log filter row */
.filter-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.filter-row label { margin: 0; }
.filter-row select, .filter-row input { min-width: 140px; }

/* suggest items rendered as <button> (customer picker) — neutralise the
   global button chrome so they read as list rows */
button.suggest-item { display: block; width: 100%; text-align: left;
  background: none; border: none; border-bottom: 1px solid var(--hairline);
  border-radius: 0; box-shadow: none; min-height: auto; font-weight: 400;
  cursor: pointer; }
button.suggest-item:hover { transform: none; }

/* ---- notification bell ---------------------------------------------- */
.notif { position: relative; }
.notif summary { list-style: none; cursor: pointer; font-size: 17px;
  padding: 6px 8px; border-radius: 10px; position: relative;
  display: inline-flex; align-items: center; }
.notif summary::-webkit-details-marker { display: none; }
.notif summary:hover { background: rgba(0, 0, 0, 0.05); }
.notif-count { position: absolute; top: 0; right: 0; background: var(--red);
  color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
  border-radius: 999px; padding: 2px 5px; min-width: 16px;
  text-align: center; }
.notif-list { position: absolute; right: 0; top: calc(100% + 6px);
  width: min(340px, 88vw); max-height: 60vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--hairline);
  border-radius: 14px; box-shadow: var(--shadow-lift); z-index: 60;
  padding: 6px; }
.notif-item { display: block; padding: 9px 12px; border-radius: 9px;
  text-decoration: none; color: var(--ink); font-size: 13.5px;
  line-height: 1.35; }
.notif-item:hover { background: rgba(0, 0, 0, 0.04); }
.notif-item.n-late { color: var(--red); font-weight: 600; }
.notif-item.n-ready { color: var(--green); font-weight: 600; }
.notif-item.n-pending { color: var(--muted); }

/* Mine / All segmented toggle */
.seg { display: inline-flex; border: 1px solid var(--hairline);
  border-radius: 999px; overflow: hidden; background: var(--card); }
.seg a { padding: 7px 16px; font-size: 13.5px; font-weight: 600;
  text-decoration: none; color: var(--muted); }
.seg a.on { background: var(--ink); color: var(--card); }

@media (max-width: 900px) { .board { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .board { grid-template-columns: 1fr; } }
/* On small screens the reader's own column comes first: office/QA live in
   AWAITING BI + QA REVIEW, techs in ON SITE (UX audit M1). Desktop keeps
   workflow order. */
@media (max-width: 900px) {
  .board-office .kcol-AWAITING_BI { order: -2; }
  .board-office .kcol-QA_REVIEW { order: -1; }
  .board-tech .kcol-ON_SITE { order: -2; }
  .board-tech .kcol-DRAFT { order: -1; }
}

/* ---- section tiles -------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3); margin-bottom: var(--space-4); }
.tile { display: flex; justify-content: space-between; align-items: center;
  gap: var(--space-2); padding: 20px 18px; background: var(--card);
  border: 1px solid var(--hairline); border-radius: 16px; text-decoration: none;
  color: var(--ink); font-weight: 600; letter-spacing: -0.01em;
  box-shadow: var(--shadow-card);
  transition: transform 300ms var(--ease), box-shadow 300ms var(--ease); }
.tile:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.tile .st { font-size: 12.5px; font-weight: 600; padding: 4px 10px;
  border-radius: 980px; white-space: nowrap; }
.st-done { background: rgba(48, 209, 88, 0.16); color: var(--green); }
.st-partial { background: rgba(255, 159, 10, 0.16); color: var(--amber); }
.st-todo { background: rgba(0, 0, 0, 0.06); color: var(--muted); }

/* ---- gates & findings ----------------------------------------------- */
.gate { background: rgba(255, 159, 10, 0.10);
  border: 1px solid rgba(255, 159, 10, 0.25); border-radius: 14px;
  padding: var(--space-3) var(--space-4); margin: var(--space-3) 0;
  font-size: 14px; }
.gate ul { margin: 6px 0 0 18px; }
.blocks { border-color: rgba(215, 0, 21, 0.25); background: rgba(215, 0, 21, 0.06); }
.blocks ul { margin: 6px 0 0 18px; }

/* ---- offline indicator ---------------------------------------------- */
#save-indicator { position: fixed; bottom: 20px; right: 20px; z-index: 210;
  padding: 8px 18px; border-radius: 980px; font-weight: 600; font-size: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18); }
#save-indicator.save-ok { background: rgba(36, 138, 61, 0.94); color: #fff; }
#save-indicator.save-bad { background: rgba(215, 0, 21, 0.95); color: #fff; }

#session-expired { position: fixed; inset: 0; z-index: 400;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(20, 20, 22, 0.72);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%); }
#session-expired[hidden] { display: none; }

button.busy { position: relative; color: transparent !important; }
button.busy::after { content: ""; position: absolute; inset: 0; margin: auto;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff; animation: busy-spin 0.7s linear infinite; }
button.busy:not(.primary):not(.danger)::after {
  border-color: rgba(0, 0, 0, 0.15); border-top-color: var(--blue); }
@keyframes busy-spin { to { transform: rotate(360deg); } }

#net-indicator { position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: rgba(29, 29, 31, 0.85); color: #fff;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  padding: 10px 22px; border-radius: 980px; font-weight: 600; font-size: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25); z-index: 200; }

/* ---- typeahead suggestions ------------------------------------------ */
.suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 60;
  background: var(--card); border-radius: 12px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16); }
.suggest:empty { display: none; }
.suggest-item { display: block; padding: 10px 14px; text-decoration: none;
  color: var(--ink); font-weight: 500; font-size: 14px;
  border-bottom: 1px solid var(--hairline); }
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover { background: rgba(0, 113, 227, 0.07); }
.suggest-meta { display: block; font-size: 12px; color: var(--muted);
  font-weight: 400; }

/* ---- lightbox -------------------------------------------------------- */
#lightbox { position: fixed; inset: 0; z-index: 300;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; cursor: zoom-out;
  background: rgba(20, 20, 22, 0.82);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%); }
#lightbox[hidden] { display: none; }
#lightbox img { max-width: 94vw; max-height: 88vh; border-radius: 14px;
  background: #fff; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5); }
.lightbox-hint { color: rgba(255, 255, 255, 0.75); font-size: 13px;
  font-weight: 600; }

/* ---- checklist rows: segmented, glove-sized ------------------------- */
.check-row { display: grid; grid-template-columns: 1fr auto;
  gap: var(--space-2); align-items: center; padding: 12px 4px;
  border-bottom: 1px solid var(--hairline); }
.check-row:last-child { border-bottom: none; }
.check-row .opts { display: flex; gap: 6px; }
.check-row .opt { min-width: 64px; min-height: 44px; border-radius: 980px;
  border: 1px solid var(--rule); background: #fff; font-weight: 600;
  transition: background 200ms var(--ease), transform 200ms var(--ease),
    box-shadow 200ms var(--ease); }
.check-row .opt:hover { transform: none; box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.check-row .opt.sel-ok, .check-row .opt.sel-pass { background: #2eaa4c;
  border-color: #2eaa4c; color: #fff; }
.check-row .opt.sel-issue, .check-row .opt.sel-fail { background: var(--red);
  border-color: var(--red); color: #fff; }
.check-row .opt.sel-amber { background: #d59a20; color: #fff;
  border-color: #d59a20; }
.check-row .opt.sel-red { background: var(--red); color: #fff;
  border-color: var(--red); }
.check-row .opt.sel-na, .check-row .opt.sel-3p { background: #6e6e73;
  border-color: #6e6e73; color: #fff; }
.check-row .notes { grid-column: 1 / -1; }

/* ---- signature pad -------------------------------------------------- */
.sig-pad { border: 2px dashed var(--rule); border-radius: 16px; background: #fff;
  touch-action: none; width: 100%; height: 180px; }

/* ---- misc shared bits ----------------------------------------------- */
.card-fail { border-color: rgba(215, 0, 21, 0.25); }
img { max-width: 100%; border-radius: 12px; }

/* ---- phones ---------------------------------------------------------- */
@media (max-width: 720px) {
  /* fallback for unconverted tables: sideways scroll inside the card */
  table:not(.stack-m) { display: block; overflow-x: auto;
    -webkit-overflow-scrolling: touch; }
  table:not(.stack-m) th, table:not(.stack-m) td { white-space: nowrap; }
  td .button, th .button { min-height: 38px; padding: 6px 14px; }

  /* the real mobile treatment: each row becomes a labelled card.
     Cells carry their column name in data-label. */
  table.stack-m, table.stack-m tbody, table.stack-m tr,
  table.stack-m td { display: block; width: 100%; }
  table.stack-m thead { display: none; }
  table.stack-m tr { background: var(--card); border: 1px solid var(--hairline);
    border-radius: 12px; padding: 8px 12px; margin-bottom: 10px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04); }
  table.stack-m tr:last-child { margin-bottom: 0; }
  table.stack-m td { border: none; padding: 5px 0; white-space: normal;
    display: flex; gap: 12px; justify-content: space-between;
    align-items: baseline; flex-wrap: wrap; }
  table.stack-m td[data-label]::before { content: attr(data-label);
    font-size: 10.5px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--muted); flex: 0 0 auto; }
  table.stack-m td.t-actions { justify-content: flex-end; }
  table.stack-m td input, table.stack-m td select { flex: 1 1 160px; }
}

@media (max-width: 640px) {
  main { padding: var(--space-4) var(--space-3) var(--space-6); }
  .facts { grid-template-columns: 1fr 1fr; }

  .topbar { padding: 8px var(--space-3); gap: 8px; }
  .topbar .brand { font-size: 15px; }
  .topbar .who { font-size: 12.5px; max-width: 34vw; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; }
  .topbar .who em { display: none; }
  .topbar button.ghost { min-height: 34px; padding: 5px 12px; font-size: 13.5px; }
  .topbar .navlink { font-size: 13.5px; }

  .card { padding: var(--space-4); border-radius: 14px; }
  .page-head { margin-bottom: var(--space-4); }
  .page-head .button { flex: 1 1 auto; }

  /* checklist rows: question above, answer buttons in a full-width row —
     nothing cramps, targets stay glove-sized */
  .check-row { grid-template-columns: 1fr; gap: 8px; padding: 12px 0; }
  .service-row .opts { display: grid; grid-template-columns: 1fr 1fr; }
  .check-row .opts { display: grid; grid-template-columns: 1fr 1fr 1fr;
    gap: 8px; }
  .check-row .opt { min-width: 0; width: 100%; }

  .tiles { grid-template-columns: 1fr; }
  .sig-pad { height: 150px; }
  #lightbox img { max-width: 98vw; border-radius: 10px; }
  .suggest-item { padding: 12px 14px; }
}

/* ---------------------------------------------------- forms package (v2) */
.frail { position: sticky; top: 0; z-index: 30; display: flex; gap: 8px;
  overflow-x: auto; padding: 10px 2px; margin: 0 0 12px;
  background: var(--bg, #f5f5f7); -webkit-overflow-scrolling: touch; }
.frail-link { display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; font-size: 13px; color: inherit;
  text-decoration: none; padding: 6px 10px; border-radius: 980px;
  background: rgba(0,0,0,0.05); }
.fchip { font-variant-numeric: tabular-nums; font-size: 12px;
  padding: 1px 7px; border-radius: 980px; background: #6e6e73; color: #fff; }
.fchip.done { background: #2eaa4c; }
.form-row .frow-label { display: flex; gap: 8px; align-items: baseline;
  flex-wrap: wrap; }
.refdot { cursor: help; opacity: .55; }
.nowrap { white-space: nowrap; }
.m-opts { align-items: center; flex-wrap: wrap; }
.m-value { max-width: 130px; }
.unit { min-width: 30px; }
.choice-opts { flex-wrap: wrap; }
.choice-opts .opt { min-width: 0; padding: 0 14px; }
.opt.sm { min-width: 44px; min-height: 36px; }
.subchecks { grid-column: 1 / -1; margin: 2px 0 0 14px; }
.subcheck { display: flex; justify-content: space-between; gap: 10px;
  align-items: center; padding: 4px 0; font-size: 14px;
  border-bottom: 1px dashed rgba(0,0,0,0.08); }
.subcheck:last-child { border-bottom: none; }
.prow { grid-column: 1 / -1; display: grid;
  grid-template-columns: 60px 1fr 2fr 90px auto auto; gap: 6px;
  align-items: center; }
.prow .pcheck { display: flex; gap: 4px; align-items: center;
  font-size: 13px; white-space: nowrap; }
.fulltext, .ftext { width: 100%; }
.photorow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.photo-add { cursor: pointer; }
.photoform { display: inline; margin: 0; }
@media (max-width: 700px) {
  .prow { grid-template-columns: 1fr 1fr; }
  .m-value { max-width: 110px; }
}

.assetrow { display: flex; justify-content: space-between; gap: 10px;
  align-items: center; flex-wrap: wrap; padding: 10px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06); }
.assetrow:last-child { border-bottom: none; }
.assetrow .opts { display: flex; gap: 6px; flex-wrap: wrap;
  align-items: center; }

/* ---- planner: left tab rail + sortable tables ---- */
.planner-wrap { display: flex; gap: 22px; align-items: flex-start; }
.planner-nav { flex: 0 0 200px; position: sticky; top: 14px;
  display: flex; flex-direction: column; gap: 6px; }
.planner-nav .ptab { display: flex; justify-content: space-between;
  align-items: center; gap: 8px; padding: 11px 14px; border-radius: 12px;
  text-decoration: none; color: var(--ink); font-weight: 600;
  font-size: 14.5px; border: 1px solid var(--hairline);
  background: var(--card); }
.planner-nav .ptab:hover { border-color: var(--blue); }
.planner-nav .ptab.active { background: var(--blue); color: #fff;
  border-color: var(--blue); }
.planner-nav .ptab.active .badge { background: rgba(255,255,255,.25);
  color: #fff; }
.planner-body { flex: 1; min-width: 0; }
.planner-data { margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--hairline); display: flex;
  flex-direction: column; gap: 8px; }
.tiny { font-size: 12.5px; }
@media (max-width: 820px) {
  .planner-wrap { display: block; }
  .planner-nav { position: static; flex-direction: row; flex-wrap: wrap;
    margin-bottom: 14px; }
  .planner-nav .ptab { flex: 1 1 auto; justify-content: center; }
  .planner-data { flex-basis: 100%; border-top: 0; padding-top: 0; }
}

table.sortable thead th { cursor: pointer; user-select: none;
  white-space: nowrap; }
table.sortable thead th::after { content: "\2195"; opacity: .3;
  margin-left: 5px; font-size: 11px; }
table.sortable thead th[aria-sort="ascending"]::after { content: "\2191";
  opacity: .9; }
table.sortable thead th[aria-sort="descending"]::after { content: "\2193";
  opacity: .9; }
