/* Lumina Axis — purple & gold, engineering title-block motif. System fonts only (works offline). */
:root {
  --aubergine: #26153B;
  --purple: #4B2A7B;
  --purple-ink: #3A1F63;
  --purple-wash: #F1ECF7;
  --gold: #C9A227;
  --gold-soft: #F5EBC8;
  --paper: #F6F5F8;
  --surface: #FFFFFF;
  --ink: #1C1726;
  --muted: #655E72;
  --line: #DAD4E3;
  --ok: #2F7D4F; --ok-bg: #E5F2EA;
  --warn: #8F5E00; --warn-bg: #FBF0D6;
  --bad: #B3261E; --bad-bg: #FBE6E4;
  --info: #3A5A9B; --info-bg: #E6ECF7;
  --display: "Bahnschrift", "DIN Alternate", "DIN Next", "Roboto Condensed", "Arial Narrow", sans-serif;
  --body: "Segoe UI", system-ui, -apple-system, "Roboto", "Helvetica Neue", Arial, sans-serif;
  --r: 6px;
  --side: 232px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--body); color: var(--ink); background: var(--paper); -webkit-text-size-adjust: 100%; }
a { color: var(--purple); text-underline-offset: 2px; }
a:hover { color: var(--purple-ink); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: .01em; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.2rem; margin-top: 1.6em; } h3 { font-size: 1.02rem; }
h1:focus { outline: none; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.ok-text { color: var(--ok); } .bad-text { color: var(--bad); } .warn-text { color: var(--warn); }
code, .mono { font-family: Consolas, "Cascadia Mono", ui-monospace, monospace; font-size: .88em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; z-index: 99; background: #fff; padding: 8px; }
.prose { max-width: 70ch; }

/* ---------------------------------------------------------------- layout */
#app { min-height: 100vh; display: grid; grid-template-columns: var(--side) minmax(0, 1fr); grid-template-rows: auto auto 1fr; grid-template-areas: "side top" "side band" "side main"; }
.side { grid-area: side; background: var(--aubergine); color: #E9E2F3; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 16px; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { width: 38px; height: 38px; color: #fff; display: grid; place-items: center; }
.brand-mark svg, .brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-name { font-family: var(--display); font-size: 1.15rem; font-weight: 600; line-height: 1.1; }
.brand-name small { display: block; font-size: .72rem; font-weight: 400; color: #BFB3D3; letter-spacing: .02em; }
.nav { display: flex; flex-direction: column; padding: 10px 8px; gap: 2px; flex: 1; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; color: #D9CFE8; text-decoration: none; border-radius: var(--r); border-left: 3px solid transparent; }
.nav a svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(201,162,39,.14); color: #fff; border-left-color: var(--gold); }
.side-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.who { font-size: .85rem; color: #fff; } .who small { display: block; color: #BFB3D3; }
.top { grid-area: top; display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.search { flex: 1; max-width: 520px; }
.search input { width: 100%; }
.status { display: flex; align-items: center; gap: 8px; font-size: .82rem; line-height: 1.25; margin-left: auto; }
.status small { color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); } .dot.off { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.icon-btn { background: none; border: 1px solid transparent; border-radius: var(--r); width: 38px; height: 38px; display: inline-grid; place-items: center; cursor: pointer; color: var(--ink); font-size: 1.2rem; position: relative; text-decoration: none; }
.icon-btn:hover { background: var(--purple-wash); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.spinning svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bell span { position: absolute; top: 2px; right: 2px; background: var(--bad); color: #fff; border-radius: 9px; font-size: .68rem; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; }
.offline-band { grid-area: band; display: none; background: var(--gold-soft); color: #5B4500; padding: 8px 24px; font-size: .88rem; border-bottom: 1px solid #E7D48E; }
body.is-offline .offline-band { display: block; }
main#main { grid-area: main; padding: 24px 32px 96px; max-width: 1280px; width: 100%; min-width: 0; }
.top, .offline-band { min-width: 0; }
.refresh-hint { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--r); display: flex; gap: 12px; align-items: center; z-index: 20; }

/* ---------------------------------------------------------------- page structure */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head.sub { margin: 22px 0 8px; align-items: center; }
.page-head.sub h2 { margin: 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.home-head p { margin: 0 0 2px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.two-col > section > h2:first-child, section > h2:first-child { margin-top: .4em; }

/* The title block: modelled on an engineering drawing title block. */
.title-block { display: grid; grid-template-columns: minmax(260px, 2.2fr) repeat(4, minmax(110px, 1fr)); border: 1.5px solid var(--ink); background: var(--surface); margin-bottom: 16px; position: relative; }
.title-block::before { content: ""; position: absolute; left: -1.5px; top: -1.5px; bottom: -1.5px; width: 6px; background: var(--gold); }
.title-block > div { padding: 8px 12px 9px; border-left: 1px solid var(--ink); border-bottom: 1px solid var(--ink); min-width: 0; overflow-wrap: anywhere; }
.title-block .tb-main { grid-row: span 2; border-left: none; padding-left: 18px; display: flex; flex-direction: column; justify-content: center; }
.title-block .tb-main h1 { margin: 2px 0 0; font-size: 1.45rem; }
.title-block .tb-wide { grid-column: span 4; }
.title-block > div:nth-last-child(-n+1) { border-bottom: none; }
.tb-label { display: block; font-family: var(--display); font-size: .74rem; color: var(--muted); letter-spacing: .03em; margin-bottom: 1px; }
.project-tb { margin-bottom: 0; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 14px 0 16px; overflow-x: auto; scrollbar-width: thin; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--purple); border-bottom-color: var(--purple); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg a { padding: 6px 12px; text-decoration: none; color: var(--muted); font-size: .9rem; border-right: 1px solid var(--line); }
.seg a:last-child { border-right: none; }
.seg a.on { background: var(--purple); color: #fff; }

.flow { list-style: none; padding: 0; margin: 0 0 4px; display: flex; flex-wrap: wrap; gap: 0; counter-reset: s; font-size: .82rem; color: var(--muted); }
.flow li { counter-increment: s; padding: 4px 18px 4px 0; position: relative; }
.flow li::before { content: counter(s); font-family: var(--display); color: var(--purple); margin-right: 5px; }
.flow li:not(:last-child)::after { content: ""; position: absolute; right: 7px; top: 50%; width: 6px; height: 6px; border-top: 1.5px solid var(--gold); border-right: 1.5px solid var(--gold); transform: translateY(-50%) rotate(45deg); }

/* figures row (not cards) */
.figures { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1.5px solid var(--ink); border-bottom: 1px solid var(--line); margin: 6px 0 18px; }
.figure { padding: 12px 16px 12px 0; text-decoration: none; color: var(--ink); display: flex; align-items: baseline; gap: 10px; }
.figure + .figure { padding-left: 16px; border-left: 1px solid var(--line); }
.figure b { font-family: var(--display); font-size: 2rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--purple); }
.figure span { color: var(--muted); font-size: .88rem; line-height: 1.25; }
.figure.is-bad b { color: var(--bad); } .figure.is-warn b { color: var(--warn); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; }
table.grid { width: 100%; border-collapse: collapse; background: var(--surface); font-variant-numeric: tabular-nums; }
.grid th, .grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.grid th { font-family: var(--display); font-weight: 600; font-size: .82rem; color: var(--muted); background: #FAF9FC; border-bottom: 1.5px solid var(--ink); white-space: nowrap; }
.grid .r { text-align: right; } .grid .c { text-align: center; }
.grid.list tbody tr { cursor: pointer; }
.grid.list tbody tr:hover { background: var(--purple-wash); }
.grid tr.superseded td { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.25); }
.grid tr.row-selected { background: var(--gold-soft); }
.grid tr.sub-row td { padding-top: 0; border-top: none; }
.grid.edit input, .grid.edit select { width: 100%; min-width: 80px; }
.grid.compare td { vertical-align: middle; }
.sync-col { width: 1%; white-space: nowrap; }
.totals { text-align: right; margin: 8px 0 18px; }
.empty-inline { padding: 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r); background: var(--surface); }
.empty { padding: 48px 0; text-align: center; }
.meter { display: inline-block; width: 64px; height: 6px; background: var(--line); border-radius: 3px; vertical-align: middle; position: relative; overflow: hidden; }
.meter::after, .bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--v); background: var(--purple); }
.bar { display: inline-block; width: 100px; height: 8px; background: var(--line); position: relative; overflow: hidden; border-radius: 2px; }

/* ---------------------------------------------------------------- badges, chips, notices */
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-muted { background: #ECE9F0; color: #4F485C; } .badge-ok { background: var(--ok-bg); color: var(--ok); } .badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); } .badge-info { background: var(--info-bg); color: var(--info); }
.chip { display: inline-block; font-size: .74rem; padding: 0 7px; border-radius: 3px; border: 1px solid; white-space: nowrap; }
.chip-warn { color: var(--warn); border-color: #E2C36A; background: var(--warn-bg); } .chip-bad { color: var(--bad); border-color: #EBA8A2; background: var(--bad-bg); }
.prov { font-family: var(--display); color: var(--warn); border-bottom: 1px dashed var(--warn); }
.notice { padding: 10px 14px; border-left: 4px solid var(--info); background: var(--info-bg); margin: 10px 0; border-radius: 0 var(--r) var(--r) 0; }
.notice-ok { border-color: var(--ok); background: var(--ok-bg); } .notice-warn { border-color: var(--gold); background: var(--gold-soft); } .notice-bad { border-color: var(--bad); background: var(--bad-bg); }
.notice-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.swatch { display: inline-block; width: 14px; height: 14px; border: 1px solid var(--line); vertical-align: middle; }

/* ---------------------------------------------------------------- buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: var(--r); border: 1px solid var(--purple); background: var(--purple); color: #fff; font: 600 .92rem var(--body); cursor: pointer; text-decoration: none; min-height: 38px; }
.btn:hover { background: var(--purple-ink); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--purple); border-color: var(--line); }
.btn-ghost:hover { background: var(--purple-wash); color: var(--purple-ink); }
.btn-danger { background: var(--bad); border-color: var(--bad); } .btn-danger:hover { background: #8E1D17; }
.btn-danger-text { color: var(--bad); }
.btn-sm { padding: 4px 10px; min-height: 30px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn.on-dark { background: transparent; color: #E9E2F3; border-color: rgba(255,255,255,.25); }
.link-btn { background: none; border: none; color: var(--purple); text-decoration: underline; cursor: pointer; padding: 0; font: inherit; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #C9C1D6; border-radius: var(--r); padding: 7px 10px; min-height: 38px; max-width: 100%; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--purple); outline: 2px solid var(--purple-wash); }
input[type=checkbox], input[type=radio] { min-height: auto; width: 18px; height: 18px; accent-color: var(--purple); }
.check { display: inline-flex; align-items: center; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-weight: 600; font-size: .88rem; }
.field input, .field select, .field textarea { width: 100%; }
.req { font-style: normal; font-weight: 400; color: var(--muted); font-size: .78rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; margin: 10px 0; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 0; flex-wrap: wrap; }
.form-actions.sticky { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--paper) 30%); padding-top: 22px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 6px 0 10px; }
.filters label { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; }
.actions-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
.lines { width: 100%; }
.lines .btn { margin-top: 6px; }
.attach-field { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { width: 96px; height: 96px; border: 1px solid var(--line); border-radius: var(--r); background: #EEE; padding: 0; cursor: pointer; position: relative; overflow: hidden; display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-state { position: absolute; left: 0; right: 0; bottom: 0; font-size: .66rem; background: rgba(28,23,38,.72); color: #fff; padding: 1px 4px; }
.file-icon { font-family: var(--display); color: var(--purple); }
.preview { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; }
.rev-add { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.rev-add input { width: auto; flex: 1 1 110px; }

dl.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); }
dl.fields > div { padding: 10px 14px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); min-width: 0; }
dl.fields > div.wide { grid-column: 1 / -1; }
dl.fields dt, dl.kv dt { font-family: var(--display); font-size: .78rem; color: var(--muted); }
dl.fields dd, dl.kv dd { margin: 2px 0 0; overflow-wrap: anywhere; }
dl.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 24px; margin: 8px 0 16px; }
dl.kv dd { font-variant-numeric: tabular-nums; font-size: 1.02rem; }
pre.json { white-space: pre-wrap; font-size: .8rem; margin: 0; max-height: 240px; overflow: auto; }
.history { margin-top: 24px; } .history summary { cursor: pointer; font-weight: 600; }

/* lists */
.worklist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.worklist li { padding: 9px 2px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.worklist li.unread { border-left: 3px solid var(--gold); padding-left: 10px; }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.quick-btn { display: block; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--purple); border-radius: var(--r); text-decoration: none; color: var(--ink); font-weight: 600; min-height: 56px; }
.quick-btn:hover { border-left-color: var(--gold); background: var(--purple-wash); }

/* kanban & calendar */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; }
.kcol { background: #EEEBF3; border-radius: var(--r); padding: 10px; min-height: 160px; }
.kcol.drop { outline: 2px dashed var(--purple); }
.kcol h3 { font-size: .95rem; margin: 2px 2px 10px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; margin-bottom: 8px; cursor: grab; }
.kcard a { font-weight: 600; text-decoration: none; color: var(--ink); }
.kmeta { font-size: .8rem; color: var(--muted); margin: 3px 0; }
.kwait { font-size: .78rem; color: var(--warn); }
.kmove { margin-top: 6px; width: 100%; min-height: 30px; font-size: .82rem; padding: 3px 6px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; } .cal-head h3 { margin: 0; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: var(--surface); }
.cal-dow { font-family: var(--display); font-size: .78rem; color: var(--muted); padding: 4px 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal-cell { min-height: 92px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; font-size: .78rem; }
.cal-cell.empty { background: #FAF9FC; }
.cal-cell.today { background: var(--gold-soft); }
.cal-d { font-family: var(--display); color: var(--muted); }
.cal-item { display: block; padding: 2px 4px; margin-top: 2px; border-left: 3px solid var(--purple); background: var(--purple-wash); text-decoration: none; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item.late { border-left-color: var(--bad); } .cal-item.done { opacity: .55; } .cal-item.ms { border-left-color: var(--gold); background: var(--gold-soft); }

/* forms (inspection) */
.ff-section { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 6px 18px 14px; margin: 14px 0; }
.ff-section legend { font-family: var(--display); font-weight: 600; font-size: 1.05rem; padding: 0 6px; }
.ff { padding: 10px 0; border-bottom: 1px solid #EEE; }
.ff-label { display: block; font-weight: 600; margin-bottom: 6px; }
.ff input:not([type=radio]):not([type=checkbox]), .ff select, .ff textarea { width: 100%; max-width: 520px; }
.ff-err { color: var(--bad); font-size: .85rem; }
.pf { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.pf label { position: relative; }
.pf input { position: absolute; opacity: 0; }
.pf span { display: block; padding: 8px 18px; cursor: pointer; border-right: 1px solid var(--line); min-width: 70px; text-align: center; font-weight: 600; }
.pf label:last-child span { border-right: none; }
.pf input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: -3px; }
.pf-pass input:checked + span { background: var(--ok); color: #fff; } .pf-fail input:checked + span { background: var(--bad); color: #fff; } .pf-na input:checked + span { background: #6B6478; color: #fff; }
.pfv { font-weight: 700; } .pfv-pass { color: var(--ok); } .pfv-fail { color: var(--bad); }
.ffv-list { margin: 0; } .ffv { padding: 8px 0; border-bottom: 1px solid #EEE; display: grid; grid-template-columns: minmax(180px, 1fr) 2fr; gap: 12px; }
.ffv dt { font-weight: 600; } .ffv dd { margin: 0; }
.signoff { margin-top: 6px; font-size: .85rem; color: var(--purple-ink); }
.stages { padding-left: 20px; } .stages li { margin: 6px 0; } .stages li.current b { color: var(--purple); } .stages li.done b::after { content: " ✓"; color: var(--ok); }
.sigpad { width: 100%; height: 200px; border: 1px dashed var(--purple); border-radius: var(--r); touch-action: none; background: #fff; display: block; }
.fd-section { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); margin: 12px 0; padding: 10px 14px; }
.fd-section legend input { font-family: var(--display); font-weight: 600; }
.fd-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 0; border-bottom: 1px solid #EEE; }
.fd-row input:first-child { flex: 2 1 220px; } .fd-row .narrow { width: 90px; }
.fd-cond { font-size: .82rem; color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.matrix-wrap { max-height: 70vh; }
.matrix th span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.matrix thead th { position: sticky; top: 0; z-index: 1; }
.conflict { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--gold); padding: 12px 16px; margin: 10px 0; border-radius: 0 var(--r) var(--r) 0; }
.conflict tr.clash td { background: var(--warn-bg); }
.pick { display: flex; gap: 6px; align-items: flex-start; cursor: pointer; }
.mail { background: var(--surface); border: 1px solid var(--line); padding: 10px 14px; margin: 8px 0; border-radius: var(--r); }
.mail pre { white-space: pre-wrap; font-family: var(--body); margin: 6px 0 0; }

/* dialogs & toasts */
dialog { border: none; border-radius: 10px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(28,23,38,.35); }
dialog.wide { width: min(880px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(38,21,59,.55); }
.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.modal-body h2 { margin: 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--r); border-left: 4px solid var(--info); box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast-ok { border-left-color: #5BC184; } .toast-warn { border-left-color: var(--gold); } .toast-bad { border-left-color: #F2726A; }

/* sign-in */
body.auth { background: var(--aubergine); }
body.auth #app { display: grid; place-items: center; grid-template-columns: 1fr; grid-template-areas: none; padding: 16px; }
.auth-card { background: var(--surface); width: min(420px, 100%); padding: 32px 30px 22px; border-top: 6px solid var(--gold); border-radius: 4px; }
.auth-mark { width: 52px; height: 52px; color: var(--purple); }
.auth-company { font-family: var(--display); color: var(--muted); margin: 6px 0 18px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.env-note { font-size: .78rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; margin-bottom: 0; }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 960px) {
  .title-block { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .title-block .tb-main { grid-column: 1 / -1; grid-row: auto; }
  .title-block .tb-wide { grid-column: 1 / -1; }
  .title-block > div { border-left: none; border-right: 1px solid var(--ink); }
  .two-col { grid-template-columns: 1fr; gap: 0; }
  dl.fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  #app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "band" "main"; }
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 10; flex-direction: row; padding-bottom: env(safe-area-inset-bottom); }
  .brand, .side-foot { display: none; }
  .nav { flex-direction: row; overflow-x: auto; padding: 4px; gap: 0; }
  .nav a { flex-direction: column; gap: 2px; font-size: .68rem; padding: 6px 10px; border-left: none; border-top: 3px solid transparent; border-radius: 0; min-width: 64px; }
  .nav a.active { border-top-color: var(--gold); }
  .top { padding: 8px 12px; flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .status .sync-text small { display: none; }
  main#main { padding: 16px 16px 110px; }
  h1 { font-size: 1.45rem; }
  .figures { grid-template-columns: repeat(2, 1fr); }
  .figure:nth-child(3) { padding-left: 0; border-left: none; }
  .figure b { font-size: 1.6rem; }
  .form-grid { grid-template-columns: 1fr; }
  dl.fields { grid-template-columns: 1fr; }
  .ffv { grid-template-columns: 1fr; gap: 2px; }
  .kanban { grid-template-columns: repeat(4, 82vw); scroll-snap-type: x mandatory; } .kcol { scroll-snap-align: start; }
  .cal-cell { min-height: 64px; } .cal-item { font-size: .68rem; }
  .form-actions.sticky { bottom: 64px; }
  .refresh-hint { bottom: 80px; }
  #toasts { bottom: 80px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- print (offline form/report printing) */
@media print {
  .side, .top, .offline-band, .actions-bar, .form-actions, .tabs, #toasts, .refresh-hint, button { display: none !important; }
  #app { display: block; } main#main { padding: 0; max-width: none; }
  body { background: #fff; font-size: 11pt; }
  .title-block { border-color: #000; } .ff-section, .ffv { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}

/* ---------------------------------------------------------------- v1.0 brand: logo on the company's deep purple */
:root { --brand-band: #151225; --brand-gold: #EFD189; }
.side { background: var(--brand-band); }
.brand { padding: 14px 14px 14px; }
.brand-mark { width: 52px; height: 52px; border-radius: 4px; overflow: hidden; background: var(--brand-band); }
.brand-mark img { object-fit: cover; }
.brand-name { color: var(--brand-gold); }
.auth-mark { width: 92px; height: 92px; border-radius: 6px; overflow: hidden; background: var(--brand-band); margin: 0 auto 4px; }
.auth-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.auth-card { text-align: left; } .auth-company { text-align: center; }
/* Branded header strip on every form (fill, view, print) */
.form-brand { display: flex; align-items: center; gap: 14px; background: var(--brand-band); color: #fff; padding: 10px 16px; border-bottom: 3px solid var(--brand-gold); border-radius: 4px 4px 0 0; margin-bottom: 12px; }
.form-brand img { width: 58px; height: 58px; object-fit: cover; border-radius: 3px; flex: none; }
.form-brand .fb-main { flex: 1; min-width: 0; }
.form-brand .fb-co { color: var(--brand-gold); font-family: var(--display); font-size: .82rem; letter-spacing: .04em; }
.form-brand .fb-title { font-family: var(--display); font-size: 1.25rem; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.form-brand .fb-ref { text-align: right; font-family: var(--display); font-size: .8rem; color: #D9CFE8; white-space: nowrap; }
.form-brand .fb-ref b { display: block; color: #fff; font-size: .95rem; }
.tpl-card .tpl-logo { width: 30px; height: 30px; border-radius: 3px; object-fit: cover; vertical-align: middle; margin-right: 6px; }
@media print { .form-brand { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* sites, library, cards */
.site-grid, .tpl-grid, .people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.site-card, .tpl-card, .person-card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--purple); border-radius: var(--r); text-decoration: none; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.site-card:hover, .tpl-card:hover, .person-card:hover { border-top-color: var(--gold); background: var(--purple-wash); }
.site-no { font-family: var(--display); color: var(--muted); font-size: .8rem; }
.site-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--muted); }
.callout { background: var(--bad-bg); border-left: 4px solid var(--bad); padding: 10px 14px; border-radius: 0 var(--r) var(--r) 0; }
.quick-btn small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; margin-top: 2px; }
.quick-btn.alt { border-left-color: var(--gold); }
.photo-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.photo-wall figure { margin: 0; }
.tpl-group { margin: 18px 0 6px; font-size: 1rem; color: var(--purple-ink); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.tpl-card .tpl-code { font-family: var(--display); font-size: .8rem; color: var(--muted); }
.tpl-card .tpl-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.person-card { flex-direction: row; align-items: center; gap: 12px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--purple-wash); color: var(--purple); display: grid; place-items: center; font-family: var(--display); font-weight: 600; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.tag { display: inline-block; font-size: .76rem; padding: 0 8px; border-radius: 10px; background: var(--purple-wash); color: var(--purple-ink); margin: 1px 2px; }
.tags-input { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 6px 0; }

/* charts */
.chart { width: 100%; max-width: 760px; height: auto; display: block; }
.chart text { font: 11px var(--body); fill: var(--muted); }
.chart .axis { stroke: var(--line); } .chart .grid-l { stroke: #EEE; }
.chart .s0 { stroke: var(--purple); } .chart .s1 { stroke: var(--gold); } .chart .s2 { stroke: var(--ok); }
.chart-legend { display: flex; gap: 16px; font-size: .85rem; margin: 4px 0 10px; flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 6px; }
.barlist { margin: 0; padding: 0; }
.barlist .barrow { display: grid; grid-template-columns: minmax(110px, 1.2fr) 2fr minmax(70px, auto); gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px solid #EEE; font-size: .9rem; }
.barlist .bl-bar { height: 10px; background: var(--purple-wash); border-radius: 2px; position: relative; overflow: hidden; }
.barlist .bl-bar i { position: absolute; inset: 0 auto 0 0; background: var(--purple); }
.barlist .bl-val { text-align: right; font-variant-numeric: tabular-nums; }
.defs { font-size: .85rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
.defs dt { font-weight: 600; color: var(--ink); } .defs dd { margin: 0 0 6px; }

/* workload, ITP, drawings */
.workload { overflow-x: auto; }
.workload table td.wl { text-align: center; font-variant-numeric: tabular-nums; min-width: 44px; }
.wl-ok { background: var(--ok-bg); } .wl-high { background: var(--warn-bg); } .wl-over { background: var(--bad-bg); color: var(--bad); font-weight: 700; }
.itp-row.hold td:first-child { border-left: 4px solid var(--bad); } .itp-row.witness td:first-child { border-left: 4px solid var(--gold); }
.pt { font-family: var(--display); font-weight: 700; font-size: .78rem; padding: 0 6px; border-radius: 3px; }
.pt-hold { background: var(--bad-bg); color: var(--bad); } .pt-witness { background: var(--gold-soft); color: #6B5200; } .pt-review { background: var(--info-bg); color: var(--info); } .pt-surveillance { background: #ECE9F0; color: #4F485C; }
.viewer { width: 100%; height: 72vh; border: 1px solid var(--line); background: #fff; }
.viewer-none { padding: 40px 20px; text-align: center; border: 1px dashed var(--line); background: var(--surface); }
.superseded-band { background: var(--bad); color: #fff; padding: 8px 14px; font-weight: 600; border-radius: var(--r); margin: 8px 0; }
.label-card { border: 1.5px solid var(--ink); padding: 12px; display: inline-block; background: #fff; text-align: center; }
.label-card svg { display: block; margin: 6px auto; max-width: 100%; }
.stage-col h3 small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
.perm-group { border: 1px solid var(--line); border-radius: var(--r); padding: 6px 12px 10px; margin: 8px 0; background: var(--surface); }
.perm-group legend { font-family: var(--display); font-weight: 600; padding: 0 4px; }
.perm-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 3px 0; border-bottom: 1px solid #F0EEF3; font-size: .88rem; }
.perm-row .from-role { color: var(--muted); font-size: .78rem; }
@media (max-width: 720px) {
  .form-brand { flex-wrap: wrap; } .form-brand .fb-ref { text-align: left; width: 100%; }
  .barlist li { grid-template-columns: 1fr 1fr; } .barlist .bl-val { grid-column: 2; }
  .perm-row { grid-template-columns: 1fr auto; } .perm-row .from-role { grid-column: 1 / -1; }
}
a.barrow { text-decoration: none; color: var(--ink); } a.barrow:hover { background: var(--purple-wash); }
figure.chart { margin: 0 0 12px; } figure.chart svg { width: 100%; height: auto; max-width: 760px; display: block; }
figure.chart figcaption { display: flex; gap: 16px; font-size: .85rem; flex-wrap: wrap; } figure.chart .key i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 6px; }
dialog { max-height: 92vh; overflow: auto; }
.calc-out { display: inline-block; min-width: 90px; padding: 6px 10px; background: var(--purple-wash); border-radius: var(--r); font-variant-numeric: tabular-nums; font-weight: 600; }
ul.plain { margin: 0; padding-left: 18px; }
/* Logo is a wordmark on a square purple field: show it as a wide crop around the lettering. */
.brand { padding: 10px 12px; }
.brand-mark { width: 100%; height: 84px; border-radius: 4px; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.form-brand img { width: 150px; height: 60px; object-fit: cover; }
.auth-mark { width: 240px; height: 120px; max-width: 100%; }
@media (max-width: 720px) { .form-brand img { width: 120px; height: 48px; } }
.brand-mark { display: block; }
.brand-mark img { display: block; height: 84px; }
.figure { min-width: 0; } .figure b { overflow-wrap: anywhere; }
.figures { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 720px) { .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); } .figure { flex-wrap: wrap; } .figure b { font-size: 1.3rem; } }
.figure b { overflow-wrap: break-word; flex: none; max-width: 100%; }
.figure span { flex: 1 1 0; min-width: 0; }
@media (max-width: 720px) { .figure span { flex-basis: 100%; } }
.figures.money .figure { flex-direction: column; align-items: flex-start; gap: 2px; }
.figures.money .figure b { font-size: 1.35rem; }
.figures.money .figure span { flex: none; }
.site-grid, .tpl-grid, .people-grid { grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); }
