:root {
  --paper: #f3f6f6;
  --surface: #ffffff;
  --sunk: #e6ecec;
  --ink: #1f2a37;
  --ink-2: #4a5563;
  --ink-3: #66707e;
  --line: #d3dcdd;
  --accent: #4a5b72;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ef;
  --teal: #60a7a1;
  --teal-ink: #2f6f69;
  --orange: #f15a29;
  --amber: #f7941d;
  --brand-stripe: linear-gradient(90deg, #60a7a1 0 25%, #4a5b72 25% 50%, #f15a29 50% 75%, #f7941d 75% 100%);
  --chart: #60a7a1;
  --p1: #a3211a; --p1-soft: #fbe9e7;
  --p2: #9a5205; --p2-soft: #fbefdf;
  --p3: #4a5b72; --p3-soft: #e6ebf1;
  --p4: #56615e; --p4-soft: #ebe8e0;
  --good: #22683a; --good-soft: #e3f1e6;
  --radius: 8px;
  --font: Poppins, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font); }
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.08rem; }
h3 { font-size: 0.95rem; }
p { margin: 0 0 0.6rem; }
a { color: var(--accent); }
ul, ol { margin: 0; padding-left: 1.2rem; }
.muted { color: var(--ink-2); }
.small { font-size: 0.85rem; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 0.75rem; }
.stack-lg > * + * { margin-top: 1.1rem; }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Buttons and inputs */
button, .btn {
  font: inherit; font-weight: 600; font-size: 0.9rem; padding: 0.5rem 0.85rem; min-height: 40px;
  border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
}
button:hover, .btn:hover { filter: brightness(1.12); }
button.ghost, .btn.ghost { background: var(--surface); color: var(--accent); border-color: var(--line); }
button.ghost:hover, .btn.ghost:hover { background: var(--accent-soft); filter: none; }
button.danger { background: var(--p1); border-color: var(--p1); }
button.tiny { min-height: 32px; padding: 0.2rem 0.55rem; font-size: 0.82rem; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
label { display: block; font-weight: 600; font-size: 0.85rem; }
label.check { display: flex; gap: 0.5rem; align-items: center; font-weight: 500; font-size: 0.92rem; }
input, select, textarea {
  font: inherit; font-weight: 400; width: 100%; margin-top: 0.2rem; padding: 0.5rem 0.6rem; min-height: 40px;
  border: 1px solid #b9b5a9; border-radius: 6px; background: var(--surface); color: var(--ink);
}
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; margin: 0; flex: none; accent-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
.form-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }
.form-grid .full { grid-column: 1 / -1; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; min-width: 0; }
.card > h2:first-child, .card > .spread:first-child { margin-bottom: 0.65rem; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.grid-main { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1.75fr) minmax(280px, 1fr); align-items: start; }

