/* Layout: sticky toolbar over a master/detail customer register (list → record on phones); forms and reports open in a right-hand sheet. */
:root {
  --bg: #f2f5f6;
  --surface: #ffffff;
  --surface-2: #e8eef0;
  --ink: #13222a;
  --muted: #566871;
  --line: #d2dbdf;
  --accent: #0a6b66;
  --accent-hover: #085752;
  --accent-ink: #ffffff;
  --accent-soft: #d6ebe8;
  --ok: #1d7439;
  --ok-soft: #dcefe1;
  --warn: #8a5800;
  --warn-soft: #f6e8c8;
  --bad: #ae2a20;
  --bad-soft: #f7dcd8;
  --scrim: rgba(13, 24, 30, .45);
  --shadow: 0 1px 2px rgba(19, 34, 42, .06), 0 10px 28px rgba(19, 34, 42, .10);
  --sig-bg: #ffffff;
  --sig-ink: #13222a;
  --f-display: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e161a; --surface: #152128; --surface-2: #1c2b33; --ink: #e3ebee; --muted: #91a4ac; --line: #293a43;
    --accent: #43b8ae; --accent-hover: #5fc9c0; --accent-ink: #052421; --accent-soft: #123936;
    --ok: #63c784; --ok-soft: #15301f; --warn: #e3ac46; --warn-soft: #382a0f; --bad: #f08a80; --bad-soft: #3b1a17;
    --scrim: rgba(0, 0, 0, .6); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 28px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e161a; --surface: #152128; --surface-2: #1c2b33; --ink: #e3ebee; --muted: #91a4ac; --line: #293a43;
  --accent: #43b8ae; --accent-hover: #5fc9c0; --accent-ink: #052421; --accent-soft: #123936;
  --ok: #63c784; --ok-soft: #15301f; --warn: #e3ac46; --warn-soft: #382a0f; --bad: #f08a80; --bad-soft: #3b1a17;
  --scrim: rgba(0, 0, 0, .6); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 28px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
img { max-width: 100%; }
html, body { min-height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.5; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: .005em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--f-mono); font-size: .9em; letter-spacing: .01em; }
.muted { color: var(--muted); }
.wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); max-width: 1320px; margin: 0 auto; }

