/* Panel Calculator — hand-written, no framework, to match the repo's
   no-dependency rule. Form left, live output right, one screen. */

:root {
  --ink: #14181d;
  --ink-2: #4a545f;
  --ink-3: #7c8794;
  --line: #e2e6eb;
  --line-2: #cfd5dd;
  --bg: #eef1f4;
  --card: #ffffff;
  --rail: #171c22;
  --rail-2: #232a32;
  --accent: #0f6dd3;
  --ok: #1f9254;
  --bad: #d13438;
  --dev: #b7791f;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
  --top-h: 62px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
}

/* ---------- top bar ---------- */

.top {
  height: var(--top-h);
  background: var(--rail);
  color: #dfe4ea;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 20;
}
/* the landing screen hides this with [hidden] — CSS specificity does not
   sort attribute selectors before class selectors by itself, so without this
   `.top { display: flex }` above would win and the header would stay on
   screen under the landing card. Same trap `.gate` was already fixed for. */
.top[hidden] { display: none; }

.brand { display: flex; gap: 11px; align-items: center; flex: none; }
.brand-mark {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #16b0a8);
  font-weight: 700; font-size: 13px; color: #fff;
}
.brand strong { display: block; font-size: 14px; }
.brand small { color: #8d99a6; font-size: 11px; }

.job-fields { display: flex; gap: 14px; align-items: center; }
.job-fields label { display: flex; align-items: center; gap: 7px; font-size: 12px; color: #98a3b0; }
.job-fields input {
  width: 116px; background: var(--rail-2); border: 1px solid #38424e;
  color: #fff; border-radius: 7px; padding: 6px 9px; font: inherit; font-size: 13px;
}
.job-fields .unit-tag { color: #6f7b88; font-size: 10px; font-style: normal; }

.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.top-actions select,
.top-actions input[type="search"] {
  background: var(--rail-2); border: 1px solid #38424e; color: #cfd6de;
  border-radius: 7px; padding: 7px 10px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.top-actions input[type="search"] { width: 168px; cursor: text; }
.top-actions input[type="search"]::placeholder { color: #6f7b88; }
/* "No job HI-9999" — said next to the box that was typed into, not in an alert */
.top-msg { font-size: 11.5px; color: #e0a44a; white-space: nowrap; }

/* ---------- shell ---------- */

.app {
  display: grid;
  grid-template-columns: 350px 1fr;
  align-items: start;
}
.app[hidden] { display: none; }

/* ---------- form ---------- */

.form {
  position: sticky;
  top: var(--top-h);
  height: calc(100vh - var(--top-h));
  overflow-y: auto;
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 16px 16px 60px;
}

.room-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.room-tab {
  font: inherit; font-size: 12px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2);
  border-radius: 999px; padding: 6px 13px;
}
.room-tab.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.room-tab.add { border-style: dashed; color: var(--accent); border-color: var(--accent); }

.group { border-top: 1px solid var(--line); padding: 14px 0 4px; }
.group:first-of-type { border-top: none; }
.group h3 {
  margin: 0 0 10px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .8px; color: var(--ink-3);
}

.f { display: block; margin-bottom: 10px; position: relative; }
.f > span { display: block; font-size: 11px; color: var(--ink-2); margin-bottom: 4px; }
.f .unit-tag {
  position: absolute; right: 9px; bottom: 9px;
  font-size: 10px; font-style: normal; color: var(--ink-3); pointer-events: none;
}
.f input, .f select {
  width: 100%; font: inherit; font-size: 13px;
  border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px;
  background: #fff; color: var(--ink);
}
.f input:focus, .f select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.row3 .f > span { font-size: 10.5px; }

.hint { margin: 2px 0 10px; font-size: 10.5px; color: var(--ink-3); line-height: 1.5; }

/* a figure the form worked out rather than asked for — reads like a disabled
   input so it is plainly not somewhere to type */
.derived {
  font-size: 13px; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; background: var(--bg-2, #f6f7f9); color: var(--ink-2);
}

.build-up { margin-top: 12px; }
.build-up h4 {
  margin: 0 0 6px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--ink-3);
}

/* the wall chain's closure readout, and anything else the form has to warn
   about mid-edit. Amber, not red: the form passes through invalid states on
   the way to a valid job, so these report rather than stop anything. */
.chain-ok { margin: 6px 0 10px; font-size: 11px; color: var(--ok); }
.chain-gap, .bad-note {
  margin: 6px 0 10px; font-size: 11px; line-height: 1.5; color: var(--dev);
  background: #fff8ea; border: 1px solid #f0d29a; border-radius: 8px; padding: 8px 10px;
}
.derived.is-bad { color: var(--bad); border-color: var(--bad); }

/* the drawing sheet: one canvas carrying every view, so it is given the room
   to breathe and its own scroll rather than being squeezed into the column */
.draw.sheet .draw-svg {
  overflow: auto; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px;
}
.draw.sheet .draw-svg svg { display: block; min-width: 100%; }

.dl-row {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
}
.dl-label { font-size: 10.5px; color: var(--ink-3); margin-right: 2px; }
.chip-dl {
  font: inherit; font-size: 10.5px; cursor: pointer; color: var(--ink-2);
  background: var(--card); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 3px 9px;
}
.chip-dl:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 3D view ---------- */

.draw-tools { display: flex; align-items: center; gap: 8px; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg-btn {
  font: inherit; font-size: 11.5px; cursor: pointer; padding: 5px 13px;
  background: var(--card); color: var(--ink-2); border: none;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--line-2); }
.seg-btn.is-on { background: var(--accent); color: #fff; }

.wrap3d { margin-top: 4px; }
canvas.view3d {
  display: block; width: 100%; height: 560px;
  background: linear-gradient(#fbfcfd, #eef1f4);
  border: 1px solid var(--line); border-radius: 10px;
  cursor: grab; touch-action: none;
}
canvas.view3d:active { cursor: grabbing; }

.tools3d { display: flex; align-items: center; gap: 14px; margin: 10px 0 0; flex-wrap: wrap; }
.views3d .seg-btn { min-width: 38px; padding: 5px 9px; }

/* the sheet is a set of views, so it says so under the pointer */
.draw-svg.is-clickable svg { cursor: zoom-in; }

/* what a wall gives up at each of its ends */
.end-note { margin: -4px 0 10px; padding-left: 2px; }

/* ---------- flashing ---------- */

.flash-block h3 {
  margin: 0 0 4px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .8px; color: var(--ink-3);
}
table.flash { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
table.flash th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--ink-3); font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--line-2);
}
table.flash td { padding: 7px 10px; border-bottom: 1px solid var(--line); color: var(--ink-2); }
table.flash .num { text-align: right; font-family: var(--mono); color: var(--ink); }
table.flash .mono { font-family: var(--mono); }
table.flash .fl-room td {
  background: var(--bg); font-weight: 600; color: var(--ink); font-size: 11.5px;
}
table.flash tfoot td {
  border-top: 2px solid var(--line-2); border-bottom: none;
  font-weight: 600; color: var(--ink);
}
.fl-note { display: block; font-size: 10px; font-style: normal; color: var(--ink-3); margin-top: 2px; }

/* a flashing the estimator typed in, not one the engine worked out */
table.flash .fl-typed td:first-child { border-left: 2px solid var(--dev); padding-left: 8px; }
.fl-tag {
  margin-left: 6px; font-style: normal; font-size: 9.5px; text-transform: uppercase;
  letter-spacing: .4px; color: var(--dev); border: 1px solid #f0d29a;
  background: #fff8ea; border-radius: 999px; padding: 1px 6px;
}

.extra-flash {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 10px 2px; margin-bottom: 8px; background: var(--card);
}
.extra-flash-head { display: flex; align-items: flex-start; gap: 8px; }
.extra-flash-head .f { flex: 1; }
.hint3d { font-size: 10.5px; color: var(--ink-3); }
.btn.ghost { background: var(--card); color: var(--ink-2); }

/* ---------- the sign-in gate ---------- */

/* Signed out, the tool is not there to be used — so the parts of the header
   that act on a job are gone too, rather than sitting there doing nothing. */
body.signed-out .app,
body.signed-out .job-fields,
body.signed-out #fileMenu,
body.signed-out #jobSearch,
body.signed-out #jobSearchMsg,
body.signed-out #printBtn,
body.signed-out #mailBtn,
body.signed-out #accountMenu { display: none; }

/* Shown by the body class, not by the `hidden` attribute alone.
   `.gate { display: grid }` outranks the browser's own `[hidden] {
   display: none }`, so the card stayed on screen — empty, because the form is
   only built when the page is actually locked. Both are set here so neither
   can win by accident. */
.gate { display: none; }
.gate[hidden] { display: none; }
body.signed-out .gate {
  display: grid; place-items: center;
  min-height: calc(100vh - var(--top-h)); padding: 40px 20px;
}
.gate-card {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 34px 30px 28px;
  box-shadow: 0 12px 40px rgb(0 0 0 / 8%);
}
.gate-card .brand-mark { width: 46px; height: 46px; font-size: 16px; margin: 0 auto 14px; }
.gate-card h1 { margin: 0 0 6px; font-size: 21px; letter-spacing: -.2px; }
.gate-sub { margin: 0 0 22px; font-size: 13px; color: var(--ink-3); }

.auth-form { display: flex; flex-direction: column; gap: 9px; text-align: left; }
.auth-form input {
  font: inherit; font-size: 13.5px; padding: 10px 12px;
  border: 1px solid var(--line-2); border-radius: 9px;
  background: var(--card); color: var(--ink);
}
.auth-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.auth-form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.auth-form .row2 .btn { padding: 9px 13px; }
.auth-form .hint { margin: 0; }

/* said, not hidden: a server with no Supabase runs unlocked, and should say so */
.gate-reason:empty { display: none; }
.gate-reason {
  grid-column: 1 / -1; margin: 0; padding: 10px 16px;
  background: #fff8ea; border-bottom: 1px solid #f0d29a;
  font-size: 12.5px; color: var(--dev);
}

/* ---------- the administrator's screen ---------- */

.admin[hidden] { display: none; }
.admin {
  max-width: 900px; margin: 0 auto; padding: 26px 20px 60px;
}
.admin-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.admin-head h2 { margin: 0; font-size: 20px; flex: 1; }

/* ---------- the landing screen: Create or Upload ---------- */

#landing {
  display: grid; place-items: center; min-height: 100vh; padding: 40px 20px;
}
/* #landing (specificity 100) would otherwise outrank [hidden] (specificity
   10), the exact trap CLAUDE.md records for .gate — the card would stay on
   screen, empty, under whatever was shown after it. */
#landing[hidden] { display: none; }
.landing-card {
  width: 100%; max-width: 520px; text-align: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 40px 34px 34px;
  box-shadow: 0 12px 40px rgb(0 0 0 / 8%);
}
.landing-card .brand-mark { width: 50px; height: 50px; font-size: 17px; margin: 0 auto 16px; }
.landing-card h1 { margin: 0 0 8px; font-size: 24px; letter-spacing: -.3px; }
.landing-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 26px; }
.landing-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  text-align: left; padding: 16px 18px; border-radius: 12px; width: 100%;
}
.landing-btn strong { font-size: 15px; }
.landing-btn span { font-size: 12px; opacity: .85; font-weight: 400; }
.landing-btn.primary span { opacity: .9; }

/* ---------- upload a drawing ---------- */

.upload-drop {
  border: 2px dashed var(--line-2); border-radius: 14px; padding: 36px 20px;
  text-align: center; cursor: pointer; background: var(--card);
}
.upload-drop.is-over { border-color: var(--accent); background: #f3fbfa; }
.upload-drop input[type="file"] { display: none; }
.upload-preview { max-width: 100%; max-height: 360px; border-radius: 10px; margin: 16px auto 0; display: block; }
.upload-notes {
  margin-top: 16px; padding: 12px 14px; background: #fff8ea;
  border: 1px solid #f0d29a; border-radius: 10px; font-size: 12.5px; color: var(--dev);
  white-space: pre-wrap;
}
.upload-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 16px; }
.upload-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--ink-3); }
.upload-fields input { font: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; }
.upload-fields + .upload-notes { margin-bottom: 4px; }
.upload-read { white-space: pre-line; font-size: 12.5px; }
.upload-notes { white-space: pre-line; }
#uploadBody h4 { margin: 22px 0 0; font-size: 14px; }
.admin .scroller { border: 1px solid var(--line); border-radius: 11px; background: var(--card); }
.admin td, .admin th { text-align: left; white-space: nowrap; }
.admin td:last-child { display: flex; gap: 6px; flex-wrap: wrap; }
.admin .btn { padding: 4px 10px; font-size: 12px; }
.admin input.days {
  width: 74px; font: inherit; font-size: 12px; padding: 4px 8px;
  border: 1px solid var(--line-2); border-radius: 7px; background: var(--card); color: var(--ink);
}
.ok-tag, .dev-tag {
  font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
}
.ok-tag { background: #e7f6ed; color: var(--ok); }
.dev-tag { background: #fff8ea; color: var(--dev); }

/* ---------- the estimator's own settings ---------- */

/* Borrows the .admin panel for its frame; only the form inside is new.
   One column at every width: these are long URLs, and a link cut in half by a
   two-column grid is a link nobody can check before pasting over it. */
.settings-form { display: flex; flex-direction: column; gap: 18px; margin: 20px 0 0; }
.settings-field { display: flex; flex-direction: column; gap: 6px; }
.settings-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.settings-field input {
  font: inherit; font-size: 13px; padding: 9px 11px; width: 100%;
  border: 1px solid var(--line-2); border-radius: 9px;
  background: var(--card); color: var(--ink);
}
.settings-field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
/* the hint sits under its box, not over it — these run to three lines */
.settings-field .hint { margin: 0; }

.settings-actions { margin: 22px 0 0; }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  font-weight: 600; padding: 9px 18px;
}
.btn.primary:hover { filter: brightness(1.07); }
.btn.primary:disabled { opacity: .55; cursor: default; filter: none; }

.settings-msg:empty { display: none; }
.settings-msg { margin: 14px 0 0; font-size: 12.5px; }
.settings-msg.ok { color: var(--ok); font-weight: 600; }

.settings-field textarea {
  font: inherit; font-size: 13px; padding: 9px 11px; width: 100%;
  border: 1px solid var(--line-2); border-radius: 9px; resize: vertical;
  background: var(--card); color: var(--ink); line-height: 1.55;
}
.settings-field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* the two attachments are stated, not offered — a job goes out as its BOQ and
   its drawings or it does not go out */
.attached {
  margin: 16px 0 0; padding: 11px 14px; font-size: 12.5px; line-height: 1.55;
  background: var(--bg-2, #f6f7f9); border: 1px solid var(--line); border-radius: 9px;
  color: var(--ink-2);
}

/* ---------- header menus (File, account) ---------- */

/* details/summary, so a menu opens and closes itself with no script */
.menu { position: relative; }
.menu > summary { list-style: none; user-select: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-items {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  min-width: 190px; padding: 6px;
  background: var(--card); border: 1px solid var(--line-2);
  border-radius: 10px; box-shadow: 0 10px 28px rgb(0 0 0 / 18%);
  display: flex; flex-direction: column; gap: 2px;
}
.menu-items > button {
  text-align: left; font: inherit; font-size: 13px; color: var(--ink);
  background: none; border: 0; border-radius: 7px; padding: 8px 10px; cursor: pointer;
}
.menu-items > button:hover { background: var(--bg); }
/* set apart because it cannot be undone, unlike everything above it */
.menu-items > button.danger { color: var(--bad); border-top: 1px solid var(--line); margin-top: 4px; }

.menu-items.account { min-width: 250px; gap: 8px; padding: 12px; }
.menu-items.account input {
  font: inherit; font-size: 13px; padding: 8px 10px;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--card); color: var(--ink);
}
.menu-items.account .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.menu-items.account .hint { margin: 0; }

/* the picked panel's own figures, read straight off the model */
.pick3d {
  display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline;
  margin-top: 10px; padding: 10px 12px; min-height: 42px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.pick3d b { font-size: 12.5px; color: var(--ink); }
.pick3d span { font-size: 12px; color: var(--ink-2); font-family: var(--mono); }
.pick3d .muted { color: var(--ink-3); font-family: var(--sans); }

.link-del {
  background: none; border: none; color: var(--bad); font: inherit; font-size: 11.5px;
  cursor: pointer; padding: 0; text-decoration: underline;
}

/* walls */

.wall {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px; background: #fcfdfe;
}
.wall.is-shared { background: #f6f8fa; border-style: dashed; }
.wall.is-shared .skins { opacity: .55; }
.shared-note {
  margin: 6px 0 0; padding: 6px 8px; border-radius: 6px;
  background: #fff; border: 1px solid var(--line);
}

.partition {
  margin: 8px 0 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 10.5px; color: var(--accent);
}
.partition > span::before { content: '⇄ '; }
.link-go {
  background: none; border: none; color: var(--accent); font: inherit;
  font-size: 10.5px; cursor: pointer; padding: 0; text-decoration: underline;
}
.wall-head { display: flex; justify-content: space-between; align-items: baseline; }
.wall-head b { font-size: 12.5px; }
.from-tag {
  font-size: 10px; padding: 1px 6px; border-radius: 8px; margin-left: 6px;
  color: var(--dev); background: #fff8ea; border: 1px solid #f0d29a;
}
.wall-len { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.wall-toggles { display: flex; gap: 14px; margin-top: 7px; flex-wrap: wrap; }

.chk { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-2); cursor: pointer; }
.chk input { accent-color: var(--accent); }
.chk.door input { accent-color: #c2185b; }
/* decided by the room on the other side, so shown but not changeable here */
.chk.is-locked { cursor: not-allowed; color: var(--ink-3); opacity: .65; }
.chk.is-locked input { cursor: not-allowed; }

.override {
  margin: 8px 0 0; font-size: 10.5px; color: var(--dev);
  background: #fff8ea; border: 1px solid #f0d29a; border-radius: 6px; padding: 5px 8px;
}

.door-box {
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line-2);
}

.add-room {
  margin-top: 8px; width: 100%;
  background: none; border: 1px dashed var(--line-2); color: var(--accent);
  border-radius: 7px; padding: 5px; font: inherit; font-size: 11px; cursor: pointer;
}
.add-room:hover { border-color: var(--accent); background: #f2f7fd; }

.corners {
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line);
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px;
}
/* one end of the wall: its tick, its corner leg and the note under both. A
   column each, so the two ends stay side by side and nothing interleaves. */
.corner-end { min-width: 0; }
.corner-end .f { margin: 4px 0 2px; }
.corner-end .f > span { font-size: 10.5px; }
.corner-end .f input { font-size: 12px; padding: 5px 7px; }
.chk.corner input { accent-color: #b4651a; }
.chk.chq { margin: 8px 0 6px; font-weight: 600; color: var(--ink-2); }
.chk.chq input { accent-color: #e3a008; }
.chk.corner { font-size: 10.5px; }

.skins { margin-top: 9px; display: grid; gap: 6px; }
.skin { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.skin > span { font-size: 10.5px; color: var(--ink-2); white-space: nowrap; }
.skin-pair { display: flex; gap: 5px; }
.skin-pair select {
  font: inherit; font-size: 11px; padding: 4px 6px;
  border: 1px solid var(--line-2); border-radius: 6px; background: #fff; color: var(--ink);
}

.skin-cell { color: var(--ink-3); font-size: 11.5px; }

/* ---------- output ---------- */

.out { padding: 22px 26px 70px; min-width: 0; }
.muted { color: var(--ink-3); font-size: 13px; }

.summary { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 11px; padding: 12px 16px; min-width: 128px;
}
.card small {
  display: block; color: var(--ink-3); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .6px;
}
.card b { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.card b em { font-style: normal; font-size: 12px; color: var(--ink-3); margin-left: 3px; }

/* each room is its own labelled section — drawings then its BOQ */
.room-head {
  font-size: 14px; letter-spacing: .3px; font-weight: 600;
  color: var(--ink); margin: 34px 0 14px;
  padding: 10px 16px; background: var(--rail); color: #fff;
  border-radius: 10px;
}
.room-head:first-of-type { margin-top: 0; }
/* every room's sheet lives under this one heading */
.boq-head { background: var(--accent); }

/* the heading and the workbook button sit on one line; the heading keeps its
   own margins, so the row only has to align them */
.boq-head-row { display: flex; align-items: center; gap: 12px; }
.boq-head-row .room-head { flex: 1; margin-bottom: 14px; }
.boq-head-row .btn { flex: none; }
@media (max-width: 640px) {
  .boq-head-row { flex-wrap: wrap; }
  .boq-head-row .room-head { flex-basis: 100%; margin-bottom: 8px; }
  .boq-head-row .btn { min-height: 40px; margin-bottom: 14px; }
}

.grand { border-color: var(--accent); }
.grand td.desc { font-weight: 600; }
.grand td.num { font-size: 15px; }

.block {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; margin-bottom: 18px;
}
.block-head { padding: 13px 18px; border-bottom: 1px solid var(--line); }
.block-head h3 { margin: 0; font-size: 13px; letter-spacing: .4px; }
.block-head p { margin: 3px 0 0; font-size: 11.5px; color: var(--ink-3); font-family: var(--mono); }

.draw { padding: 0; }
.layout { border-color: var(--accent); margin-bottom: 26px; }
.layout .draw-head { background: #f2f7fd; }
.draw-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; padding: 12px 18px; border-bottom: 1px solid var(--line);
}
.draw-head h3 { margin: 0; font-size: 13.5px; }
.draw-head p { margin: 3px 0 0; font-size: 11px; color: var(--ink-3); font-family: var(--mono); }
/* The drawing as it was uploaded, above everything generated from it. It scrolls
   inside its own box so a sheet that is metres wide never widens the page, and
   it is a plain details element, so it folds away with no script. */
.out-slot:empty { display: none; }
.uploaded-drawing {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px 14px; margin-bottom: 22px; min-width: 0;
}
.uploaded-drawing[hidden] { display: none; }
.uploaded-drawing > summary {
  cursor: pointer; font-weight: 600; font-size: 14px; min-height: 40px;
  display: flex; align-items: center; gap: 8px; list-style: none;
}
.uploaded-drawing > summary::-webkit-details-marker { display: none; }
.uploaded-drawing > summary::before { content: "▸"; transition: transform .15s; }
.uploaded-drawing[open] > summary::before { transform: rotate(90deg); }
.uploaded-drawing .hint { margin: 2px 0 10px; }
.uploaded-box {
  max-height: 42vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; -webkit-overflow-scrolling: touch;
}
.uploaded-view { display: block; max-width: 100%; height: auto; margin: 0 auto; }
embed.uploaded-view { width: 100%; height: 40vh; min-height: 300px; }
.uploaded-drawing .link-go { display: inline-block; margin-top: 10px; min-height: 40px; line-height: 40px; }
.draw-svg { padding: 16px; overflow-x: auto; text-align: center; }
.draw-svg svg { max-width: 100%; height: auto; }

.btn {
  font: inherit; font-size: 12.5px; cursor: pointer; flex: none;
  border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2);
  border-radius: 8px; padding: 6px 13px;
}
.btn:hover { border-color: var(--ink-3); }
/* the Guide and Back buttons are links, so they need the plain look too */
a.btn { text-decoration: none; display: inline-block; line-height: 1.5; }

/* ---------- BOQ table ---------- */

.scroller { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th {
  background: #fafbfc; color: var(--ink-3);
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
}
td.desc, th.desc { text-align: left; white-space: normal; min-width: 220px; }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #f7f9fb; }
tr.total td {
  border-top: 2px solid var(--line-2); border-bottom: none;
  font-weight: 700; background: #fafbfc;
}
tr.total td.desc { text-transform: uppercase; letter-spacing: .5px; font-size: 11px; }

.error {
  background: #fdecec; border: 1px solid #f5b7b7; color: #97231f;
  border-radius: 9px; padding: 11px 14px; font-size: 13px; margin: 0 0 12px;
}

/* Said, not corrected. Used where the estimator has typed figures that do not
   add up — the door's frame + leaf + frame against its module. Amber, the
   colour this repo already uses for "look at this", never red for "wrong". */
.warn {
  background: #fff8ea; border: 1px solid #f0d29a; color: var(--dev);
  border-radius: 9px; padding: 9px 12px; font-size: 12px;
  line-height: 1.55; margin: -4px 0 12px;
}

/* A finding, not a failure: the job still builds, but a wall is missing from
   it. Amber, the same colour the verifier's ! rows use. */
.problems {
  background: #fff8ea; border: 1px solid #f0d29a;
  border-radius: 11px; padding: 13px 16px; margin: 0 0 22px;
}
.problems h3 {
  margin: 0 0 8px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .8px; color: var(--dev);
}
.problems ul { margin: 0; padding-left: 18px; }
.problems li { font-size: 12.5px; line-height: 1.6; color: var(--ink-2); margin-bottom: 4px; }
.problems .hint { margin: 8px 0 0; }

/* ---------- the guide page ---------- */

/* /guide renders GUIDE.md itself — see web/guide.js. There is no second copy
   of the instructions, so everything below is styling for that one file. */
.guide {
  max-width: 860px;
  margin: 0 auto;
  padding: 30px 24px 90px;
  background: var(--card);
  min-height: calc(100vh - var(--top-h));
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.75;
}
.guide h1 { font-size: 26px; margin: 0 0 18px; letter-spacing: -.2px; }
.guide h2 {
  font-size: 20px; margin: 44px 0 14px; padding-top: 22px;
  border-top: 1px solid var(--line);
}
.guide h3 { font-size: 16px; margin: 32px 0 10px; }
.guide h4 { font-size: 14px; margin: 24px 0 8px; color: var(--ink-2); }
.guide p { margin: 0 0 14px; }
.guide ul, .guide ol { margin: 0 0 16px; padding-left: 22px; }
.guide li { margin-bottom: 6px; }
.guide a { color: var(--accent); }
.guide code {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px;
}
.guide pre {
  background: var(--rail); color: #dfe4ea; border-radius: 10px;
  padding: 14px 16px; overflow-x: auto; margin: 0 0 18px;
}
.guide pre code { background: none; border: none; padding: 0; color: inherit; font-size: 12.5px; }
.guide blockquote {
  margin: 0 0 18px; padding: 12px 16px;
  background: #fff8ea; border: 1px solid #f0d29a; border-radius: 10px;
}
.guide blockquote :last-child { margin-bottom: 0; }
.guide hr { border: none; border-top: 1px solid var(--line); margin: 34px 0; }
.guide .scroller { margin: 0 0 20px; border: 1px solid var(--line); border-radius: 10px; }
/* the BOQ tables are all figures and right-align; the guide's are prose */
.guide th, .guide td { text-align: left; white-space: normal; }
.guide td:first-child { font-weight: 600; }

/* ---------- print ---------- */

/* A4 — the shop, 5 October 2026: the drawing must come out on A4 when printed
   or saved as a PDF through the browser's own print dialog, not whatever the
   OS defaults to. Landscape, because a job sheet is wider than it is tall. */
@page {
  size: A4 landscape;
  margin: 10mm;
}

@media print {
  .top, .form { display: none; }
  .app { display: block; }
  .out { padding: 0; }
  .block { border: none; page-break-inside: avoid; }
  .summary { gap: 8px; }
  /* the drawing sheet scrolls on screen; printed, it must fit the page
     rather than being clipped to whatever the scroll box shows */
  .draw.sheet .draw-svg { overflow: visible; border: none; padding: 0; }
  .draw.sheet .draw-svg svg { width: 100%; height: auto; max-width: 100%; }
  .draw-tools, .dl-row { display: none; }
  /* the uploaded drawing is a reference on screen, not part of the issued sheet */
  .uploaded-drawing, .out-slot { display: none; }
}

/* ---------- narrow screens ---------- */

/* A tablet: one column, the form above the output rather than beside it. */
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .form {
    position: static; height: auto; max-height: none;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .top { height: auto; padding: 10px 14px; flex-wrap: wrap; gap: 10px; }
  .top-actions { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .job-fields { flex-wrap: wrap; }
}

/* A phone. The engine is the same; what changes is that nothing may sit off
   the side of the screen, and every control has to be big enough to hit with
   a thumb — 44px is the size a finger actually needs. */
@media (max-width: 640px) {
  .top { gap: 8px; padding: 10px 12px; }
  .brand small { display: none; }
  .job-fields { width: 100%; gap: 8px; }
  .job-fields label { flex: 1; }
  .job-fields input { width: 100%; min-width: 0; }
  .top-actions select,
  .top-actions input[type="search"],
  .btn { min-height: 40px; }
  .top-actions input[type="search"] { flex: 1; width: auto; min-width: 120px; }

  .out { padding: 14px 12px 60px; }
  .form { padding: 14px 12px 40px; }

  /* two-up and three-up rows stack rather than squeeze */
  .row2, .row3 { grid-template-columns: 1fr; }
  /* the four figures go two by two instead of running off the side */
  .summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .summary .card { min-width: 0; }

  /* a form control has to be thumb-sized, and 16px stops iOS zooming on focus.
     .corner-end wins on specificity off the phone, so it is named again here —
     without it the corner leg box would be the one control iOS zooms into. */
  .f input, .f select, .auth-form input,
  .settings-field input,
  .corner-end .f input { min-height: 42px; font-size: 16px; }

  /* two corner ends side by side leaves nothing to type in — one per row */
  .corners { grid-template-columns: 1fr; }
  .settings-actions .btn.primary { min-height: 42px; width: 100%; }
  .chk { min-height: 40px; display: flex; align-items: center; }
  .chk input { width: 20px; height: 20px; }

  /* a menu that hangs off the right edge is unreachable on a phone */
  .menu-items { right: auto; left: 0; min-width: min(78vw, 300px); }
  .menu-items.account { min-width: min(84vw, 320px); }

  .gate-card { padding: 26px 20px 22px; }
  .admin { padding: 18px 12px 60px; }
  .admin td:last-child { gap: 5px; }

  /* the sheet is wide by nature; it scrolls inside its own box, never the page */
  .draw-svg, .scroller { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .guide { padding: 22px 16px 70px; font-size: 15px; }
}

/* Nothing may push the page sideways — a drawing sheet is metres wide and the
   phone is not, so the overflow belongs to the box that holds it. */
body { overflow-x: hidden; }
svg { max-width: 100%; height: auto; }
