:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #16202c;
  --muted: #667085;
  --line: #e3e6ea;
  --brand: #0f172a;
  --accent: #1d6fe0;
  --ok: #17864a;
  --warn: #b7791f;
  --radius: 14px;
  /* on-theme cursor over anything clickable (desktop only) — needle-nose
     pliers, hotspot on the nose tip (3 3). White fill + dark outline so it
     reads on both the light and dark backgrounds. */
  --click-cursor: url("../assets/cursor-pliers.svg") 3 3, pointer;
  /* frosted-glass button/tile fills so the campus photo shows through blank areas */
  --glass: rgba(255, 255, 255, .55);
  --glass-line: rgba(255, 255, 255, .55);
  --accent-glass: rgba(29, 111, 224, .82);
  --brand-glass: rgba(15, 23, 42, .68);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216; --card: #191d23; --ink: #e8ebee;
    --muted: #98a2b3; --line: #2a2f37; --brand: #0b0e12; --accent: #4c9dff;
    --glass: rgba(24, 28, 34, .5);
    --glass-line: rgba(255, 255, 255, .14);
    --accent-glass: rgba(76, 157, 255, .82);
    --brand-glass: rgba(11, 14, 18, .68);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
}
/* Campus building photo behind every screen, held under a scrim so cards and
   loose text stay readable. Fixed pseudo-elements (not background-attachment:
   fixed, which janks on iOS). Dial the scrim alpha to taste. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2;
  background: url("../assets/app-bg.jpg") center center / cover no-repeat;
  transform: scale(1.06); filter: blur(3px) saturate(1.05);
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(to bottom,
    rgba(245, 246, 248, .94), rgba(245, 246, 248, .80) 45%, rgba(245, 246, 248, .72));
}
@media (prefers-color-scheme: dark) {
  body::after {
    background: linear-gradient(to bottom,
      rgba(15, 18, 22, .93), rgba(15, 18, 22, .82) 45%, rgba(15, 18, 22, .74));
  }
}
a { color: var(--accent); text-decoration: none; }
/* needle-nose pliers cursor over every clickable thing (links, tiles, summaries) — buttons
   & co. get it from their own rules; this covers what relies on the UA default */
