:root { --bg:#f4f6f9; --panel:#fff; --ink:#1c2533; --muted:#6b7686; --line:#e3e7ee; --brand:#0b2353; --accent:#f57c00; --nav:#0b2353; --ok:#1f9d55; --warn:#d98a00; --bad:#d64545; }
* { box-sizing: border-box; }
body { margin:0; font:14px/1.45 system-ui,-apple-system,"Segoe UI",Tahoma,sans-serif; background:var(--bg); color:var(--ink); display:flex; min-height:100vh; }
#nav { width:230px; background:var(--nav); color:#c9d3e0; display:flex; flex-direction:column; padding:14px 10px; position:sticky; top:0; height:100vh; overflow:auto; flex-shrink:0; }
.brand { font-weight:700; font-size:18px; color:#fff; padding:4px 8px 12px; } .brand span { color:#4aa3ff; }
#projectFilter { margin:0 6px 10px; padding:6px; border-radius:6px; border:0; }
#menu .grp { display:flex; align-items:center; gap:6px; width:100%; background:none; border:0; font:inherit; font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:#7f8ca0; margin:6px 0 2px; padding:6px 8px; border-radius:6px; cursor:pointer; text-align:start; }
#menu .grp span { flex:1; }
#menu .grp i { font-style:normal; font-size:10.5px; background:#1d2f4a; color:#9fb0c6; border-radius:9px; padding:0 6px; letter-spacing:0; }
#menu .grp::before { content:'▸'; font-size:10px; transition:transform .15s; }
#menu .grp.open::before { transform:rotate(90deg); }
#menu .grp:hover, #menu .grp.here { color:#c9d3e0; }
#menu .gitems { margin:0 0 6px; }
#menu a .mbadge { float:inline-end; background:#d64545; color:#fff; border-radius:9px; padding:0 7px; font-size:11.5px; line-height:18px; }
[dir=rtl] #menu .grp::before { content:'◂'; }
[dir=rtl] #menu .grp.open::before { transform:rotate(-90deg); }
#menu a { display:block; padding:6px 10px; border-radius:6px; color:#c9d3e0; text-decoration:none; cursor:pointer; }
#menu a.on, #menu a:hover { background:#1d2f4a; color:#fff; }
.navfoot { margin-top:auto; display:flex; flex-direction:column; gap:6px; padding:10px 6px 0; }
.navfoot button, .navfoot a { background:#1d2f4a; color:#c9d3e0; border:0; padding:7px; border-radius:6px; text-align:center; text-decoration:none; cursor:pointer; }
main { flex:1; padding:20px 26px; min-width:0; }
header { display:flex; justify-content:space-between; align-items:center; margin-bottom:16px; gap:10px; }
h1 { margin:0; font-size:22px; }
.btn { background:var(--accent); color:#fff; border:0; padding:8px 14px; border-radius:7px; cursor:pointer; font-weight:600; }
.btn.ghost { background:#e8eef7; color:var(--brand); }
.btn.sm { padding:3px 9px; font-size:12px; }
.cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:12px; margin-bottom:16px; }
.card { background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:14px; }
.card .k { color:var(--muted); font-size:12px; } .card .v { font-size:22px; font-weight:700; margin-top:4px; }
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
@media (max-width:1000px){ .grid2 { grid-template-columns:1fr; } }
table { width:100%; border-collapse:collapse; background:var(--panel); border:1px solid var(--line); border-radius:10px; overflow:hidden; }
th, td { padding:8px 10px; border-bottom:1px solid var(--line); text-align:start; vertical-align:top; }
th { background:#f8fafc; font-size:12px; color:var(--muted); font-weight:600; }
.tag { display:inline-block; padding:2px 8px; border-radius:20px; font-size:12px; background:#eef1f5; }
.tag.ok { background:#e3f6ec; color:var(--ok); } .tag.warn { background:#fff3dc; color:var(--warn); } .tag.bad { background:#fde8e8; color:var(--bad); }
.bar { height:8px; background:#e8ecf2; border-radius:6px; overflow:hidden; min-width:80px; } .bar i { display:block; height:100%; background:var(--brand); }
.gantt { position:relative; height:20px; background:#f0f3f7; border-radius:4px; } .gantt i { position:absolute; top:3px; height:14px; border-radius:4px; background:#9cc6f3; } .gantt b { position:absolute; top:3px; height:14px; border-radius:4px; background:var(--brand); }
h3 { margin:6px 0 10px; font-size:15px; }
.alert { padding:10px 12px; border-radius:8px; margin-bottom:8px; background:#fff3dc; border:1px solid #f3dca8; }
.alert.bad { background:#fde8e8; border-color:#f3c2c2; }
.steps { display:flex; gap:4px; flex-wrap:wrap; } .steps span { padding:2px 8px; border-radius:4px; background:#eef1f5; font-size:12px; } .steps span.done { background:#e3f6ec; color:var(--ok); } .steps span.cur { background:#dcecff; color:var(--brand); font-weight:600; }
dialog { border:0; border-radius:12px; padding:0; width:min(520px,92vw); box-shadow:0 20px 50px rgba(0,0,0,.25); }
dialog form { padding:18px; display:grid; gap:10px; }
dialog label { display:grid; gap:4px; font-size:12px; color:var(--muted); }
dialog input, dialog select, dialog textarea { padding:8px; border:1px solid var(--line); border-radius:6px; font:inherit; color:var(--ink); }
.row { display:flex; gap:8px; justify-content:flex-end; }
.photos img { width:70px; height:70px; object-fit:cover; border-radius:6px; margin-inline-end:4px; }
.chart { display:flex; align-items:flex-end; gap:6px; height:160px; padding:10px; background:var(--panel); border:1px solid var(--line); border-radius:10px; }
.chart div { flex:1; display:flex; flex-direction:column; justify-content:flex-end; align-items:center; font-size:10px; color:var(--muted); height:100%; }
.chart div i { width:100%; background:var(--brand); border-radius:3px 3px 0 0; } .chart div i.over { background:var(--bad); }
.muted { color:var(--muted); }
@media (max-width:760px){ body { flex-direction:column; } #nav { width:100%; height:auto; position:static; } main { padding:16px; } table { display:block; overflow-x:auto; } }
.lnk { color:var(--brand); font-weight:600; text-decoration:none; } .lnk:hover { text-decoration:underline; }
a.btn { text-decoration:none; display:inline-block; }
#userSel { margin:0 6px 10px; padding:6px; border-radius:6px; border:0; background:#1d2f4a; color:#c9d3e0; }
.docgrid { display:grid; grid-template-columns:minmax(0,1.6fr) minmax(280px,1fr); gap:16px; align-items:start; }
@media (max-width:1000px){ .docgrid { grid-template-columns:1fr; } }
.sheet { background:#fff; border:1px solid var(--line); border-radius:6px; padding:28px; box-shadow:0 2px 10px rgba(0,0,0,.05); }
.sheet-h { display:flex; justify-content:space-between; border-bottom:2px solid var(--ink); padding-bottom:10px; margin-bottom:14px; }
.sheet h4 { margin:16px 0 6px; font-size:13px; text-transform:uppercase; color:var(--muted); }
table.kv { border-radius:0; } table.kv th { width:34%; }
.body { padding:10px; background:#fafbfc; border:1px solid var(--line); border-radius:6px; }
.sigs { display:grid; grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); gap:12px; margin-top:22px; }
.sigline { border-bottom:1px solid #999; min-height:42px; font-size:12px; color:var(--ok); padding-top:4px; }
.card h3 { margin-top:0; } .card + .card { margin-top:12px; }
.card textarea { width:100%; padding:8px; border:1px solid var(--line); border-radius:6px; font:inherit; }
.timeline > div { border-inline-start:3px solid #dcecff; padding:4px 10px; margin-bottom:8px; } .timeline p { margin:4px 0 0; }
.atts { display:flex; gap:8px; flex-wrap:wrap; } .att { width:96px; cursor:pointer; text-align:center; background:#fff; border:1px solid var(--line); border-radius:8px; padding:6px; font-size:11px; overflow:hidden; }
.att img { width:100%; height:64px; object-fit:cover; border-radius:4px; } .att small { display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } .fileic { font-size:34px; height:64px; line-height:64px; } .att.add { font-size:28px; color:var(--brand); display:flex; flex-direction:column; justify-content:center; }
.photos.big img { width:160px; height:120px; cursor:zoom-in; }
.mstrip { display:flex; gap:10px; overflow-x:auto; padding-bottom:6px; } .ms { min-width:190px; background:#fff; border:1px solid var(--line); border-top:4px solid var(--brand); border-radius:8px; padding:10px; cursor:pointer; font-size:13px; } .ms.done { border-top-color:var(--ok); }
.spark { display:inline-flex; align-items:flex-end; gap:2px; height:22px; } .spark i { width:5px; background:#9cc6f3; border-radius:1px; }
.up { color:var(--bad); } .down { color:var(--ok); }
#menuBtn { display:none; float:inline-end; background:#1d2f4a; color:#fff; border:0; border-radius:6px; padding:2px 10px; font-size:18px; }
@media (max-width:760px){ #menuBtn { display:inline-block; } #nav:not(.open) #menu, #nav:not(.open) .navfoot, #nav:not(.open) #userSel { display:none; } }
#gsearch { margin-inline-start:auto; padding:8px 12px; border:1px solid var(--line); border-radius:8px; min-width:220px; font:inherit; }
header { flex-wrap:wrap; }
.gallery { display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:12px; } .gallery figure { margin:0; background:#fff; border:1px solid var(--line); border-radius:10px; overflow:hidden; } .gallery img { width:100%; height:140px; object-fit:cover; cursor:zoom-in; } .gallery figcaption { padding:6px 8px; font-size:12px; }
.takt { color:#fff; font-size:12px; padding:6px; border-radius:6px; text-align:center; cursor:pointer; min-width:80px; }
.org, .org ul { list-style:none; padding-inline-start:28px; position:relative; } .org { padding:0; } .org li { margin:8px 0; position:relative; } .org ul li::before { content:''; position:absolute; inset-inline-start:-18px; top:22px; width:14px; border-top:2px solid #c9d6e6; } .org ul { border-inline-start:2px solid #c9d6e6; margin-inline-start:12px; }
.ocard { display:inline-block; background:#fff; border:1px solid var(--line); border-top:3px solid var(--brand); border-radius:8px; padding:8px 12px; font-size:13px; }
.brand span { margin-inline-start:6px; font-weight:600; }
.docgrid.one { grid-template-columns:1fr; }

.brand img { height:34px; max-width:100%; background:#fff; border-radius:8px; padding:6px 10px; box-sizing:content-box; display:inline-block; vertical-align:middle; }
#menu a.on { background:#16336d; color:#fff; box-shadow:inset 3px 0 0 var(--accent); }
.bar i, .gantt b { background:var(--accent); }
.lnk { color:#0b4fa8; }

/* Server mode: signed-in user in the sidebar */
.whoami { color:#fff; padding:8px; font-size:13px; display:grid; gap:2px; }
.whoami small { opacity:.75; }
.whoami button { margin-top:6px; justify-self:start; background:transparent; color:#fff; border:1px solid rgba(255,255,255,.4); border-radius:6px; padding:4px 10px; cursor:pointer; font:inherit; }

/* Dashboard warnings: summary pills + one card per group */
.alsum { display:flex; gap:8px; flex-wrap:wrap; margin:0 0 12px; }
.pill { font-size:13px; font-weight:600; padding:4px 12px; border-radius:20px; background:#fff3dc; color:#8a5a00; }
.pill.bad { background:#fde8e8; color:#b00020; }
.algroups { display:grid; grid-template-columns:repeat(auto-fill, minmax(280px, 1fr)); gap:12px; align-items:start; margin-bottom:20px; }
.algroup { background:#fff; border:1px solid #e3e8f0; border-top:3px solid #f0b429; border-radius:10px; padding:12px; }
.algroup.bad { border-top-color:#d64545; }
.algroup h4 { margin:0 0 8px; display:flex; justify-content:space-between; align-items:center; font-size:14px; }
.algroup h4 b { background:#eef1f5; border-radius:20px; padding:1px 9px; font-size:12px; }
.algroup .alert { margin-bottom:6px; padding:8px 10px; font-size:13.5px; border-width:0 0 0 3px; border-style:solid; border-radius:6px; background:#fffaf0; border-color:#f0b429; }
.algroup .alert.bad { background:#fff5f5; border-color:#d64545; }
.algroup .alert a { color:inherit; text-decoration:none; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }   /* two lines; the record has the rest */
.algroup .alert a:hover { text-decoration:underline; }
.algroup details summary { cursor:pointer; font-size:13px; color:#0b4fa8; margin:4px 0 6px; }

/* Server mode: notifications bell, panel and the email preference */
.bellbtn { position:relative; background:#fff; border:1px solid var(--line); border-radius:8px; padding:6px 10px; font-size:16px; line-height:1; cursor:pointer; }
.bellbtn:hover { border-color:var(--brand); }
.bellbtn i { position:absolute; top:-7px; inset-inline-end:-7px; background:var(--accent); color:#fff; font:700 11px/1 system-ui,sans-serif; font-style:normal; border-radius:10px; padding:3px 6px; }
#notifPanel { position:fixed; z-index:50; inset-inline-end:16px; width:min(380px, calc(100vw - 32px)); max-height:70vh; display:flex; flex-direction:column; background:var(--panel); border:1px solid var(--line); border-top:3px solid var(--accent); border-radius:10px; box-shadow:0 14px 40px rgba(11,35,83,.25); }
#notifPanel[hidden] { display:none; }
.np-head { display:flex; justify-content:space-between; align-items:center; padding:10px 12px; border-bottom:1px solid var(--line); color:var(--brand); }
.np-list { overflow:auto; }
.np-item { display:block; padding:10px 12px; border-bottom:1px solid var(--line); color:var(--ink); text-decoration:none; cursor:pointer; }
.np-item:hover { background:#f4f7fb; }
.np-item.unread { background:#fff7ec; box-shadow:inset 3px 0 0 var(--accent); }
.np-item b { display:block; color:var(--brand); } .np-item small { display:block; color:var(--muted); }
.np-empty { padding:14px 12px; margin:0; }
.emailpref { display:flex; gap:6px; align-items:center; margin-top:6px; font-size:12px; opacity:.9; cursor:pointer; }

/* ======================================================================================================
   Print. Every document is printed by the browser's own Print -> Save as PDF, so this is the print layout:
   A4, black on white, no controls, tables that paginate with a repeating header, blocks that stay together.
   The letterhead (.lh) and footer (.lf) are print-only elements written by print.js; the running page header,
   footer and page numbers are @page margin boxes (Chromium 131+) fed from variables print.js sets.
   ====================================================================================================== */
.print-only { display:none; }
.tick { font-family:"Segoe UI Symbol","Apple Symbols","Noto Sans Symbols 2","DejaVu Sans",system-ui,sans-serif; }
/* The chrome-less document page (print.html): the document alone, on a white A4-width sheet, the way it prints. */
body.printpage { display:block; min-height:0; background:#fff; }
.printpage main { max-width:210mm; margin:0 auto; padding:10mm 14mm 16mm; }
.printpage .print-only { display:block; }
.printpage .lh .lh-row { display:flex; }
.printpage .docgrid, .printpage .grid2 { display:block; }
.printpage .sheet { border:0; box-shadow:none; padding:0; }
.printpage .sheet-h { display:none; }
.printpage .pv { display:inline; }
@media screen { .printpage td.num { white-space:nowrap; } }
.printpage tr.print-only { display:table-row; }
.toast { position:fixed; inset-inline-end:16px; bottom:16px; z-index:60; background:var(--brand); color:#fff; padding:10px 16px; border-radius:8px; box-shadow:0 8px 24px rgba(11,35,83,.3); font-size:13px; }
@page {
  size:A4; margin:20mm 14mm 22mm;
  @top-left { content:var(--pm-hl, ''); font:8pt system-ui,"Segoe UI",Tahoma,sans-serif; color:#444; unicode-bidi:plaintext; vertical-align:bottom; padding-bottom:3mm; }
  @top-right { content:var(--pm-hr, ''); font:8pt system-ui,"Segoe UI",Tahoma,sans-serif; color:#444; unicode-bidi:plaintext; vertical-align:bottom; padding-bottom:3mm; }
  @bottom-left { content:var(--pm-fl, ''); white-space:pre-line; font:7.5pt/1.35 system-ui,"Segoe UI",Tahoma,sans-serif; color:#444; unicode-bidi:plaintext; vertical-align:top; padding-top:3mm; width:78%; }
  @bottom-right { content:var(--pm-fr, ''); white-space:pre-line; font:7.5pt/1.35 system-ui,"Segoe UI",Tahoma,sans-serif; color:#444; unicode-bidi:plaintext; vertical-align:top; padding-top:3mm; }
}
@page :first { @top-left { content:none; } @top-right { content:none; } }

@media print {
  html { background:#fff; }
  body { display:block !important; min-height:0; background:#fff !important; color:#000; font-size:10pt; line-height:1.35; }
  main { display:block; padding:0 !important; min-width:0; }
  /* nothing interactive */
  #nav, #menuBtn, main > header, dialog, #notifPanel, .bellbtn, #gsearch, .noprint, .btn, button, select, textarea, input:not([type=checkbox]),
  .atts, #attPreview, .toast, .navfoot, .ctl, .row:has(> input, > select, > textarea, > button) { display:none !important; }
  .print-only { display:block; }
  .pv.print-only { display:inline; }
  html.mb .lf { display:none !important; }
  a, .lnk { color:inherit !important; text-decoration:none !important; font-weight:inherit; }
  /* checkboxes print as ticks */
  input[type=checkbox] { appearance:none; -webkit-appearance:none; width:auto; height:auto; margin:0 .35em 0 0; border:0; background:none; font-size:11pt; line-height:1; display:inline-block; }
  input[type=checkbox]::before { content:'\2610'; }
  input[type=checkbox]:checked::before { content:'\2611'; }

  /* page structure: documents are one column; the screen's right-hand column follows the sheet */
  .docgrid, .grid2 { display:block !important; }
  .docgrid > div { min-width:0; }
  .sheet { border:0; box-shadow:none; border-radius:0; padding:0; background:none; }
  .sheet-h { display:none !important; }
  h1, h2, h3, h4 { color:#000; break-after:avoid; page-break-after:avoid; }
  h3 { font-size:11pt; margin:10pt 0 4pt; }
  .sheet h4, .trail h4 { font-size:9pt; margin:12pt 0 4pt; padding-bottom:2pt; border-bottom:.75pt solid #555; color:#000; }
  p, li { orphans:3; widows:3; }
  .muted, th { color:#333 !important; }

  /* tables: header repeats on every page, rows are not cut in half */
  table { display:table !important; overflow:visible !important; width:100%; border:0; border-radius:0; background:none; border-collapse:collapse; font-size:9pt; }
  table[style*="overflow"], div[style*="overflow-x"] { overflow:visible !important; }
  th, td { padding:3pt 5pt; border:.5pt solid #777; color:#000; overflow-wrap:break-word; vertical-align:top; background:none; }
  th { font-weight:700; text-align:start; }
  thead { display:table-header-group; }
  thead th { border-bottom:1.25pt solid #000; }
  tfoot { display:table-footer-group; }
  tfoot td, tr.tot td { font-weight:700; border-top:1.25pt solid #000; }
  tr, img, figure, .sigs > div, .lh, .steps { break-inside:avoid; page-break-inside:avoid; }
  table.kv th { width:30%; }
  table.kv thead th { width:auto; }
  .body { background:none; border:.5pt solid #777; border-radius:0; padding:5pt 7pt; }
  .card { background:none; border:.5pt solid #777; border-radius:0; padding:6pt 8pt; margin:0 0 8pt !important; break-inside:avoid; page-break-inside:avoid; }
  .card:has(table) { break-inside:auto; page-break-inside:auto; }
  .card h3 { margin-top:0; }
  .alert, .alert.bad { background:none !important; border:.5pt solid #000; border-radius:0; padding:3pt 6pt; break-inside:avoid; }
  .steps span, .steps span.done, .steps span.cur { background:none; border:.5pt solid #777; color:#000; }
  .steps span.cur { font-weight:700; border-width:1pt; }
  .tag, .bar, .bar i { print-color-adjust:exact; -webkit-print-color-adjust:exact; }
  /* status tags: black on white with an outline, so they read on any printer */
  .tag, .tag.ok, .tag.warn, .tag.bad { background:#fff !important; color:#000 !important; border:.6pt solid #000; font-weight:600; padding:0 5pt; }
  .tag.bad { border-width:1.2pt; }
  .bar { border:.5pt solid #777; }

  /* signatures and approvals stay together */
  .sigs { display:grid; grid-template-columns:repeat(auto-fit, minmax(38mm, 1fr)); gap:10pt; margin-top:18pt; break-inside:avoid; page-break-inside:avoid; }
  .sigline { color:#000; min-height:30pt; border-bottom:.75pt solid #000; }
  .trail { break-inside:auto; margin-top:10pt; }

  /* photos: a grid that continues onto the next page */
  .photos.big { display:grid; grid-template-columns:repeat(3, 1fr); gap:6pt; margin-bottom:8pt; }
  .photos.big img { width:100%; height:auto; aspect-ratio:4 / 3; object-fit:cover; margin:0; border:.5pt solid #777; border-radius:0; break-inside:avoid; page-break-inside:avoid; }

  /* letterhead block (first page) */
  .lh { margin:0 0 10pt; }
  .lh-row { display:flex; justify-content:space-between; align-items:flex-start; gap:12pt; padding-bottom:6pt; border-bottom:1.5pt solid #000; }
  .lh-co { display:flex; align-items:center; gap:8pt; min-width:0; }
  .lh-logo { max-height:18mm; max-width:46mm; width:auto; height:auto; object-fit:contain; }
  .lh-name { font-size:15pt; font-weight:700; line-height:1.15; }
  .lh-det { font-size:7.5pt; color:#333; margin-top:2pt; }
  .lh-det span { display:block; }
  .lh-doc { text-align:end; flex:none; max-width:55%; }
  .lh-title { font-size:12.5pt; font-weight:700; letter-spacing:.03em; text-transform:uppercase; }
  .lh-no { font-size:11pt; margin-top:1pt; }
  .lh-meta { display:flex; flex-wrap:wrap; margin-top:6pt; border-top:.5pt solid #777; border-inline-start:.5pt solid #777; }
  .lh-c { flex:1 1 30%; padding:2pt 6pt 3pt; border-bottom:.5pt solid #777; border-inline-end:.5pt solid #777; min-width:0; }
  .lh-c span { display:block; font-size:6.5pt; letter-spacing:.05em; text-transform:uppercase; color:#444; }
  .lh-c b { font-size:9pt; overflow-wrap:anywhere; }
  /* colour is for the screen: inline status colours print black */
  [style*="color"], .up, .down { color:#000 !important; }
  /* approval trail and history: oldest first, entries not cut in half */
  .timeline { display:flex; flex-direction:column-reverse; }
  .timeline > div { break-inside:avoid; page-break-inside:avoid; }
  .card:has(.timeline) { break-inside:auto; page-break-inside:auto; }
  /* attached files: names only */
  .attlist.print-only { display:block; margin-top:10pt; break-inside:avoid; }
  .attlist h4 { margin:0 0 4pt; font-size:9pt; border-bottom:.75pt solid #555; padding-bottom:2pt; text-transform:uppercase; }
  .attlist ol, .pack ol, .pack ul.gate { margin:2pt 0; padding-inline-start:18pt; }
  .pack ul.gate { list-style:none; padding:0; }
  tr.print-only { display:table-row; }
  td.num, th.num { white-space:nowrap; }
  .pv-text { white-space:pre-wrap; }
  /* right-to-left pages: dates and numbers keep their own order */
  html[dir=rtl] .timeline small, html[dir=rtl] .sigline small { display:inline-block; direction:ltr; unicode-bidi:isolate; }
  .tick { font-size:11pt; line-height:1; }
  /* the server's PDF has its own footer (Chromium template) */
  .pdf .lf { display:none !important; }
  /* in-flow footer: for browsers without page margin boxes */
  .lf { margin-top:14pt; padding-top:4pt; border-top:.5pt solid #777; font-size:8pt; color:#333; break-inside:avoid; }
}

/* Approval levels on a document */
.lvlwrap { margin-top:22px; }
.lvlwrap h4 { margin:0 0 8px; }
.lvls { display:flex; gap:10px; overflow-x:auto; padding-bottom:6px; }
.lvl { flex:0 0 150px; }
.lvl-h { font-size:12px; font-weight:700; color:#5b6780; text-align:center; margin-bottom:4px; }
.lvl-c { border:1px solid #c9d3e6; border-radius:10px; padding:10px; display:grid; gap:4px; text-align:center; background:#fff; min-height:150px; align-content:start; }
.lvl-c small { color:#5b6780; font-size:11.5px; }
.lvl-sig { font-family:'Snell Roundhand','Segoe Script','Brush Script MT',cursive; font-size:18px; color:#0b2353; border-bottom:1px dotted #9aa6bd; min-height:30px; line-height:30px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.lvl-act { justify-self:center; font-size:11.5px; font-weight:700; padding:2px 10px; border-radius:20px; background:#eef1f5; color:#5b6780; }
.lvl.done .lvl-c { border-color:#3559e0; } .lvl.done .lvl-act { background:#3559e0; color:#fff; }
.lvl.cur .lvl-c { border-color:var(--accent); border-width:2px; } .lvl.cur .lvl-act { background:var(--accent); color:#fff; }
.lvl.bad .lvl-c { border-color:#d64545; } .lvl.bad .lvl-act { background:#d64545; color:#fff; }
.lvl-cm { margin:2px 0 0; font-size:12px; text-align:start; background:#f6f8fb; border-radius:6px; padding:4px 6px; }
.lvl-old { margin-top:8px; } .lvl-old summary { cursor:pointer; font-size:13px; color:#0b4fa8; margin-bottom:6px; }

/* My actions on the dashboard */
.inbox { margin-bottom:18px; }
.inbox-q { display:grid; grid-template-columns:repeat(auto-fit, minmax(170px, 1fr)); gap:12px; }
.iq { background:#fff; border:1px solid #e3e8f0; border-radius:10px; padding:12px 14px; text-decoration:none; color:inherit; display:grid; gap:2px; }
.iq:hover { border-color:#b9c4d8; }
.iq small { color:#5b6780; font-size:13px; } .iq b { font-size:30px; line-height:1.1; }
.iq i { height:4px; width:46px; border-radius:4px; background:#f0b429; margin:4px 0; }
.iq.bad i { background:#d64545; } .iq.ok i { background:#2fa66a; }
.iq span { font-size:12px; color:#5b6780; }
.tabs { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:10px; }
.tab { padding:6px 12px; border-radius:20px; background:#eef1f5; color:inherit; text-decoration:none; font-size:13.5px; }
.tab.on { background:var(--brand); color:#fff; }
@media print { .lvls { flex-wrap:wrap; overflow:visible; } .lvl { flex-basis:32mm; } .lvl-c { min-height:0; } .lvl.done .lvl-act, .lvl.cur .lvl-act, .lvl.bad .lvl-act { background:none; color:#000; border:.5pt solid #000; } .inbox { display:none; } }

/* Dashboard widgets */
section[data-w] { margin-bottom:20px; }
.dsgrid { display:grid; grid-template-columns:repeat(auto-fit, minmax(380px, 1fr)); gap:12px; align-items:start; }
.card.ds table { font-size:13px; margin-top:8px; } .card.ds th { font-size:11.5px; white-space:nowrap; } .card.ds td, .card.ds th { padding:5px 6px; text-align:center; } .card.ds td:first-child, .card.ds th:first-child { text-align:start; }
.stack { display:flex; height:6px; border-radius:6px; overflow:hidden; background:#eef1f5; margin:6px 0; } .stack i { display:block; }
.legend span { margin-inline-end:14px; white-space:nowrap; } .legend i, .sumrow i { display:inline-block; width:9px; height:9px; border-radius:50%; margin-inline-end:5px; }
.bars { display:flex; align-items:flex-end; gap:14px; overflow-x:auto; padding-top:6px; }
.bars a { display:grid; justify-items:center; gap:4px; text-decoration:none; color:inherit; min-width:64px; }
.bars i { display:block; width:38px; border-radius:6px 6px 0 0; } .bars small { font-size:11px; color:#5b6780; text-align:center; max-width:84px; }
.sumrow { display:grid; grid-template-columns:1fr auto 42px; gap:8px; align-items:center; font-size:13.5px; padding:3px 0; border-top:1px solid #f0f2f6; } .sumrow small { color:#5b6780; text-align:end; }
.card.ds { overflow-x:auto; } .dsgrid { grid-template-columns:repeat(auto-fit, minmax(460px, 1fr)); }

/* Payment certificate detail */
.ipcd h4 { margin:18px 0 6px; }
table.ipc th, table.ipc td { font-size:13px; } table.ipc tr.off td { color:#9aa6bd; }
table.ipc tr.tot td, table.ipc tr.tot th { font-weight:700; border-top:2px solid #c9d3e6; }
table.ipc.sum td { text-align:end; white-space:nowrap; }

/* Open / closed documents */
.closedbar { background: #fff4e5; border: 1px solid #f0b429; color: #7a4b00; border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; font-weight: 600; }
.tag.closedtag { background: #e8ecfb; color: #3559e0; }
.tag.opentag { background: #e6f6ee; color: #1d7a4a; }
.lockic { font-size: 12px; }
.openstate.is-closed { border-color: #f0b429; }

/* Structured addressing */
.addrform .addrrow { display: grid; grid-template-columns: 92px 1fr; gap: 4px 8px; align-items: center; margin-bottom: 6px; }
.addrform .addrrow input[name$=".contact"] { grid-column: 2; }
.addrform select, .addrform input { width: 100%; padding: 6px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.kv.addr { margin-top: 8px; }

/* Related documents */
.relrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.relrow:last-of-type { border-bottom: 0; }

/* Handover readiness */
button.tab { border: 0; cursor: pointer; font: inherit; }
.hsum { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.hsum .kpi { display: flex; flex-direction: column; min-width: 110px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; text-align: start; font: inherit; color: inherit; }
.hsum .kpi b { font-size: 20px; } .hsum .kpi span { font-size: 12px; color: var(--muted); }
.hsum .kpi.blk { cursor: pointer; } .hsum .kpi.blk.on { border-color: var(--brand); box-shadow: 0 0 0 2px #0b235322; }
.hwrap { overflow-x: auto; max-width: 100%; }
.hmx { border-collapse: collapse; background: var(--panel); font-size: 13px; }
.hmx th, .hmx td { border: 1px solid var(--line); padding: 4px 6px; vertical-align: middle; }
.hmx th.hl { text-align: start; font-weight: 500; min-width: 240px; max-width: 360px; }
.hmx th.hb small { display: block; color: var(--muted); font-weight: 400; }
.hmx td.hc { text-align: center; min-width: 96px; } .hmx td.na { color: var(--muted); }
tr.hside th { background: #eef1f5; text-align: start; font-weight: 600; }
.hs { display: inline-block; border: 0; border-radius: 6px; padding: 3px 8px; font: inherit; font-size: 12px; cursor: pointer; line-height: 1.25; }
.hs small { display: block; font-size: 10.5px; opacity: .85; }
.hs.s0 { background: #fde8e8; color: #a32d2d; } .hs.s1 { background: #fff3dc; color: #8a5a00; }
.hs.s2 { background: #e3f6ec; color: #1d7a4a; } .hs.s3 { background: #dfe8ff; color: #2442b8; }
.hs.dim { opacity: .3; }
.hlines tr.open td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.hother { border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; margin: 8px 0; max-height: 180px; overflow: auto; }
.hother label { display: flex; gap: 6px; align-items: center; margin: 2px 0; }
@media print { .hs { background: none !important; border: 1px solid #999; } }
.hph { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; } .hph img { width: 56px; height: 42px; object-fit: cover; border-radius: 4px; }
.cp { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 4px; font-size: 13px; } .cp:hover { color: var(--brand); }

/* Risk matrix, overdue rows */
.riskmx { border-collapse: collapse; margin: 6px 0 16px; font-size: 13px; }
.riskmx th, .riskmx td { border: 1px solid var(--line); width: 70px; height: 34px; text-align: center; padding: 2px 4px; }
.riskmx td.ok { background: #e3f6ec; } .riskmx td.warn { background: #fff3dc; } .riskmx td.bad { background: #fde8e8; }
tr.late td { color: var(--bad); }

/* Register grid tools */
.gbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.gbar #gq { flex: 1 1 220px; max-width: 340px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; font: inherit; background: var(--panel); color: var(--ink); }
.gbar select { padding: 5px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: var(--panel); color: var(--ink); }
.gby { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.gcols { position: relative; font-size: 13px; }
.gcols summary { cursor: pointer; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); list-style: none; }
.gcols[open] > div { position: absolute; z-index: 20; top: 110%; inset-inline-start: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; box-shadow: 0 6px 20px rgba(0,0,0,.12); min-width: 200px; max-height: 320px; overflow: auto; }
.gcols label { display: flex; gap: 6px; align-items: center; padding: 2px 0; white-space: nowrap; }
.gcount { font-size: 13px; }
.gchips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.gchip { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 20px; padding: 3px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.gchip b { font-weight: 600; color: var(--muted); margin-inline-start: 2px; }
.gchip.on { background: var(--brand); border-color: var(--brand); color: #fff; } .gchip.on b { color: #fff; }
.gchip:disabled { opacity: .45; cursor: default; }
.ggrp { margin-bottom: 12px; } .ggrp > summary { cursor: pointer; padding: 6px 2px; }
body.gridfull #nav { display: none; }
body.gridfull main { padding: 12px 16px; }
@media print { .gbar, .gchips { display: none; } }

/* Dark theme (screen only; printed documents stay black on white) */
@media screen {
  :root[data-theme="dark"] { color-scheme: dark; --bg:#0f1522; --panel:#182131; --ink:#e3e8f1; --muted:#97a3b6; --line:#2a3548; --brand:#7fa8ff; --nav:#0a0f19; --ok:#4cc48a; --warn:#f0b429; --bad:#f07070; }
  [data-theme="dark"] .btn.ghost { background:#24314a; color:#cfe0ff; }
  [data-theme="dark"] th, [data-theme="dark"] tr.hside th { background:#1e2839; }
  [data-theme="dark"] .tag, [data-theme="dark"] .steps span, [data-theme="dark"] .algroup h4 b, [data-theme="dark"] .lvl-act, [data-theme="dark"] .tab, [data-theme="dark"] .stack { background:#26324a; color:var(--ink); }
  [data-theme="dark"] .tag.ok, [data-theme="dark"] .hs.s2, [data-theme="dark"] .riskmx td.ok, [data-theme="dark"] .tag.opentag { background:#173a2a; color:#7fe0ad; }
  [data-theme="dark"] .tag.warn, [data-theme="dark"] .hs.s1, [data-theme="dark"] .riskmx td.warn, [data-theme="dark"] .pill { background:#3b2e10; color:#f6cd6a; }
  [data-theme="dark"] .tag.bad, [data-theme="dark"] .hs.s0, [data-theme="dark"] .riskmx td.bad, [data-theme="dark"] .pill.bad { background:#40191c; color:#ff9a9a; }
  [data-theme="dark"] .hs.s3, [data-theme="dark"] .tag.closedtag { background:#1d2a55; color:#a9bdff; }
  [data-theme="dark"] .alert, [data-theme="dark"] .algroup .alert, [data-theme="dark"] .closedbar { background:#2e2611; border-color:#6a5317; color:var(--ink); }
  [data-theme="dark"] .alert.bad, [data-theme="dark"] .algroup .alert.bad { background:#3a1a1d; border-color:#a44; }
  [data-theme="dark"] .sheet, [data-theme="dark"] .att, [data-theme="dark"] .ms, [data-theme="dark"] .gallery figure, [data-theme="dark"] .ocard, [data-theme="dark"] .algroup,
  [data-theme="dark"] .bellbtn, [data-theme="dark"] .lvl-c, [data-theme="dark"] .iq { background:var(--panel); border-color:var(--line); color:var(--ink); }
  [data-theme="dark"] .body, [data-theme="dark"] .lvl-cm { background:#131b29; }
  [data-theme="dark"] .bar, [data-theme="dark"] .gantt { background:#26324a; }
  [data-theme="dark"] .lnk, [data-theme="dark"] .algroup details summary, [data-theme="dark"] .lvl-old summary { color:#8fb4ff; }
  [data-theme="dark"] #menu a, [data-theme="dark"] .navfoot a { color:#c9d3e0; }
  [data-theme="dark"] .lvl-h, [data-theme="dark"] .lvl-c small, [data-theme="dark"] .iq small, [data-theme="dark"] .iq span, [data-theme="dark"] .bars small { color:var(--muted); }
  [data-theme="dark"] .lvl-sig { color:#cfe0ff; }
  [data-theme="dark"] .np-item:hover { background:#1e2839; } [data-theme="dark"] .np-item.unread { background:#2a2414; }
  [data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea { background:#121a28; color:var(--ink); border-color:var(--line); }
  [data-theme="dark"] .sumrow { border-top-color:var(--line); }
  [data-theme="dark"] .brand img { background:#fff; }
}

/* Reports centre and builder */
.rcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.rcard { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; color: inherit; text-decoration: none; }
.rcard:hover { border-color: var(--brand); }
.rcard small { grid-column: 1; color: var(--muted); font-size: 12.5px; }
.rcard span { grid-column: 2; grid-row: 1 / 3; align-self: center; font-size: 22px; font-weight: 700; }
.rbuild { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .rbuild { grid-template-columns: 1fr; } }
.rform { display: grid; gap: 10px; }
.rform label { display: grid; gap: 3px; font-size: 13px; color: var(--muted); }
.rform input:not([type=checkbox]), .rform select { padding: 6px; border: 1px solid var(--line); border-radius: 6px; font: inherit; color: var(--ink); background: var(--panel); min-width: 0; }
.rform fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 0; }
.rform legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
.rcols { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.rcols label, .rform label.rchk { display: flex; gap: 6px; align-items: center; color: var(--ink); }
.rfrow { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 4px; margin-bottom: 6px; }
.rgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rptmeta { margin: 4px 0 10px; }
.rfil { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 6px; }
.rchart { display: grid; gap: 4px; margin: 0 0 14px; max-width: 640px; }
.rrow { display: grid; grid-template-columns: minmax(90px, 180px) 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.rrow span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rrow i { height: 12px; min-width: 2px; border-radius: 3px; background: var(--brand); }
table.rtable tr.rgrp th { background: var(--bg); color: var(--ink); font-size: 13px; }
table.rtable tr.rtot td { border-top: 2px solid var(--line); }
@media print { #nav, header #actions, #gsearch, .rform { display: none !important; } .rbuild { display: block; } .rrow i { background: #555 !important; } }

/* Project tree */
.ptree { display: inline-block; }
.tag.pk-programme { background: #e8ecfb; color: #3559e0; } .tag.pk-sub-project { background: #eef1f5; color: var(--muted); }
@media screen { [data-theme="dark"] .tag.pk-programme { background: #1d2a55; color: #a9bdff; } }

/* Parallel signatures, check codes, distribution */
.lvl-par { border-top: 1px dashed var(--line); padding-top: 4px; margin-top: 2px; display: grid; gap: 1px; }
.lvl-par .lvl-sig { font-size: 15px; min-height: 0; }
.lvl-code { font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; color: var(--muted); letter-spacing: .03em; }
.dlrow { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-bottom: 8px; }
.dlrow select, .dlrow input { padding: 6px; border: 1px solid var(--line); border-radius: 6px; font: inherit; min-width: 0; }
.dlsent > div { padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }

/* Notification settings and channel matrix */
button.emailpref { background: none; border: 0; color: inherit; padding: 0; text-align: start; }
.chkrow { display: flex !important; gap: 8px; align-items: center; margin: 4px 0; }
.mobrow { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin: 6px 0; }
table.chmx td:not(:first-child), table.chmx th:not(:first-child) { text-align: center; width: 110px; }

/* Bulk snag actions (bulk.js) */
.bulkbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 8px; }
.bulkbar button:disabled { opacity: .45; cursor: default; }
td > input.bsel, th > input.ball { width: auto; margin: 0; }
fieldset.bldpick { border: 1px solid var(--line, #ddd); border-radius: 8px; padding: 6px 10px; max-height: 220px; overflow: auto; margin: 6px 0; }
fieldset.bldpick legend { font-size: 13px; padding: 0 4px; }
fieldset.bldpick label.chkrow { display: flex; gap: 8px; align-items: center; font-weight: normal; margin: 2px 0; }
fieldset.bldpick input { width: auto; }

/* Admin screens (web/admin.js) */
table.admtbl tr.click { cursor: pointer; } table.admtbl tr.click:hover td { background: #f5f8fd; }
.admacc { font-size: 12px; }
.admwrap { overflow-x: auto; max-width: 100%; }
.admrow { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin: 4px 0; }
.admbtns { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.btn.danger { color: var(--bad); border-color: #f3c2c2; }
.muted.small, p.small { font-size: 12px; }
.admperm { max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; }
.admperm table.chmx th, .admperm table.chmx td { padding: 4px 8px; }
.admperm table.chmx td:not(:first-child), .admperm table.chmx th:not(:first-child) { width: 70px; }
.admperm thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
.admperm tr.admsec th, .admperm tr.admsec td { background: #f2f5fa; }
.admperm td.admmod { padding-inline-start: 20px; }
.admco { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.admco form label { display: grid; gap: 4px; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
.admco form input, .admco form textarea { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; color: var(--ink); box-sizing: border-box; }
.admlogo img { max-height: 80px; max-width: 100%; display: block; margin: 6px 0; }
@media (max-width: 800px) { .admco { grid-template-columns: 1fr; } }
.admtbl td.nowrap { white-space: nowrap; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.admperm td.admmod, .admperm tr.admsec th { min-width: 150px; }

/* Company screen: modules in the plan */
.adm-mods { list-style:none; padding:0; margin:6px 0; display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:4px 14px; }
.adm-mods li.off { color:#8a94a6; }
.adm-mods li span { display:inline-block; width:16px; color:var(--ok); }
.adm-mods li.off span { color:#8a94a6; }
/* Lists keep to their key columns; a table that is still too wide scrolls inside its box, never the page. */
.tscroll { max-width:100%; overflow-x:auto; border-radius:10px; }
.tscroll > table { margin:0; }
td .sub { font-size:12px; margin-top:2px; }
.nowrap { white-space:nowrap; }
input.prog { width:90px; vertical-align:middle; }
@media print { .tscroll { overflow:visible; } }
/* BOQ import preview */
.bi-how { margin-bottom:12px; }
.bi-how label.btn { cursor:pointer; }
tr.bi-bad td { background:#fff5f5; }
[data-theme="dark"] tr.bi-bad td { background:#3a1a1d; }

/* Drawn signatures (B7) */
.inkrow { display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-top:10px; }
.inkprev { height:36px; max-width:140px; background:#fff; border-bottom:1px solid #9aa6bd; }
canvas.inkpad { display:block; width:100%; max-width:480px; aspect-ratio:3 / 1; background:#fff; border:1px dashed #9aa6bd; border-radius:8px; touch-action:none; cursor:crosshair; margin:8px 0; }
.lvl-ink { height:30px; max-width:100%; display:block; }
[data-theme="dark"] .lvl-ink, [data-theme="dark"] .inkprev { background:#fff; border-radius:4px; }

/* Two-step sign-in (security.js, B9) */
.seckey { font:600 18px/1.4 ui-monospace, Menlo, Consolas, monospace; letter-spacing:.06em; background:var(--bg, #f4f6f9); border:1px dashed #c9d1de; border-radius:8px; padding:8px 12px; margin:6px 0; user-select:all; }
.secsteps { padding-inline-start:20px; display:grid; gap:8px; }
.seccodes { columns:2; font:15px/1.8 ui-monospace, Menlo, Consolas, monospace; padding-inline-start:28px; user-select:all; }
.adm-2step { display:flex; flex-wrap:wrap; gap:6px 10px; align-items:center; margin-bottom:12px; }

/* Items pinned on the plan (B18, web/plans.js) */
.planweb .plan { position: relative; max-width: 900px; border: 1px solid var(--line, #d6dbe4); border-radius: 8px; overflow: hidden; }
.planweb .plan img { display: block; width: 100%; height: auto; }
.planweb .pin { position: absolute; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; background: #fff; border: 2px solid #e8710a; box-shadow: 0 1px 4px rgba(0,0,0,.3); text-decoration: none; }
.planweb .pin.jobs { border-color: #1a73e8; } .planweb .pin.hse { border-color: #f9ab00; } .planweb .pin.inspections { border-color: #d93025; } .planweb .pin.closed { opacity: .45; }
