/* UpKeepr styles. Colors live in :root so they're easy to re-theme. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #0b1f33;
  --muted: #6b7a8a;
  --border: #dfe4ea;
  --primary: #0e8a9e;   /* UpKeepr teal (from the logo) */
  --primary-text: #ffffff;
  --danger: #d1373f;
  --warn: #c77700;
  --success: #1a8f4a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .35rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
code { background: var(--bg); padding: .1em .35em; border-radius: 4px; font-size: .9em; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; white-space: nowrap; }
.brand-logo { height: 40px; width: auto; display: block; }
.nav { display: flex; gap: .15rem; align-items: center; margin-left: auto; flex-wrap: wrap; }
.nav a { padding: .4rem .55rem; border-radius: 6px; color: var(--text); font-weight: 500; font-size: .95rem; white-space: nowrap; }
.nav a.active, .nav a:hover { background: var(--bg); text-decoration: none; }
.nav .whoami { color: var(--muted); font-weight: 400; margin-left: .5rem; }
.nav-menu { position: relative; }
.nav-menu summary { list-style: none; cursor: pointer; padding: .4rem .55rem; border-radius: 6px; font-weight: 500; font-size: .95rem; white-space: nowrap; user-select: none; }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-menu summary .caret { font-size: .7em; opacity: .7; }
.nav-menu[open] summary, .nav-menu[data-active] summary, .nav-menu summary:hover { background: var(--bg); }
.nav-menu-list { position: absolute; right: 0; top: calc(100% + 4px); min-width: 12rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: .3rem; display: flex; flex-direction: column; z-index: 20; }
.nav-menu-list a { display: block; padding: .5rem .7rem; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--border); border-radius: 6px; font-size: 1.2rem; padding: .2rem .55rem; cursor: pointer; }
button.link { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: .4rem .5rem; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card.narrow { max-width: 480px; margin: 3rem auto; }
.card.callout { border-left: 4px solid var(--primary); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.prewrap { white-space: pre-wrap; }
.inline { display: inline; }
.inline.right { float: right; }
.error { color: var(--danger); white-space: pre-wrap; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; display: flex; flex-direction: column; color: var(--text); box-shadow: var(--shadow); }
.tile:hover { text-decoration: none; border-color: var(--primary); }
.tile-n { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile-danger .tile-n { color: var(--danger); }
.tile-warn .tile-n { color: var(--warn); }

/* Tables */
.table-wrap { overflow-x: auto; }
@media (min-width: 861px) { .table-wrap { overflow: visible; } }   /* lets the sticky header work on desktop */
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; position: sticky; top: var(--topbar-h, 60px); background: var(--surface); z-index: 2; box-shadow: 0 1px 0 var(--border); }
.table tr:last-child td { border-bottom: 0; }
.row-overdue td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.row-muted { opacity: .55; }

/* Lists */
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
/* Buttons in list rows keep their own size (owner, Oct 2026: "Fill out" stretched next to long form descriptions). */
.list li > .btn, .list li > form { flex: none; align-self: flex-start; white-space: nowrap; }
.list .count { font-weight: 600; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.notes { list-style: none; padding: 0; margin: 0 0 1rem; }
.notes li { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.notes li:last-child { border-bottom: 0; }
.note-meta { font-size: .8rem; color: var(--muted); margin-bottom: .15rem; }

/* Badges */
.badge, .tag { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #e9edf2; color: #3b4652; white-space: nowrap; }
.tag { font-weight: 500; font-size: .72rem; }
.tag-danger { background: #fde8e9; color: var(--danger); }
.badge-open { background: #e0f2f5; color: #0e6f80; }
.badge-in-progress { background: #fff2d6; color: #9a5b00; }
.badge-on-hold { background: #f0e6ff; color: #6b21a8; }
.badge-completed { background: #dff5e7; color: var(--success); }
.badge-cancelled { background: #eceff1; color: #607080; }
.badge-void { background: #fde8e9; color: #9b1c1c; }
.btn-void { color: var(--danger); border-color: #f1c4c6; }
.void-note { margin-bottom: 1rem; }
.ans-problem { color: var(--danger); font-weight: 700; background: #fde8e9; padding: 0 .35rem; border-radius: 4px; }
.fb-checks-wrap { margin-top: .4rem; }
.fb-checks { display: grid; gap: .35rem; margin: .3rem 0; }
.fb-check { display: grid; gap: .3rem; }
.fb-check-line { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.fb-check .fb-check-text { flex: 1 1 14rem; min-width: 0; }
.fb-check-num { display: flex; gap: .3rem .8rem; align-items: center; flex-wrap: wrap; padding-left: 1.4rem; }
.fb-check-num label { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.fb-check-num input { width: 5.5rem; padding: .3rem .4rem; }
.fb-check-num .fb-check-unit { width: 4.5rem; }
.fb-check-num select { width: auto; min-width: 0; }
.fb-check-note { flex: 1 1 100%; }
.fb-check-note code { font-size: .78rem; }
/* Inspection tables: Number / Short text answers on the fill-out page */
.insp-q-num, .insp-q-text { flex-wrap: wrap; }
.insp-q-text textarea { flex: 1 1 12rem; }
.insp-num { display: inline-flex; align-items: center; gap: .35rem; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; max-width: 100%; margin-left: auto; }
.insp-q .insp-num input[type="number"] { width: 6.5rem; flex: 0 0 6.5rem; min-width: 0; text-align: right; font-size: 1.05rem; }
.insp-q-num .insp-q-label { flex: 1 1 8rem; min-width: 0; }
.insp-unit { color: var(--muted); font-weight: 600; min-width: 1.5rem; }
.insp-num-note { flex-basis: 100%; text-align: right; font-size: .8rem; font-weight: 700; color: var(--danger); }
.insp-num-note:empty { display: none; }
.insp-num.is-out input { border-color: var(--danger); background: #fde8e9; color: var(--danger); font-weight: 700; }
.insp th.insp-text, .insp td.insp-text { text-align: left; width: auto; min-width: 8rem; }
.insp-view td.insp-bad .small { font-weight: 600; }
.fb-check select, .fb-problem select { width: auto; max-width: 16rem; }
.fb-problem { align-items: center; gap: .5rem; flex-wrap: wrap; }
.badge-urgent { background: #fde8e9; color: var(--danger); }
.badge-high { background: #ffe9d6; color: #b4530a; }
.badge-normal { background: #e9edf2; color: #3b4652; }
.badge-low { background: #f2f4f7; color: #7a8794; }
.badge-in-service { background: #dff5e7; color: var(--success); }
.badge-needs-repair { background: #fff2d6; color: #9a5b00; }
.badge-out-of-service { background: #fde8e9; color: var(--danger); }
.badge-retired { background: #eceff1; color: #607080; }
.badges { margin-top: .35rem; display: flex; gap: .35rem; flex-wrap: wrap; }

/* Forms */
.stack > * + * { margin-top: .85rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .85rem; }
.field { display: flex; flex-direction: column; gap: .25rem; }
.field-label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field-help { font-size: .8rem; color: var(--muted); }
input:not([type=checkbox]), select, textarea { width: 100%; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: var(--surface); color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: .5rem; }
/* A checkbox beside a long, wrapping sentence (e.g. the SMS consent box): box sits at the first line, not mid-paragraph. */
.check.check-top { align-items: flex-start; }
.check.check-top input[type="checkbox"] { flex: 0 0 auto; margin-top: .2em; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
/* Inside a table the cell must stay a real table cell (a flex <td> breaks the row's bottom border); lay the buttons out inline instead. */
.table td.actions { display: table-cell; white-space: nowrap; }
.table td.actions > * { display: inline-block; vertical-align: middle; margin: 0 0 .25rem .35rem; }
.table td.actions > form.inline { display: inline-block; }
.table td.actions .inline-details { vertical-align: middle; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .75rem 1rem; }
.filters select, .filters input { width: auto; min-width: 150px; }
.filters .check { display: inline-flex; align-items: center; gap: .35rem; margin: 0; white-space: nowrap; }
.filters .check input { min-width: 0; width: auto; }
.filters input[type=search] { flex: 1; min-width: 200px; }
/* Filter bars with labelled boxes (Audit log): line the boxes and the Filter / Clear buttons up along the bottom, not the middle (owner, Oct 2026). */
.filters:has(> .field) { align-items: flex-end; }
.filters:has(> .field) > .actions { margin: 0; }
.filters:has(> .field) :is(select, input, .actions .btn) { height: 2.7rem; box-sizing: border-box; }
.filters:has(> .field) .actions .btn { display: inline-flex; align-items: center; }

.btn { display: inline-block; padding: .5rem .9rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: #b9c2cc; }
.btn-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn-primary:hover { filter: brightness(.95); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-small { padding: .3rem .6rem; font-size: .85rem; }

/* Flash */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.flash-success { background: #dff5e7; border-color: #b6e6c8; color: #14532d; }
.flash-error { background: #fde8e9; border-color: #f5bcc0; color: #7f1d1d; }

/* details as collapsible cards */
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary h2 { display: inline; }
details.card > summary::before { content: "▸ "; color: var(--muted); }
details.card[open] > summary::before { content: "▾ "; }
details.card[open] > summary { margin-bottom: .75rem; }
/* Facility page tiles (Open work orders, Assets, Scheduled tasks, Completed forms) start collapsed (owner, Oct 2026); side-by-side ones keep their own height. */
.fac-tiles { align-items: start; }
details.fac-tile > summary { display: flex; align-items: baseline; gap: .35rem; }
details.fac-tile > summary h2 { margin: 0; }
.inline-details { position: relative; display: inline-block; }
.inline-details summary { list-style: none; }
.popover { position: absolute; right: 0; top: 2.2rem; z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; width: 300px; box-shadow: 0 8px 24px rgba(16,24,40,.15); text-align: left; }

/* Mobile */
@media (max-width: 860px) {
  /* Never let content push the page wider than the phone: grid items and cards may shrink, tables scroll inside their card. */
  body { overflow-x: hidden; }
  .container, .grid-2 > *, .card, .table-wrap { min-width: 0; max-width: 100%; }
  .table th { position: static; box-shadow: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .nav-toggle { display: block; }
  .brand-logo { height: 34px; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; }
  body.nav-open .nav { display: flex; }
  .nav-menu-list { position: static; box-shadow: none; border: 0; border-left: 2px solid var(--border); border-radius: 0; margin-left: .75rem; padding: 0; }
  .nav-menu { width: 100%; }
  .topbar { flex-wrap: wrap; }
  .filters select, .filters input { width: 100%; }
  .dl { grid-template-columns: 1fr; gap: 0 }
  .dl dt { margin-top: .4rem; }
  .popover { position: static; width: 100%; margin-top: .5rem; }
}
@media (max-width: 520px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  html { font-size: 15px; }
}

/* Forms library */
.req { color: var(--danger); }
.radio-row { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.radio-row label { display: flex; align-items: center; gap: .35rem; margin: 0; }
.radio-row input { width: auto; min-width: 0; flex: none; }
.checklist { display: flex; flex-direction: column; gap: .35rem; }
.form-section { margin-top: 1.25rem; }
.sigpad { width: 100%; max-width: 600px; height: 180px; border: 1px dashed #b9c2cc; border-radius: 8px; background: #fff; touch-action: none; display: block; }
.signature-img { max-height: 120px; }
.answers { border-collapse: collapse; width: 100%; }
.answers th, .answers td { border-bottom: 1px solid var(--border); padding: .5rem .6rem; text-align: left; vertical-align: top; }
.answers th { width: 40%; color: var(--muted); font-weight: 600; }
.answers .answers-heading th { background: var(--bg); color: var(--text); text-transform: uppercase; font-size: .8rem; letter-spacing: .03em; }
.hidden { display: none !important; }
/* Form builder */
.fb-row { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.fb-handle { cursor: grab; color: var(--muted); padding: .55rem .2rem; user-select: none; }
.fb-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .4rem; }   /* min-width 0: a long question can't push the row off the page */
.fb-line { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.fb-line .fb-label { flex: 2; min-width: 200px; }
.fb-line select { width: auto; min-width: 170px; }
.fb-line .fb-help { flex: 1; }
.fb-options textarea { width: 100%; }
.fb-req { white-space: nowrap; }

/* Vendors */
.contact-card { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin-top: .25rem; }
.contact-card > div + div::before { content: "·"; color: var(--muted, #6b7a8a); margin-right: 1rem; }

/* Client switcher (header) */
.client-switch select { padding: .35rem 1.8rem .35rem .6rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); font-weight: 600; color: var(--text); width: auto; max-width: 320px; }
.client-pill { display: inline-block; padding: .35rem .8rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.site-picker { display: grid; grid-template-columns: 1fr; gap: .5rem 1rem; max-height: 320px; overflow: auto; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.site-group .check { display: block; margin: .15rem 0; }
.popover-wide { min-width: 420px; }
@media (max-width: 860px) { .client-switch { order: 2; margin-left: auto; } .popover-wide { min-width: 0; } }

/* "Viewing as" banner (owner impersonating a user) */
.viewing-as { position: sticky; top: var(--topbar-h, 60px); z-index: 9; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .5rem 1rem; background: #fff2d6; color: #7a4a00; border-bottom: 2px solid #f0c060; }
.viewing-as .btn { background: #fff; }

/* Calendar */
.cal-toolbar { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; justify-content: space-between; }
.cal-toolbar .filters { padding: 0; }
.cal-title { font-size: 1.1rem; min-width: 11rem; text-align: center; }
.cal-legend { display: inline-flex; gap: .4rem; flex-wrap: wrap; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-dow { background: var(--bg); padding: .4rem; text-align: center; font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.cal-day { background: var(--surface); min-height: 108px; padding: .3rem .35rem; font-size: .8rem; }
.cal-empty { background: var(--bg); }
.cal-today { background: #f0fafb; box-shadow: inset 0 0 0 2px var(--primary); }
.cal-num { font-weight: 600; color: var(--muted); margin-bottom: .25rem; }
.cal-num a { color: var(--muted); }
.cal-today .cal-num, .cal-today .cal-num a { color: var(--primary); }
.cal-item { display: block; padding: .15rem .4rem; margin-bottom: .2rem; border-radius: 4px; font-size: .76rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #0b1f33; border-left: 3px solid transparent; }
.cal-item:hover { text-decoration: none; filter: brightness(.96); }
.cal-event { background: #f0e6ff; border-left-color: #6b21a8; }
.cal-wo { background: #e0f2f5; border-left-color: var(--primary); }
.cal-wo.cal-urgent { background: #ffe9d6; border-left-color: #b4530a; }
.cal-wo.cal-done { opacity: .55; text-decoration: line-through; }
.cal-pm { background: #dff5e7; border-left-color: #14532d; }
.cal-legend .cal-item { display: inline-block; margin: 0; }
@media (max-width: 860px) { .cal-day { min-height: 70px; } .cal-item { font-size: .68rem; } .cal-legend { display: none; } }
.cal-agenda, .cal-jump { display: none; }
/* Phones: compact month grid (day number + coloured dots per item, tap a day to jump to it) + a full-width agenda list. */
@media (max-width: 640px) {
  .cal-toolbar { justify-content: center; }
  .cal-toolbar .actions { width: 100%; justify-content: space-between; flex-wrap: nowrap; }
  .cal-title { min-width: 0; flex: 1; }
  .cal-toolbar .filters, .cal-toolbar .filters select { width: 100%; }
  .cal-dow { padding: .3rem 0; font-size: .65rem; letter-spacing: 0; }
  .cal-day { min-height: 52px; padding: .25rem .15rem; position: relative; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 3px; justify-content: center; }
  .cal-num { width: 100%; text-align: center; margin: 0 0 2px; font-size: .8rem; }
  .cal-day .cal-item { width: 7px; height: 7px; padding: 0; margin: 0; border: 0; border-radius: 50%; font-size: 0; line-height: 0; pointer-events: none; }
  .cal-day .cal-event { background: #6b21a8; } .cal-day .cal-wo { background: var(--primary); } .cal-day .cal-wo.cal-urgent { background: #b4530a; } .cal-day .cal-pm { background: #14532d; }
  .cal-day .cal-wo.cal-done { opacity: .35; }
  .cal-jump { display: block; position: absolute; inset: 0; z-index: 1; }
  .cal-day.has-items .cal-num a { position: relative; z-index: 2; }
  .cal-agenda { display: block; margin-top: 1rem; }
  .cal-agenda h2 { margin-bottom: .5rem; }
  .cal-legend-m { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .75rem; }
  .cal-legend-m .cal-item { display: inline-block; margin: 0; }
  .cal-agenda-day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .75rem; margin-bottom: .6rem; scroll-margin-top: calc(var(--topbar-h, 60px) + 12px); }
  .cal-agenda-day h3 { margin: 0 0 .4rem; font-size: .8rem; }
  .cal-agenda-day .cal-item { font-size: .9rem; padding: .45rem .6rem; white-space: normal; margin-bottom: .35rem; }
  .cal-today-row { border-color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
}

/* Parts inventory */
.qty { display: inline-flex; align-items: center; gap: .35rem; }
.qty-n { min-width: 2ch; text-align: center; font-size: 1rem; }
.btn-qty { padding: .1rem .55rem; font-size: 1rem; line-height: 1.2; min-width: 1.9rem; }
.btn-qty:disabled { opacity: .35; cursor: not-allowed; }
.row-low td { background: #fff7f7; }
.table .center, .center { text-align: center; }
.nowrap { white-space: nowrap; }
.stock-big { display: flex; align-items: baseline; gap: .75rem; margin-bottom: .75rem; }
.stock-n { font-size: 2.4rem; font-weight: 700; color: var(--primary); }
.stock-low .stock-n { color: var(--danger); }
.pos { color: var(--success); } .neg { color: var(--danger); }

/* Site chips (calendar events): tap to select, highlighted when chosen */
.site-chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: .5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); max-height: 240px; overflow: auto; }
.site-chip { display: inline-flex; align-items: center; padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: .9rem; user-select: none; transition: background .1s, color .1s; }
.site-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.site-chip:hover { border-color: var(--primary); }
.site-chip:has(input:checked) { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.site-chip-all:has(input:checked) { background: var(--text); border-color: var(--text); }
.site-chip:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Footer: help & feedback */
.site-foot { max-width: 1200px; margin: 0 auto; padding: 1rem 1rem 2rem; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); }
.foot-links { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; font-size: .85rem; }
.narrow-form { max-width: 720px; }
.feedback-item h2 { font-size: 1.05rem; }

/* Inspection tables (one row per asset; Y/N checks) */
.insp { border-collapse: collapse; width: 100%; font-size: .92rem; }
.insp th, .insp td { border: 1px solid var(--border); padding: .4rem .5rem; vertical-align: middle; text-align: left; }
.insp thead th { background: var(--bg); font-weight: 600; vertical-align: bottom; }
.insp th.insp-check, .insp td.insp-check { text-align: center; width: 6.5rem; }
.insp .insp-yn { justify-content: center; gap: .6rem; }
.insp .insp-yn label { gap: .2rem; }
.insp td input[type="text"], .insp td input:not([type]) { min-width: 9rem; width: 100%; }
.insp-view tr.insp-flag td { background: #fff4f4; }
.insp-view td.insp-bad { color: var(--danger); font-weight: 700; background: #fde8e9; }
.answers td.answers-wide { padding: .5rem 0; }
.fb-category { width: auto; min-width: 200px; }
.insp thead th .small { text-transform: none; font-weight: 400; letter-spacing: 0; }
@media (max-width: 860px) {
  /* On phones each asset becomes a card: checks stacked with Y/N on the right */
  .insp.insp-fill, .insp.insp-fill tbody, .insp.insp-fill tr, .insp.insp-fill td { display: block; width: auto; }
  .insp.insp-fill thead { display: none; }
  .insp.insp-fill tr { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .75rem; padding: .5rem .6rem; background: #fff; }
  .insp.insp-fill td { border: 0; padding: .3rem .1rem; }
  .insp.insp-fill td.insp-type:empty { display: none; }
  .insp.insp-fill td.insp-type::before { content: 'Type: '; color: var(--muted); }
  .insp.insp-fill td.insp-check { display: flex; justify-content: space-between; align-items: center; gap: .75rem; text-align: left; width: auto; border-top: 1px solid var(--border); }
  .insp.insp-fill td.insp-check::before { content: attr(data-label); font-size: .92rem; }
  .insp.insp-fill .insp-yn { flex-shrink: 0; gap: .9rem; }
  .insp.insp-fill .insp-yn label { font-weight: 600; }
  .insp.insp-fill td.insp-comment { border-top: 1px solid var(--border); padding-top: .5rem; }
}
/* Inspection fill-out: one block per asset, all its questions together */
.insp-assets { display: grid; gap: .75rem; }
.insp-asset { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem .75rem; margin: 0; background: #fff; min-width: 0; }
.insp-asset legend { padding: 0 .3rem; font-size: 1rem; }
.insp-asset-n { color: var(--muted); font-size: .8rem; font-weight: 400; }
.insp-q { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .45rem 0; border-top: 1px solid var(--border); }
.insp-q:first-of-type { margin-top: .4rem; }
/* Yes / No / N/A questions (fire door form): on phones the three answers go under the question so the text keeps the full width. */
@media (max-width: 640px) { .insp-q-na { flex-wrap: wrap; } .insp-q-na .insp-q-label { flex: 1 1 100%; } .insp-q-na .insp-yn { margin-left: auto; } }
.insp-q-cb input[type="checkbox"] { width: 1.6rem; height: 1.6rem; flex: 0 0 auto; margin: 0 .35rem 0 0; accent-color: var(--teal, #0e8a9e); }
.insp-cb-pair { display: inline-flex; align-items: center; gap: .9rem; flex: 0 0 auto; }
.insp-cb-na { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.insp-cb-na input[type="checkbox"] { width: 1.35rem; height: 1.35rem; margin: 0; }
.insp-q .insp-yn { flex-shrink: 0; gap: 1rem; }
.insp-q .insp-yn label { font-weight: 600; }
.insp-asset-comment { width: 100%; margin-top: .4rem; }
.form-grid .field-wide { grid-column: 1 / -1; }
.push-right { margin-left: auto; }
.edit-actions { margin-top: .85rem; }

/* Facility maps */
.map-img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; display: block; }
.map-pdf { width: 100%; height: 75vh; border: 1px solid var(--border); border-radius: 8px; }
/* Audit log */
.audit-table td { vertical-align: top; }
.audit-details summary { cursor: pointer; }
.audit-fields { display: grid; grid-template-columns: max-content 1fr; gap: .1rem .6rem; margin: .3rem 0 0; font-size: .85rem; }
.audit-fields dt { color: var(--muted); }
.audit-fields dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.nowrap { white-space: nowrap; }
.check.inline { display: inline-flex; margin-left: .5rem; }

/* Feedback screenshots */
.shot-preview, .shot-strip { display: flex; flex-wrap: wrap; gap: .5rem; }
.shot-preview img, .shot-strip img { height: 90px; max-width: 160px; object-fit: cover; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.shot-preview:empty { display: none; }

/* Card heading with controls on the right */
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.card-head h2 { margin-bottom: .75rem; }
.sort-links { white-space: nowrap; margin-top: .1rem; color: var(--muted); }
.sort-links a { color: var(--muted); }
.sort-links a.active { color: var(--primary); font-weight: 600; text-decoration: underline; }

/* Master library (developer-owned, shared by toggle) */
.tag-master { background: color-mix(in srgb, var(--primary) 14%, #fff); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.share-toggles { display: flex; flex-wrap: wrap; gap: .2rem .8rem; }
.share-toggles .check { margin: 0; font-size: .85rem; white-space: nowrap; }

/* Sign-in code entry */
.code-input { font-size: 1.6rem; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }

/* Danger zone (delete a form template) */
.danger-zone { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.danger-zone > summary h2 { color: var(--danger); }
.callout.callout-danger, .callout-danger { padding: .75rem 1rem; border-radius: 6px; margin-bottom: .75rem; background: #fde8e9; border-left: 4px solid var(--danger); color: #7a1c22; }
.callout-danger ul { margin: .4rem 0 0 1.2rem; }

/* Drag & drop upload zones (app.js wraps every input[type=file]) */
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 1.25rem 1rem; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--bg); color: var(--muted); text-align: center; cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; }
.dropzone:hover, .dropzone:focus-visible { border-color: var(--primary); color: var(--text); outline: none; }
.dropzone:focus-visible { box-shadow: 0 0 0 3px rgba(14, 138, 158, .2); }
.dropzone.is-over { border-color: var(--primary); border-style: solid; background: rgba(14, 138, 158, .06); color: var(--primary); }
.dropzone.is-rejected { border-color: var(--danger); background: rgba(209, 55, 63, .06); animation: dz-shake .3s; }
.dropzone.is-invalid { border-color: var(--danger); }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 1; font-size: 0; }
/* The invisible real file input covers the whole zone so a tap opens the picker natively — iPhones (Safari and Chrome)
   could come back from the camera without the photo when the picker was opened by script on a hidden 1 px input. */
.dropzone .dz-files { position: relative; z-index: 2; }
.dropzone .dz-icon { color: var(--primary); }
.dropzone .dz-text { font-size: .95rem; }
.dropzone .dz-text strong { color: var(--text); font-weight: 600; }
.dropzone .dz-browse { color: var(--primary); text-decoration: underline; }
.dropzone.has-files { border-style: solid; background: var(--surface); }
.dz-files { width: 100%; margin-top: .35rem; display: flex; flex-direction: column; gap: .3rem; text-align: left; }
.dz-file { display: flex; align-items: center; gap: .5rem; padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: .9rem; }
.dz-file .dz-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dz-file .dz-size { flex: none; font-size: .8rem; }
.dz-remove { flex: none; border: 0; background: transparent; color: var(--muted); font-size: 1.2rem; line-height: 1; padding: 0 .25rem; cursor: pointer; border-radius: 4px; }
.dz-remove:hover { color: var(--danger); background: rgba(209, 55, 63, .08); }
.dz-file .dz-label { flex: 1 1 200px; min-width: 0; width: auto; padding: .3rem .5rem; font-size: .9rem; }
@media (max-width: 600px) { .dz-file { flex-wrap: wrap; } .dz-file .dz-label { flex-basis: 100%; order: 3; } }

/* Facility maps: existing floors on the edit form, floor tabs on the maps page */
.map-rows { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .75rem; }
.map-row { display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.map-row-label { flex: 1 1 220px; margin: 0; display: flex; flex-direction: column; gap: .25rem; }
.map-row-file { flex: 1 1 160px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-bottom: .5rem; font-size: .9rem; }
.map-row-remove { margin: 0 0 .5rem; white-space: nowrap; }
.floor-tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .75rem; border-bottom: 1px solid var(--border); padding-bottom: .5rem; }
.floor-tab { border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; padding: .4rem .9rem; border-radius: 999px; cursor: pointer; }
.floor-tab.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.floor-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.floor-head h3 { margin: 0; }
@keyframes dz-shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.dropzone .dz-mobile { display: none; }
@media (max-width: 640px), (hover: none) { .dropzone { padding: 1rem .75rem; } .dropzone .dz-desktop { display: none; } .dropzone .dz-mobile { display: inline; } }

/* Reports */
.tiles.tiles-5 { grid-template-columns: repeat(5, 1fr); }
.tiles .tile-n { overflow-wrap: anywhere; }
.bars { display: flex; flex-direction: column; gap: .45rem; }
.bar-row { display: grid; grid-template-columns: minmax(7rem, 30%) 1fr auto; gap: .6rem; align-items: center; font-size: .92rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: .8rem; background: var(--bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bar { height: 100%; background: var(--primary); border-radius: 999px; }
.bar-n { min-width: 2.5rem; text-align: right; font-weight: 600; }
@media (max-width: 900px) { .tiles.tiles-5 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .tiles.tiles-5 { grid-template-columns: repeat(2, 1fr); } .bar-row { grid-template-columns: minmax(5rem, 35%) 1fr auto; } .bar-col { display: none; } }

/* Notifications & messages */
.nav-badge { display: inline-block; min-width: 1.25rem; padding: 0 .35rem; margin-left: .3rem; border-radius: 999px; background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700; line-height: 1.25rem; text-align: center; vertical-align: middle; }
.nav .bell { position: relative; padding: .4rem .5rem; border-radius: 6px; font-size: 1.05rem; text-decoration: none; }
.nav .bell.active, .nav .bell:hover { background: var(--bg); }
.nav .bell .nav-badge { position: absolute; top: -2px; right: -4px; margin: 0; }
.badge-n { display: inline-block; min-width: 1.3rem; padding: 0 .4rem; border-radius: 999px; background: var(--danger); color: #fff; font-size: .75rem; font-weight: 700; line-height: 1.3rem; text-align: center; vertical-align: middle; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif { display: flex; align-items: center; gap: .5rem; padding: .7rem .25rem; border-bottom: 1px solid var(--border); }
.notif:last-child { border-bottom: 0; }
.notif.is-read { opacity: .6; }
.notif-link { display: flex; gap: .75rem; flex: 1; min-width: 0; color: var(--text); text-decoration: none; }
.notif-link:hover strong { text-decoration: underline; color: var(--primary); }
.notif-icon { font-size: 1.2rem; flex: none; }
.notif-body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.mention { color: var(--primary); font-weight: 600; }
.mention-menu { position: absolute; z-index: 30; margin-top: -2px; min-width: 14rem; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: .25rem; }
.mention-item { padding: .4rem .6rem; border-radius: 6px; cursor: pointer; }
.mention-item.active, .mention-item:hover { background: var(--bg); color: var(--primary); }
.chat-form, .notes + form, form.stack { position: relative; }
.chat-layout { display: grid; grid-template-columns: 17rem 1fr; gap: 1rem; align-items: start; }
.chat-side h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 .4rem; }
.conv { display: flex; flex-wrap: wrap; align-items: center; gap: 0 .5rem; padding: .5rem .6rem; border-radius: 8px; color: var(--text); text-decoration: none; }
.conv:hover, .conv.active { background: var(--bg); text-decoration: none; }
.conv.active .conv-name { color: var(--primary); font-weight: 600; }
.conv-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-sub { flex-basis: 100%; }
.chat-new { display: flex; gap: .4rem; margin-top: 1rem; }
.chat-new select { flex: 1; min-width: 0; }
.chat-main { display: flex; flex-direction: column; min-height: 70vh; }
.chat-head { border-bottom: 1px solid var(--border); padding-bottom: .6rem; margin-bottom: .6rem; }
.chat-head h2 { margin: 0; }
.chat-log { flex: 1; overflow-y: auto; max-height: 60vh; padding: .25rem .25rem 0; display: flex; flex-direction: column; gap: .6rem; }
.msg { max-width: 78%; padding: .5rem .75rem; border-radius: 12px; background: var(--bg); align-self: flex-start; }
.msg.mine { background: rgba(14, 138, 158, .12); align-self: flex-end; }
.msg-meta { font-size: .8rem; margin-bottom: .15rem; }
.msg-body { white-space: pre-wrap; word-break: break-word; }
.chat-form { display: flex; gap: .5rem; align-items: flex-end; margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.chat-form textarea { flex: 1; resize: vertical; }
@media (max-width: 860px) { .chat-layout { grid-template-columns: 1fr; } .chat-main { min-height: 0; } .chat-log { max-height: 50vh; } .msg { max-width: 92%; } }
.members { position: relative; color: var(--primary); text-decoration: underline dotted; cursor: help; outline: none; }
.members-pop { display: none; position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; min-width: 14rem; max-height: 60vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: .4rem .2rem; text-align: left; white-space: nowrap; }
.members:hover .members-pop, .members:focus .members-pop, .members:focus-within .members-pop { display: block; }
.members-row { display: flex; justify-content: space-between; gap: 1rem; padding: .25rem .6rem; color: var(--text); }

/* Calculated form fields */
.calc-out { display: block; padding: .5rem .6rem; border: 1px dashed var(--border); border-radius: 6px; background: var(--bg); font-weight: 600; min-height: 2.4rem; }
.calc-out.is-empty::before { content: '—'; color: var(--muted); font-weight: 400; }
.calc-out.is-pass { color: var(--success); background: #dff5e7; border-color: #bfe8cd; }
.calc-out.is-fail { color: var(--danger); background: #fde8e9; border-color: #f5c2c5; }
.fb-key { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }   /* long keys (made from long questions) wrap instead of widening the row */
.fb-key code { word-break: break-all; }
.fb-formula { flex-wrap: wrap; }
.fb-formula-in { flex: 1 1 320px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; }
.fb-dec { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.fb-dec input { width: 4rem; padding: .3rem .4rem; }

/* Region picker above the site chips */
.region-pick { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.region-pick select { width: auto; max-width: 100%; padding: .35rem .5rem; }

/* Chat: moderator delete button (System Administrator / Developer) */
.msg-del { display: inline; margin-left: .35rem; }
.msg-del button { padding: 0 .2rem; font-size: .8rem; opacity: .45; }
.msg:hover .msg-del button, .msg-del button:focus { opacity: 1; }

/* Work-order photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.photo { margin: 0; }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; background: var(--bg); }
.photo figcaption { margin-top: .25rem; display: flex; align-items: center; justify-content: space-between; gap: .25rem; }
.photo figcaption .link { padding: 0 .2rem; }
.dropzone.is-busy { opacity: .6; pointer-events: none; }
.dropzone.is-busy::after { content: 'Preparing photos…'; font-size: .85rem; color: var(--muted); }

/* Facility maps: drag-to-reorder floor tabs (Maintenance Director+) */
.floor-tabs.is-sortable { align-items: center; }
.floor-tabs.is-sortable .floor-tab { cursor: grab; touch-action: none; user-select: none; }
.floor-tabs.is-sorting .floor-tab { cursor: grabbing; }
.floor-tab.is-dragging { box-shadow: 0 6px 16px rgba(11, 31, 51, .22); transform: scale(1.04); position: relative; z-index: 2; }
.floor-sort-hint { margin-left: auto; }
.floor-tabs.is-saving .floor-sort-hint::after { content: ' · saving…'; }
.floor-tabs.is-saved .floor-sort-hint::after { content: ' · saved ✓'; color: var(--success); }

/* ---- AI: "Convert to digital form" + "Ask UpKeepr" help assistant ---- */
.btn-ai { border-color: color-mix(in srgb, #7c4dcc 45%, var(--border)); color: #5b2fa8; }
.btn-ai:disabled { opacity: .75; cursor: progress; }
.callout-ai { padding: .75rem 1rem; border-radius: 6px; background: #f3effc; border-left: 4px solid #7c4dcc; }
.callout-ai .ai-notes { margin-top: .5rem; padding-top: .5rem; border-top: 1px solid #e0d6f5; }
.ask-fab { position: fixed; right: 1rem; bottom: 1rem; z-index: 40; border: 0; border-radius: 999px; padding: .65rem 1rem; font: inherit; font-weight: 700;
  background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(11, 31, 51, .25); cursor: pointer; }
.ask-fab:hover { filter: brightness(.95); }
.ask-panel { position: fixed; right: 1rem; bottom: 1rem; z-index: 41; width: min(400px, calc(100vw - 2rem)); height: min(560px, calc(100vh - 6rem));
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(11, 31, 51, .25); }
.ask-panel[hidden] { display: none; }
.ask-head { display: flex; align-items: center; justify-content: space-between; padding: .6rem .8rem; border-bottom: 1px solid var(--border); }
.ask-head-actions { display: flex; align-items: center; gap: .5rem; }
.ask-x { border: 0; background: none; font-size: 1rem; cursor: pointer; color: var(--muted); padding: .2rem .4rem; }
.ask-log { flex: 1; overflow-y: auto; padding: .75rem; display: flex; flex-direction: column; gap: .5rem; }
.ask-msg { max-width: 90%; padding: .5rem .7rem; border-radius: 10px; font-size: .92rem; overflow-wrap: anywhere; }
.ask-msg p { margin: 0 0 .4rem; } .ask-msg p:last-child { margin-bottom: 0; }
.ask-msg ol, .ask-msg ul { margin: .2rem 0 .4rem 1.2rem; padding: 0; }
.ask-bot { background: var(--bg); align-self: flex-start; }
.ask-me { background: var(--primary); color: #fff; align-self: flex-end; white-space: pre-wrap; }
.ask-err { background: #fde8e9; color: #7a1c22; align-self: flex-start; }
.ask-wait { color: var(--muted); font-style: italic; }
.ask-meta { margin-top: .3rem; font-size: .75rem; color: var(--muted); }
.ask-form { display: flex; gap: .4rem; padding: .6rem; border-top: 1px solid var(--border); align-items: flex-end; }
.ask-form textarea { flex: 1; resize: none; font: inherit; padding: .45rem .55rem; border: 1px solid var(--border); border-radius: 6px; }
.ask-foot { margin: 0; padding: 0 .75rem .5rem; font-size: .72rem; color: var(--muted); }
.site-foot { padding-bottom: 4rem; }
@media (max-width: 640px) {
  .ask-fab { right: .75rem; bottom: .75rem; padding: .55rem .85rem; }
  .ask-panel { right: 0; left: 0; bottom: 0; width: 100%; height: 85vh; border-radius: 12px 12px 0 0; }
  .ask-form textarea { font-size: 16px; }   /* stops iPhones zooming in on focus */
}
@media print { .ask-fab, .ask-panel { display: none !important; } }
/* Form Library: table on the left, a fixed-width upload card on the right; buttons stack in one column so nothing squeezes the sidebar. */
.library-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
.library-grid > * { min-width: 0; }
.table td.lib-actions { width: 1%; }
.lib-btns { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; min-width: 14rem; }
.lib-btns > .btn { text-align: center; }
.lib-btns .lib-full { grid-column: 1 / -1; margin: 0; }
.lib-btns .lib-full .btn { width: 100%; text-align: center; }
@media (max-width: 860px) { .library-grid { grid-template-columns: 1fr; } }

/* ---- Scan-to-request QR codes (src/routes/requests.js) ---- */
.photo-file { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem; aspect-ratio: 4 / 3; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); padding: .5rem; text-align: center; color: var(--text); }
.photo-file:hover { text-decoration: none; border-color: var(--primary); }
.photo-file-icon { font-size: 2rem; line-height: 1; }
.photo-file-name { font-size: .8rem; word-break: break-word; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.qr-panel { border-top: 1px solid var(--border); margin-top: 1.25rem; padding-top: 1rem; }
.qr-box { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; }
.qr-img { width: 200px; height: 200px; border: 1px solid var(--border); border-radius: 8px; background: #fff; flex: none; }
.qr-side { flex: 1 1 280px; min-width: 0; }
.qr-link { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.public-main { max-width: 640px; }
.public-card h1 { margin: .15rem 0 .25rem; }
.public-site { font-size: 1.1rem; margin: 0 0 1rem; }
.public-thanks { text-align: center; }
.public-check { width: 56px; height: 56px; border-radius: 50%; background: var(--success); color: #fff; font-size: 2rem; line-height: 56px; margin: .5rem auto; }
.btn-block { display: block; width: 100%; padding: .8rem; font-size: 1.05rem; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.public-page .topbar span.brand { pointer-events: none; }   /* QR form: logo is not a link; legal pages use <a class="brand" href="/"> */

.qr-network { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--border); max-width: 720px; }
.qr-network code { font-size: .85em; }

/* ---- Privacy policy (/privacy) ---- */
.policy { max-width: 760px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem 1.75rem 2rem; line-height: 1.6; }
.policy h1 { margin-bottom: .1rem; }
.policy h2 { font-size: 1.1rem; margin: 1.75rem 0 .5rem; text-transform: none; letter-spacing: 0; color: var(--text); }
.policy ul { padding-left: 1.25rem; }
.policy li { margin: .3rem 0; }
.sms-optin-sample { margin: 1rem 0 1.25rem; }
.sms-optin-shot { margin: 1rem 0 1.25rem; }
.sms-optin-shot img { display: block; max-width: 100%; width: 560px; height: auto; border: 1px solid var(--border, #d0d7de); border-radius: var(--radius); }
.sms-optin-sample .card { max-width: 440px; margin: 0 0 .35rem; }
.sms-optin-sample .card h3 { margin: 0 0 .6rem; }
.sms-optin-sample .check { line-height: 1.45; }
.sms-samples code { white-space: normal; word-break: break-word; }
.policy-promise { background: #eef8fa; border: 1px solid #bfe3ea; border-radius: var(--radius); padding: .5rem 1.25rem 1rem; margin: 1rem 0 1.5rem; }
.policy-promise h2 { margin-top: .75rem; }
.public-foot { max-width: 640px; margin: 0 auto; }
@media (max-width: 640px) { .policy { padding: 1rem; border-radius: 0; border-left: 0; border-right: 0; } }

.acct-box { background: #f3fafb; border: 1px solid #cde9ee; border-radius: 10px; padding: .75rem .9rem; }
.acct-box .check { display: flex; gap: .5rem; align-items: flex-start; margin: 0; }
.acct-box p { margin: .4rem 0 0 1.6rem; }

/* Billing (src/routes/billing.js) */
.tiles.tiles-4 { grid-template-columns: repeat(4, 1fr); }
.tiles.tiles-4 .tile:hover { border-color: var(--border); }
@media (max-width: 900px) { .tiles.tiles-4 { grid-template-columns: repeat(2, 1fr); } }
.steps { padding-left: 1.2rem; line-height: 1.6; } .steps li { margin: .35rem 0; }

/* Developer settings → Role permissions matrix: fits the card width, no sideways scrolling */
.perm-table { width: 100%; table-layout: fixed; font-size: .8rem; }
.perm-table col.perm-col-area { width: 17%; }
.perm-table th, .perm-table td { padding: .3rem .25rem; }
.perm-table thead th { white-space: normal; vertical-align: bottom; text-transform: none; letter-spacing: 0; font-size: .74rem; line-height: 1.2; text-align: center; }
.perm-table thead th.perm-area-head { text-align: left; }
.perm-table .perm-area { text-align: left; font-weight: 600; font-size: .8rem; line-height: 1.25; text-transform: none; letter-spacing: 0; color: var(--text); cursor: help; }
.perm-info { color: var(--muted, #8a97a3); font-weight: 400; font-size: .75rem; }
.perm-table .perm-group th { background: #eef6f8; color: #0b1f33; text-transform: uppercase; letter-spacing: .04em; font-size: .68rem; padding: .3rem .5rem; }
.perm-cell { text-align: center; }
.perm-select { width: 100%; min-width: 0; padding: .25rem .15rem; font-size: .76rem; border-radius: 6px; text-overflow: ellipsis; }
.perm-none { background: #f3f4f6; color: #6b7280; }
.perm-read { background: #e0f2fe; color: #075985; }
.perm-write { background: #dcfce7; color: #166534; }
.perm-full { background: #fef3c7; color: #92400e; }
.perm-changed .perm-select { box-shadow: 0 0 0 2px #0e8a9e; }
.perm-pill { display: inline-block; padding: .15rem .45rem; border-radius: 6px; font-size: .74rem; white-space: nowrap; }
.perm-legend { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; margin: .25rem 0 .75rem; color: var(--muted, #5b6b7a); }
.perm-legend .perm-pill { margin-left: .4rem; }
.perm-legend .perm-pill:first-child { margin-left: 0; }
.perm-rolepick { display: none; }
/* Narrow screens: one role at a time (picked above the table) */
@media (max-width: 900px) {
  .perm-rolepick { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; font-weight: 600; }
  .perm-rolepick select { width: auto; flex: 1; }
  .perm-table [data-role].perm-off { display: none; }
  .perm-table { table-layout: auto; }
  .perm-table col { width: auto !important; }
  .perm-table td[data-role] { width: 45%; }
  .perm-table .perm-area { font-size: .88rem; }
  .perm-select { font-size: .88rem; padding: .35rem .3rem; }
}

/* Work orders filter bar: on phones the dropdowns fold behind a "Filters" button so the list shows first */
.filter-toggle { display: none; }
.wo-filters .filter-more { display: contents; }
.filter-count { display: inline-block; min-width: 1.3em; padding: 0 .35em; margin-left: .2rem; border-radius: 999px; background: var(--primary, #0e8a9e); color: #fff; font-size: .75rem; line-height: 1.3em; text-align: center; }
@media (max-width: 640px) {
  .wo-filters { gap: .5rem; padding: .6rem; }
  .wo-filters .filter-toggle { display: inline-flex; align-items: center; gap: .25rem; order: 2; flex: none; white-space: nowrap; }
  .wo-filters input[type=search] { order: 1; flex: 1; width: auto; min-width: 0; }
  .wo-filters .filter-more, .wo-filters .filter-clear, .wo-filters .filter-submit { display: none; }
  .wo-filters.open .filter-more { display: grid; grid-template-columns: 1fr; gap: .5rem; order: 3; width: 100%; }
  .wo-filters.open .filter-more select { width: 100%; min-width: 0; }
  .wo-filters.open .filter-submit { display: inline-flex; order: 4; flex: 1; justify-content: center; }
  .wo-filters.open .filter-clear { display: inline-flex; order: 5; }
}

/* Work order tables on phones: one card per work order instead of a wide table (no sideways scrolling) */
@media (max-width: 640px) {
  .table-wrap:has(> .wo-table) { overflow-x: visible; background: transparent; box-shadow: none; border: 0; }
  .wo-table, .wo-table tbody { display: block; width: 100%; }
  .wo-table thead { display: none; }
  .wo-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem; padding: .7rem .8rem; margin-bottom: .5rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
  .wo-table tr.row-overdue { border-left: 4px solid var(--danger); }
  .wo-table tr.row-overdue td:first-child { box-shadow: none; }
  .wo-table td { display: block; padding: 0; border: 0; font-size: .88rem; }
  .wo-table td.wo-id { font-size: .8rem; }
  .wo-table td.wo-id::before { content: "#"; }
  .wo-table td.wo-id { flex: 0 0 auto; }
  .wo-table td.wo-title { flex: 1 1 calc(100% - 3rem); min-width: 0; }
  .wo-table td.wo-pri { order: 3; }
  .wo-table td.wo-status { order: 3; }
  .wo-table td.wo-fac, .wo-table td.wo-who, .wo-table td.wo-due, .wo-table td.wo-done { order: 4; flex: 1 1 45%; color: var(--text); }
  .wo-table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted, #6b7a8a); font-size: .78rem; }
  .wo-table td.is-empty { display: none; }
}

/* Calendar drag and drop (desktop) */
.cal-item[draggable="true"] { cursor: grab; }
.cal-dragging { opacity: .45; }
.cal-drag-on [data-cal-drop] { outline: 1px dashed #b9c2cc; outline-offset: -3px; }
.cal-drop-over { background: #e6f6f2 !important; outline: 2px solid #14532d !important; outline-offset: -3px; }
.cal-saving { opacity: .6; }
.cal-drag-hint { margin: 0 0 .5rem; }
@media (max-width: 640px) { .cal-drag-hint { display: none; } }

/* "‹ Back" button above the page title (every logged-in page except the dashboard) */
.back-row { margin: 0 0 .75rem; }
.btn-back { padding-left: .9rem; padding-right: 1rem; }
@media print { .back-row { display: none; } }
.user-filters { padding: 0 0 .75rem; }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { background: #fdecec; }
/* `form.stack { position: relative }` (chat/notes forms) must not pull popovers back into the page flow */
form.stack.popover { position: absolute; }
@media (max-width: 860px) { form.stack.popover { position: static; } }
.popover .popover-title { display: block; }

/* Edit facility → Reset site data (developer only) */
.danger-zone { margin-top: 1.25rem; border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border)); border-radius: var(--radius); padding: .75rem 1rem; background: #fff8f8; }
.danger-zone summary { cursor: pointer; color: var(--danger); }
.danger-zone[open] summary { margin-bottom: .75rem; }
.reset-list { display: grid; gap: .45rem; }
.reset-list .check { align-items: flex-start; }

/* Single-choice location chips (chips.sitePick). In a filter bar they take a full row of their own. */
.filters .filter-chips { flex: 1 1 100%; max-height: 132px; }
.site-chips-one .site-chip-all:has(input:checked) { background: var(--text); border-color: var(--text); }
.site-chip input { min-width: 0 !important; }
.site-picker .site-chips { border: 0; padding: .25rem 0; background: transparent; max-height: none; }
/* Pop-ups often sit inside a no-wrap table cell (the row's Edit button); their text must still wrap inside the box. */
.popover { white-space: normal; }
/* Location chips in filter bars and the Users "Sites this user can see" list show every chip — no inner scroll. */
.filters .filter-chips, .site-picker { max-height: none; overflow: visible; }
.site-chips { max-height: none; overflow: visible; }   /* every location chip is always visible — no inner scrollbar */

/* Completed form drawn on the organisation's original paper form (src/pdf-forms.js). Letter-shaped, scales to width. */
.pf-sheet { position: relative; width: 100%; max-width: 816px; aspect-ratio: 612 / 792; container-type: inline-size; background: #fff; border: 1px solid var(--line, #d7dde3); box-shadow: 0 2px 10px rgba(0,0,0,.06); margin: 0 auto; overflow: hidden; }
.pf-bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pf-marks { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.pf-text { position: absolute; line-height: 1; white-space: nowrap; font-family: Helvetica, Arial, sans-serif; color: rgb(18, 42, 120); }
.pf-foot { position: absolute; left: 5.88%; bottom: 0.8%; color: #828282; font-family: Helvetica, Arial, sans-serif; white-space: nowrap; }
.pf-details { margin-top: 1rem; }
.pf-details > summary { cursor: pointer; font-weight: 600; }
@media print {
  .pf-print-body { margin: 0; }
  .pf-print-body .pf-sheet { width: 8.5in; max-width: none; border: 0; box-shadow: none; }
  .pf-sheet + .pf-sheet { margin-top: 0 !important; break-before: page; }   /* per-door layouts: one sheet per page */
}
.pf-sheet + .pf-sheet { margin-top: 1rem; }
a.pf-wrap { display: block; color: inherit; text-decoration: none; }

/* Phones: every data table (except the ones with their own phone layout) turns into one card per row, each cell
   labelled with its column header (app.js copies the <th> text into data-label), so nothing scrolls sideways. */
@media (max-width: 640px) {
  .table-wrap:has(> table.table:not(.wo-table):not(.perm-table):not(.insp-fill)) { overflow-x: visible; background: transparent; box-shadow: none; border: 0; }
  table.table:not(.wo-table):not(.perm-table):not(.insp-fill), table.table:not(.wo-table):not(.perm-table):not(.insp-fill) > tbody { display: block; width: 100%; }
  table.table:not(.wo-table):not(.perm-table):not(.insp-fill) > thead { display: none; }
  table.table:not(.wo-table):not(.perm-table):not(.insp-fill) > tbody > tr { display: block; padding: .6rem .75rem; margin-bottom: .5rem; background: #fff; border: 1px solid var(--border, #d7dde3); border-radius: 10px; }
  table.table:not(.wo-table):not(.perm-table):not(.insp-fill) > tbody > tr > td { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; padding: .18rem 0; border: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; min-width: 0; }
  table.table:not(.wo-table):not(.perm-table):not(.insp-fill) > tbody > tr > td > * { min-width: 0; max-width: 100%; }
  table.table:not(.wo-table):not(.perm-table):not(.insp-fill) > tbody > tr > td[data-label]:not(:first-child)::before { content: attr(data-label); flex: 0 0 34%; color: var(--muted, #6b7a8a); font-size: .78rem; }
  table.table:not(.wo-table):not(.perm-table):not(.insp-fill) > tbody > tr > td:first-child { display: block; }
  table.table:not(.wo-table):not(.perm-table):not(.insp-fill) > tbody > tr > td.is-empty { display: none; }
  /* Labelled cells: the label sits in a fixed left column and the value always stays to its right (a long value, e.g.
     a file name, used to drop under the label). */
  table.table:not(.wo-table):not(.perm-table):not(.insp-fill) > tbody > tr > td[data-label]:not(:first-child):not(.is-empty):not([data-label=""]) { display: block; position: relative; padding-left: calc(34% + .6rem); }
  table.table:not(.wo-table):not(.perm-table):not(.insp-fill) > tbody > tr > td[data-label]:not(:first-child):not(.is-empty):not([data-label=""])::before { position: absolute; left: 0; top: .3rem; width: 34%; }
  /* Buttons in a phone card never let their wording spill outside the button. */
  table.table:not(.wo-table):not(.perm-table):not(.insp-fill) > tbody > tr > td .btn { white-space: normal; overflow-wrap: break-word; }
  /* Form Library: the action buttons use the card's full width (Open | Download, then Convert and Remove underneath). */
  table.table td.lib-actions { width: auto; }
  td.lib-actions > .lib-btns { flex: 1 1 100%; width: 100%; min-width: 0; }
}

/* Site filters on list pages (chips.sitePick bare + allLabel): a collapsible "Sites: …" button on phones, always open (no button) on desktop. */
.site-collapse { width: 100%; }
.site-collapse > summary { list-style: none; cursor: pointer; }
.site-collapse > summary::-webkit-details-marker { display: none; }
.site-collapse > summary::after { content: " ▾"; }
.site-collapse[open] > summary::after { content: " ▴"; }
.site-collapse[open] > summary { margin-bottom: .5rem; }
@media (min-width: 641px) { .site-collapse > summary { display: none; } }
@media (max-width: 640px) { .site-collapse > summary { width: 100%; justify-content: center; } }

/* Parts used on a work order (src/wo-parts.js) */
.parts-use { display: grid; grid-template-columns: minmax(0, 1fr) 6rem minmax(0, 1fr) auto; gap: .6rem; align-items: end; margin-top: .75rem; }
.parts-use .field { margin: 0; }
.parts-total { text-align: right; margin: .5rem 0 0; }
@media (max-width: 640px) { .parts-use { grid-template-columns: 1fr 5.5rem; } .parts-use .field:first-child, .parts-use .parts-note, .parts-use .btn { grid-column: 1 / -1; } .parts-total { text-align: left; } }

/* Digital vault filters */
.vault-filters .vault-search { flex: 1 1 100%; }
.vault-filters .vault-search .field { width: 100%; }
.vault-sites { flex: 1 1 100%; }
.pager { justify-content: center; margin-top: .75rem; align-items: center; }

/* Phones: the 🔔 sits in the top bar just left of the ☰ menu button (the copy inside the menu is hidden). */
.bell-mobile { display: none; position: relative; padding: .3rem .45rem; border-radius: 6px; font-size: 1.15rem; text-decoration: none; }
.bell-mobile .nav-badge { position: absolute; top: -3px; right: -5px; margin: 0; }
@media (max-width: 860px) {
  .bell-mobile { display: inline-block; margin-left: auto; }
  .bell-mobile + .nav-toggle { margin-left: .35rem; }
  .nav .bell { display: none; }
}

/* My account → Notifications on this device */
.push-status { margin: .25rem 0 .6rem; font-weight: 600; }
.push-ios { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .75rem; margin-bottom: .6rem; }
.push-panel [hidden] { display: none !important; }

/* Phones: with the ☰ menu open, the top bar (menu + Settings list) scrolls on its own inside the screen,
   so a long Settings list can be scrolled right away instead of first scrolling the whole page. */
@media (max-width: 860px) {
  body.nav-open .topbar { max-height: 100vh; max-height: 100dvh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
}
textarea:not([data-no-autogrow]) { overflow-y: hidden; resize: vertical; min-height: 2.6rem; }

/* Form builder: Preview pop-up (public/form-builder.js) */
body.fb-preview-open { overflow: hidden; }
.fb-preview-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(11, 31, 51, .55); display: flex; align-items: stretch; justify-content: center; padding: 1.5rem; }
.fb-preview-box { background: var(--bg); border-radius: var(--radius); width: 100%; max-width: 1000px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.fb-preview-bar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.fb-preview-bar .muted { flex: 1; min-width: 12rem; }
.fb-preview-modes { display: inline-flex; gap: .25rem; }
.fb-preview-modes .is-on { background: var(--primary); border-color: var(--primary); color: #fff; }
.fb-preview-scroll { flex: 1; overflow: auto; padding: 1rem; }
.fb-preview-frame { margin: 0 auto; }
.fb-preview-phone { max-width: 390px; border: 8px solid var(--text); border-radius: 28px; padding: .75rem; background: var(--bg); min-height: 100%; }
.fb-preview-phone .table-wrap { overflow-x: auto; }
.fb-preview-desktop { max-width: 820px; }
.fb-preview-sig { height: 120px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
@media (max-width: 700px) {
  .fb-preview-overlay { padding: 0; }
  .fb-preview-box { border-radius: 0; }
  .fb-preview-modes { display: none; }
  .fb-preview-phone { max-width: none; border: 0; border-radius: 0; padding: 0; }
}

/* Reports: saved reports + actions (src/routes/reports.js) */
.saved-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.saved-item { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 999px; padding: .3rem .4rem .3rem .85rem; background: var(--surface); }
.saved-item.is-on { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(14, 138, 158, .15); }
.saved-item a { text-decoration: none; }
.report-current { margin: .15rem 0; }
.report-actions { margin: -.25rem 0 1rem; flex-wrap: wrap; }
.report-actions .popover, .saved-item .popover { left: 0; right: auto; z-index: 30; }
.report-show .checklist-inline { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.report-schedule [hidden] { display: none !important; }
.text-warn { color: var(--warn); font-weight: 600; }
@media (max-width: 700px) { .report-actions .popover, .saved-item .popover { position: fixed; left: .75rem; right: .75rem; top: 4rem; min-width: 0; width: auto; max-height: 80vh; overflow: auto; } }

/* Type-to-filter pick lists (public/select-search.js) */
.ss-panel { position: fixed; z-index: 1100; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(16, 24, 40, .18); overflow: hidden; }
.ss-panel .ss-input { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: .55rem .7rem; outline: none; flex: none; }
.ss-list { overflow-y: auto; padding: .25rem 0; flex: 1; min-height: 0; }
.ss-opt { padding: .45rem .75rem; cursor: pointer; white-space: normal; line-height: 1.3; }
.ss-opt.is-current { font-weight: 600; }
.ss-opt.is-active { background: color-mix(in srgb, var(--primary) 14%, transparent); }
.ss-opt.is-disabled { color: var(--muted); cursor: default; }
.ss-group { padding: .5rem .75rem .2rem; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.ss-empty { padding: .6rem .75rem; color: var(--muted); }
.ss-panel.ss-sheet { left: .5rem; right: .5rem; top: 12vh; max-height: 70vh; }
.ss-panel.ss-sheet .ss-input { font-size: 16px; }   /* stops iPhones zooming in */

/* Work order page: Details card edits in place; collapsible description (src/routes/work-orders.js) */
.grid-2 > .wo-details.is-editing, .grid-2 > .asset-details.is-editing { grid-column: 1 / -1; }
.asset-details .card-head { align-items: center; }
.wo-details .card-head { align-items: center; }
.wo-desc { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .75rem; }
.wo-desc > summary { list-style: none; cursor: pointer; display: flex; flex-direction: column; gap: .15rem; }
.wo-desc > summary::-webkit-details-marker { display: none; }
.wo-desc-title { font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.wo-desc-title::after { content: " ▸"; }
.wo-desc[open] .wo-desc-title::after { content: " ▾"; }
.wo-desc[open] .wo-desc-preview { display: none; }
.wo-desc-preview { font-size: .92rem; }
.wo-desc > p { margin-top: .5rem; }

/* Users → Add a team member: no location picked (public/app.js [data-sites-required]) */
.field-invalid .site-picker { outline: 2px solid var(--danger); outline-offset: 4px; border-radius: 6px; }

/* Whole work-order row / phone card opens the work order (app.js) */
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: rgba(14, 138, 158, .05); }
@media (max-width: 640px) { .wo-table tr.row-link:hover td { background: transparent; } .wo-table tr.row-link:active { background: #eef8fa; } }

/* Work order Details: inline-edit controls look like plain values until hovered / focused */
.dl-inline dt { display: flex; align-items: center; min-height: 2.1rem; }
.dl-inline dd { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; min-height: 2.1rem; }
.dl-inline .ie-ctl { border: 1px solid transparent; background-color: transparent; box-shadow: none; padding: .25rem 1.4rem .25rem .45rem; margin: 0 0 0 -.45rem;
  border-radius: 6px; font: inherit; color: inherit; width: auto; max-width: 100%; min-width: 0; height: auto; line-height: 1.4; cursor: pointer; }
.dl-inline select.ie-ctl { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, #9aa6b2 50%), linear-gradient(135deg, #9aa6b2 50%, transparent 50%);
  background-position: calc(100% - 11px) 55%, calc(100% - 7px) 55%; background-size: 4px 4px; background-repeat: no-repeat; }
.dl-inline input.ie-ctl { cursor: text; width: 11rem; padding-right: .45rem; }
.dl-inline input.ie-ctl[type="date"] { width: 10.5rem; }
.dl-inline .ie-ctl:hover { border-color: var(--border); background-color: #fff; }
.dl-inline .ie-ctl:focus { border-color: var(--primary, #0e8a9e); background-color: #fff; outline: none; box-shadow: 0 0 0 3px rgba(14,138,158,.15); }
.dl-inline .ie-ctl.ie-busy { opacity: .6; }
.ie-msg { font-size: .78rem; color: var(--success, #1a7f4b); }
.ie-msg.ie-bad { color: var(--danger); }
.ie-open { text-decoration: none; font-size: .85rem; color: var(--muted, #6b7a8a); }
.class-new { display: flex; gap: .4rem; margin-top: .35rem; }
.class-new.hidden { display: none; }
.class-new input { flex: 1 1 auto; min-width: 0; }

/* Assets list bulk actions */
.bulk-bar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; position: sticky; top: .5rem; z-index: 4; padding: .6rem .9rem; border-color: var(--primary, #0e8a9e); }
.bulk-bar[hidden] { display: none; }
.bulk-bar .bulk-group { display: inline-flex; gap: .4rem; align-items: center; }
.bulk-bar select { width: auto; }
.bulk-bar .bulk-num { width: 8.5rem; }
.table .bulk-col { width: 2.2rem; text-align: center; }
.table .bulk-col input { width: 1.05rem; height: 1.05rem; cursor: pointer; }
.table tr.is-selected td { background: #eef8fa; }
@media (max-width: 860px) { .table.has-bulk td.bulk-col { text-align: left; } .table.has-bulk td.bulk-col::before { content: none !important; } }

/* ---- Collapsible filter panel (Reports, Capital forecast) ---- */
.filters-collapse { padding: 0; }
.filters-collapse > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: .75rem; padding: .7rem 1rem; user-select: none; }
.filters-collapse > summary::-webkit-details-marker { display: none; }
.filters-collapse > summary::before { content: '▸'; color: var(--muted); transition: transform .15s; display: inline-block; }
.filters-collapse[open] > summary::before { transform: rotate(90deg); }
.filters-collapse-title { font-weight: 600; }
.filters-collapse-sum { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.filters-collapse[open] .filters-collapse-sum { display: none; }
.filters-collapse > form { border-top: 1px solid var(--border); padding: 1rem; margin: 0; box-shadow: none; border-radius: 0 0 var(--radius) var(--radius); }

/* ---- Report tabs + segmented control ---- */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.seg a { padding: .4rem .9rem; font-size: .9rem; color: var(--text); text-decoration: none; white-space: nowrap; }
.seg a + a { border-left: 1px solid var(--border); }
.seg a.on { background: var(--primary); color: #fff; }
.report-tabs { margin-bottom: .9rem; }
.pill { display: inline-block; font-size: .75rem; padding: .1rem .55rem; border-radius: 999px; font-weight: 600; background: #eef1f4; color: var(--text); white-space: nowrap; }
.p-over { background: #fde8e9; color: #9b1c1c; } .p-soon { background: #fff4d6; color: #7a5600; } .p-ok { background: #e3f6ec; color: #1a7f4b; }
.tag-ok { background: #e3f6ec; color: #1a7f4b; border-color: #9fd8b7; }
.num { font-variant-numeric: tabular-nums; }

/* ---- Capital forecast ---- */
.cap-infl-row { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }
.cap-infl-row input.cap-rate { width: 4.5rem !important; max-width: 4.5rem; flex: none; }
.fc-scroll { overflow-x: auto; }
.fc-chart { display: grid; gap: .5rem; align-items: end; height: 210px; padding: .5rem .25rem 0; border-bottom: 1px solid var(--border); }
.fc-col { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; text-decoration: none; }
.fc-col:hover .fc-stack { opacity: .8; }
.fc-stack { display: flex; flex-direction: column-reverse; border-radius: 5px 5px 0 0; overflow: hidden; }
.fc-amt { font-size: .72rem; color: var(--muted); text-align: center; margin-bottom: .2rem; white-space: nowrap; }
.fc-x { display: grid; gap: .5rem; font-size: .76rem; color: var(--muted); text-align: center; padding-top: .3rem; }
.fc-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: .7rem; }
.fc-legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.cap-table .cap-past td { background: #fff6f6; }
.cap-table .cap-total td { background: var(--bg); }
.cap-list .cap-group-head th { background: var(--bg); font-size: .85rem; text-align: left; padding-top: .55rem; }
.fieldset.capital-fields { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem 1rem 1rem; margin: 1rem 0 0; }
.fieldset.capital-fields legend { font-weight: 600; padding: 0 .35rem; }

/* ---- Site visits ---- */
.sv-sec { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .9rem; background: #fff; box-shadow: var(--shadow); }
.sv-sec h3 { margin: 0; padding: .6rem .9rem; background: var(--bg); border-bottom: 1px solid var(--border); font-size: .98rem; display: flex; justify-content: space-between; align-items: center; gap: .75rem; border-radius: var(--radius) var(--radius) 0 0; }
.sv-sec h3 .sv-sec-title { font-weight: 600; max-width: 24rem; }
.sv-row { display: grid; grid-template-columns: minmax(0, 1.2fr) auto minmax(0, 1fr) auto; gap: .6rem; align-items: center; padding: .5rem .9rem; border-top: 1px solid var(--border); }
.sv-rows .sv-row:first-child { border-top: 0; }
.sv-row.is-bad { background: #fff7f7; }
.sv-custom { background: #fbfdfd; }
.sv-opts { display: inline-flex; gap: .25rem; }
.sv-opt { position: relative; margin: 0; cursor: pointer; }
.sv-opt input { position: absolute; opacity: 0; pointer-events: none; }
.sv-opt span { display: inline-block; border: 1px solid var(--border); border-radius: 6px; padding: .25rem .6rem; font-size: .82rem; background: #fff; white-space: nowrap; }
.sv-opt input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 1px; }
.sv-opt-good input:checked + span { background: #e3f6ec; border-color: #9fd8b7; color: #1a7f4b; font-weight: 600; }
.sv-opt-attention input:checked + span { background: #fde8e9; border-color: #f1b4b8; color: #9b1c1c; font-weight: 600; }
.sv-opt-na input:checked + span { background: #eef1f4; border-color: #c3ccd5; font-weight: 600; }
.sv-row input[type=text] { font-size: .88rem; padding: .35rem .5rem; }
.sv-tools { display: inline-flex; align-items: center; gap: .35rem; }
.sv-cam { cursor: pointer; font-size: 1rem; border: 1px solid var(--border); border-radius: 6px; padding: .15rem .45rem; background: #fff; margin: 0; white-space: nowrap; }
.sv-cam.has-new { border-color: var(--primary); background: #e6f6f8; }
.sv-cam-n { font-size: .75rem; margin-left: .15rem; color: var(--muted); }
.sv-cam-n:empty { display: none; }
.sv-add { padding: .45rem .9rem; border-top: 1px dashed var(--border); }
.sv-actions { margin-top: 1rem; }
.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.ph { margin: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.ph img { display: block; width: 100%; height: 130px; object-fit: cover; }
.ph figcaption { display: flex; gap: .3rem; align-items: center; padding: .35rem .45rem; font-size: .82rem; }
.ph figcaption input { font-size: .82rem; padding: .25rem .4rem; flex: 1; min-width: 0; }
.row-bad td { background: #fff7f7; }
.dl-2 { grid-template-columns: max-content 1fr max-content 1fr; }
@media (max-width: 760px) {
  .sv-row { grid-template-columns: 1fr auto; }
  .sv-row .sv-label { grid-column: 1 / -1; }
  .sv-row .sv-note { grid-column: 1 / 2; }
  .dl-2 { grid-template-columns: max-content 1fr; }
  .filters-collapse > summary { flex-wrap: wrap; }
}

/* ── Dark mode switch: My account → Appearance (click your name). The choice lives in localStorage ('upk-theme') on
   each device; THEME_HEAD in src/html.js applies it before the page paints, so there's no white flash. */
.brand-logo-dark { display: none; }
html[data-theme="dark"] .brand-logo-light { display: none; }
html[data-theme="dark"] .brand-logo-dark { display: block; }
.theme-pick { display: flex; gap: .5rem; flex-wrap: wrap; }
.theme-pick label { display: flex; align-items: center; gap: .4rem; margin: 0; padding: .45rem .8rem; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: var(--surface); font-weight: 500; }
.theme-pick input { width: auto; margin: 0; }
.theme-pick label:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 30%, transparent); }

/* ── Dark mode ─────────────────────────────────────────────────────────────────────────────────────────────
   Screen only — printouts, PDFs and the paper-form sheet (.pf-sheet) always stay black-on-white.
   Most of the app follows the :root variables; the rules below re-tint the few places that use fixed light colors
   (status badges, flashes, callouts, highlighted rows). Signature pads, QR codes and photos keep a white backing. */
@media screen {
  html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0e151d;
    --surface: #16202b;
    --text: #e4ebf2;
    --muted: #93a3b4;
    --border: #2a3847;
    --primary: #17a2b8;
    --primary-text: #ffffff;
    --danger: #f2707a;
    --warn: #f0a447;
    --success: #43c97c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
    --line: #2a3847;
    --t-red: rgba(242, 112, 122, .16);   --t-red-b: rgba(242, 112, 122, .4);   --t-red-c: #ff9aa2;
    --t-amber: rgba(240, 164, 71, .16);  --t-amber-b: rgba(240, 164, 71, .4);  --t-amber-c: #f6c27f;
    --t-green: rgba(67, 201, 124, .15);  --t-green-b: rgba(67, 201, 124, .4);  --t-green-c: #7fe0a6;
    --t-teal: rgba(23, 162, 184, .18);   --t-teal-b: rgba(23, 162, 184, .45);  --t-teal-c: #6fd6e6;
    --t-purple: rgba(167, 128, 240, .18); --t-purple-b: rgba(167, 128, 240, .45); --t-purple-c: #c9b2ff;
    --t-gray: rgba(148, 163, 180, .16);  --t-gray-c: #b7c3cf;
    --t-blue: rgba(96, 165, 250, .16);   --t-blue-c: #9cc8ff;
    --raised: #1d2936;                    /* inputs-in-cards, row cards on phones */
  }
  html[data-theme="dark"] body { background: var(--bg); }
  html[data-theme="dark"] .btn:hover { border-color: #46586b; }
  html[data-theme="dark"] .btn-primary:hover { filter: brightness(1.1); }
  html[data-theme="dark"] .nav-menu-list,
  html[data-theme="dark"] .popover,
  html[data-theme="dark"] .mention-menu,
  html[data-theme="dark"] .members-pop,
  html[data-theme="dark"] .ss-panel,
  html[data-theme="dark"] .ask-panel { box-shadow: 0 10px 30px rgba(0, 0, 0, .55); }
  html[data-theme="dark"] .nav-toggle { color: var(--text); }

  /* Badges and tags */
  html[data-theme="dark"] .badge, html[data-theme="dark"] .tag,
  html[data-theme="dark"] .badge-normal { background: var(--t-gray); color: var(--t-gray-c); }
  html[data-theme="dark"] .badge-low,
  html[data-theme="dark"] .badge-cancelled,
  html[data-theme="dark"] .badge-retired { background: rgba(148, 163, 180, .1); color: #98a6b4; }
  html[data-theme="dark"] .badge-open { background: var(--t-teal); color: var(--t-teal-c); }
  html[data-theme="dark"] .badge-in-progress,
  html[data-theme="dark"] .badge-needs-repair { background: var(--t-amber); color: var(--t-amber-c); }
  html[data-theme="dark"] .badge-high { background: rgba(240, 130, 60, .18); color: #ffb183; }
  html[data-theme="dark"] .badge-on-hold { background: var(--t-purple); color: var(--t-purple-c); }
  html[data-theme="dark"] .badge-completed,
  html[data-theme="dark"] .badge-in-service,
  html[data-theme="dark"] .tag-ok,
  html[data-theme="dark"] .p-ok { background: var(--t-green); color: var(--t-green-c); border-color: var(--t-green-b); }
  html[data-theme="dark"] .tag-danger,
  html[data-theme="dark"] .badge-urgent,
  html[data-theme="dark"] .badge-out-of-service,
  html[data-theme="dark"] .badge-void,
  html[data-theme="dark"] .p-over,
  html[data-theme="dark"] .ans-problem { background: var(--t-red); color: var(--t-red-c); }
  html[data-theme="dark"] .p-soon { background: var(--t-amber); color: var(--t-amber-c); }
  html[data-theme="dark"] .pill { background: var(--t-gray); }
  html[data-theme="dark"] .tag-master { background: var(--t-teal); color: var(--t-teal-c); border-color: var(--t-teal-b); }
  html[data-theme="dark"] .btn-void { border-color: var(--t-red-b); }

  /* Messages and callouts */
  html[data-theme="dark"] .flash-success { background: var(--t-green); border-color: var(--t-green-b); color: var(--t-green-c); }
  html[data-theme="dark"] .flash-error,
  html[data-theme="dark"] .callout-danger,
  html[data-theme="dark"] .ask-err { background: var(--t-red); border-color: var(--t-red-b); color: var(--t-red-c); }
  html[data-theme="dark"] .callout.callout-danger, html[data-theme="dark"] .callout-danger { border-left-color: var(--danger); }
  html[data-theme="dark"] .viewing-as { background: #3a2c10; color: var(--t-amber-c); }
  html[data-theme="dark"] .viewing-as .btn { background: var(--surface); }
  html[data-theme="dark"] .callout-ai { background: var(--t-purple); border-left-color: #a780f0; }
  html[data-theme="dark"] .callout-ai .ai-notes { border-top-color: var(--t-purple-b); }
  html[data-theme="dark"] .btn-ai { color: var(--t-purple-c); border-color: var(--t-purple-b); }
  html[data-theme="dark"] .policy-promise,
  html[data-theme="dark"] .acct-box { background: var(--t-teal); border-color: var(--t-teal-b); }
  html[data-theme="dark"] .danger-zone { background: rgba(242, 112, 122, .06); }
  html[data-theme="dark"] .btn-danger-text:hover { background: var(--t-red); }
  html[data-theme="dark"] .calc-out.is-pass { background: var(--t-green); border-color: var(--t-green-b); }
  html[data-theme="dark"] .calc-out.is-fail { background: var(--t-red); border-color: var(--t-red-b); }

  /* Highlighted / flagged rows */
  html[data-theme="dark"] .row-low td,
  html[data-theme="dark"] .row-bad td,
  html[data-theme="dark"] .cap-table .cap-past td,
  html[data-theme="dark"] .sv-row.is-bad,
  html[data-theme="dark"] .insp-view tr.insp-flag td { background: rgba(242, 112, 122, .08); }
  html[data-theme="dark"] .insp-view td.insp-bad { background: var(--t-red); }
  html[data-theme="dark"] .insp-num.is-out input { background: var(--t-red); color: var(--t-red-c); }
  html[data-theme="dark"] .table tr.is-selected td,
  html[data-theme="dark"] tr.row-link:hover td { background: rgba(23, 162, 184, .1); }
  html[data-theme="dark"] .msg.mine { background: rgba(23, 162, 184, .2); }

  /* Calendar */
  html[data-theme="dark"] .cal-today { background: rgba(23, 162, 184, .1); }
  html[data-theme="dark"] .cal-item { color: var(--text); }
  html[data-theme="dark"] .cal-event { background: var(--t-purple); border-left-color: #a780f0; }
  html[data-theme="dark"] .cal-wo { background: var(--t-teal); }
  html[data-theme="dark"] .cal-wo.cal-urgent { background: rgba(240, 130, 60, .2); border-left-color: #f0823c; }
  html[data-theme="dark"] .cal-pm { background: var(--t-green); border-left-color: var(--success); }
  html[data-theme="dark"] .cal-drop-over { background: rgba(67, 201, 124, .15) !important; outline-color: var(--success) !important; }

  /* Role permissions matrix */
  html[data-theme="dark"] .perm-table .perm-group th { background: var(--raised); color: var(--text); }
  html[data-theme="dark"] .perm-none { background: var(--t-gray); color: #98a6b4; }
  html[data-theme="dark"] .perm-read { background: var(--t-blue); color: var(--t-blue-c); }
  html[data-theme="dark"] .perm-write { background: var(--t-green); color: var(--t-green-c); }
  html[data-theme="dark"] .perm-full { background: var(--t-amber); color: var(--t-amber-c); }

  /* Things that were plain white boxes */
  html[data-theme="dark"] .insp.insp-fill tr,
  html[data-theme="dark"] .insp-asset,
  html[data-theme="dark"] .seg,
  html[data-theme="dark"] .sv-sec,
  html[data-theme="dark"] .sv-opt span,
  html[data-theme="dark"] .sv-cam,
  html[data-theme="dark"] .ph { background: var(--surface); }
  html[data-theme="dark"] .sv-custom { background: var(--raised); }
  html[data-theme="dark"] .sv-cam.has-new { background: var(--t-teal); }
  html[data-theme="dark"] .sv-opt-good input:checked + span { background: var(--t-green); border-color: var(--t-green-b); color: var(--t-green-c); }
  html[data-theme="dark"] .sv-opt-attention input:checked + span { background: var(--t-red); border-color: var(--t-red-b); color: var(--t-red-c); }
  html[data-theme="dark"] .sv-opt-na input:checked + span { background: var(--t-gray); border-color: #46586b; }
  html[data-theme="dark"] .dl-inline .ie-ctl:hover,
  html[data-theme="dark"] .dl-inline .ie-ctl:focus { background-color: var(--raised); }
  html[data-theme="dark"] .sigpad { border-color: #46586b; }   /* stays white: the signature is drawn in dark ink */
  html[data-theme="dark"] .cal-drag-on [data-cal-drop] { outline-color: #46586b; }
  html[data-theme="dark"] .fb-preview-overlay { background: rgba(0, 0, 0, .65); }
  html[data-theme="dark"] .site-chip-all:has(input:checked) { color: var(--bg); }
  html[data-theme="dark"] .area-card { background: var(--surface); }
  html[data-theme="dark"] .fd-fail { background: var(--t-amber); border-color: var(--t-amber-b); color: var(--t-amber-c); }
  html[data-theme="dark"] .area-room, html[data-theme="dark"] .room-chip { background: var(--t-teal); color: var(--t-teal-c); border-color: var(--t-teal-b); }
  html[data-theme="dark"] .room-chip.is-on { background: var(--primary); color: #fff; }
  html[data-theme="dark"] .area-loose { background: var(--t-amber); border-color: var(--t-amber-b); color: var(--t-amber-c); }
  html[data-theme="dark"] .area-loose-chip { background: var(--surface); border-color: var(--t-amber-b); }
  html[data-theme="dark"] .pf-sheet { border-color: #46586b; }
}
@media screen and (max-width: 640px) {
  html[data-theme="dark"] .wo-table tr.row-link:active { background: rgba(23, 162, 184, .12); }
}
@media screen and (max-width: 860px) {
  html[data-theme="dark"] table.table:not(.wo-table):not(.perm-table):not(.insp-fill) > tbody > tr { background: var(--surface); }
}

/* One-line text boxes that wrap (textarea[data-single-line], see input() in src/html.js): look exactly like a
   normal text box, grow downward when the text is longer than the box, and can't be dragged bigger. */
textarea[data-single-line] { resize: none; overflow-y: hidden; min-height: 0; height: auto; line-height: 1.45; display: block; }
.fb-line textarea[data-single-line], .fb-check textarea[data-single-line] { display: inline-block; vertical-align: top; }

/* Asset page: ‹ Previous · 3 of 40 · Next › through the Assets list it was opened from (owner, Oct 2026). */
.asset-nav { display: flex; align-items: center; justify-content: flex-end; gap: .6rem; margin: -.25rem 0 .5rem; }
.btn.is-disabled { opacity: .4; pointer-events: none; }
@media (max-width: 640px) { .asset-nav { justify-content: space-between; } }

/* Form builder: an inspection table's rows follow the form's Asset category + Classification (owner, Oct 2026). */
.fb-cat { flex-direction: column; align-items: flex-start; gap: .25rem; }
.fb-cat-note { padding: .5rem .75rem; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); }
.fb-cat-note.fb-cat-missing { background: #fdf3e3; border-color: #f3d39c; color: #8a5300; }
@media screen { html[data-theme="dark"] .fb-cat-note.fb-cat-missing { background: var(--t-amber); border-color: var(--t-amber-b); color: var(--t-amber-c); } }
/* Saved / print view of an inspection table too wide for a page: one block per asset (owner, Oct 2026; same test as the PDF). */
.insp-blocks { display: grid; gap: .6rem; }
.insp-block { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; break-inside: avoid-page; }
.insp-block-head { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; padding: .4rem .7rem; background: var(--bg); border-bottom: 1px solid var(--border); }
.insp-block.insp-flag .insp-block-head { background: #fff4f4; }
.insp-block-row { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem .7rem; border-top: 1px solid var(--border); }
.insp-block-row:first-of-type { border-top: 0; }
.insp-block-row b { white-space: nowrap; }
.insp-block-row.insp-bad { color: var(--danger); background: #fde8e9; font-weight: 700; }
.insp-block-comment { color: var(--muted); }
@media screen { html[data-theme="dark"] .insp-block.insp-flag .insp-block-head { background: rgba(242, 112, 122, .08); } html[data-theme="dark"] .insp-block-row.insp-bad { background: var(--t-red); } }
/* Form disclaimer (owner, Oct 2026): typed in the form builder; above Submit on the fill page, at the bottom of the saved form. */
.form-disclaimer { border-left: 3px solid var(--warn); background: #fdf3e3; color: #6b4300; padding: .55rem .8rem; font-size: .88rem; line-height: 1.5; white-space: pre-line; }
.form-disclaimer strong { font-weight: 700; }
.form-disclaimer-saved { margin-top: .25rem; }
.pf-disc { position: absolute; left: 5.88%; right: 5.88%; bottom: 2.4%; color: #828282; font-family: Helvetica, Arial, sans-serif; line-height: 1.25; }
@media screen { html[data-theme="dark"] .form-disclaimer { background: var(--t-amber); color: var(--t-amber-c); } }

/* ── Receptacles by room (src/routes/receptacles.js; owner, Oct 2026) ─────────────────────────────────────────── */
.rec-tiles { grid-template-columns: repeat(4, 1fr); }
/* Fire Doors page (src/routes/fire-doors.js): one tile per door, receptacle-page styling around it */
.fd-doors { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem; }
.fd-door { display: flex; flex-direction: column; gap: .35rem; min-height: 78px; padding: .7rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.fd-door:hover { border-color: var(--primary); text-decoration: none; }
.fd-door.is-bad { border-color: var(--warn); }
.fd-door.is-sel { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent); }
.fd-door-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; font-size: .9rem; line-height: 1.3; }
.fd-door-head .rec-dot { margin-top: .2rem; }
.fd-dl { margin-bottom: .75rem; }
.fd-last { border-top: 1px solid var(--border); padding-top: .7rem; margin-bottom: .75rem; display: grid; gap: .35rem; font-size: .92rem; }
.fd-fail { display: grid; gap: .25rem; padding: .6rem .75rem; border-radius: 8px; border: 1px solid #f0c38a; background: #fff4e6; color: #8a4a08; }
.fd-fail a { color: inherit; font-weight: 700; }
.tile-ok .tile-n { color: var(--success); }
.rec-filter { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.rec-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.rec-chip { display: inline-flex; align-items: center; min-height: 40px; padding: 0 1rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: .92rem; }
.rec-chip:hover { border-color: var(--primary); text-decoration: none; }
.rec-chip.is-on { background: var(--text); border-color: var(--text); color: var(--surface); font-weight: 600; }
.rec-search { display: flex; gap: .4rem; flex: 1 1 260px; margin: 0; }
.rec-search input[type=search] { flex: 1; min-width: 0; }
.rec-legend { display: flex; flex-wrap: wrap; gap: .9rem; font-size: .85rem; color: var(--muted); }
.rec-legend > span { display: inline-flex; gap: .35rem; align-items: center; }
.rec-layout { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: flex-start; }
.rec-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 1.4rem; }
.rec-area-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; margin-bottom: .6rem; flex-wrap: wrap; }
.rec-area-head h2 { margin: 0; }
.rec-rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .6rem; }
.rec-room { display: flex; flex-direction: column; gap: .5rem; min-height: 72px; padding: .7rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.rec-room:hover { border-color: var(--primary); text-decoration: none; }
.rec-room.is-bad { border-color: var(--warn); }
.rec-room.is-sel { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent); }
.rec-room-head { display: flex; justify-content: space-between; gap: .4rem; font-weight: 700; font-size: .92rem; }
.rec-dots { display: flex; flex-wrap: wrap; gap: 4px; }
.rec-dot { width: 13px; height: 13px; border-radius: 3px; display: inline-block; flex: 0 0 auto; }
.rec-pass { background: #2f9a5e; }
.rec-fail { background: #ef8f35; box-shadow: inset 0 0 0 2px #8a4510; }
.rec-due { background: #c9d2db; }
.rec-panel { flex: 1 1 320px; min-width: 0; scroll-margin-top: 80px; }
.rec-panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; margin-bottom: .6rem; }
.rec-panel-head h2 { margin: 0; }
.rec-outlets { list-style: none; margin: 0 0 .75rem; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.rec-outlets li { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.rec-outlets li a { display: flex; flex-direction: column; min-width: 0; color: var(--text); }
.rec-tag { font-size: .75rem; font-weight: 700; padding: .15rem .6rem; border-radius: 999px; white-space: nowrap; }
.rec-tag-pass { background: #dff5e7; color: #156b3a; }
.rec-tag-fail { background: #ffe9d6; color: #9a4a08; }
.rec-tag-due { background: #e9edf2; color: #3b4652; }
.rec-fail-note { color: var(--warn); font-size: .9rem; }
.rec-add { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: flex-start; }
.rec-add-form { flex: 999 1 520px; min-width: 0; }
.rec-add-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 1rem; }
.rec-add-side .card { margin: 0; }
.rec-per { border: 0; padding: 0; margin: 0; min-width: 0; }
.rec-per-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .35rem; }
.rec-per-chips .site-chip { min-width: 48px; min-height: 40px; justify-content: center; }
.rec-preview { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.rec-preview li { display: flex; justify-content: space-between; gap: .6rem; padding: .45rem .6rem; border-radius: 6px; background: var(--bg); font-size: .88rem; }
.rec-preview li .muted { text-align: right; }
.rec-upload { border-style: dashed; }
@media (max-width: 640px) { .rec-tiles { grid-template-columns: repeat(2, 1fr); } }

/* Receptacles · All facilities overview */
.rec-facs { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.rec-fac { display: flex; flex-direction: column; gap: .6rem; margin: 0; color: var(--text); }
.rec-fac:hover { border-color: var(--primary); text-decoration: none; }
.rec-fac.is-bad { border-color: var(--warn); }
.rec-fac-head { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.rec-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--bg); }
.rec-bar > span { height: 100%; }
.rec-fac-counts { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .85rem; color: var(--muted); }
.rec-fac-counts > span { display: inline-flex; gap: .35rem; align-items: center; }
.rec-fac .rec-fail-note { margin: 0; }
.rec-empty .rec-chip { gap: .4rem; }

/* Inspection tables room by room (public/insp-rooms.js) */
.insp-rooms { display: flex; flex-direction: column; gap: .9rem; }
.insp-rooms-bar { display: flex; flex-direction: column; gap: .5rem; padding: .7rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.insp-rooms-prog { display: flex; align-items: center; gap: .6rem; }
.insp-rooms-prog progress { flex: 1; height: 10px; accent-color: var(--success); }
.insp-room-chips { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .2rem; }
.insp-room-chip { flex: 0 0 auto; min-width: 52px; min-height: 40px; padding: 0 .6rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.insp-room-chip.is-done { background: #dff5e7; border-color: #9fd8b5; color: #156b3a; }
.insp-room-chip.is-bad { background: #ffe9d6; border-color: #f1b27a; color: #9a4a08; }
.insp-room-chip.is-cur { outline: 2px solid var(--primary); outline-offset: 1px; }
.insp-rooms-bar [data-insp-showall] { align-self: flex-start; }
.insp-room { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; background: var(--bg); scroll-margin-top: 80px; }
.insp-room.is-bad { border-color: var(--warn); }
.insp-room-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .7rem; }
.insp-room-head > div { display: flex; flex-direction: column; }
.insp-room-head strong { font-size: 1.15rem; }
.btn.insp-allpass { min-height: 48px; padding: 0 1.2rem; background: var(--success); border-color: var(--success); color: #fff; }
.insp-room-nav { display: flex; gap: .6rem; }
.insp-room-nav .btn { flex: 1; min-height: 48px; justify-content: center; }
@media (max-width: 640px) { .btn.insp-allpass { width: 100%; justify-content: center; } }
@media screen {
  html[data-theme="dark"] .rec-tag-pass, html[data-theme="dark"] .insp-room-chip.is-done { background: var(--t-green); color: var(--t-green-c); border-color: var(--t-green-b); }
  html[data-theme="dark"] .rec-tag-fail, html[data-theme="dark"] .insp-room-chip.is-bad { background: var(--t-amber); color: var(--t-amber-c); border-color: var(--t-amber-b); }
  html[data-theme="dark"] .rec-tag-due { background: var(--t-gray); color: var(--t-gray-c); }
  html[data-theme="dark"] .rec-due { background: #3a4654; }
  html[data-theme="dark"] .rec-pass { background: #3fae6e; }
  html[data-theme="dark"] .btn.insp-allpass { background: #2f8f5b; border-color: #2f8f5b; }
}

/* Edit facility → Areas & rooms (src/areas.js editorHtml, app.js [data-areas-editor]) */
.areas-editor { display: grid; gap: .8rem; }
.areas-editor-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: .5rem 1rem; }
.areas-editor-head p { margin: 0; max-width: 46rem; }
.area-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: .75rem; align-items: start; }
.area-card { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; display: grid; gap: .55rem; background: #fbfcfd; min-width: 0; }
.area-card-head { display: flex; align-items: center; gap: .45rem; color: var(--primary); }
.area-card-head input { flex: 1 1 auto; min-width: 0; font-weight: 700; color: var(--text); }
.area-card-head .muted { white-space: nowrap; }
.area-rooms { display: flex; flex-wrap: wrap; gap: .35rem; min-height: 1.9rem; align-items: center; }
.area-room { display: inline-flex; align-items: center; gap: .15rem; padding: .15rem .2rem .15rem .6rem; border-radius: 999px; background: #e3f3f5; color: #08515d; font-size: .85rem; font-weight: 600; }
.area-room button { border: 0; background: transparent; color: inherit; cursor: pointer; width: 1.6rem; height: 1.6rem; border-radius: 999px; font-size: 1rem; line-height: 1; }
.area-room button:hover { background: rgba(0,0,0,.08); }
.area-add { display: flex; gap: .4rem; }
.area-add input { flex: 1 1 auto; min-width: 0; }
.area-loose { border: 1px dashed #c9a24a; background: #fff8e8; color: #6b4a00; border-radius: var(--radius); padding: .7rem .8rem; display: grid; gap: .5rem; }
.area-loose-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.area-loose-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .3rem .2rem .6rem; border: 1px solid #e8d6a8; border-radius: 8px; background: #fff; font-size: .85rem; font-weight: 600; }
.area-loose-chip select { width: auto; padding: .15rem .3rem; font-size: .85rem; font-weight: 400; }
/* Room # boxes on forms (areas.roomField) */
.room-chips { display: grid; gap: .3rem; margin-top: .35rem; }
.room-chip-list { display: flex; flex-wrap: wrap; gap: .35rem; }
.room-chip { min-height: 2.4rem; padding: .3rem .75rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; }
.room-chip:hover { border-color: var(--primary); }
.room-chip.is-on { background: var(--primary); border-color: var(--primary); color: #fff; }
.room-auto { color: var(--primary); }
.room-opt { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; }
.room-panel .ss-list { padding-top: .25rem; }


/* Asset labels (Assets ▸ Asset Labels) */
.label-pick-head { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.table th.label-tick, .table td.label-tick { width: 2.2rem; }

/* Bulk edit outlets (src/routes/receptacles-edit.js + public/rec-edit.js) */
.rec-edit-filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.rec-edit-filters .field { margin: 0; min-width: 150px; }
.rec-edit-filters .rec-edit-q { flex: 1 1 200px; }
.rec-edit-filters .check { padding-bottom: .55rem; }
.rec-edit-tools { margin-bottom: 1rem; }
.rec-edit-count { border-radius: 999px; padding: .15rem .65rem; font-size: .8rem; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.rec-edit-count.is-on { background: #e3f4f7; color: #0b6d7d; border-color: #a9dde6; }
.rec-edit-toolgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem; margin-top: .6rem; }
.rec-edit-tool { display: flex; flex-direction: column; gap: .5rem; border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; background: var(--bg); min-width: 0; }
.rec-edit-tool > .btn { align-self: flex-start; }
.rec-edit-tool-h { font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.rec-edit-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.rec-edit-row > * { flex: 1 1 120px; min-width: 0; }
.rec-edit-row > .muted { flex: 0 0 auto; }
.rec-edit-row [data-set-val] select, .rec-edit-row [data-set-val] input { width: 100%; }
.rec-edit-note { margin: .6rem 0 0; color: var(--success); font-weight: 600; }
.rec-edit-table td { padding-top: .3rem; padding-bottom: .3rem; vertical-align: middle; }
.rec-edit-table input:not([type=checkbox]), .rec-edit-table select { width: 100%; min-width: 90px; box-sizing: border-box; }
.rec-edit-table tr.is-ticked { background: color-mix(in srgb, var(--primary) 6%, transparent); }
.rec-edit-table .is-changed { background: #e3f4f7; border-color: var(--primary); }
.rec-edit-bar { position: sticky; bottom: 0; z-index: 3; display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-top: .75rem; }
.rec-edit-key { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; background: #e3f4f7; border: 1px solid var(--primary); vertical-align: -1px; margin-right: .3rem; }
.rec-review .rec-before { color: var(--muted); text-decoration: line-through; }
.rec-review .rec-after { color: var(--primary); font-weight: 600; }
.rec-review-bad .rec-after { color: var(--danger); }
.rec-review-why { font-size: .8rem; font-weight: 400; color: var(--danger); margin-top: .15rem; }
.rec-panel-head .actions { display: flex; gap: .4rem; flex-wrap: wrap; }
@media screen {
  html[data-theme="dark"] .rec-edit-count.is-on { background: var(--t-teal); color: var(--t-teal-c); border-color: var(--t-teal-b); }
  html[data-theme="dark"] .rec-edit-table .is-changed, html[data-theme="dark"] .rec-edit-key { background: var(--t-teal); border-color: var(--t-teal-b); }
  html[data-theme="dark"] .rec-edit-tool { background: var(--raised); }
}