a[href], summary, [role="button"], .pickrow, input[type="checkbox"], input[type="radio"] {
  cursor: var(--click-cursor);
}
h1 { font-size: 1.3rem; margin: 0 0 .7rem; }
h3 { margin: 1rem 0 .3rem; }
hr { border: none; border-top: 1px solid var(--line); margin: 1.2rem 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* wraps the topbar + the section nav bar so they scroll away and stick back
   together as one unit, instead of each needing its own top offset math */
.chrome { position: sticky; top: 0; z-index: 10; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; padding: .6rem .9rem;
  padding-top: calc(.6rem + env(safe-area-inset-top));
  background: var(--brand-glass); color: #fff;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
/* per-section "log list · calendar" nav (see SECTION_BARS in app.js) — shown
   on every page within a section, not just its landing page */
.section-bar {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .5rem .9rem;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.section-bar[hidden] { display: none; }
/* same two-tone brand scheme as the topbar's "ST. JAMES / Facilities Logbook" */
.section-bar-label { font-weight: 700; color: #00a6e2; }
.section-bar-actions { display: flex; gap: .5rem; }
.section-bar-actions .btn { color: #f5871f; }
.brand {
  color: #f5871f;               /* "Facilities Logbook" — orange */
  font-weight: 700; font-size: 1.2rem; letter-spacing: .02em; line-height: 1.12;
  display: flex; flex-direction: column;
}
.brand-eyebrow {
  font-size: .72rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase;
  color: #00a6e2;               /* "ST. JAMES" — George Brown blue */
}
.topbar-right { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.signed-in {
  font-size: .8rem; color: rgba(255, 255, 255, .85);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw;
}
.icon-btn {
  background: rgba(255,255,255,.12); color: #fff; border: 0; flex: none;
  width: 34px; height: 34px; border-radius: 9px; font-size: 1rem;
  display: grid; place-items: center; cursor: var(--click-cursor);
}
.icon-btn svg { display: block; }
.spin { animation: spin 0.8s linear infinite; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* brief "updating…" toast when a new service worker takes over */
#update-bar {
  position: fixed; left: 0; right: 0;
  bottom: calc(.9rem + env(safe-area-inset-bottom));
  margin: 0 auto; width: max-content; max-width: calc(100% - 1.2rem); z-index: 1200;
  padding: .55rem 1.1rem; border-radius: 999px;
  background: #1f2937; color: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
  font-size: .9rem;
}

main { padding: 1rem; max-width: 820px; margin: 0 auto; }
/* desktop: use more of the screen and scale the type up a touch — the crew
   run this on their laptops too, not just phones */
@media (min-width: 1000px) {
  body { font-size: 16px; }
  main { max-width: 1360px; padding: 1.5rem 2rem; }
  h1 { font-size: 1.5rem; }
  .hubgrid { gap: 1rem; }
  .mainhub { gap: 1rem; min-height: calc(100vh - 7rem); }
  .hubtile .hubtile-name { font-size: 1.15rem; }
}
.loading { padding: 3rem; text-align: center; color: var(--muted); }
.error {
  background: rgba(253, 236, 236, .72); color: #a12; padding: 1rem; border-radius: var(--radius);
  border: 1px solid rgba(193, 57, 43, .35);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
@media (prefers-color-scheme: dark) { .error { background: rgba(58, 30, 30, .66); color: #f3b4b4; } }

.back { display: inline-block; margin-bottom: .6rem; }
.banner {
  background: rgba(183, 121, 31, .8); color: #fff; padding: .6rem .8rem;
  border-radius: 10px; margin-bottom: .8rem; cursor: var(--click-cursor); font-weight: 600;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

/* add-to-home-screen */
.install-bar {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 10px;
  padding: .55rem .7rem; margin-bottom: .8rem; font-weight: 600;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.install-bar a { color: var(--ink); }
.install-actions { display: flex; gap: .4rem; flex-shrink: 0; }
button.sm, .btn.sm { min-height: 34px; padding: .35rem .7rem; border-radius: 8px; font-size: .85rem; }
.installpage h2 { font-size: 1rem; margin: 1.3rem 0 .5rem; }
.install-hero { display: block; margin: .8rem 0 1rem; border-radius: 20px; }
.ok-note { color: #16a34a; font-weight: 600; }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: none; }
.step { display: flex; gap: .7rem; align-items: flex-start; padding: .55rem 0; border-bottom: 1px solid var(--line); line-height: 1.5; }
.step:last-child { border-bottom: 0; }
.step-n {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; font-size: .85rem;
  display: grid; place-items: center;
}
.ios-share { vertical-align: -5px; margin: 0 2px; }
.installpage details { margin-top: 1.2rem; }
.installpage summary { cursor: var(--click-cursor); color: var(--accent); font-weight: 600; padding: .4rem 0; }

/* landing / sign-in */
.landing {
  position: relative; margin: -1rem -1rem 0; padding: 2rem 1.25rem;
  min-height: calc(100vh - 120px); display: grid; place-items: center;
}
.landing-bg {
  position: absolute; inset: 0; z-index: 0; overflow: hidden;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr;
}
.landing-bg span { background-size: cover; background-position: center; }
.landing-bg::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,14,22,.74), rgba(10,14,22,.93));
}
.landing-card {
  position: relative; z-index: 1; width: 100%; max-width: 360px;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 18px;
  padding: 1.6rem 1.35rem 1.4rem;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.55);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.landing-icon { display: block; border-radius: 15px; }
.landing-org { font-weight: 800; font-size: 1.08rem; letter-spacing: -.01em; margin: .85rem 0 0; }
.landing-sub { font-size: .9rem; font-weight: 500; color: var(--muted); margin: .15rem 0 1.1rem; }
.landing .loginbox { max-width: none; }
.landing-install { display: inline-block; margin-top: 1rem; font-size: .85rem; }
.signin-msg { margin: .3rem 0 0; }
/* required-field validation (requireFields helper) */
.signin-msg.form-error { color: #d63a2e; font-weight: 700; }
.field-missing { outline: 2px solid #d63a2e; outline-offset: 3px; border-radius: 10px; }

/* signed-in hub */
.hub-hi { color: var(--muted); font-size: .9rem; margin: .2rem 0 1rem; }
/* main menu (#/) only: a 2×3 grid of SQUARE tiles, vertically centred */
.mainhub {
  display: flex; flex-direction: column; gap: .55rem;
  min-height: calc(100dvh - 6.5rem);
}
.mainhub > *:not(.hubgrid) { flex: 0 0 auto; }
.mainhub > .hubgrid {
  flex: 0 0 auto; margin: auto; max-width: 30rem; grid-auto-rows: auto;
}
.mainhub .hubgrid > .hubtile { aspect-ratio: 1 / 1; }

/* used by the main menu and the EBI landing — normal-sized tiles by default */
.hubgrid {
  display: grid; gap: .55rem; align-items: stretch;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(10.25rem, auto);
}
.hubtile {
  display: flex; flex-direction: column; align-items: flex-start; gap: .1rem;
  width: auto; min-width: 0; max-width: none;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: var(--radius);
  padding: .85rem .95rem 1rem; color: var(--ink);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}

/* photo-backed hub tile (e.g. HVAC PM) — dark scrim keeps the label readable */
.hubtile.photo {
  background: var(--glass) center/cover no-repeat;
  position: relative; overflow: hidden;
  border-color: rgba(255, 255, 255, .28);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.hubtile.photo::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(155deg, rgba(14, 19, 27, .30), rgba(14, 19, 27, .80));
}
.hubtile.photo > * { position: relative; z-index: 1; }
.hubtile.photo .hubtile-name { color: #fff; }
.hubtile.photo .hubtile-sub { color: rgba(255, 255, 255, .82); }

.hubtile-name { font-weight: 700; font-size: 1.05rem; }
.hubtile-sub { font-size: .82rem; color: var(--muted); }

/* non-centred tile buttons: pin the label group to the bottom-left of the
   button (an image strip, where present, stays at the top) */
.hubtile > .hubtile-name,
.tile > .tile-name,
.hubtile.ebitile > .ebitile-body { margin-top: auto; }

/* alternating brand-coloured outlines on the hub tiles (left column = blue like
   "ST. JAMES", right column = orange like "Facilities Logbook") */
.hubgrid > .hubtile:nth-child(odd)  { border: 1.5px solid #00a6e2; }
.hubgrid > .hubtile:nth-child(even) { border: 1.5px solid #f5871f; }

/* subtle per-section colour theme — the pages behind each hub tile pick up its
   outline colour (blue = HVAC PM / Unrequested Work / Work Orders / EBI,
   orange = HVAC Ordering / General Deficiencies / Parts & Tools). Re-points the
   accent tokens so links, primary buttons, chips, checkboxes etc. follow. */
#app[data-theme="blue"] {
  --section: #00a6e2; --accent: #00a6e2; --accent-glass: rgba(0, 122, 168, .92);
  background: rgba(0, 166, 226, .05);
}
#app[data-theme="orange"] {
  --section: #f5871f; --accent: #e0770c; --accent-glass: rgba(193, 105, 18, .95);
  background: rgba(245, 135, 31, .06);
}
#app[data-theme] .back { color: var(--section); }
#app[data-theme] > section > h1 { border-bottom: 2px solid var(--section); padding-bottom: .25rem; }
#app[data-theme] > section > .ebi-head { border-bottom: 2px solid var(--section); padding-bottom: .35rem; }
#app[data-theme] > section > .ebi-head h1 { border-bottom: 0; padding-bottom: 0; }

/* single-select list — column style (fallback for any non-chip picklist) */
.picklist { display: flex; flex-direction: column; }
.pickrow {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem .2rem; border-top: 1px solid var(--line); cursor: var(--click-cursor);
}
.pickrow:first-child { border-top: 0; }
.pickrow span { font-weight: 600; }

/* admin per-unit checklist trimmer (#/unit/:id/checklist) */
.checklist-customize h3 {
  margin: 1rem 0 .1rem; font-size: .82rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted);
}
.checklist-customize h3:first-child { margin-top: 0; }
.checklist-customize .pickrow span { font-weight: 500; }
.checklist-customize input:not(:checked) ~ span { color: var(--muted); text-decoration: line-through; }
.pickrow.techrow span { flex: 1; }

/* single-select list — chip style (building / floor / labour / equipment):
   wraps across the width so long lists don't need much scrolling */
.picklist.chips { flex-direction: row; flex-wrap: wrap; gap: .4rem; padding: .2rem 0; }
.picklist.chips .pickrow {
  border: 1px solid var(--glass-line); border-radius: 10px;
  padding: .45rem .7rem; gap: .4rem; background: var(--glass);
  font-size: .92rem; border-top: 1px solid var(--glass-line);
}
.picklist.chips .pickrow .chk { display: none; }
.picklist.chips .pickrow.on {
  background: var(--accent-glass); border-color: transparent; color: #fff;
}
.chip-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .15);
}
.picklist.chips .pickrow.on .chip-dot { box-shadow: 0 0 0 1px rgba(255, 255, 255, .55); }

/* section header list button goes green while its list has open/unacknowledged
   items (Parts "Requests", EBI "All Deficiencies" / "All Bypasses") */
.btn.list-open { background: var(--ok); border-color: transparent; color: #fff; font-weight: 700; }

/* a part/tool request marked "ordered" — dim the row, keep the "ordered for" tag */
.loglist li.part-ordered a > span:not(.tag) { opacity: .45; }

/* "additional techs" — pick names as chips; each ticked name gets its own
   labour-time chip picker listed below */
.picklist.chips.techchips .pickrow.techrow span { flex: none; }
.tech-hours-list { display: flex; flex-direction: column; gap: .6rem; margin-top: .6rem; }
.tech-hours-row { border-left: 3px solid var(--glass-line); padding-left: .6rem; }
.tech-hours-name {
  display: block; font-weight: 700; font-size: .8rem; color: var(--muted);
  margin-bottom: .25rem;
}

/* sum-select labour chips: running total sits under the wrapped chips */
.sumwrap { display: flex; flex-direction: column; gap: .35rem; }
.sum-total { font-weight: 700; color: var(--accent); min-height: 1.2em; }
.pl-legend {
  display: flex; flex-wrap: wrap; gap: .3rem .9rem;
  margin: 0 0 .5rem; font-size: .76rem; color: var(--muted);
}
.pl-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.uwform .row.textrow { grid-template-columns: 1fr; }
.uwform textarea, .uwform input[type="text"] { width: 100%; }

/* unit grid */
.grid {
  display: grid; gap: .8rem;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.tile {
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: var(--radius);
  overflow: hidden; color: var(--ink); display: flex; flex-direction: column;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
/* the image/icon strip keeps a solid fill — only the blank name/loc area goes glass */
.tile-img {
  aspect-ratio: 4/3; background: var(--glass) center/cover no-repeat;
  display: grid; place-items: center;
}
.tile-icon { width: 46%; opacity: .8; }
.tile-name { font-weight: 700; padding: .5rem .6rem 0; }
.tile-loc { font-size: .8rem; color: var(--muted); padding: .1rem .6rem .6rem; }

/* unit header */
.unit-head { display: flex; gap: .9rem; align-items: center; margin-bottom: 1rem; }
.unit-photo {
  width: 96px; height: 96px; object-fit: cover; border-radius: 12px;
  background: var(--glass); flex: none; cursor: zoom-in;
}

/* "on file" card — carried spec (filter size/qty/MERV) for ordering */
.speccard {
  border: 1px solid var(--glass-line); background: var(--glass);
  border-radius: var(--radius); padding: .7rem .9rem; margin-bottom: 1rem;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.speccard.muted { color: var(--muted); font-size: .9rem; }
.speccard-h {
  font-weight: 700; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); margin-bottom: .4rem;
}
/* building header row: title left, "Filters" button pinned right */
.bld-head { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.bld-head h1 { margin: 0; }

/* per-building filter roll-up (#/building/:id/filters) */
.bld-filters { display: flex; flex-direction: column; gap: .5rem; margin: .6rem 0 1rem; }
.bf-unit {
  border: 1px solid var(--glass-line); border-left: 3px solid #00a6e2;
  border-radius: 10px; padding: .5rem .75rem; background: var(--glass);
}
.bf-unit h3 { margin: 0 0 .2rem; font-size: .95rem; }
.bf-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .15rem; }
.bf-lines li { font-size: .92rem; }
.bf-kind { display: inline-block; min-width: 4.5rem; font-weight: 700; }
/* pleated / bag / box colour key — used on per-unit line labels and the
   totals cards' left accent */
.bf-k-pleated { color: hsl(205 62% 44%); }
.bf-k-bag     { color: hsl(150 55% 36%); }
.bf-k-box     { color: hsl(32 78% 42%); }
@media (prefers-color-scheme: dark) {
  .bf-k-pleated { color: hsl(205 70% 66%); }
  .bf-k-bag     { color: hsl(150 55% 60%); }
  .bf-k-box     { color: hsl(35 80% 62%); }
}

.bf-totals { margin-top: 1.2rem; }
.bf-totals h3 { font-size: 1rem; margin: 0 0 .4rem; }
/* one card per filter type in the totals */
.bf-tk {
  border: 1px solid var(--glass-line); border-left: 4px solid var(--muted);
  border-radius: 10px; padding: .55rem .8rem; margin-bottom: .6rem; background: var(--glass);
}
.bf-tk.bf-k-pleated { border-left-color: hsl(205 62% 50%); }
.bf-tk.bf-k-bag     { border-left-color: hsl(150 55% 42%); }
.bf-tk.bf-k-box     { border-left-color: hsl(32 78% 50%); }
.bf-tk h4 { margin: 0 0 .25rem; font-size: .95rem; }
.bf-tk table.kv { margin: 0; }
.bf-tk .bf-sub th, .bf-tk .bf-sub td {
  border-top: 1.5px solid var(--line); padding-top: .4rem; font-weight: 700;
}
.bf-grand {
  margin-top: .9rem; padding: .6rem .8rem; border-radius: 10px;
  background: var(--accent-glass); color: #fff; font-size: 1rem;
}

.speccard-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: .3rem 0; }
.speccard-row > span:first-child { color: var(--muted); padding-top: .15rem; }
.speccard-row.edit input { flex: 1 1 9rem; max-width: 60%; }
.speccard-h { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.speccard-h .btn.sm { text-transform: none; letter-spacing: 0; }
.speccard-f { font-size: .76rem; color: var(--muted); margin-top: .55rem; display: flex; gap: .4rem; }

/* structured filter/belt/grease spec value — one labelled line per size */
.spec-lines { display: flex; flex-direction: column; gap: .2rem; }
.spec-line { font-weight: 700; }
.speccard-row .spec-lines { align-items: flex-end; text-align: right; }
/* filter / belt size, colour-coded (hash-to-hue, --rowhue set inline by
   sizeChip() in app.js) so the same size reads the same everywhere it's listed */
.size-chip {
  display: inline-block; padding: 0 .4rem; border-radius: 6px;
  background: hsl(var(--rowhue, 212) 75% 45% / .16);
  color: hsl(var(--rowhue, 212) 60% 34%);
  font-weight: 700; letter-spacing: .01em;
}
@media (prefers-color-scheme: dark) {
  .size-chip { background: hsl(var(--rowhue, 212) 70% 60% / .20); color: hsl(var(--rowhue, 212) 75% 76%); }
}

/* HVAC Ordering form — small qty/size/MERV cells side by side */
.spec-grid { display: flex; flex-wrap: wrap; gap: .6rem .8rem; }
.spec-cell { display: flex; flex-direction: column; gap: .2rem; flex: 1 1 6rem; }
.spec-cell span { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.spec-cell input { width: 100%; }

/* form */
.logform fieldset {
  border: 1px solid var(--glass-line); border-radius: var(--radius);
  margin: 0 0 .9rem; padding: .4rem .9rem .9rem; background: var(--glass);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.logform legend { font-weight: 700; padding: 0 .4rem; }

/* PM checklist: colour each section by its title so the tick-box rows are
   easier to scan — "Filters" one hue, "Airside" another, etc. --rowhue is set
   per <fieldset> in unitForm(). */
.pm-checklist fieldset { border-left: 4px solid hsl(var(--rowhue, 212) 58% 52%); }
.pm-checklist legend { color: hsl(var(--rowhue, 212) 50% 38%); }
@media (prefers-color-scheme: dark) {
  .pm-checklist legend { color: hsl(var(--rowhue, 212) 62% 72%); }
}

/* one checklist row: task | control | comment.
   Phone: task + control on line 1, comment wraps full-width below.
   >=620px: all three inline like a table row. */
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .4rem .7rem;
  padding: .6rem 0;
  border-top: 1px solid var(--line);
}
.row:first-of-type { border-top: 0; }

/* PM checklist rows: hue-tinted card per section + zebra so adjacent rows
   read apart at a glance. */
.pm-checklist .row {
  padding: .55rem .6rem;
  margin-bottom: .3rem;
  border-top: 0;
  border-radius: 8px;
  border-left: 3px solid hsl(var(--rowhue, 212) 55% 55%);
  background: hsl(var(--rowhue, 212) 60% 50% / .06);
}
.pm-checklist .row:nth-of-type(even) { background: hsl(var(--rowhue, 212) 55% 48% / .13); }
@media (prefers-color-scheme: dark) {
  .pm-checklist .row { background: hsl(var(--rowhue, 212) 55% 55% / .10); }
  .pm-checklist .row:nth-of-type(even) { background: hsl(var(--rowhue, 212) 55% 55% / .18); }
}
.row .task { font-weight: 600; }
.row .cmt { grid-column: 1 / -1; }
.chk {
  width: 24px; height: 24px; flex: none; margin: 0;
  accent-color: var(--accent); cursor: var(--click-cursor);
}
/* primary control + N/A checkbox, sitting in the row's middle cell */
.marks { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; justify-content: flex-end; }
.mk { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; color: var(--muted); cursor: var(--click-cursor); }
.mk.na .chk { accent-color: var(--muted); }
.numwrap { display: flex; align-items: center; gap: .4rem; }
.numwrap input { width: 6.5rem; }
.unit { color: var(--muted); }
.textrow, .photorow { grid-template-columns: 1fr; }
.textrow .task, .photorow .task { margin-bottom: .3rem; }

/* single-select segmented control (e.g. VFD status) */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button {
  border: 0; border-radius: 0; min-height: 40px; padding: .45rem .9rem;
  background: var(--glass); color: var(--ink); font-size: .92rem;
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-glass); color: #fff; font-weight: 600; }

@media (min-width: 620px) {
  .row { grid-template-columns: 220px auto 1fr; }
  .row.textrow { grid-template-columns: 220px 1fr; }
  .row.photorow { grid-template-columns: 220px 1fr; }
  .row .cmt { grid-column: auto; }
  .marks { justify-content: flex-start; }
}
input, textarea, select {
  font: inherit; color: var(--ink); background: var(--glass);
  border: 1px solid var(--glass-line); border-radius: 10px; padding: .55rem .6rem; width: 100%;
}
input[type="file"] { padding: .4rem; }
textarea { resize: vertical; }

.shots { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.shots img {
  width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line);
  cursor: zoom-in;
}

/* work order: issuer vs tech authored blocks (notes + photos, attributed) */
.wo-authored {
  margin: .9rem 0; padding: .7rem .9rem; border-radius: var(--radius);
  border: 1px solid var(--glass-line); border-left: 4px solid hsl(212 58% 52%);
  background: hsl(212 60% 50% / .05);
}
.wo-authored + .wo-authored { border-left-color: hsl(150 52% 44%); background: hsl(150 55% 45% / .06); }
.wo-authored h3 { margin: 0 0 .1rem; font-size: .9rem; }
.wo-authored .muted.small { display: block; margin-bottom: .4rem; }
.wo-authored-note { margin: .2rem 0 .3rem; white-space: pre-wrap; }
.wo-context { margin-bottom: 1rem; }
.wo-issuer-note, .wo-issuer-shots { margin-top: .5rem; }
.wo-issuer-note p { margin: .2rem 0 0; white-space: pre-wrap; }

/* full-screen photo viewer */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: rgba(0, 0, 0, .92);
  cursor: zoom-out; -webkit-tap-highlight-color: transparent;
  touch-action: none; overflow: hidden;
}
.lightbox.zoomed { cursor: grab; }
.lightbox.zoomed:active { cursor: grabbing; }
.lb-img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 6px; box-shadow: 0 10px 50px rgba(0, 0, 0, .55);
  touch-action: none; will-change: transform;
  user-select: none; -webkit-user-select: none; -webkit-user-drag: none;
}
.lb-close {
  position: fixed; top: max(.6rem, env(safe-area-inset-top)); right: .8rem;
  width: 2.4rem; height: 2.4rem; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .16); color: #fff;
  font-size: 1rem; line-height: 1; cursor: var(--click-cursor);
}
html.lb-open, html.lb-open body { overflow: hidden; }
@media (prefers-reduced-motion: no-preference) {
  .lightbox { animation: lb-fade .12s ease-out; }
  @keyframes lb-fade { from { opacity: 0; } to { opacity: 1; } }
}

.formbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
/* every action button on a page is the same width (shares the row equally,
   wraps on narrow screens); capped so a lone button doesn't span the page */
.formbar > button,
.formbar > .btn {
  flex: 0 1 auto; min-width: 7.5rem;
  text-align: center; justify-content: center;
}
button, .btn {
  font: inherit; cursor: var(--click-cursor); border-radius: 10px; padding: .5rem .85rem;
  border: 1px solid var(--glass-line); background: var(--glass); color: var(--ink); min-height: 40px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.primary { background: var(--accent-glass); border-color: transparent; color: #fff; font-weight: 600; }
.ghost { background: transparent; }
.danger { background: transparent; border-color: #c0392b; color: #c0392b; }
button:disabled { opacity: .6; }

/* lists / tables — each row is its own card with a colour accent hashed from
   its own label (--rowhue, set inline by logLi() in app.js: same unit/part/
   title text always gets the same colour) so a long list is easy to scan and
   tell rows apart, instead of a bare hairline between them. Rows with no hue
   given (a handful of admin/picker lists) fall back to one neutral tone. */
.loglist { list-style: none; padding: 0; margin: .6rem 0 0; display: flex; flex-direction: column; gap: .5rem; }
.loglist li {
  --rowhue: 212;
  border: 1px solid var(--line);
  border-left: 5px solid hsl(var(--rowhue) 60% 45%);
  border-radius: 10px;
  background: hsl(var(--rowhue) 75% 50% / .08);
  overflow: hidden;
}
@media (prefers-color-scheme: dark) {
  .loglist li { border-left-color: hsl(var(--rowhue) 70% 64%); background: hsl(var(--rowhue) 70% 55% / .12); }
}
.loglist a {
  display: flex; gap: .7rem; align-items: center; flex-wrap: wrap;
  padding: .75rem .8rem; color: var(--ink);
}
.tag {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
  padding: .1rem .45rem; border-radius: 6px; background: var(--line); color: var(--muted);
}
.tag.ok { background: #dcf1e4; color: var(--ok); }
@media (prefers-color-scheme: dark) { .tag.ok { background: #14351f; } }
.tag.warn { background: #fdf0dc; color: var(--warn); }
@media (prefers-color-scheme: dark) { .tag.warn { background: #3a2e17; color: #e5b567; } }
.tag.flag { background: var(--warn); color: #fff; font-weight: 700; }
.tag.urgent { background: #d63a2e; color: #fff; font-weight: 700; }
.tag.reject { background: #f7d9d5; color: #b23b2c; }
@media (prefers-color-scheme: dark) { .tag.reject { background: #3a201c; color: #e79a8e; } }
.wo-new { display: inline-block; margin: .2rem 0 .4rem; }
.hub-badge {
  position: absolute; top: .5rem; right: .5rem; z-index: 3;
  min-width: 1.4rem; height: 1.4rem; padding: 0 .35rem;
  border-radius: 999px; background: #d63a2e; color: #fff;
  font-size: .8rem; font-weight: 800; line-height: 1;
  display: grid; place-items: center;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .4);
}
.loglist li.wo-unseen { border-left-color: #d63a2e; }
.loglist li.wo-urgent { border-left-color: #d63a2e; border-left-width: 7px; background: rgba(214, 58, 46, .09); }

/* work-order intake: "urgent" toggle */
.urgent-check { display: flex; align-items: center; gap: .6rem; padding: .3rem .2rem; cursor: var(--click-cursor); }
.urgent-check input { width: 22px; height: 22px; flex: none; accent-color: #d63a2e; margin: 0; }

/* "re-use a past part" recall search */
.recall { margin: 0 0 .9rem; }
.recall > .task { display: block; margin-bottom: .3rem; }
.recall input { width: 100%; }
.recall-results {
  margin-top: .2rem; border: 1px solid var(--glass-line); border-radius: 10px;
  background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  max-height: 15rem; overflow-y: auto;
}
.recall-results li { border-bottom: 1px solid var(--glass-line); }
.recall-results li:last-child { border-bottom: 0; }
.recall-hit {
  display: flex; gap: .6rem; align-items: center; width: 100%;
  padding: .6rem .7rem; background: none; border: 0; text-align: left;
  color: var(--ink); font: inherit; cursor: var(--click-cursor);
}
.recall-hit:hover, .recall-hit:focus-visible { background: var(--accent-glass); color: #fff; }
.recall-hit span:first-child { font-weight: 600; flex: 1; }

/* "flag for follow-up" toggle button (PM log form + admin log view) */
.flagbtn { border-color: var(--warn); color: var(--warn); }
.flagbtn.on { background: var(--warn); border-color: var(--warn); color: #fff; }

/* Honeywell EBI section */
.hubtile.ebitile { padding: 0; overflow: hidden; }
.ebitile-pic {
  height: 74px; background: var(--glass) center/cover no-repeat;
  border-bottom: 1px solid var(--glass-line);
}
.ebitile-body { padding: .75rem .95rem .9rem; display: flex; flex-direction: column; gap: .1rem; }
.ebi-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.ebi-head h1 { margin-bottom: 0; }
.head-btns { display: flex; gap: .4rem; flex-wrap: wrap; }
.ebi-resolved { margin-top: 1.2rem; }
.ebi-resolved summary { cursor: var(--click-cursor); color: var(--muted); font-weight: 600; padding: .4rem 0; }
.addunit-btn { display: inline-block; margin-top: 1rem; }

.notif-box { margin-top: .8rem; display: flex; flex-direction: column; gap: .35rem; align-items: flex-start; }
.notif-box .btn { width: 100%; text-align: center; }
.notif-box p { margin: 0; }
.notif-help { border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: 8px; padding: .5rem .7rem; }
.notif-help ol { margin: .3rem 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .15rem; }
.notif-help p { margin: .15rem 0; }

.pw-details { margin-top: .8rem; }
.pw-details summary { cursor: var(--click-cursor); color: var(--accent); font-weight: 600; padding: .4rem 0; }
.pw-details .loginbox { margin-top: .4rem; }
.show-pass { display: flex; align-items: center; gap: .45rem; font-size: .9rem; color: var(--muted); cursor: var(--click-cursor); }
.show-pass input { width: 18px; height: 18px; margin: 0; flex: none; }
.errrow { display: flex; flex-direction: column; gap: .15rem; padding: .55rem .2rem; width: 100%; }
.errrow .small { word-break: break-word; }

table.kv { width: 100%; border-collapse: collapse; margin-top: .8rem; }
table.kv th, table.kv td {
  text-align: left; padding: .55rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top;
}
table.kv tbody th { font-weight: 600; color: var(--muted); width: 40%; }
table.kv thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
table.kv td.mark {
  min-width: 3.5rem; text-align: center; font-weight: 700;
  color: var(--ok); white-space: nowrap;
}
table.kv td.mark.warn { color: var(--warn); }
table.kv td.cmt { white-space: pre-wrap; }

.loginbox { display: grid; gap: .5rem; max-width: 320px; }
.notes p { white-space: pre-wrap; }

/* calendar */
.cal-head { display: flex; align-items: center; gap: .4rem; margin-bottom: .7rem; }
.cal-head select { flex: 1; padding: .55rem .4rem; }
.cal-nav {
  min-height: 44px; padding: .4rem .8rem; font-size: 1.2rem; line-height: 1;
  background: var(--glass);
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; touch-action: pan-y; }
.cal-dow {
  text-align: center; font-size: .68rem; text-transform: uppercase;
  letter-spacing: .03em; color: var(--muted); padding: .25rem 0;
}
.cal-cell {
  position: relative;
  min-height: 66px; border: 1px solid var(--glass-line); border-radius: 8px;
  padding: 3px 4px; background: var(--glass); color: var(--ink);
  display: flex; flex-direction: column; gap: 1px; overflow: hidden;
}
.cal-flag {
  position: absolute; top: 4px; right: 4px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn); box-shadow: 0 0 0 2px var(--bg);
}
.cal-cell.empty { background: transparent; border: 0; }
.cal-cell.has { border-color: var(--accent); }
.cal-cell.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-num { font-size: .72rem; font-weight: 600; color: var(--muted); }
.cal-cell.today .cal-num { color: var(--accent); }
.cal-u {
  font-size: .6rem; line-height: 1.25; background: var(--accent); color: #fff;
  border-radius: 3px; padding: 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-more { font-size: .58rem; color: var(--muted); }