/* Priority and status tags always carry words, never colour alone */
.tag { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.08rem 0.45rem; border-radius: 4px; font-size: 0.76rem; font-weight: 650; white-space: nowrap; }
.p1 { background: var(--p1); color: #fff; }
.p2 { background: var(--p2-soft); color: var(--p2); box-shadow: inset 0 0 0 1px var(--p2); }
.p3 { background: var(--p3-soft); color: var(--p3); }
.p4 { background: var(--p4-soft); color: var(--p4); }
.tag.status { background: var(--sunk); color: var(--ink-2); }
.tag.warn { background: var(--p2-soft); color: var(--p2); }
.tag.bad { background: var(--p1-soft); color: var(--p1); }
.tag.good { background: var(--good-soft); color: var(--good); }

/* Banners */
.banner { border-radius: var(--radius); padding: 0.7rem 0.95rem; border: 1px solid var(--line); background: var(--surface); }
.banner.warn { background: var(--p2-soft); border-color: #e3c28f; }
.banner.bad { background: var(--p1-soft); border-color: #e7b1ac; }
.banner.info { background: var(--accent-soft); border-color: #a9d0cc; }
.banner.good { background: var(--good-soft); border-color: #b5d8bd; }
.sample { background: var(--ink); color: #fff; font-size: 0.8rem; padding: 0.25rem 1rem; text-align: center; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -0.2rem; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th { text-align: left; font-size: 0.75rem; font-weight: 650; color: var(--ink-2); padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th.right { text-align: right; }
td { padding: 0.5rem; border-bottom: 1px solid #ece9e1; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.link { cursor: pointer; }
tr.link:hover td { background: #f8f6f1; }
td a.title { font-weight: 600; text-decoration: none; color: var(--ink); }
td a.title:hover { text-decoration: underline; }

/* Stat tiles */
.tiles { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem 0.9rem; min-width: 0; }
.tile .value { font-size: 1.65rem; font-weight: 680; font-variant-numeric: tabular-nums; line-height: 1.2; letter-spacing: -0.02em; }
.tile .label { font-size: 0.8rem; color: var(--ink-2); }
.tile .sub { font-size: 0.75rem; color: var(--ink-3); }

/* ---------- Member page ---------- */
.member-header { background: #fff; color: var(--ink); padding: 0.9rem 1rem 1rem; border-bottom: 5px solid transparent; border-image: var(--brand-stripe) 1; }
.member-header .logo { height: 46px; width: auto; display: block; margin-bottom: 0.35rem; }
.member-header .inner, .member-main { max-width: 900px; margin: 0 auto; }
.member-header h1 { color: var(--accent); }
.member-header a { color: var(--accent); font-weight: 600; }
.member-main { padding: 1rem; display: grid; gap: 1rem; grid-template-columns: minmax(0, 1.7fr) minmax(240px, 1fr); align-items: start; }
.chat-log { display: flex; flex-direction: column; gap: 0.6rem; }
.msg { max-width: 92%; padding: 0.55rem 0.8rem; border-radius: 10px; background: var(--sunk); }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; }
.script { border: 2px solid var(--p1); background: var(--p1-soft); border-radius: var(--radius); padding: 0.75rem 0.9rem; }
.script h3 { color: var(--p1); margin-bottom: 0.25rem; font-size: 1.02rem; }
.call-now { background: var(--p1); border-color: var(--p1); font-size: 1.05rem; margin-top: 0.4rem; width: 100%; }
.phone-big { font-size: 1.3rem; font-weight: 700; text-decoration: none; display: block; color: var(--accent); }
.refcode { font-size: 1.55rem; font-weight: 700; letter-spacing: 0.05em; font-variant-numeric: tabular-nums; }

/* ---------- Staff app ---------- */
.shell { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: 100vh; }
.side { background: #33404f; color: #e3e8ee; border-top: 5px solid transparent; border-image: var(--brand-stripe) 1; padding: 1rem 0.7rem; display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { font-weight: 680; font-size: 1rem; color: #fff; padding: 0 0.5rem; line-height: 1.25; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: #d3dae3; text-decoration: none; padding: 0.42rem 0.55rem; border-radius: 6px; font-weight: 550; display: flex; justify-content: space-between; align-items: center; }
.side nav a:hover { background: #45546a; color: #fff; }
.side nav a.active { background: #f3f6f6; color: #33404f; box-shadow: inset 4px 0 0 var(--teal); }
.side .count { background: var(--p1); color: #fff; font-size: 0.72rem; font-weight: 700; border-radius: 10px; padding: 0 0.42rem; }
.side .who { margin-top: auto; font-size: 0.82rem; padding: 0 0.5rem; }
.side .who strong { color: #fff; display: block; }
.side .who button { margin-top: 0.4rem; background: transparent; border-color: #6a7a90; color: #e3e8ee; min-height: 32px; font-size: 0.8rem; }
.main { padding: 1.1rem 1.4rem 3rem; min-width: 0; max-width: 1240px; }
.page-head { display: flex; gap: 0.75rem; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; margin-bottom: 1rem; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }

.filters { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: end; }
.filters label { flex: 1 1 130px; max-width: 200px; }
.filters label.grow { flex: 2 1 200px; max-width: 340px; }

.alert-item { display: flex; gap: 0.6rem; justify-content: space-between; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid #ece9e1; }
.alert-item:last-child { border-bottom: 0; }
.statement { font-size: 1.04rem; border-left: 3px solid var(--accent); padding: 0.1rem 0 0.1rem 0.75rem; white-space: pre-wrap; overflow-wrap: anywhere; }
dl.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.25rem 0.8rem; margin: 0; font-size: 0.9rem; }
dl.facts dt { color: var(--ink-2); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 0.85rem; }
.timeline li { padding: 0.32rem 0 0.32rem 0.8rem; border-left: 2px solid var(--line); }

/* Charts: single series in one hue, thin marks, rounded data end, direct values */
.bars { display: grid; gap: 0.3rem; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 165px) minmax(0, 1fr) auto; gap: 0.55rem; align-items: center; font-size: 0.86rem; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 22px; display: flex; align-items: center; }
.bar { height: 12px; min-width: 2px; background: var(--chart); border-radius: 0 4px 4px 0; }
.bar-row:hover .bar { filter: brightness(0.85); }
.bar-row .val { font-variant-numeric: tabular-nums; color: var(--ink); min-width: 3.4rem; text-align: right; }
.cols { display: flex; align-items: flex-end; gap: 2px; height: 130px; border-bottom: 1px solid var(--line); padding-top: 18px; }
.col-wrap { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; cursor: default; }
.col-wrap:hover .col { filter: brightness(0.85); }
.col { width: min(100%, 28px); background: var(--chart); border-radius: 4px 4px 0 0; min-height: 1px; }
.col-val { font-size: 0.72rem; color: var(--ink-2); font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.col-labels { display: flex; gap: 2px; margin-top: 3px; }
.col-labels span { flex: 1 1 0; min-width: 0; text-align: center; font-size: 0.72rem; color: var(--ink-3); overflow: hidden; }
.meter { position: relative; height: 14px; background: var(--sunk); border-radius: 4px; margin: 0.3rem 0 0.2rem; }
.meter .fill { height: 100%; background: var(--chart); border-radius: 4px; max-width: 100%; }
.meter .fill.over { background: var(--p1); }
.meter .tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }
#tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: #fff; font-size: 0.8rem; padding: 0.3rem 0.5rem; border-radius: 5px; max-width: 260px; display: none; }
details.data { margin-top: 0.5rem; font-size: 0.85rem; }
details.data summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.metric-met { color: var(--good); font-weight: 650; }
.metric-miss { color: var(--p1); font-weight: 650; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; width: min(480px, calc(100vw - 32px)); color: var(--ink); }
dialog::backdrop { background: rgb(20 30 28 / 0.45); }
#toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 0.55rem 0.95rem; border-radius: 6px; z-index: 60; display: none; max-width: calc(100vw - 32px); }
#toast.err { background: var(--p1); }
.print-only { display: none; }
.plan-steps { font-size: 0.84rem; color: var(--ink-2); margin-top: 0.2rem; }
.checkbox-print { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  /* Phone: a slim top bar with the menu button; the full menu opens on tap (Sam, 2026-11-14). */
  .side { position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 0.45rem 0.7rem; gap: 0.5rem; }
  .side .brand { flex: 1; font-size: .95rem; }
  .side .brand small { display: none; }
  .side .menu-btn { display: inline-flex; }
  .side nav, .side .who { display: none; width: 100%; }
  .side.open nav { display: flex; flex-direction: column; }
  .side.open .who { display: block; margin: .4rem 0 .2rem; }
  .side nav a { padding: .7rem .6rem; font-size: 1rem; }
  /* The print bar stays off the staff side on phones: printing is under More. */
  body.staff-app .pt-bar { display: none !important; }
  .main { padding: 0.9rem 1rem 3rem; }
  .grid-main, .grid-2, .member-main { grid-template-columns: minmax(0, 1fr); }
  .hide-sm { display: none; }
  .filters label, .filters label.grow { max-width: none; }
  .bar-row { grid-template-columns: minmax(80px, 110px) minmax(0, 1fr) auto; }
}

@media print {
  body { background: #fff; font-size: 11pt; }
  .side, .no-print, #toast, #tip, details.data, button, .sample { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .card, .tile, .banner { border-color: #999; break-inside: avoid; box-shadow: none; }
  .print-only { display: block; }
  .checkbox-print { display: inline-block; width: 14px; height: 14px; border: 1.5px solid #000; margin-right: 6px; vertical-align: -2px; }
  .bar, .col, .meter .fill, .p1, .tag { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .grid-main, .grid-2 { grid-template-columns: 1fr; }
  tr { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}

/* Photos and voice */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; min-height: 0; }
.file-btn { display: inline-flex; width: fit-content; font-weight: 600; cursor: pointer; }
.file-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.file-btn[hidden] { display: none; }
.thumbs { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.thumbs:empty { display: none; }
.thumb { width: 110px; display: grid; gap: 0.25rem; }
.thumb img { width: 110px; height: 110px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; background: var(--sunk); }
.voice-player { width: 100%; height: 40px; }
.rec-live { font-weight: 650; color: var(--p1); }
.rec-time { color: var(--ink); }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--p1); animation: rec-pulse 1.1s infinite; }
@keyframes rec-pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.7rem; }
.gallery figure { margin: 0; min-width: 0; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; cursor: zoom-in; background: var(--sunk); }
.gallery figcaption { font-size: 0.76rem; color: var(--ink-2); margin-top: 0.2rem; }
.voice-item { border-top: 1px solid var(--line); padding-top: 0.6rem; }
.voice-item:first-child { border-top: 0; padding-top: 0; }
.transcript { background: var(--paper); border-radius: 6px; padding: 0.5rem 0.7rem; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.92rem; }
dialog.photo-view { width: min(1000px, calc(100vw - 32px)); padding: 0.6rem; }
dialog.photo-view img { width: 100%; max-height: 80vh; object-fit: contain; display: block; }
#net-banner { background: var(--p2); color: #fff; font-size: 0.85rem; text-align: center; padding: 0.3rem 1rem; }
#alarm-banner { display: flex; gap: 0.75rem; justify-content: center; align-items: center; flex-wrap: wrap; background: var(--p1); color: #fff; padding: 0.45rem 1rem; font-weight: 650; }
#alarm-banner a { color: #fff; }
.health-row { display: flex; gap: 0.6rem; justify-content: space-between; align-items: center; padding: 0.45rem 0; border-bottom: 1px solid #ece9e1; }
.health-row:last-child { border-bottom: 0; }

@media print {
  #net-banner, #alarm-banner, audio { display: none !important; }
  .gallery { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Report pathway ---------- */
.card h3 { font-size: .95rem; margin: .6rem 0 0; padding-top: .6rem; border-top: 1px solid var(--line); }
.steps { list-style: none; display: flex; flex-wrap: wrap; gap: .3rem; margin: 0; padding: 0; counter-reset: step; }
.steps li { counter-increment: step; font-size: .78rem; padding: .25rem .55rem; border-radius: 999px; background: var(--sunk); color: var(--ink-3); }
.steps li::before { content: counter(step) ". "; }
.steps li.done { background: var(--good-soft); color: var(--good); }
.steps li.current { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; font-size: .88rem; }
.checklist li { display: flex; gap: .45rem; align-items: baseline; color: var(--ink-2); }
.checklist .mark { width: 1.1rem; text-align: center; color: var(--p2); font-weight: 700; }
.checklist li.done .mark { color: var(--good); }
.checklist li.done { color: var(--ink); }
.signed-block { border: 1px solid var(--good); border-radius: var(--radius); padding: .75rem; background: var(--good-soft); }
.signature-line { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: .6rem; }
.sig-img { height: 54px; width: auto; background: #fff; border: 1px solid var(--line); border-radius: 4px; }
.sig-pad { display: block; width: 100%; max-width: 600px; height: auto; aspect-ratio: 10 / 3; background: #fff; border: 1px dashed var(--ink-3); border-radius: 6px; touch-action: none; cursor: crosshair; }
.brief { border-left: 3px solid var(--accent); padding: .3rem 0 .3rem .7rem; }
.voice-item.deviation { border-left: 3px solid var(--p1); }
table.edit input, table.edit select { width: 100%; min-width: 4rem; padding: .3rem .4rem; }
table.edit td { vertical-align: top; }
select.needs { border-color: var(--p2); background: var(--p2-soft); }
.row.choices { flex-wrap: wrap; }
.row.choices button { white-space: normal; text-align: left; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ask-log { max-height: 340px; overflow-y: auto; }
.ask-log:empty { display: none; }
.thumb video { width: 100%; height: 100%; object-fit: cover; }
.status-now { border-left: 6px solid var(--accent); }
.status-now.good { border-left-color: var(--good); background: var(--good-soft); }
.status-now.warn { border-left-color: var(--p2); background: var(--p2-soft); }
.status-now.bad { border-left-color: var(--p1); background: var(--p1-soft); }
.status-now .step { font-size: 1.25rem; font-weight: 700; margin: 0; }
.status-now .waiting { font-size: 1rem; margin: .25rem 0 0; }
.gallery video { width: 100%; max-height: 260px; background: #000; border-radius: 6px; }

.locmap { height: 240px; width: 100%; border: 1px solid var(--line); border-radius: 6px; margin-top: .4rem; background: var(--sunk); }
.leaflet-container { font: inherit; }
.locmap-big { height: 420px; }

.qr-code svg { width: 260px; height: 260px; display: block; }
@media print {
  body.printing-qr > *:not(dialog) { display: none !important; }
  body.printing-qr dialog { position: static; border: 0; box-shadow: none; max-width: none; }
  .qr-code svg { width: 9cm; height: 9cm; }
}

/* ---------- Contacts-style members ---------- */
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-block; background: var(--sunk); }
.avatar-initials { display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; letter-spacing: .02em; }
.contact-search input { width: 100%; font-size: 1.05rem; padding: .75rem 1rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.contact-list { padding: .3rem 0; }
.contact-letter { font-size: .8rem; font-weight: 700; color: var(--accent); padding: .6rem 1rem .2rem; }
.contact-row { display: flex; align-items: center; gap: .8rem; padding: .55rem 1rem; color: inherit; text-decoration: none; border-radius: 8px; }
.contact-row:hover, .contact-row:focus-visible { background: var(--sunk); }
.contact-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.contact-main .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-side { text-align: right; flex: none; }
.contact-head { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 1rem 0 1.4rem; }
.contact-photo { display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.contact-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .7rem 1rem; }
.note { border-left: 3px solid var(--line); padding: .2rem 0 .2rem .6rem; }
.step-notes { display: grid; gap: .3rem; }

/* ---------- Help chat popup ---------- */
.helper-bubble { position: fixed; right: 18px; bottom: 18px; z-index: 50; display: inline-flex; align-items: center; gap: .5rem; border-radius: 999px; padding: .5rem 1rem .5rem .5rem; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.helper-face { width: 34px; height: 34px; border-radius: 50%; background: #fff; color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.helper-panel { position: fixed; right: 18px; bottom: 18px; z-index: 60; width: min(380px, calc(100vw - 24px)); height: min(600px, calc(100vh - 36px)); display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.3); overflow: hidden; }
.helper-panel[hidden], .helper-bubble[hidden] { display: none; }
.helper-head { display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem; background: var(--accent); color: var(--accent-ink); }
.helper-head .small { opacity: .85; }
.helper-close { margin-left: auto; background: transparent; color: inherit; border: 0; font-size: 1.6rem; line-height: 1; min-height: 0; padding: 0 .3rem; }
.helper-log { flex: 1; overflow-y: auto; padding: .8rem; display: flex; flex-direction: column; gap: .5rem; background: var(--paper); }
.helper-msg { max-width: 90%; padding: .5rem .7rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-size: .93rem; }
.helper-msg ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.helper-msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-color: var(--accent); }
.helper-note { margin: .4rem 0 0; font-size: .85rem; font-weight: 600; }
.helper-emergency { border-color: var(--p1); background: var(--p1-soft); }
.helper-emergency p { margin: .3rem 0 .5rem; }
.helper-choices { display: flex; flex-wrap: wrap; gap: .35rem; }
.helper-choices button { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: .3rem .7rem; min-height: 0; font-size: .85rem; }
.helper-input { display: flex; gap: .4rem; padding: .5rem; border-top: 1px solid var(--line); }
.helper-input textarea { flex: 1; resize: none; min-height: 40px; }
.helper-foot { margin: 0; padding: 0 .8rem .5rem; font-size: .75rem; color: var(--ink-3); }
@media (max-width: 520px) { .helper-panel { right: 0; bottom: 0; width: 100vw; height: 100vh; border-radius: 0; } }
@media print { .helper-bubble, .helper-panel { display: none !important; } }

/* ---------- Elder assistance ---------- */
.tag.elder { background: #f6e7b0; color: #5a4300; border: 1px solid #c9a227; font-weight: 700; }
.elder-offer { border: 2px solid #c9a227; background: #fdf6dc; border-radius: 10px; padding: .7rem .8rem; display: grid; gap: .5rem; }
.elder-offer button { width: fit-content; }
.elder-card { border-left: 4px solid #c9a227; }

/* ---------- Fort McMurray #468 First Nation branding ---------- */
.side .brand { display: flex; align-items: center; gap: 0.5rem; }
.side .brand img { width: 34px; height: 34px; background: #fff; border-radius: 50%; padding: 3px; }
.side .brand small { display: block; font-weight: 500; font-size: 0.72rem; color: #c7d0db; }
.login-logo { width: 100%; max-width: 300px; height: auto; display: block; margin: 0 0 0.8rem; }
button:not(.ghost):not(.danger):not(.tiny):focus-visible, .btn:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.card h2 { color: var(--accent); }
@media print { .member-header { border-image: none; border-bottom: 2px solid #999; } }
.elder-offer .elder-title { margin: 0; font-size: 1rem; color: #5a4300; }

/* ---------- Training site: black and white, with a banner ---------- */
html.training { filter: grayscale(1); }
.training-banner { background: #000; color: #fff; padding: .55rem 16px; font: 600 14px/1.4 system-ui, sans-serif; text-align: center; border-bottom: 3px solid #fff; }
.training-banner a { color: #fff; text-decoration: underline; margin-left: .4rem; }
.training-ribbon { position: fixed; top: 14px; right: -46px; z-index: 950; transform: rotate(45deg); background: #000; color: #fff; font: 800 13px/1 system-ui, sans-serif; letter-spacing: .12em; padding: 7px 52px; box-shadow: 0 2px 6px rgba(0,0,0,.3); pointer-events: none; }
@media print { .training-ribbon { position: absolute; } }

/* ---------- Preliminary assessments: the label is impossible to miss ---------- */
.ai-label { border: 2px solid #a3211a; background: #fbe9e7; color: #5c120e; border-radius: 8px; padding: .6rem .75rem; font-size: .9rem; }
.ai-label strong { display: block; font-size: 1rem; }
.prelim { border: 1px dashed #a3211a; border-radius: 10px; padding: .7rem; background: #fffaf9; }
/* Elder help: one small line under the report, so the report box is the page's first job. */
.elder-link { margin: .2rem 0 .4rem; }
button.linkish { background: none; border: 0; padding: 0; color: var(--accent, #4a5b72); text-decoration: underline; font: inherit; font-weight: 600; cursor: pointer; min-height: 0; }
/* Willow's button stands out: dark ink, white text, a gold ring (Sam: it blended into the page). */
.helper-bubble { background: #12302d; color: #fff; border: 3px solid #e0b43a; font-weight: 700; font-size: 1rem; }
.helper-bubble:hover, .helper-bubble:focus-visible { background: #0b1f1d; outline: 3px solid #fff; outline-offset: 2px; }
.helper-bubble .helper-face { background: #e0b43a; color: #12302d; }
/* Her hello: a small card above the button that slides up, waits, then slides back down. */
.helper-hello { position: fixed; right: 18px; bottom: 84px; z-index: 55; max-width: min(300px, calc(100vw - 36px)); background: #fff; color: #1d2725; border: 2px solid #12302d; border-radius: 12px; padding: .6rem .8rem; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: .95rem; cursor: pointer; opacity: 0; transform: translateY(12px); transition: opacity .35s, transform .35s; }
.helper-hello.show { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) { .helper-hello { transition: none; } }
/* Crew instructions: priority 5 is red, 4 orange, 3 blue, 2 and 1 grey. */
.ins-card .ins-item { border: 1px solid var(--line); border-left-width: 6px; border-radius: 8px; padding: .55rem .7rem; margin: 0 0 .6rem; background: var(--surface, #fff); }
.ins-item.ins-hot { border-left-color: #b42318; }
.ins-item.ins-calm { border-left-color: #4a5b72; }
.ins-pri { display: inline-block; font-weight: 700; font-size: .8rem; border-radius: 4px; padding: .1rem .45rem; color: #fff; background: #6a7572; }
.ins-pri-5 { background: #b42318; } .ins-pri-4 { background: #c4590f; } .ins-pri-3 { background: #2f5d8a; }
.ins-people { margin: .35rem 0 0; padding-left: 1.1rem; }
.ins-pick { display: flex; flex-wrap: wrap; gap: .4rem; }
.ins-pick button { min-width: 3.2rem; }
.ins-send summary { cursor: pointer; }

/* Staff menu: the app's short list, then everything else under More. */
.side .menu-btn { display: none; margin-left: auto; background: #45546a; color: #fff; border: 1px solid #6a7a90; min-height: 44px; padding: 0 1rem; font-weight: 700; }
.side .app-name { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #aab6c3; padding: .2rem .55rem .3rem; }
.side details.more summary { cursor: pointer; color: #d3dae3; padding: .42rem .55rem; border-radius: 6px; font-weight: 550; list-style: none; }
.side details.more summary::after { content: ' ▾'; }
.side details.more[open] summary::after { content: ' ▴'; }
.side details.more a { padding-left: 1.1rem; font-weight: 500; }
/* Needs approval and What we need: one row per job, big tap targets. */
.appr-row { display: flex; justify-content: space-between; gap: .8rem; align-items: center; padding: .75rem .6rem; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: inherit; min-height: 44px; }
.appr-row:hover, .appr-row:focus-visible { background: #f3f6f6; }
.appr-main { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.appr-side { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; text-align: right; flex: none; }
.needs-tally { list-style: none; margin: 0; padding: 0; columns: 2 220px; }
.needs-tally li { display: flex; justify-content: space-between; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--line); break-inside: avoid; }
/* Who's on: a slim strip at the top of staff pages, presence dots, and the message thread. */
.hud { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; align-items: center; padding: .35rem 1rem; background: #eef3f2; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; font-size: .88rem; }
.hud:hover { background: #e2ecea; }
.hud-unread { background: #b42318; color: #fff; border-radius: 999px; padding: .05rem .55rem; font-size: .8rem; font-weight: 700; }
.pres { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .35rem; vertical-align: middle; background: #9aa5a3; }
.pres-on { background: #22a35a; } .pres-away { background: #e0b43a; }
.msg-log { max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: .45rem; }
.msg { max-width: 85%; padding: .5rem .7rem; border-radius: 12px; background: #f1f3f4; border: 1px solid var(--line); }
.msg.mine { align-self: flex-end; background: #e2ecea; }
/* Staff list, levels, points bar, badges and the crew board. */
.staff-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) auto; gap: .6rem; align-items: center; padding: .6rem .4rem; border-bottom: 1px solid var(--line); }
.staff-row.inactive { opacity: .55; }
.staff-main { display: flex; flex-direction: column; gap: .1rem; color: inherit; text-decoration: none; }
.staff-acts { justify-content: flex-end; flex-wrap: wrap; gap: .3rem; }
.lvl { display: inline-block; font-size: .72rem; font-weight: 700; background: #12302d; color: #e0b43a; border-radius: 999px; padding: .05rem .5rem; margin-left: .3rem; vertical-align: middle; }
.xp-bar { height: 12px; background: #e6ecea; border-radius: 999px; overflow: hidden; }
.xp-bar span { display: block; height: 100%; background: linear-gradient(90deg, #22a35a, #e0b43a); }
.badges { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .6rem; }
.badge { font-size: .78rem; font-weight: 600; border: 1px solid #c9a227; background: #fdf6dc; color: #5a4300; border-radius: 999px; padding: .1rem .55rem; }
ol.board { margin: 0; padding-left: 1.4rem; }
ol.board a { display: flex; gap: .5rem; align-items: center; justify-content: space-between; padding: .45rem 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
ol.board strong { margin-left: auto; }
@media (max-width: 700px) { .staff-row { grid-template-columns: minmax(0, 1fr); } .staff-acts { justify-content: flex-start; } }