/* Toolbar */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand-mark { width: 30px; height: 30px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.brand h1 { font-size: 1.35rem; text-transform: uppercase; letter-spacing: .04em; }
.tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 9px; }
.tab { border: 0; background: none; padding: 6px 14px; border-radius: 7px; cursor: pointer; font-weight: 500; color: var(--muted); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.conn[data-state="live"]::before { background: var(--ok); }
.conn[data-state="readonly"]::before { background: var(--warn); }
.conn[data-state="offline"]::before { background: var(--bad); }

main { padding-block: 20px 48px; }
.notice { border: 1px solid var(--line); background: var(--warn-soft); color: var(--ink); border-radius: var(--r); padding: 10px 14px; margin-bottom: 16px; font-size: .9rem; }

/* Buttons and inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 7px; cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.btn.ghost { border-color: transparent; background: none; }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 8px 10px; min-width: 0; }
textarea.input { resize: vertical; min-height: 84px; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: grid; gap: 4px; min-width: 0; }
label.field > span, .label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.req::after { content: " *"; color: var(--bad); }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; letter-spacing: .02em; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }

/* Customers: master/detail */
.split { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.list-pane { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 72px); max-height: calc(100vh - 110px); display: flex; flex-direction: column; }
.list-head { padding: 12px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.list-head .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.count { font-size: .8rem; color: var(--muted); }
.cust-list { list-style: none; margin: 0; padding: 4px; overflow-y: auto; flex: 1; }
.cust-row { width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 7px; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: center; }
.cust-row:hover { background: var(--surface-2); }
.cust-row[aria-current="true"] { background: var(--accent-soft); }
.cust-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cust-meta { grid-column: 1; font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cust-row .pill { grid-column: 2; grid-row: 1 / span 2; }
.list-empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: .9rem; }

.detail-pane { min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.record-head { padding: 20px 22px 16px; display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.record-head h2 { font-size: 1.8rem; }
.record-head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 24px; padding: 18px 22px; }
.fact { min-width: 0; }
.fact .v { overflow-wrap: anywhere; }
.copyable { cursor: copy; border-bottom: 1px dashed var(--line); }
.notes { padding: 0 22px 18px; white-space: pre-wrap; color: var(--muted); }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px 10px; border-top: 1px solid var(--line); }
.history-head h3 { font-size: 1.2rem; }
.history { list-style: none; margin: 0; padding: 0 10px 12px; }
.hist-row { width: 100%; border: 0; background: none; text-align: left; cursor: pointer; display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 4px 14px; align-items: center; padding: 10px 12px; border-radius: 7px; }
.hist-row:hover { background: var(--surface-2); }
.hist-row .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-row .s { font-size: .8rem; color: var(--muted); }
.due-strip { margin: 0 22px 18px; padding: 10px 14px; border-radius: 8px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; background: var(--surface-2); }
.back { display: none; margin-bottom: 12px; }
.confirm { margin: 0 22px 18px; padding: 12px 14px; border-radius: 8px; background: var(--bad-soft); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; }

.welcome { padding: 32px 28px; }
.welcome h2 { font-size: 1.9rem; margin-bottom: 6px; }
.welcome > p { color: var(--muted); max-width: 60ch; margin: 0 0 22px; }
.steps { list-style: none; padding: 0; margin: 0 0 24px; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; counter-reset: step; }
.steps li { counter-increment: step; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.steps li::before { content: counter(step); font-family: var(--f-display); font-weight: 700; font-size: 1.5rem; color: var(--accent); display: block; line-height: 1; margin-bottom: 6px; }
.steps b { display: block; margin-bottom: 2px; }
.steps span { color: var(--muted); font-size: .9rem; }

/* Reports */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
.stat .n { font-family: var(--f-display); font-size: 1.9rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat.warn .n { color: var(--warn); }
.stat.bad .n { color: var(--bad); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .input { max-width: 320px; flex: 1 1 200px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: .85rem; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.spacer { flex: 1; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.grid th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
table.grid td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr.clickable { cursor: pointer; }
table.grid tbody tr.clickable:hover td { background: var(--surface-2); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; cursor: pointer; text-align: left; }

/* Import */
.import-grid { display: grid; gap: 16px; max-width: 980px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; }
.panel h2 { font-size: 1.35rem; margin-bottom: 4px; }
.panel > p { color: var(--muted); margin: 0 0 14px; max-width: 70ch; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 28px 16px; text-align: center; background: var(--bg); transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop p { margin: 6px 0 0; color: var(--muted); font-size: .9rem; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .8rem; margin: 16px 0 10px; text-transform: uppercase; letter-spacing: .08em; }
.or::before, .or::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.format-hint { margin-top: 14px; font-size: .85rem; color: var(--muted); }
.format-hint code { font-family: var(--f-mono); font-size: .85em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; margin-bottom: 18px; }
.import-stats { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; }
.radio-row { display: flex; gap: 18px; flex-wrap: wrap; margin: 12px 0 16px; }
.radio-row label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 12px 0 6px; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; justify-content: flex-end; }
.sheet-scrim { position: absolute; inset: 0; background: var(--scrim); }
.sheet-panel { position: relative; width: min(820px, 100%); height: 100%; background: var(--bg); box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(24px); } to { transform: none; } }
.sheet-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: calc(env(safe-area-inset-top, 0px) + 14px) max(20px, env(safe-area-inset-right, 0px)) 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 1.35rem; }
.sheet-body { flex: 1; overflow-y: auto; padding: 20px max(20px, env(safe-area-inset-right, 0px)) 28px 20px; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 12px max(20px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 12px) 20px; background: var(--surface); border-top: 1px solid var(--line); }
.sheet-foot .err { color: var(--bad); margin-right: auto; align-self: center; font-size: .9rem; }
fieldset.sec { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 16px 18px 18px; margin: 0 0 14px; min-width: 0; }
fieldset.sec legend { font-family: var(--f-display); font-weight: 700; font-size: 1.05rem; text-transform: uppercase; letter-spacing: .05em; padding: 0 6px; margin-left: -6px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 14px; }
.fgrid + .fgrid, .fgrid + label.field, .sec > label.field + label.field { margin-top: 12px; }
.span-2 { grid-column: span 2; }
.unit { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--bg); display: grid; gap: 10px; }
.unit + .unit { margin-top: 10px; }
.unit-head { display: flex; justify-content: space-between; align-items: center; }
.unit-head b { font-family: var(--f-display); font-size: 1rem; text-transform: uppercase; letter-spacing: .05em; }
.part { display: grid; grid-template-columns: minmax(0, 1fr) 80px auto; gap: 8px; align-items: center; }
.part + .part { margin-top: 8px; }
.add-row { margin-top: 10px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { border: 1px solid var(--line); border-radius: 7px; padding: 8px 14px; cursor: pointer; font-weight: 500; background: var(--surface); }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg input[value="satisfactory"]:checked + label { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.seg input[value="advisory"]:checked + label { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.seg input[value="unsatisfactory"]:checked + label { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.sig-wrap { display: grid; gap: 6px; }
.sig { width: 100%; height: 150px; background: var(--sig-bg); border: 1px solid var(--line); border-radius: 8px; touch-action: none; cursor: crosshair; display: block; }
.sig-foot { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; color: var(--muted); }
.picked { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); }
.picked b { display: block; }
.results { display: grid; gap: 2px; margin-top: 6px; }
.results button { text-align: left; border: 1px solid transparent; background: var(--bg); border-radius: 6px; padding: 8px 10px; cursor: pointer; }
.results button:hover { border-color: var(--line); }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 40; font-weight: 500; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

@media (max-width: 820px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .list-pane { position: static; max-height: none; }
  .split.has-selection .list-pane { display: none; }
  .split:not(.has-selection) .detail-pane { display: none; }
  .back { display: inline-flex; }
  .record-head h2 { font-size: 1.5rem; }
  .span-2 { grid-column: auto; }
  .hist-row { grid-template-columns: minmax(0, 1fr) auto; }
  .hist-row .d { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); }
}
@media (max-width: 520px) {
  .brand h1 { font-size: 1.15rem; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 6px 8px; }
  .part { grid-template-columns: minmax(0, 1fr) 64px auto; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Service report sheet */
.rpt { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; color: var(--ink); font-family: var(--f-body); }
.rpt-top { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.rpt-top h1 { font-family: var(--f-display); font-size: 1.7rem; text-transform: uppercase; letter-spacing: .04em; margin: 0; }
.rpt-no { font-family: var(--f-mono); font-size: .95rem; color: var(--muted); margin-top: 2px; }
.rpt-stamp { align-self: flex-start; border: 2px solid currentColor; border-radius: 6px; padding: 6px 12px; font-family: var(--f-display); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 1rem; }
.rpt-stamp.ok { color: var(--ok); } .rpt-stamp.warn { color: var(--warn); } .rpt-stamp.bad { color: var(--bad); }
.rpt-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 20px; padding: 16px 22px; background: var(--surface-2); }
.rpt-k { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.rpt-v { overflow-wrap: anywhere; }
.rpt-sec { padding: 16px 22px; border-top: 1px solid var(--line); }
.rpt-sec h2 { font-family: var(--f-display); font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 8px; color: var(--muted); }
.rpt-sec p { margin: 0; white-space: pre-wrap; }
.rpt-table-wrap { overflow-x: auto; }
.rpt table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.rpt th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rpt td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.rpt tr:last-child td { border-bottom: 0; }
.rpt-sign { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-end; }
.rpt-sign img { max-width: 280px; width: 100%; height: auto; background: var(--sig-bg); border-bottom: 1px solid var(--ink); }
.rpt .pill { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.rpt .pill.ok { background: var(--ok-soft); color: var(--ok); } .rpt .pill.warn { background: var(--warn-soft); color: var(--warn); } .rpt .pill.bad { background: var(--bad-soft); color: var(--bad); } .rpt .pill.neutral { background: var(--surface-2); color: var(--muted); }

.rpt-brand { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; padding: 18px 22px; background: var(--rpt-band, #000046); color: #ffffff; border-bottom: 4px solid var(--rpt-stripe, #f11712); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.rpt-logo { display: block; height: 40px; width: auto; max-width: 100%; }
.rpt-brand-name { font-family: var(--f-display); font-size: 1.4rem; font-weight: 700; letter-spacing: .03em; }
.rpt-brand-contact { font-size: .82rem; line-height: 1.55; text-align: right; color: #ffffff; }
.rpt-top { align-items: center; }
.rpt-stamp { align-self: center; }
.rpt-foot { padding: 12px 22px; border-top: 1px solid var(--line); font-size: .78rem; color: var(--muted); }
@media (max-width: 520px) { .rpt-brand-contact { text-align: left; } .rpt-logo { height: 32px; } }

.rpt-checks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 20px; }
.rpt-checks li { display: flex; gap: 8px; align-items: baseline; color: var(--muted); }
.rpt-checks li.done { color: var(--ink); }
.rpt-checks .tick { width: 1em; font-weight: 700; color: var(--muted); }
.rpt-checks li.done .tick { color: var(--ok); }
.rpt-reading { color: var(--muted); font-size: .9em; }
.rpt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 20px; }

/* Self-hosted additions: account button, sign-in page, team table, print */
.account-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px 5px 10px; cursor: pointer; font-size: .85rem; font-weight: 500; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-btn:hover { border-color: var(--muted); }
.account-btn .conn { font-size: 0; gap: 0; }
.rpt-co { text-align: right; font-size: .85rem; color: var(--muted); line-height: 1.4; }
.rpt-co b { display: block; color: var(--ink); font-size: .95rem; }
.role-pill { text-transform: capitalize; }

.auth-body { min-height: 100vh; display: grid; place-items: center; padding-block: 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.auth { width: min(420px, 100%); display: grid; gap: 18px; }
.auth-brand { display: flex; gap: 12px; align-items: center; }
.auth-brand h1 { font-size: 1.6rem; text-transform: uppercase; letter-spacing: .04em; }
.auth-card { padding: 24px; display: grid; gap: 14px; }
.auth-card h2 { font-size: 1.4rem; }
.auth-card p { margin: 0; }
.auth-error { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: 7px; font-size: .9rem; }

@media print {
  @page { margin: 12mm; }
  :root:root:root { --bg: #fff; --surface: #fff; --surface-2: #eef3f4; --ink: #13222a; --muted: #566871; --line: #d2dbdf; --accent: #0a6b66; --ok: #1d7439; --ok-soft: #dcefe1; --warn: #8a5800; --warn-soft: #f6e8c8; --bad: #ae2a20; --bad-soft: #f7dcd8; color-scheme: light; }
  body { background: #fff; }
  body.printing > :not(#sheet) { display: none !important; }
  body.printing .sheet { position: static; display: block; }
  body.printing .sheet-scrim, body.printing .sheet-head, body.printing .sheet-foot, body.printing .confirm { display: none !important; }
  body.printing .sheet-panel { width: 100%; height: auto; box-shadow: none; background: #fff; animation: none; }
  body.printing .sheet-body { overflow: visible; padding: 0; }
  .rpt { border: 0; border-radius: 0; }
  .rpt-sec, .rpt table tr { break-inside: avoid; }
}

.brand-icon { width: 32px; height: 32px; border-radius: 6px; display: block; }
.email-log { margin-top: 16px; }
.email-log ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; }
.email-log li { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 0; overflow-wrap: anywhere; }
#custChips .chip { font-size: .8rem; padding: 3px 10px; }
.panel code { font-family: var(--f-mono); font-size: .85em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
@media print { .email-log { display: none; } .rpt-brand { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

.checks-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 14px; }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); min-width: 0; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check:has(input:disabled) { opacity: .6; cursor: not-allowed; }
.check-reading { grid-column: 1 / -1; }
.sheet-foot .auto-email { margin-right: auto; padding: 6px 10px; flex: 1 1 260px; font-size: .9rem; }
.sheet-foot .auto-email + .err { margin-right: 0; flex-basis: 100%; order: 3; }
.unit-head { gap: 8px; }
.unit-head .spacer { flex: 1; }
.cmd { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 7px; padding: 8px 10px; min-width: 0; }
.cmd code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-family: var(--f-mono); font-size: .8rem; background: none; padding: 0; }
.unit-pick { margin-bottom: 4px; }
.unit-pick select { border-color: var(--accent); border-width: 2px; font-weight: 500; }
.unit-pick-note { margin: 4px 0 12px; font-size: .85rem; }
#units:not(:empty) { margin-bottom: 4px; }
.es-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.es-head h2 { margin: 0; }
.es-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.es-box { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: var(--bg); min-width: 0; }
.es-title { font-family: var(--f-display); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: .95rem; margin-bottom: 8px; }
.es-row { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px; padding: 4px 0; align-items: baseline; overflow-wrap: anywhere; }
.es-warn { margin: 8px 0 0; color: var(--bad); font-size: .9rem; }
.es-stats { margin: 14px 0 0; }
.es-last { font-weight: 600; margin-top: 6px; }
.es-fail { margin-top: 12px; padding: 10px 14px; border-radius: 8px; background: var(--bad-soft); color: var(--ink); font-size: .9rem; overflow-wrap: anywhere; }

/* Home dashboard */
a.brand { color: inherit; text-decoration: none; border-radius: 8px; }
a.brand:hover h1 { color: var(--accent); }
.home-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 16px; }
.home-head h2 { font-size: 1.8rem; }
.home-head p { margin: 2px 0 0; }
.home-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.home-stat .n { font-size: 2.2rem; }
.home-stat[role="button"] { cursor: pointer; }
.home-stat[role="button"]:hover { border-color: var(--muted); }
.stat-sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.home-wide { grid-column: 1 / -1; }
.home-card { padding: 16px 18px; min-width: 0; }
.home-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.home-card-head h3 { font-size: 1.2rem; }
.home-card-head .muted { font-size: .82rem; }
.home-card .history { padding: 0; }
.home-empty { margin: 0; }
.table-wrap.flat { border: 0; border-radius: 0; background: none; }
.table-wrap.flat th { background: none; }

.chart { position: relative; height: 220px; padding: 22px 0 26px 30px; }
.chart-grid { position: absolute; inset: 22px 0 26px 30px; pointer-events: none; }
.chart-grid span { position: absolute; left: -30px; right: 0; border-top: 1px solid var(--line); font-size: .7rem; color: var(--muted); line-height: 0; padding-top: 0; font-variant-numeric: tabular-nums; }
.chart-grid span::before { content: none; }
.chart-bars { position: relative; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 2px; height: 100%; align-items: end; }
.chart-col { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; outline: none; }
.chart-col:hover .chart-bar, .chart-col:focus-visible .chart-bar { background: var(--accent-hover); }
.chart-col:focus-visible { box-shadow: 0 0 0 2px var(--accent); border-radius: 4px; }
.chart-bar { width: min(28px, 70%); background: var(--accent); border-radius: 4px 4px 0 0; min-height: 0; }
.chart-val { font-size: .75rem; font-weight: 600; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.chart-x { position: absolute; bottom: -22px; font-size: .72rem; color: var(--muted); white-space: nowrap; }
.chart-tip { position: absolute; z-index: 50; background: var(--ink); color: var(--bg); font-size: .8rem; padding: 6px 10px; border-radius: 6px; pointer-events: none; box-shadow: var(--shadow); max-width: 260px; }

.meter { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.meter-n { width: 2.5em; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.meter-track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; min-width: 60px; }
.meter-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hbars li { display: grid; grid-template-columns: minmax(90px, 40%) 1fr 2.5em; gap: 10px; align-items: center; font-size: .9rem; }
.hbars b { text-align: right; font-variant-numeric: tabular-nums; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stack { display: flex; gap: 2px; height: 16px; border-radius: 4px; overflow: hidden; margin-bottom: 14px; }
.stack-seg { display: block; min-width: 4px; outline: none; }
.stack-seg:focus-visible { box-shadow: inset 0 0 0 2px var(--ink); }
.stack-seg.satisfactory, .key.satisfactory { background: var(--ok); }
.stack-seg.advisory, .key.advisory { background: var(--warn); }
.stack-seg.unsatisfactory, .key.unsatisfactory { background: var(--bad); }
.stack-seg.none, .key.none { background: var(--line); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.legend li { display: grid; grid-template-columns: 12px 1fr auto 3em; gap: 10px; align-items: center; font-size: .9rem; }
.legend b { font-variant-numeric: tabular-nums; }
.legend .muted { text-align: right; font-size: .82rem; font-variant-numeric: tabular-nums; }
.key { width: 12px; height: 12px; border-radius: 3px; }

@media (max-width: 820px) { .home-grid { grid-template-columns: minmax(0, 1fr); } .chart { height: 180px; } }
@media (max-width: 520px) { .chart-x { font-size: .62rem; } .home-stat .n { font-size: 1.8rem; } }
.brand-icon { background: #ffffff; padding: 2px; }
@media (max-width: 520px) {
  .home-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .home-stat { padding: 10px 12px; }
  .home-head h2 { font-size: 1.5rem; }
  .tab { padding: 6px 4px; font-size: .88rem; }
}
