:root {
  --bg: #f6f7f9; --panel: #fff; --text: #14181f; --muted: #5b6573;
  --line: #d9dee6; --accent: #0b5cff; --crit: #b42318; --warn: #b54708; --ok: #067647;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --panel: #171b23; --text: #e8ebf0; --muted: #9aa5b4;
    --line: #2a3140; --accent: #6da0ff; --crit: #ff8a80; --warn: #ffb870; --ok: #6ee0a8;
  }
}
* { box-sizing: border-box; }
/* The hidden attribute must win over any display rule below. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, sans-serif; }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { letter-spacing: .12em; }
.tag { color: var(--muted); }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 53px); }
nav { padding: 12px; border-right: 1px solid var(--line); background: var(--panel); }
nav button { display: flex; justify-content: space-between; width: 100%; margin: 2px 0; padding: 8px; border: 0; border-radius: 6px; background: none; color: var(--text); text-align: left; }
nav button[aria-current="page"] { background: color-mix(in srgb, var(--accent) 15%, transparent); }
nav button:disabled { color: var(--muted); }
nav small { color: var(--muted); }
main { padding: 16px; min-width: 0; }
input, select, button { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); }
button { cursor: pointer; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin: 8px 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.card b { display: block; font-size: 22px; }
.card span { color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); display: block; overflow-x: auto; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.flag { font-size: 12px; padding: 1px 6px; border-radius: 10px; border: 1px solid currentColor; margin-right: 4px; }
.flag.crit { color: var(--crit); } .flag.blocked { color: var(--warn); }
.risk { color: var(--crit); } .good { color: var(--ok); }
#message { min-height: 1.4em; color: var(--warn); }
td input { width: 5em; }
@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  nav { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  nav button { width: auto; white-space: nowrap; gap: 8px; }
}

.split { display: grid; grid-template-columns: minmax(220px, 1fr) 2fr; gap: 16px; }
.list { list-style: none; padding: 0; margin: 0 0 8px; }
.list button { width: 100%; text-align: left; margin: 2px 0; }
.list button[aria-current="true"] { border-color: var(--accent); }
.status-approved { color: var(--ok); } .status-rejected { color: var(--crit); } .status-in_review { color: var(--warn); } .status-superseded { color: var(--muted); }
@media (max-width: 720px) { .split { grid-template-columns: 1fr; } }

/* Brand theme: cyan -> blue -> purple -> magenta -> orange -> yellow on deep navy. */
:root {
  --brand-gradient: linear-gradient(90deg, #00c6ff, #1e5bff 22%, #7a2cff 45%, #ff2d87 68%, #ff7a00 86%, #ffc800);
  --accent: #4b3bff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #080e24; --panel: #0f1a3a; --text: #eaf0ff; --muted: #9db0d8;
    --line: #25336a; --accent: #8fa2ff;
  }
}
.top { position: relative; padding: 8px 16px; }
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--brand-gradient); }
.logo-pill { display: inline-flex; background: #fff; border-radius: 10px; padding: 2px 10px; }
.logo { height: 34px; width: auto; display: block; }
.whoami { margin-left: auto; color: var(--muted); font-size: 14px; }
nav button[aria-current="page"] { background: var(--brand-gradient); color: #fff; }
nav button[aria-current="page"] small { color: #fff; }
button[type="submit"], #cmp-go, #impact-go { background: linear-gradient(90deg, #1e5bff, #7a2cff); color: #fff; border-color: transparent; }
.card { border-top: 3px solid transparent; border-image: var(--brand-gradient) 1; }
h2 { letter-spacing: .02em; }

.splash { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; padding: 0 16px 2vh;
  background: #0b1433 url("assets/splash.webp") center / cover no-repeat; }
.splash[hidden] { display: none; }
.signin { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px 8px; align-items: center; width: min(480px, 100%); padding: 10px 12px; border-radius: 14px;
  background: rgba(8, 14, 36, .72); backdrop-filter: blur(8px); border: 1px solid rgba(255, 255, 255, .18); color: #eaf0ff; }
.signin input { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .3); }
.signin p { grid-column: 1 / -1; margin: 0; min-height: 0;  color: #ffb870; font-size: 14px; }
body.signed-out { overflow: hidden; }
.top .mark { height: 40px; width: 40px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 4px; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 12px; }
.details dt { color: var(--muted); } .details dd { margin: 0; }
.line { grid-template-columns: 2fr 1fr 1fr auto; }
td button { margin-right: 4px; }
.status-delivered { color: var(--ok); } .status-cancelled { color: var(--muted); } .status-issued { color: var(--accent); }
@media (max-width: 720px) { .signin { grid-template-columns: 1fr; } .whoami { display: none; } .line { grid-template-columns: 1fr 1fr; } }
.viewer { height: 600px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: hidden; display: flex; flex-direction: column; }
.viewer.empty { display: grid; place-items: center; padding: 24px; color: var(--muted); text-align: center; }
.viewer-tools { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px; border-bottom: 1px solid var(--line); }
.viewer-tools button { padding: 4px 8px; font-size: 13px; }
.viewer-tools button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: transparent; }
.viewer-gap { width: 12px; }
.viewer-status { margin-left: auto; color: var(--muted); font-size: 13px; text-align: right; }
.viewer-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.viewer-stage > canvas { display: block; }
.sheet-stage { background: #8d939e; touch-action: none; cursor: grab; }
.sheet-stage[data-tool]:not([data-tool="select"]) { cursor: crosshair; }
.sheet-content { position: absolute; top: 0; left: 0; transform-origin: 0 0; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); }
.sheet-page { width: 100%; height: 100%; }
.sheet-page > * { display: block; width: 100%; height: 100%; }
.sheet-overlay { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.sheet-overlay g { cursor: pointer; }

/* Sales */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 8px 12px; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--text); border-image: var(--brand-gradient) 1; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.stack { display: grid; gap: 8px; }
.field { display: grid; gap: 2px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea { color: var(--text); }
textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); width: 100%; resize: vertical; }
.check { display: inline-flex; gap: 6px; align-items: center; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chips button { border-radius: 99px; padding: 3px 10px; font-size: 13px; }
.chips button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: transparent; }
button.primary { background: linear-gradient(90deg, #1e5bff, #7a2cff); color: #fff; border-color: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); margin-right: 4px; white-space: nowrap; }
.badge.good { color: var(--ok); border-color: currentColor; } .badge.bad { color: var(--crit); border-color: currentColor; }
.badge.warn { color: var(--warn); border-color: currentColor; } .badge.mute { color: var(--muted); }
.badge.kind-event { color: var(--accent); border-color: currentColor; }
.queue { list-style: none; padding: 0; margin: 0; }
.queue li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.summary { margin: 0 auto 0 0; font-weight: 600; }
.warn { color: var(--warn); min-height: 1.2em; margin: 0; }
.log { list-style: none; padding: 0; margin: 0; font-size: 13px; color: var(--muted); }
.radar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin: 8px 0; }
.radar-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.radar-card h3 { margin: 6px 0 2px; }
.radar-card dl { margin: 6px 0; display: grid; gap: 2px; }
.radar-card dt { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin-top: 4px; }
.radar-card dd { margin: 0; font-size: 14px; }
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); padding: 0; width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(8, 14, 36, .6); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.dialog-head h2 { margin: 0; font-size: 18px; }
#dialog-message { margin: 0; padding: 0 16px; color: var(--warn); }
#dialog-message:not(:empty) { padding: 8px 16px; }
#dialog-body { padding: 12px 16px 16px; display: grid; gap: 12px; }
#dialog-body h3 { margin: 8px 0 0; }
.showcase-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.showcase-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.showcase-card h3 { margin: 8px 0 0; }
.cover { aspect-ratio: 16 / 10; border-radius: 8px; overflow: hidden; background: #0b1433; }
.cover img, .present-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-empty { width: 100%; height: 100%; display: grid; place-items: center; color: #cfd8ff; font-size: 14px; background: linear-gradient(135deg, #0b1e5c, #5a23c8 55%, #ff2d87); }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.thumb { position: relative; width: 64px; height: 46px; border-radius: 6px; overflow: hidden; padding: 0; border: 1px solid var(--line); background: #0b1433; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 0; right: 0; padding: 0 5px; border: 0; border-radius: 0 0 0 6px; background: rgba(8, 14, 36, .8); color: #fff; line-height: 1.3; }

/* Showcase presentation: always the dark brand stage, whatever the theme. */
dialog.present { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; border: 0; border-radius: 0; padding: 0; color: #eaf0ff;
  background: radial-gradient(circle at 80% 10%, rgba(122, 44, 255, .35), transparent 45%), radial-gradient(circle at 5% 95%, rgba(0, 198, 255, .28), transparent 40%), #080e24; }
dialog.present[open] { display: grid; grid-template-rows: auto 1fr auto; }
.present-top, .present-nav { display: flex; align-items: center; gap: 16px; padding: 14px clamp(16px, 4vw, 48px); }
.present-top img { height: 34px; width: 34px; }
.present-tabs { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.present button { background: none; color: #b8c6ee; border: 1px solid rgba(255, 255, 255, .18); }
.present button[aria-current="true"] { color: #fff; border-image: var(--brand-gradient) 1; }
.present-nav { justify-content: center; }
.present-body { overflow: auto; padding: 0 clamp(16px, 6vw, 96px); display: grid; align-items: center; }
.present-page { max-width: 1200px; width: 100%; margin: 0 auto; }
.present-cover h1 { font-size: clamp(2rem, 5.5vw, 4.4rem); line-height: 1.04; margin: 8px 0 16px; background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.present-logo { width: min(300px, 60vw); display: block; background: #fff; border-radius: 16px; padding: 10px 16px; margin-bottom: 24px; }
.present .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .3em; text-transform: uppercase; color: #8fa2ff; margin: 0 0 8px; }
.present .lead { font-size: 1.05rem; color: #c9d4f5; max-width: 40rem; }
.present h2 { font-size: clamp(1.4rem, 3vw, 2.2rem); margin: 8px 0; }
.present-work { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: clamp(16px, 4vw, 56px); align-items: center; }
.present-list, .present-steps { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.present-list button, .present-steps button { width: 100%; text-align: left; white-space: pre; }
.present-photo { aspect-ratio: 16 / 10; max-height: 56vh; border-radius: 12px; overflow: hidden; background: #0b1433; }
.present-contact { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin-top: 24px; font-size: 1.1rem; }
.present-contact dt { color: #8fa2ff; } .present-contact dd { margin: 0; }
@media (max-width: 760px) { .present-work { grid-template-columns: 1fr; } }
.day h3 { margin: 10px 0 2px; font-size: 14px; color: var(--accent); }

/* Engineering, Workshop and Build-up */
.bar { display: inline-block; width: 90px; height: 8px; border-radius: 99px; background: var(--line); vertical-align: middle; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); }
.bar-fill.good { background: var(--ok); } .bar-fill.warn { background: var(--warn); } .bar-fill.bad { background: var(--crit); }
.util { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.gates { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.gate { display: grid; gap: 6px; align-content: start; }
.gate .row { justify-content: space-between; margin: 0; }
.gate .bar { width: 100%; }
.gate.na { opacity: .6; }
.blockers { margin: 0; padding-left: 20px; color: var(--crit); }
.blockers li { margin: 2px 0; }
.notes { margin: 0; padding-left: 20px; color: var(--muted); font-size: 13px; }
.disclaimer { border-top: 1px solid var(--line); padding-top: 8px; }
.calc-form { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.custom-section { grid-column: 1 / -1; }
.diagram { width: 100%; max-width: 560px; height: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.dg-text { fill: var(--text); font: 11px system-ui, sans-serif; }
.dg-line, .dg-dim-line { stroke: var(--muted); stroke-width: 1; }
.dg-member { stroke: var(--text); stroke-width: 4; }
.dg-load, .dg-point { stroke: var(--accent); fill: none; stroke-width: 1.5; }
.dg-point { stroke: var(--crit); }
.dg-support, .dg-fixed, .dg-toe { fill: var(--muted); stroke: none; }
.dg-wall, .dg-plate, .dg-post { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: var(--text); stroke-width: 1.5; }
.dg-post { fill: color-mix(in srgb, var(--accent) 35%, transparent); }
.dg-bolt { fill: var(--panel); stroke: var(--text); stroke-width: 2; }
.dg-weld { fill: var(--warn); stroke: none; opacity: .8; }
.calc-sheet h3 { margin: 4px 0; }
#print-root { display: none; }
@media print {
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; padding: 0; color: #000; background: #fff; }
  body.printing #print-root * { color: #000 !important; border-color: #888 !important; }
  body.printing table { display: table; }
  body.printing .bar { display: none; }
  body.printing .dg-text { fill: #000; }
}
.grid > *, .stack > *, .row > * { min-width: 0; }
.field input, .field select { width: 100%; max-width: 100%; box-sizing: border-box; text-overflow: ellipsis; }
select { max-width: 100%; }
.hazard { grid-template-columns: 2fr 1fr 2fr; }
.check input { width: auto; }
textarea { box-sizing: border-box; }
#dialog-body td input, #dialog-body td select { min-width: 9em; }
#dialog-body td input[name^="n"], #dialog-body td input[name="note"] { width: 100%; min-width: 16em; }
.alerts { margin: 0; padding-left: 20px; }
.alert-risk { color: var(--crit); } .alert-warn { color: var(--warn); } .alert-info { color: var(--muted); }
