/* T-CUT · shop-drawing palette: graphite, birch ply, blueprint blue */
:root {
  --ink: #1d2a33;
  --ink-2: #4d5c66;
  --side: #22303a;
  --side-2: #2d3e4a;
  --paper: #f3f2ef;
  --panel: #ffffff;
  --line: #d3dadf;
  --line-2: #eeece7;
  --accent: #4A3B46;
  --accent-ink: #ffffff;
  --ply: #d9bf8c;
  --ply-2: #b8925a;
  --ok: #2f7d4f;
  --warn: #a8660f;
  --err: #b42318;
  --r: 6px;
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-c: 'Barlow Condensed', 'Arial Narrow', 'Barlow', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--paper); line-height: 1.45; }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
small, .small { font-size: .87rem; }
.muted { color: var(--ink-2); }
h1, h2, h3 { font-family: var(--font-c); font-weight: 600; letter-spacing: .01em; line-height: 1.15; }

/* ---------- plywood edge mark ---------- */
.ply {
  display: inline-block; width: 26px; height: 26px; border-radius: 3px; flex: none;
  background: repeating-linear-gradient(180deg, var(--ply) 0 4px, var(--ply-2) 4px 5px, #e8d3a8 5px 8px, var(--ply-2) 8px 9px);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.18);
}

/* ---------- shell ---------- */
body.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  background: var(--side); color: #d9d9d9; display: flex; flex-direction: column; gap: 18px;
  padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-right: 5px solid transparent;
  border-image: repeating-linear-gradient(180deg, var(--ply) 0 6px, var(--ply-2) 6px 7px, #e8d3a8 7px 12px, var(--ply-2) 12px 13px) 5;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-name { font-family: var(--font-c); font-size: 1.7rem; font-weight: 700; letter-spacing: .04em; }
.who { display: flex; flex-direction: column; font-size: .9rem; padding-bottom: 14px; border-bottom: 1px solid var(--side-2); }
.who strong { color: #fff; font-weight: 600; }
.who span { color: #a3a3a3; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: #d9d9d9; text-decoration: none; padding: 8px 10px; border-radius: var(--r); }
.side nav a:hover { background: var(--side-2); }
.side nav a.on { background: #2b2b2b; color: #fff; box-shadow: inset 3px 0 0 var(--ply); }
.logout { margin-top: auto; color: #a3a3a3; font-size: .9rem; }
.main { padding: 22px 28px 60px; min-width: 0; max-width: 1240px; }
body.wide .main { max-width: none; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.top h1 { margin: 0; font-size: 2rem; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lede { color: var(--ink-2); max-width: 75ch; margin-top: 0; }
h2.sec { font-size: 1.25rem; margin: 26px 0 10px; }
.panel h2.sec:first-child { margin-top: 0; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 500 .95rem var(--font); padding: 8px 14px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: #b9b6ae; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #D9B812; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { color: var(--err); }
.btn.danger { background: var(--err); color: #fff; border-color: var(--err); }
.btn.small { padding: 5px 10px; font-size: .88rem; }
.btn.wide { width: 100%; }
.btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: .9rem; text-decoration: underline; text-underline-offset: 2px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.stack { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--ink-2); font-weight: 500; margin-bottom: 10px; }
input, select, textarea {
  font: 1rem var(--font); color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  padding: 7px 9px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(237,205,37,.15); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
input[type=color] { padding: 2px; height: 36px; }
input.num { text-align: right; }
label.check { flex-direction: row; align-items: flex-start; gap: 8px; color: var(--ink); }
label.check span { display: flex; flex-direction: column; }
label.check small { color: var(--ink-2); font-weight: 400; }
.checks { display: grid; gap: 4px; }
.seg { display: grid; gap: 6px; margin-bottom: 12px; }
.seg label { flex-direction: row; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); margin: 0; }
.seg label:has(input:checked) { border-color: var(--accent); background: #fcf7dc; }
.row2, .row3, .row4 { display: grid; gap: 0 12px; }
.row2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.panel legend { font-family: var(--font-c); font-size: 1.25rem; font-weight: 600; padding: 0; margin-bottom: 10px; float: left; width: 100%; }
fieldset.panel legend + * { clear: both; }
.form-end { display: flex; gap: 8px; justify-content: flex-end; align-items: center; grid-column: 1 / -1; margin-top: 6px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 16px; }
.panel.narrow { max-width: 560px; }
.panel.sticky { position: sticky; top: 16px; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.cols .form-end { margin-top: -4px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.split.wide-left { grid-template-columns: minmax(0, 1fr) 400px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 160px; }
.filter { display: flex; gap: 8px; margin-bottom: 12px; max-width: 520px; }
.mini { display: inline; margin: 0; }
.mini select { width: auto; padding: 3px 6px; font-size: .9rem; }

/* ---------- tables ---------- */
.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; font-size: .95rem; }
.grid th { text-align: left; font-weight: 600; font-size: .85rem; color: var(--ink-2); background: #f8f7f4; border-bottom: 1px solid var(--line); padding: 8px 10px; }
.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tfoot td { border-top: 1px solid var(--line); background: #faf9f7; }
.grid tr.strong td { font-weight: 700; font-size: 1.05rem; }
.grid tr.group td { background: #f4efe4; font-weight: 600; font-size: .85rem; color: #6b5532; }
.grid.compact td, .grid.compact th { padding: 5px 8px; font-size: .9rem; }
.grid.lines td { padding: 4px 6px; }
.grid .num, .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid td.acts { white-space: nowrap; }
.grid td.acts .link { margin-left: 10px; }
.grid tr.on td { background: #fcf7dc; }
.grid tr[data-pick] { cursor: pointer; }
.late { color: var(--err); font-weight: 600; }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 3px; border: 1px solid rgba(0,0,0,.2); vertical-align: middle; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: .8rem; font-weight: 600; background: #ecebe6; color: var(--ink-2); }
.tag.active, .tag.approved, .tag.paid { background: #e1f1e7; color: var(--ok); }
.tag.sent, .tag.invited { background: #f8eeb8; color: var(--accent); }
.tag.suspended, .tag.disabled, .tag.rejected, .tag.void { background: #fbe6e4; color: var(--err); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 7px 12px; text-decoration: none; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-color: var(--ink); font-weight: 600; }

.flash { padding: 10px 14px; border-radius: var(--r); margin-bottom: 14px; border: 1px solid; background: #fff; }
.flash.ok { border-color: #b7dcc4; background: #f1f9f4; }
.flash.error { border-color: #f0b8b2; background: #fdf3f2; color: #7a1a12; }
.flash.warn { border-color: #ebcf9f; background: #fdf7ec; }
.flash small a { word-break: break-all; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 8px; }
.stats div { padding: 14px 18px; border-left: 1px solid var(--line-2); display: flex; flex-direction: column; }
.stats div:first-child { border-left: 0; }
.stats b { font-family: var(--font-c); font-size: 1.9rem; font-weight: 600; line-height: 1.1; }
.stats span { color: var(--ink-2); font-size: .9rem; }
.meter { height: 6px; background: var(--line-2); border-radius: 3px; overflow: hidden; max-width: 420px; }
.meter span { display: block; height: 100%; background: var(--ply-2); }
.meter-label { margin: 24px 0 6px; }
.empty { padding: 50px 0; }
details.danger { margin-top: 30px; color: var(--ink-2); }
details.danger summary { cursor: pointer; }
details.paste summary { cursor: pointer; color: var(--accent); margin: 8px 0; }

/* ---------- auth ---------- */
body.bare:not(.doc) { min-height: 100vh; display: grid; }
.auth { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, 1fr); min-height: 100vh; background: var(--paper); }
.auth-side { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 30px; padding: 44px 56px; color: #f3ead8;
  background: radial-gradient(1200px 600px at -10% -20%, #3a4d5c 0%, transparent 60%), radial-gradient(900px 500px at 120% 120%, #5a3d22 0%, transparent 55%), #1e2a33; }
.auth-side::before { content: ''; position: absolute; inset: 0; opacity: .07; pointer-events: none;
  background-image: linear-gradient(#e9d6b0 1px, transparent 1px), linear-gradient(90deg, #e9d6b0 1px, transparent 1px); background-size: 46px 46px; }
.as-brand { display: flex; align-items: center; gap: 12px; font-family: var(--font-c); font-size: 1.9rem; position: relative; }
.as-brand .ply { width: 38px; height: 38px; }
.as-copy { position: relative; max-width: 560px; }
.as-copy h2 { font-family: var(--font-c); font-size: clamp(2rem, 3.4vw, 3.2rem); line-height: 1.05; margin: 0 0 14px; color: #fff; }
.as-copy p { font-size: 1.1rem; color: #cdbfa6; margin: 0 0 22px; max-width: 470px; }
.as-copy ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.as-copy li { display: flex; gap: 12px; align-items: center; font-size: 1rem; color: #ece2cf; }
.as-copy li span { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; background: rgba(233,214,176,.12); color: var(--ply); }
.as-art { position: relative; width: min(520px, 100%); height: auto; opacity: .95; }
.as-foot { position: relative; margin: 0; font-size: .82rem; color: #97a6b0; }
.auth-card { align-self: center; justify-self: center; width: 100%; max-width: 420px; padding: 40px 32px; background: transparent; border: 0; }
.auth-top { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-bottom: 28px; }
.auth-top .auth-brand { margin-right: auto; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-c); font-size: 1.6rem; font-weight: 700; }
.auth-brand.mobile-only { display: none; }
.auth-title { font-family: var(--font-c); font-size: 2.2rem; margin: 0 0 4px; }
.auth-card > p.muted { margin: 0 0 22px; }
.auth-form label { margin-bottom: 16px; font-weight: 600; }
.lbl-row { display: flex; justify-content: space-between; align-items: baseline; } .lbl-row a { font-weight: 400; font-size: .88rem; }
.in-ico { position: relative; display: block; margin-top: 6px; }
.in-ico > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-2); pointer-events: none; }
.in-ico input { padding: 13px 44px 13px 42px; font-size: 1rem; border-radius: 10px; width: 100%; }
.in-ico input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(237,205,37,.15); outline: none; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; color: var(--ink-2); }
.pw-eye:hover, .pw-eye.on { color: var(--accent); background: #fcf7dc; }
.btn.big.wide { padding: 14px; font-size: 1.05rem; border-radius: 10px; margin-top: 6px; }
.auth-help { margin-top: 22px; }
.auth .flash { margin-bottom: 16px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 22px 24px; gap: 10px; }
  .as-art, .as-copy ul, .as-copy p, .as-foot { display: none; }
  .as-copy h2 { font-size: 1.5rem; margin: 0; }
  .auth-card { padding: 28px 22px 40px; align-self: start; }
}
body.bare .main { padding: 0; max-width: none; }

/* ---------- planner ---------- */
.planner-wrap { display: grid; grid-template-columns: 190px minmax(0, 1fr) 270px 290px; gap: 14px; align-items: start; }
.palette { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; max-height: calc(100vh - 120px); overflow-y: auto; position: sticky; top: 12px; }
.pal-group h3 { font-size: .95rem; margin: 6px 4px; color: var(--ink-2); }
.pal-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: var(--r); padding: 6px; cursor: grab; font: .9rem var(--font); color: var(--ink); }
.pal-item:hover { border-color: var(--line); background: #f8f7f4; }
.pal-item span:last-child { display: flex; flex-direction: column; line-height: 1.2; }
.pal-item small { color: var(--ink-2); font-size: .78rem; }
.pal-ico { width: 26px; max-height: 34px; flex: none; border: 1.5px solid var(--ink); border-radius: 2px; background: linear-gradient(90deg, transparent 47%, var(--ink) 47% 53%, transparent 53%), var(--ply); }
.pal-ico.appl { background: #c9ced2; }
.stage { min-width: 0; }
.stage-bar { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; color: var(--ink-2); margin-bottom: 6px; }
.save-state { font-weight: 600; color: var(--ok); }
.save-state.dirty { color: var(--warn); }
.save-state.err { color: var(--err); }
.canvas { background: #fff; border: 1px solid var(--line); border-radius: var(--r); touch-action: none; }
.canvas:focus-visible { outline: 2px solid var(--accent); }
.plan { display: block; width: 100%; height: auto; max-height: 72vh; user-select: none; font-family: var(--font-c); }
.plan .wall { fill: #3a3a3a; }
.plan .floor { fill: #fbfaf7; }
.plan .grid-minor { fill: none; stroke: #eeece8; stroke-width: 2; }
.plan .grid-major { stroke: #d9dfe3; stroke-width: 4; }
.plan .wall-lab { fill: var(--ink-2); text-anchor: middle; }
.plan .cab rect { fill: #f0e3c8; stroke: var(--ink); stroke-width: 8; }
.plan .cab.upper rect { fill: rgba(237,205,37,.10); stroke: var(--accent); stroke-dasharray: 30 18; }
.plan .cab.appl rect { fill: #e2e0db; }
.plan .cab .front { stroke: var(--ply-2); stroke-width: 26; }
.plan .cab.upper .front { stroke: var(--accent); }
.plan .cab text { fill: var(--ink); text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.plan .cab text .dim { fill: var(--ink-2); font-size: .8em; }
.plan .cab { cursor: move; }
.plan .cab.sel rect { stroke: var(--accent); stroke-width: 16; fill: #fff4d9; }
.plan .guide { stroke: var(--accent); stroke-width: 5; stroke-dasharray: 20 14; }
.plan .guide-t { fill: var(--accent); font-weight: 600; }
.cab-list { margin-top: 12px; }
.inspector, .totals { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; position: sticky; top: 12px; max-height: calc(100vh - 120px); overflow-y: auto; }
.inspector label { margin-bottom: 8px; }
.inspector .u { font-weight: 400; color: #8a979f; }
.tot-big { display: flex; flex-direction: column; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.tot-big span { color: var(--ink-2); font-size: .9rem; }
.tot-big b { font-family: var(--font-c); font-size: 2.2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tot-big small { color: var(--ink-2); }
.tot-facts { display: grid; grid-template-columns: repeat(3, 1fr); margin: 10px 0; }
.tot-facts div { display: flex; flex-direction: column; }
.tot-facts dt { font-size: .8rem; color: var(--ink-2); }
.tot-facts dd { margin: 0; font-weight: 600; font-size: 1.1rem; }
.tot-groups details { border-top: 1px solid var(--line-2); }
.tot-groups summary { display: flex; justify-content: space-between; padding: 7px 0; cursor: pointer; font-size: .92rem; }
.tot-groups ul, .tot-lines { list-style: none; margin: 0; padding: 0; }
.tot-groups li { display: flex; justify-content: space-between; gap: 8px; font-size: .85rem; padding: 3px 0 3px 10px; }
.tot-groups li span { display: flex; flex-direction: column; }
.tot-groups li small { color: var(--ink-2); font-size: .78rem; }
.tot-lines { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.tot-lines li { display: flex; justify-content: space-between; padding: 3px 0; font-size: .92rem; font-variant-numeric: tabular-nums; }
.tot-lines li.rule { border-top: 1px dashed var(--line); margin-top: 4px; padding-top: 6px; font-weight: 600; }
.below { margin-top: 22px; }

/* ---------- 3D ---------- */
.render-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.render-bar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.view3d { width: 100%; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #ebe9e4; cursor: grab; }
.view3d canvas { display: block; }
.print-only { display: none; }

/* ---------- cut diagrams ---------- */
.sheet-fig { margin: 18px 0; break-inside: avoid; page-break-inside: avoid; }
.sheet-fig figcaption { font-size: .9rem; margin-bottom: 6px; color: var(--ink-2); }
.sheet-svg { width: 100%; height: auto; display: block; font-family: var(--font-c); }
.sheet-svg .sh-bg { fill: #f6f1e6; stroke: var(--ink); stroke-width: 4; }
.sheet-svg .sh-part { stroke: var(--ink); stroke-width: 3; }
.sheet-svg .sh-dim { text-anchor: middle; fill: var(--ink); font-weight: 600; }
.sheet-svg .sh-lab { text-anchor: middle; fill: var(--ink-2); }

/* ---------- printable documents ---------- */
body.doc { background: #e9e7e2; }
.doc-bar { display: flex; gap: 8px; justify-content: center; padding: 14px; }
.sheet-doc { background: #fff; max-width: 900px; margin: 0 auto 40px; padding: 40px 46px; border: 1px solid var(--line); }
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 18px; }
.doc-meta { text-align: right; }
.doc-meta h1 { margin: 0 0 4px; font-size: 2rem; }
.doc-meta p { margin: 0; }
.doc-two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.stamp { display: inline-block; border: 3px solid var(--ok); color: var(--ok); font-family: var(--font-c); font-size: 1.5rem; font-weight: 700; padding: 0 12px; transform: rotate(-6deg); }
.plan-fig { margin: 10px 0 16px; }
.plan-fig .plan { max-height: 380px; }
.plan-fig figcaption { font-size: .8rem; color: var(--ink-2); }
.sign { margin-top: 40px; }

@media print {
  @page { margin: 12mm; }
  body, body.doc { background: #fff; display: block; }
  .side, .top-actions, .noprint, .doc-bar, .render-bar, .view3d { display: none !important; }
  .main { padding: 0; }
  .sheet-doc { border: 0; padding: 0; margin: 0; max-width: none; }
  .print-only { display: block; width: 100%; }
  .grid { border-color: #999; }
  a { color: inherit; text-decoration: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1400px) {
  .planner-wrap { grid-template-columns: 180px minmax(0, 1fr) 260px; }
  .planner-wrap .totals { grid-column: 2 / 4; position: static; max-height: none; }
}
@media (max-width: 1050px) {
  body.app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 5px solid transparent; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .who { border: 0; padding: 0; }
  .logout { margin: 0 0 0 auto; }
  .cols, .split, .split.wide-left { grid-template-columns: 1fr; }
  .panel.sticky { position: static; }
  .planner-wrap { grid-template-columns: 1fr; }
  .palette { position: static; max-height: none; display: flex; gap: 10px; overflow-x: auto; }
  .pal-group { min-width: 190px; }
  .inspector, .planner-wrap .totals { position: static; max-height: none; grid-column: auto; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats div:nth-child(3) { border-left: 0; }
}
@media (max-width: 640px) {
  .main { padding: 16px; }
  .row3, .row4 { grid-template-columns: 1fr 1fr; }
  .grid { display: block; overflow-x: auto; }
  .sheet-doc { padding: 20px; }
  .doc-two { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ================= v2 additions ================= */
.side nav a { display: flex; align-items: center; gap: 10px; }
.side nav a i { width: 18px; text-align: center; color: #a3a3a3; }
.side nav a.on i, .side nav a:hover i { color: var(--ply); }
.brand-logo { max-width: 100%; max-height: 54px; object-fit: contain; background: #fff; border-radius: 4px; padding: 4px 6px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.lang { display: inline-flex; border: 1px solid #3a3a3a; border-radius: 20px; overflow: hidden; align-self: flex-start; }
.lang a { padding: 3px 11px; font-size: .8rem; font-weight: 600; color: #a3a3a3; text-decoration: none; }
.lang a.on { background: var(--ply); color: var(--side); }
body.doc .lang, .auth .lang { border-color: var(--line); }
body.doc .lang a, .auth .lang a { color: var(--ink-2); }
body.doc .lang a.on, .auth .lang a.on { color: var(--ink); }
.auth-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.logout { margin-top: 0; text-decoration: none; }
.top h1 i { color: var(--ply-2); font-size: .8em; margin-right: 4px; }
.top-actions { align-items: center; }
.top-total { font-family: var(--font-c); font-size: 1.5rem; font-weight: 700; margin: 0 6px; font-variant-numeric: tabular-nums; }
.flash { display: flex; gap: 10px; align-items: flex-start; }
.flash > i { margin-top: 3px; }
.flash.ok > i { color: var(--ok); } .flash.error > i { color: var(--err); } .flash.warn > i { color: var(--warn); }

/* tabs (buttons) */
.tabset { margin-top: 4px; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs button, .tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; font: 500 .95rem var(--font); color: var(--ink-2);
  background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; text-decoration: none; }
.tabs button:hover, .tabs a:hover { color: var(--ink); }
.tabs button[aria-selected="true"], .tabs a.on { color: var(--ink); border-bottom-color: var(--ply-2); font-weight: 600; }
.tabs button i, .tabs a i { color: var(--ply-2); }
.badge { font-style: normal; font-size: .75rem; font-weight: 600; background: #ecebe6; color: var(--ink-2); border-radius: 10px; padding: 0 7px; }
.tab-panel[hidden] { display: none !important; }
.tab-panel > .panel:first-child, .tab-panel > form > .panel:first-child { margin-top: 0; }

.stats div { position: relative; }
.stats div > i { position: absolute; right: 16px; top: 16px; color: var(--ply); font-size: 1.15rem; }
.neg { color: var(--err); } .pos { color: var(--ok); }
.big-num { font-family: var(--font-c); font-size: 2.6rem; font-weight: 700; margin: 4px 0; }
.big-num small { font-size: 1rem; color: var(--ink-2); }
.narrow-2 { max-width: 760px; }
.narrow-field { max-width: 380px; }
.span2 { grid-column: span 2; }
label.inl { flex-direction: row; align-items: center; gap: 6px; margin: 0; white-space: nowrap; }
label.inl input { width: auto; }
.logo-box { border: 1px dashed var(--line); border-radius: var(--r); min-height: 110px; display: grid; place-items: center; margin-bottom: 12px; padding: 10px; background: #faf9f7; }
.logo-box img { max-height: 90px; max-width: 100%; }
.doc-links { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-form .inl { flex: 0 0 auto; }

/* charts */
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.chart-grid.one { grid-template-columns: 1fr; max-width: 900px; }
.chart { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 10px; }
.chart figcaption { font-family: var(--font-c); font-weight: 600; font-size: 1.1rem; margin-bottom: 6px; }
.chart svg { width: 100%; height: auto; display: block; }
.ch-grid { stroke: var(--line-2); stroke-width: 1; }
.ch-ax { fill: var(--ink-2); font-size: 11px; font-family: var(--font); }
.ch-bar.s1, .sw.s1 { fill: var(--accent); background: var(--accent); }
.ch-bar.s2, .sw.s2 { fill: var(--ok); background: var(--ok); }
.ch-bar.s3, .sw.s3 { fill: var(--ply); background: var(--ply); }
.ch-bar.s4, .sw.s4 { fill: #c0563f; background: #c0563f; }
.ch-line { fill: none; stroke-width: 2.5; }
.ch-line.s1 { stroke: var(--accent); } .ch-line.s2 { stroke: var(--ok); } .ch-line.s3 { stroke: var(--ply-2); } .ch-line.s4 { stroke: #c0563f; }
.ch-dot.s1 { fill: var(--accent); } .ch-dot.s2 { fill: var(--ok); } .ch-dot.s3 { fill: var(--ply-2); } .ch-dot.s4 { fill: #c0563f; }
.ch-legend { display: flex; gap: 14px; font-size: .85rem; color: var(--ink-2); margin-top: 4px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.pipe { display: flex; height: 18px; border-radius: 9px; overflow: hidden; background: var(--line-2); margin: 6px 0 10px; }
.pipe span { min-width: 4px; }
.p-sent { background: #8fb3d6; } .p-order { background: var(--accent); } .p-prod { background: var(--ply-2); } .p-inst { background: #5aa47a; } .p-done { background: var(--ok); }
.pipe-legend { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .88rem; }
.pipe-legend b { font-weight: 600; margin-left: 4px; }

/* agenda */
.agenda { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.agenda li { display: flex; gap: 14px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line-2); }
.agenda li:last-child { border-bottom: 0; }
.agenda time { width: 46px; flex: none; text-align: center; font-size: .78rem; color: var(--ink-2); line-height: 1.1; text-transform: lowercase; }
.agenda time b { display: block; font-family: var(--font-c); font-size: 1.5rem; color: var(--ink); }
.agenda div { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.agenda small { color: var(--ink-2); }

.tag.production { background: #f4ecdc; color: #7a5a24; }
.tag.installed, .tag.completed, .tag.done { background: #e1f1e7; color: var(--ok); }
.tag.scheduled, .tag.in_progress, .tag.partial { background: #f8eeb8; color: var(--accent); }
.tag.cancelled { background: #fbe6e4; color: var(--err); }
.doc-logo { max-height: 70px; max-width: 240px; object-fit: contain; }
.stamp.void { border-color: var(--err); color: var(--err); }
.accept { margin-top: 26px; padding-top: 16px; border-top: 2px solid var(--ink); }
.planner-wrap { margin-top: 0; }

@media (max-width: 1050px) {
  .chart-grid { grid-template-columns: 1fr; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tabs button span { white-space: nowrap; }
}
@media print { .tabs, .lang { display: none !important; } }

/* ================= v3: builder & inventory ================= */
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.type-card { display: flex; flex-direction: column; gap: 4px; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  color: var(--ink); text-decoration: none; text-align: left; }
.type-card:hover { border-color: var(--ply-2); }
.type-card.new { border-style: dashed; color: var(--ink-2); }
.type-card.starter { padding: 0; }
.type-card.starter button { all: unset; display: flex; flex-direction: column; gap: 4px; padding: 10px; cursor: pointer; }
.type-card.starter button:focus-visible { outline: 2px solid var(--accent); }
.type-card small { color: var(--ink-2); }
.type-thumb { aspect-ratio: 4 / 3; display: grid; place-items: center; background: #efede8; border-radius: 4px; overflow: hidden; font-size: 2rem; color: var(--ply-2); margin-bottom: 4px; }
.type-thumb img { width: 100%; height: 100%; object-fit: cover; }

.builder { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, 1fr); gap: 18px; align-items: start; }
.builder-view { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 10px; }
.builder-view .render-bar { margin: 0; }
.builder-sum { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; transition: opacity .2s; }
.builder-sum.busy { opacity: .55; }
.builder-sum .tot-lines li small { display: block; color: var(--ink-2); font-size: .78rem; font-weight: 400; }
.builder-sum .tot-lines li span { display: flex; flex-direction: column; }
.parts-list summary { cursor: pointer; color: var(--accent); margin-bottom: 8px; }
.builder-save { margin-top: 10px; }
.columns-ed { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; align-items: flex-start; }
.col-card { flex: 0 0 270px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; }
.col-card.add { flex: 0 0 140px; min-height: 120px; border-style: dashed; display: grid; place-items: center; color: var(--ink-2); cursor: pointer; font: inherit; gap: 6px; }
.col-head { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 8px; }
.col-head b { font-family: var(--font-c); font-size: 1.05rem; white-space: nowrap; padding-bottom: 8px; }
.col-head .size-f { flex: 1; }
.items { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.it { border: 1px solid var(--line); border-left: 4px solid var(--ply); border-radius: 4px; padding: 6px 8px; background: #fbfbf9; }
.it-drawer { border-left-color: var(--accent); } .it-open { border-left-color: #9aa5ad; } .it-lift { border-left-color: var(--ok); }
.it-row { display: flex; gap: 6px; align-items: flex-end; flex-wrap: wrap; }
.it-row select { width: auto; flex: 1; }
.it-row.small { margin-top: 4px; }
.it-row .inl input[type=number] { width: 3.6em; }
.it-acts { display: flex; gap: 6px; }
.it-acts .link[disabled] { opacity: .3; cursor: default; }
.size-f { margin: 0; font-size: .78rem; }
.size-f input { width: 5.5em; }
.cpart { border-top: 1px solid var(--line-2); padding-top: 10px; margin-top: 10px; }
.xyz { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.presets { margin-top: 0; }

.inv td.thumb-cell { width: 48px; }
.inv-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; }
.swatch.big { width: 40px; height: 40px; border-radius: 4px; display: block; }
.item-photo { min-height: 180px; }
.item-photo img { max-height: 220px; }
.swatch-preview { height: 36px; border-radius: var(--r); border: 1px solid var(--line); align-self: end; margin-bottom: 10px; }
.stats.two { grid-template-columns: repeat(2, 1fr); }
.pal-thumb { width: 34px; height: 26px; object-fit: cover; border-radius: 3px; border: 1px solid var(--line); flex: none; }

@media (max-width: 1100px) {
  .builder { grid-template-columns: 1fr; }
  .builder-view { position: static; order: -1; }
}
.it-row select { min-width: 110px; }

/* ================= v4: plans, departments, field tools, production, purchasing ================= */
.mobile-bar, .nav-scrim { display: none; }
.btn.big { padding: 12px 18px; font-size: 1.05rem; }
.table-wrap { overflow-x: auto; max-width: 100%; }
.matrix th.c, .matrix td.c { text-align: center; }
.matrix th.c { font-size: .78rem; min-width: 84px; vertical-align: bottom; }
.matrix input[type=checkbox] { width: 20px; height: 20px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }
.with-btn { display: flex; gap: 6px; } .with-btn input { flex: 1; }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.plan-card { display: flex; flex-direction: column; gap: 4px; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  color: var(--ink); text-decoration: none; position: relative; cursor: pointer; }
.plan-card:hover { border-color: var(--ply-2); }
.plan-card.off { opacity: .6; }
.plan-card b { font-family: var(--font-c); font-size: 1.25rem; }
.plan-card small { color: var(--ink-2); }
.plan-type { font-size: .8rem; color: var(--ply-2); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.plan-price { font-family: var(--font-c); font-size: 1.6rem; font-weight: 700; }
.plan-price small { font-size: .9rem; font-weight: 400; }
.plan-grid.pick input { position: absolute; opacity: 0; }
.plan-grid.pick .plan-card:has(input:checked) { border: 2px solid var(--accent); background: #fcf7dc; }
.plan-grid.pick .plan-card:has(input:focus-visible) { outline: 2px solid var(--accent); }
.plan-strip { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-bottom: 12px; font-size: .92rem; }
.plan-strip b { font-family: var(--font-c); font-size: 1.2rem; }

.dept-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.dept-tags .tag { font-weight: 500; }
.dept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.dept-card { flex-direction: row; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); margin: 0; }
.dept-card:has(input:checked) { border-color: var(--accent); background: #fcf7dc; }
.dept-card span { display: flex; flex-direction: column; gap: 2px; }
.dept-card i { color: var(--ply-2); }
.dept-card small { color: var(--ink-2); font-weight: 400; }

.card-list { display: flex; flex-direction: column; gap: 8px; }
.card-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); text-decoration: none; }
.card-row:hover { border-color: var(--ply-2); }
.card-ico { width: 38px; height: 38px; border-radius: 50%; background: #f4efe4; color: var(--ply-2); display: grid; place-items: center; flex: none; }
.card-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.card-main small { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }

/* production board */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x proximity; align-items: flex-start; }
.kcol { flex: 0 0 260px; background: #ebe9e4; border-radius: var(--r); border-top: 4px solid var(--c); scroll-snap-align: start; min-height: 200px; }
.kcol.over { background: #f6ecc0; }
.kcol header { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; font-family: var(--font-c); font-size: 1.05rem; }
.kcards { display: flex; flex-direction: column; gap: 8px; padding: 0 8px 10px; }
.kcard { background: #fff; border-radius: 6px; padding: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.08); border-left: 4px solid transparent; cursor: grab; }
.kcard.prio-high { border-left-color: var(--warn); } .kcard.prio-urgent { border-left-color: var(--err); }
.kcard a { color: var(--ink); text-decoration: none; } .kcard a:hover { text-decoration: underline; }
.kcard small { display: block; color: var(--ink-2); }
.kmeta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .8rem; color: var(--ink-2); margin: 6px 0; }
.kmove { font-size: .85rem; padding: 4px 6px; }
.stage-track { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 4px; }
.stage-track span { flex: 1 0 auto; padding: 6px 12px; font-size: .82rem; background: #ecebe6; color: var(--ink-2); border-radius: 4px; white-space: nowrap; }
.stage-track span.past { background: color-mix(in srgb, var(--c) 25%, #fff); color: var(--ink); }
.stage-track span.now { background: var(--c); color: #fff; font-weight: 600; }
.next-stage { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.next-stage input { flex: 1 1 200px; }

/* photos */
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.photo-actions input[data-photo-caption] { flex: 1 1 180px; width: auto; }
.photo-actions select { width: auto; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.ph { margin: 0; position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.ph img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.ph figcaption { padding: 6px 8px; font-size: .82rem; display: flex; flex-direction: column; }
.ph figcaption small { color: var(--ink-2); }
.ph-del { position: absolute; top: 6px; right: 6px; border: 0; background: rgba(255,255,255,.9); border-radius: 50%; width: 32px; height: 32px; cursor: pointer; color: var(--err); }
.print-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.print-photos figure { margin: 0; break-inside: avoid; } .print-photos img { width: 100%; }
.print-photos figcaption { font-size: .75rem; }

/* site survey */
.survey-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.plan-box { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 8px; position: sticky; top: 12px; }
.survey-plan .floor { fill: #fbfaf7; }
.plan .wall-line, .survey-plan .wall-line { fill: none; stroke: #3a3a3a; stroke-width: 60; stroke-linejoin: miter; }
.plan .outside { fill: #e6e4df; }
.plan .gap { stroke: #fbfaf7; stroke-width: 64; }
.plan .opening { stroke-width: 26; }
.plan .swing { fill: none; stroke: #8a6a3a; stroke-width: 8; stroke-dasharray: 24 16; }
.plan .svc { stroke: #fff; stroke-width: 10; }
.plan .wall-dim { fill: var(--ink); text-anchor: middle; dominant-baseline: middle; font-weight: 600; }
.wall-row { display: flex; gap: 8px; align-items: flex-end; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.wall-row label { margin: 0; flex: 0 1 110px; }
.wall-row label.grow { flex: 1 1 140px; }
.wall-no { width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 600; flex: none; margin-bottom: 4px; }
.close-state { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 4px 0; font-weight: 600; }
.close-state.ok { color: var(--ok); } .close-state.bad { color: var(--warn); }
.op-list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.op-list li { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
.op-list li:last-child { border-bottom: 0; }
.op-list li > i { font-size: 1.2rem; width: 24px; text-align: center; }
.op-list li div { flex: 1; display: flex; flex-direction: column; }
.op-list small { color: var(--ink-2); }
.checklist { display: flex; flex-direction: column; gap: 8px; max-width: 900px; }
.check-row { display: grid; grid-template-columns: minmax(0, 1.4fr) auto minmax(0, 1fr); gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.seg-inline { display: inline-flex; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.seg-inline label { margin: 0; flex-direction: row; }
.seg-inline input { position: absolute; opacity: 0; }
.seg-inline span { padding: 7px 14px; font-size: .9rem; cursor: pointer; color: var(--ink-2); }
.seg-inline label:has(input:checked) span { background: var(--ink); color: #fff; }
.seg-inline label:has(input:focus-visible) span { outline: 2px solid var(--accent); }
.sticky-save { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap;
  padding: 10px 0; background: linear-gradient(transparent, var(--paper) 30%); margin-top: 10px; }
.sticky-save #saveHint { margin-right: auto; }
.site-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
details.quick summary { cursor: pointer; font-weight: 600; }

/* ---------- touch devices ---------- */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  input, select, textarea { min-height: 44px; font-size: 16px; } /* 16px avoids iOS zoom on focus */
  .link { padding: 6px 4px; }
  .tabs button { padding: 12px 14px; }
}

/* ---------- tablet & phone: drawer navigation ---------- */
@media (max-width: 1050px) {
  body.app { display: block; }
  .mobile-bar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 40; background: var(--side); color: #fff; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  .mobile-bar .brand-name { font-size: 1.3rem; }
  .mobile-bar .brand-logo { max-height: 34px; }
  .mobile-title { flex: 1; font-family: var(--font-c); font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; color: #cfcfcf; }
  .nav-toggle { background: none; border: 0; color: #fff; font-size: 1.4rem; width: 44px; height: 44px; cursor: pointer; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(300px, 84vw); height: 100vh; z-index: 60; transform: translateX(-105%); transition: transform .2s ease;
    flex-direction: column; align-items: stretch; flex-wrap: nowrap; border-bottom: 0; border-right: 5px solid transparent; overflow-y: auto; }
  body.nav-open .side { transform: none; }
  .side nav { flex-direction: column; }
  .side nav a { padding: 12px 10px; }
  .side-foot { margin: auto 0 0; flex-direction: column; align-items: flex-start; }
  .who { border-bottom: 1px solid var(--side-2); padding-bottom: 14px; }
  .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(15,22,28,.45); z-index: 50; }
  .nav-scrim[hidden] { display: none; }
  .main { padding: 16px 18px 80px; }
  .survey-grid { grid-template-columns: 1fr; }
  .plan-box { position: static; order: -1; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats div:nth-child(3) { border-left: 0; }
  .stats div:nth-child(n+3) { border-top: 1px solid var(--line-2); }
}
@media (max-width: 640px) {
  .top h1 { font-size: 1.5rem; }
  .top-actions .hide-sm, .hide-sm { display: none; }
  .row2, .row3, .row4 { grid-template-columns: 1fr 1fr; }
  .row2 > label:only-child { grid-column: 1 / -1; }
  .cols, .split { gap: 12px; }
  .panel { padding: 14px; }
  .stats b { font-size: 1.4rem; }
  .check-row { grid-template-columns: 1fr; }
  .wall-row { flex-wrap: wrap; }
  .wall-row label.grow { flex-basis: calc(100% - 80px); }
  .kcol { flex-basis: 82vw; }
  .sticky-save { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -2px 8px rgba(0,0,0,.06); }
  .grid.inv td:nth-child(3), .grid.inv th:nth-child(3), .grid.inv td:nth-child(7), .grid.inv th:nth-child(7) { display: none; }
  .form-end { flex-wrap: wrap; }
  .flash { font-size: .92rem; }
}
@media print { .mobile-bar, .nav-scrim, .sticky-save, .photo-actions, .ph-del { display: none !important; } }
.plan-price { white-space: nowrap; font-size: 1.35rem; }

/* ================= v5: grouped navigation, live home, CRM, chain, financials ================= */
.side { gap: 14px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px; }
.side-nav > a, .nav-group a { display: flex; align-items: center; gap: 10px; color: #d9d9d9; text-decoration: none; padding: 7px 10px; border-radius: var(--r); font-size: .95rem; }
.side-nav a i { width: 18px; text-align: center; color: #9a9a9a; }
.side-nav a:hover { background: var(--side-2); }
.side-nav a.on { background: #2b2b2b; color: #fff; box-shadow: inset 3px 0 0 var(--ply); }
.side-nav a.on i, .side-nav a:hover i { color: var(--ply); }
.nav-group { margin-top: 6px; }
.nav-group summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 6px 10px 4px;
  font-size: .72rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #9a9a9a; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary .chev { font-size: .7rem; transition: transform .15s; }
.nav-group:not([open]) summary .chev { transform: rotate(-90deg); }
.nav-group a { padding-left: 14px; }
.side-foot { margin-top: 0; border-top: 1px solid var(--side-2); padding-top: 12px; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 6px; border-radius: var(--r); }
.me:hover, .me.on { background: var(--side-2); }
.me-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-txt small { color: #a3a3a3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--ply); color: var(--side); display: grid; place-items: center; font-weight: 700; font-family: var(--font-c); flex: none; }
.avatar.big { width: 72px; height: 72px; font-size: 1.8rem; }
.foot-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.foot-row .logout { color: #a3a3a3; font-size: .88rem; }

/* home */
.hello { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; margin: -6px 0 14px; }
.hello h2 { margin: 0; font-size: 1.5rem; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #2fb36b; box-shadow: 0 0 0 0 rgba(47,179,107,.6); animation: pulse 2s infinite; vertical-align: middle; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(47,179,107,.55); } 70% { box-shadow: 0 0 0 8px rgba(47,179,107,0); } 100% { box-shadow: 0 0 0 0 rgba(47,179,107,0); } }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 14px 16px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; overflow: hidden;
  background: linear-gradient(135deg, #fff 0%, #f7f4ee 100%); border: 1px solid var(--line); }
a.kpi:hover { border-color: var(--ply-2); }
.kpi > span { font-size: .85rem; color: var(--ink-2); }
.kpi > span i { color: var(--ply-2); }
.kpi > b { font-family: var(--font-c); font-size: 1.8rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--ink-2); }
.spark { width: 100%; height: 30px; margin-top: 4px; }
.spark polyline { fill: none; stroke-width: 2.2; vector-effect: non-scaling-stroke; }
.spark.s1 polyline { stroke: var(--accent); } .spark.s2 polyline { stroke: var(--ok); }
.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.card.span2 { grid-column: span 2; }
.card h3 { font-family: var(--font-c); font-size: 1.1rem; margin: 0 0 10px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.card h3 i { color: var(--ply-2); }
.card h3 a { margin-left: auto; font-family: var(--font); font-weight: 400; }
.card .chart { border: 0; padding: 0; background: none; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 7px 0; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; font-size: .92rem; }
.feed li:last-child { border-bottom: 0; }
.feed li a { color: var(--ink); text-decoration: none; } .feed li a:hover { text-decoration: underline; }
.feed li a i { color: var(--ply-2); width: 18px; }
.feed small { color: var(--ink-2); padding-left: 22px; }
.agenda.slim { border: 0; } .agenda.slim li { padding: 7px 0; }
.chain-card-dash { margin-bottom: 14px; }

/* funnel + donut */
.funnel { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.funnel li { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: 8px; align-items: center; font-size: .88rem; }
.f-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-bar { height: 14px; background: #efede8; border-radius: 7px; overflow: hidden; }
.f-bar i { display: block; height: 100%; border-radius: 7px; transition: width .4s; }
.funnel b { font-variant-numeric: tabular-nums; min-width: 2.5em; text-align: right; }
.donut-wrap { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.donut { width: 130px; height: 130px; flex: none; }
.donut circle { transition: stroke-dasharray .4s; }
.donut-c { font-family: var(--font-c); font-size: 18px; font-weight: 700; fill: var(--ink); dominant-baseline: middle; }
.donut-legend { list-style: none; margin: 0; padding: 0; font-size: .85rem; flex: 1; min-width: 140px; }
.donut-legend li { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.donut-legend b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* process chain */
.chain-flow { display: flex; gap: 4px; overflow-x: auto; padding: 4px 0 10px; }
.flow-step { position: relative; flex: 1 0 104px; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 10px 16px; background: #efede8; color: var(--ink-2); text-decoration: none;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%); }
.flow-step:first-child { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); padding-left: 12px; border-radius: 6px 0 0 6px; }
.flow-step b { font-family: var(--font-c); font-size: 1.5rem; line-height: 1; color: var(--ink-2); }
.flow-step span { font-size: .8rem; line-height: 1.2; }
.flow-step small { font-size: .72rem; opacity: .8; }
.flow-step.busy { background: var(--c); color: #fff; } .flow-step.busy b { color: #fff; }
.chain-flow.compact .flow-step { flex-basis: 90px; padding-top: 8px; padding-bottom: 8px; }
.live-note { margin: 2px 0 10px; }
.chain-grid-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.chain-grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .9rem; }
.chain-grid th { font-size: .74rem; font-weight: 600; color: var(--ink-2); padding: 8px 4px; border-bottom: 3px solid var(--c, var(--line)); background: #f8f7f4; vertical-align: bottom; min-width: 58px; }
.chain-grid th span { display: block; max-width: 80px; margin: 0 auto; line-height: 1.15; }
.chain-grid td { border-bottom: 1px solid var(--line-2); padding: 6px 4px; text-align: center; }
.chain-grid .sticky-col { position: sticky; left: 0; background: var(--panel); text-align: left; min-width: 220px; padding-left: 12px; z-index: 1; box-shadow: 1px 0 0 var(--line-2); }
.chain-grid thead .sticky-col { background: #f8f7f4; }
.chain-grid td.sticky-col a { color: var(--ink); text-decoration: none; display: block; }
.chain-grid td.sticky-col small { color: var(--ink-2); display: block; }
.chain-grid tr.is-late td.sticky-col { box-shadow: inset 3px 0 0 var(--err); }
.cc.done { color: var(--c); }
.cc.done i { background: color-mix(in srgb, var(--c) 14%, #fff); border-radius: 50%; width: 24px; height: 24px; display: inline-grid; place-items: center; font-size: .75rem; }
.cc.skip { color: #bdbdbd; }
.pulse { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 0 var(--c); animation: pulse2 1.8s infinite; }
@keyframes pulse2 { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 60%, transparent); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.mark-btn { width: 30px; height: 30px; border-radius: 50%; border: 2px dashed var(--c); background: #fff; color: var(--c); cursor: pointer; animation: pulse2 1.8s infinite; }
.mark-btn:hover { background: var(--c); color: #fff; }
.chain-cards { display: none; flex-direction: column; gap: 8px; }
.chain-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.chain-card.is-late { border-left: 4px solid var(--err); }
.cc-top { display: flex; flex-direction: column; } .cc-top small { color: var(--ink-2); }
.cc-bar { display: flex; gap: 3px; margin: 8px 0; }
.cc-bar i { flex: 1; height: 7px; border-radius: 4px; background: #e7e5e0; }
.cc-bar i.done { background: var(--c); } .cc-bar i.now { background: var(--c); opacity: .45; } .cc-bar i.skip { background: #cfd6db; }
.cc-now { display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; font-size: .9rem; }
.chain-filter { align-items: center; flex-wrap: wrap; }
.chain-filter select { width: auto; }
.ksum { padding: 0 12px 8px; }
.design-steps { display: flex; flex-direction: column; gap: 8px; }
.dstep { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: var(--r); padding: 10px 12px; }
.dstep label { margin: 0; flex: 1 1 160px; } .dstep label.sm { flex: 0 1 90px; }
.dnum { width: 28px; height: 28px; border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center; font-weight: 700; margin-bottom: 4px; }

/* CRM */
.crm-board .kcol { flex-basis: 240px; }
.lead-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.quick-contact { display: flex; gap: 8px; flex-wrap: wrap; }
.status-steps { display: flex; gap: 4px; flex-wrap: wrap; align-items: flex-start; }
.status-steps > button, .lost-box summary { border: 1px solid var(--line); background: var(--panel); padding: 7px 12px; border-radius: 20px; cursor: pointer; font: 500 .88rem var(--font); color: var(--ink-2); list-style: none; }
.status-steps > button.on { background: var(--c); color: #fff; border-color: var(--c); }
.lost-box summary.on { background: var(--err); color: #fff; border-color: var(--err); }
.lost-box[open] { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.lost-box input { width: auto; flex: 1 1 200px; }
.kind-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.kind-pick label { margin: 0; flex-direction: row; }
.kind-pick input { position: absolute; opacity: 0; }
.kind-pick span { padding: 7px 12px; border: 1px solid var(--line); border-radius: 20px; cursor: pointer; color: var(--ink-2); font-size: .88rem; }
.kind-pick label:has(input:checked) span { background: var(--ink); color: #fff; border-color: var(--ink); }
.kind-pick label:has(input:focus-visible) span { outline: 2px solid var(--accent); }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 17px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline li { display: flex; gap: 12px; padding: 6px 0; position: relative; }
.tl-ico { width: 36px; height: 36px; border-radius: 50%; background: #fff; border: 2px solid var(--line); display: grid; place-items: center; color: var(--ply-2); flex: none; z-index: 1; }
.timeline li div { display: flex; flex-direction: column; padding-top: 6px; }
.timeline small { color: var(--ink-2); }
.late-ico { background: #fbe6e4; color: var(--err); }
.btn-row.tight { margin: 4px 0 0; gap: 4px; }

/* financials */
.period-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.chip { padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); text-decoration: none; font-size: .88rem; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.period-bar .custom { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; }
.period-bar .custom input { width: auto; }
.fin-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid.fin td { padding: 7px 12px; }
.grid.fin tr.sub td:first-child { padding-left: 26px; color: var(--ink-2); }
.grid.fin tr.rule td { border-top: 1px solid var(--line); }
.grid.fin tr.total td { border-top: 2px solid var(--ink); font-size: 1.1rem; font-weight: 700; background: #f7f4ee; }
.grid.fin small { margin-left: 6px; }

/* profile */
.profile-head { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
.access-list { list-style: none; margin: 0; padding: 0; columns: 2; }
.access-list li { padding: 4px 0; } .access-list li i { color: var(--ok); } .access-list li.off { color: var(--ink-2); } .access-list li.off i { color: #bdbdbd; }

@media (max-width: 1200px) { .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1050px) {
  .fin-grid { grid-template-columns: 1fr; }
  .side-nav { overflow: visible; }
}
@media (max-width: 900px) {
  .chain-grid-wrap { display: none; }
  .chain-cards { display: flex; }
}
@media (max-width: 640px) {
  .dash-grid { grid-template-columns: 1fr; }
  .card.span2 { grid-column: auto; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi > b { font-size: 1.35rem; }
  .period-bar .custom { margin-left: 0; }
  .access-list { columns: 1; }
  .hello h2 { font-size: 1.25rem; }
}
@media (prefers-reduced-motion: reduce) { .live-dot, .pulse, .mark-btn { animation: none; } }
.chart svg.donut { width: 130px; height: 130px; flex: none; }

/* ================= v6: work orders & labels ================= */
body.wo { display: block; }
.wo-tools { position: fixed; top: 12px; right: 12px; width: 300px; max-height: calc(100vh - 24px); overflow-y: auto; z-index: 20;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.12); }
.wo-tools h2 { font-family: var(--font-c); font-size: 1.2rem; margin: 0 0 8px; }
.wo-tools fieldset { border-top: 1px solid var(--line-2); padding: 8px 0; margin: 0; }
.wo-tools legend { font-weight: 600; font-size: .85rem; color: var(--ink-2); }
.wo-tools label { margin-bottom: 6px; }
.lbl-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.wo-doc { margin-right: 330px; padding: 16px; }
.wo-off { display: none !important; }
.wo-title { margin: 0 0 8px; font-size: 1.5rem; }
.wo-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 0 0 14px; }
.wo-meta div { border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.wo-meta dt { font-size: .75rem; color: var(--ink-2); } .wo-meta dd { margin: 0; font-weight: 700; }
.mat-letter { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 4px; border-radius: 4px; background: var(--ink); color: #fff; font-size: .85rem; }
.wo-sign { margin-top: 30px; font-size: .9rem; }
.wo-sheets { max-width: 900px; margin: 0 auto 30px; }
.wo-sheet { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
.sheet-legend { columns: 3; font-size: .78rem; margin: 8px 0 0; padding-left: 26px; }
.sheet-legend small { color: var(--ink-2); }
.sheet-svg .sh-edge { fill: #c0563f; }
.sheet-svg .sh-no { fill: var(--ink); font-weight: 700; }
.sheet-svg .sh-no.c { text-anchor: middle; }
.wo-parts td.tick, td.tick { width: 28px; border-left: 1px solid var(--line-2); }
.eico { width: 30px; height: auto; vertical-align: middle; }
.eico-b { fill: #fff; stroke: #555; stroke-width: 1; } .eico-e { fill: #c0563f; }
.wo-labels { max-width: 900px; margin: 0 auto; }
.lbl-page { position: relative; background: #fff; margin: 0 auto 14px; box-shadow: 0 1px 6px rgba(0,0,0,.15); overflow: hidden; }
.lbl-slot { position: absolute; width: var(--lw); height: var(--lh); outline: 1px dashed #c9d1d6; }
.lbl-page.roll { display: flex; }
.lbl { width: var(--lw); height: var(--lh); box-sizing: border-box; padding: calc(var(--lf) * .55) calc(var(--lf) * .7); display: flex; flex-direction: column; justify-content: space-between;
  font-family: var(--font); font-size: var(--lf); line-height: 1.12; color: #000; overflow: hidden; }
.lbl-top { display: flex; gap: .6em; align-items: baseline; }
.lbl-no { font-size: 1.7em; font-family: var(--font-c); line-height: 1; }
.lbl-loc { margin-left: auto; border: 1px solid #000; border-radius: 3px; padding: 0 .3em; font-weight: 700; }
.lbl-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lbl-cab, .lbl-mat { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .9em; }
.lbl-bottom { display: flex; align-items: center; gap: .6em; }
.lbl-size { font-size: 1.35em; font-family: var(--font-c); }
.lbl-e { height: 1.8em; width: auto; }
@media screen and (max-width: 1000px) { .wo-tools { position: static; width: auto; margin: 12px; } .wo-doc { margin-right: 0; } }
@media print {
  .wo-doc { margin: 0; padding: 0; }
  .wo-page { break-after: page; }
  .wo-sheet { break-inside: avoid; border: 0; padding: 0; margin: 0 0 8mm; }
  .wo-sheets .wo-sheet:nth-child(2n) { break-after: page; }
  .lbl-page { page: labels; box-shadow: none; margin: 0; break-after: page; }
  .lbl-slot { outline: 0; }
  .wo-labels > h2 { display: none; }
}

/* ================= v6: manufacture, deliveries, tracking, projects, services ================= */
.stage-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 14px; }
.stage-tile { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 8px; background: #efede8; color: var(--ink-2); text-decoration: none; border-top: 4px solid var(--c); }
.stage-tile b { font-family: var(--font-c); font-size: 1.6rem; line-height: 1; } .stage-tile span { font-size: .85rem; }
.stage-tile.busy { background: color-mix(in srgb, var(--c) 14%, #fff); color: var(--ink); }
.stage-sec { margin-bottom: 16px; }
.stage-sec h3 { font-family: var(--font-c); font-size: 1.15rem; margin: 6px 0 8px; display: flex; align-items: center; gap: 8px; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.mcard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 6px; border-left: 4px solid transparent; }
.mcard.prio-high { border-left-color: var(--warn); } .mcard.prio-urgent { border-left-color: var(--err); }
.mcard.is-late { box-shadow: 0 0 0 2px #f3c8c3 inset; }
.mcard header { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.mcard header a { color: var(--ink); text-decoration: none; } .mcard header .tag { white-space: nowrap; font-size: .72rem; }
.mtrack { display: flex; gap: 3px; } .mtrack i { flex: 1; height: 8px; border-radius: 4px; background: #e7e5e0; }
.mtrack i.done { background: var(--c); } .mtrack i.now { background: var(--c); animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .45; } }
.mrow { display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; }
.btn.wide { width: 100%; justify-content: center; }
.order-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.order-card { display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 10px; padding: 14px; }
.oc-main { display: flex; flex-direction: column; gap: 4px; flex: 1 1 320px; } .oc-main small { color: var(--ink-2); }
.oc-side { display: flex; flex-direction: column; gap: 6px; flex: 0 1 220px; } .oc-side label { margin: 0; }
.mtimeline { list-style: none; margin: 0 0 10px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px; }
.mtimeline li { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: 8px; background: #efede8; color: var(--ink-2); position: relative; }
.mtimeline li.done { background: color-mix(in srgb, var(--c) 16%, #fff); color: var(--ink); }
.mtimeline li.now { background: var(--c); color: #fff; } .mtimeline li.now small { color: #fff; }
.mtimeline .tdot { position: absolute; top: 8px; right: 8px; font-size: .8rem; }
.track { list-style: none; margin: 10px 0; padding: 0; position: relative; }
.track::before { content: ''; position: absolute; left: 13px; top: 14px; bottom: 14px; width: 3px; background: #e7e5e0; }
.track li { display: flex; gap: 12px; padding: 8px 0; position: relative; color: var(--ink-2); }
.track li div { display: flex; flex-direction: column; } .track li small { color: var(--ink-2); }
.track .tdot { width: 29px; height: 29px; border-radius: 50%; background: #fff; border: 3px solid #d4dadf; display: grid; place-items: center; flex: none; z-index: 1; font-size: .8rem; }
.track li.done { color: var(--ink); } .track li.done .tdot { background: var(--ok); border-color: var(--ok); color: #fff; }
.track li.now { color: var(--ink); font-weight: 600; } .track li.now .tdot { border-color: var(--accent); box-shadow: 0 0 0 4px #f6e9a6; }
.track-doc { max-width: 640px; }
.eta-big { font-size: 1.1rem; background: #fcf7dc; border-radius: 8px; padding: 10px 14px; }
.dl-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 12px; }
.dl-status { background: var(--c); color: #fff; padding: 8px 14px; border-radius: 20px; font-weight: 600; }
.dl-head .quick-contact { margin-left: auto; }
.dl-next input { flex: 1 1 160px; }

/* projects */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.pgrid.big { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.pcard { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); text-decoration: none; }
.pcard:hover { border-color: var(--ply-2); } .pcard.is-late { border-left: 4px solid var(--err); }
.pc-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.pc-row { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .85rem; color: var(--ink-2); } .pc-row b { color: var(--ink); }
.pbar { height: 10px; border-radius: 5px; background: #e7e5e0; overflow: hidden; } .pbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--ok)); border-radius: 5px; }
.pbar.sm { height: 6px; width: 90px; display: inline-block; vertical-align: middle; }
.proj-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.ph-main { flex: 1 1 260px; display: flex; flex-direction: column; gap: 4px; }
.ring { --p: 0; width: 78px; height: 78px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: radial-gradient(closest-side, var(--paper) 74%, transparent 75% 100%), conic-gradient(var(--ok) calc(var(--p) * 1%), #e7e5e0 0); }
.ring b { font-family: var(--font-c); font-size: 1.2rem; }
.timeline-days { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; margin-bottom: 12px; }
.tday { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tday header { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: #f8f7f4; border-bottom: 1px solid var(--line-2); }
.tday header .small { margin-left: auto; } .tday.today { border-color: var(--accent); } .tday.behind header { background: #fbe6e4; }
.tday ul, .checklist-ul { list-style: none; margin: 0; padding: 4px 0; }
.tday li, .checklist-ul li { display: flex; align-items: center; gap: 10px; padding: 6px 12px; }
.tt { flex: 1; display: flex; flex-direction: column; } .tt small { color: var(--ink-2); }
li.done .tt { color: var(--ink-2); text-decoration: line-through; } li.done .tt small { text-decoration: none; }
.tick-btn { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #c3ccd2; background: #fff; color: transparent; cursor: pointer; flex: none; display: grid; place-items: center; }
li.done .tick-btn { background: var(--ok); border-color: var(--ok); color: #fff; }
.kit { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kit section { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.kit h3 { margin: 0; padding: 10px 12px; border-bottom: 1px solid var(--line-2); font-family: var(--font-c); font-size: 1.05rem; }
.checks.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.claim-acts { flex-wrap: wrap; justify-content: flex-end; } .claim-acts input { width: 120px; }

/* service calculator */
.sale-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin-bottom: 12px; }
.svc-head { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; }
.svc-opts { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.svc-table td { vertical-align: middle; } .svc-table input.qty { width: 5em; }
.edge-box { display: inline-grid; grid-template-columns: 9px 46px 9px; grid-template-rows: 9px 22px 9px; vertical-align: middle; }
.edge-box .eb { border: 0; padding: 0; background: #e2e0db; cursor: pointer; }
.edge-box .eb.on { background: #c0563f; }
.edge-box .eb.L1 { grid-column: 1 / 4; grid-row: 1; border-radius: 4px 4px 0 0; }
.edge-box .eb.L2 { grid-column: 1 / 4; grid-row: 3; border-radius: 0 0 4px 4px; }
.edge-box .eb.W1 { grid-column: 1; grid-row: 2; } .edge-box .eb.W2 { grid-column: 3; grid-row: 2; }
.edge-box .eb-core { grid-column: 2; grid-row: 2; background: #f6efe2; display: grid; place-items: center; font-size: .7rem; color: var(--ink-2); }
.edge-box .eb:focus-visible { outline: 2px solid var(--accent); }
.edge-quick { font-size: .78rem; }
.svc-sum { display: flex; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.svc-sum div { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; display: flex; flex-direction: column; }
.svc-sum b { font-family: var(--font-c); font-size: 1.4rem; } .svc-sum span { font-size: .8rem; color: var(--ink-2); }
.svc-prices { margin-top: 10px; }
details.paste { margin: 8px 0; } details.paste textarea { font-family: monospace; }
@media (max-width: 640px) {
  .oc-side { flex-basis: 100%; }
  .dl-head .quick-contact { margin-left: 0; }
  .timeline-days, .kit { grid-template-columns: 1fr; }
}
[hidden] { display: none !important; }
.mcard header { flex-direction: column; align-items: flex-start; gap: 4px; }
@media (max-width: 640px) {
  .doc-head { flex-wrap: wrap; gap: 8px; }
  .doc-head h1, .doc-head .doc-title { font-size: 1.5rem; }
  .sheet-doc { padding: 16px; }
}

/* ================= v6.1: accounting exports ================= */
.export-bar { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin: -4px 0 10px; color: var(--ink-2); }
.export-bar select { width: auto; padding: 4px 8px; }
.chip-r { margin: 0; flex-direction: row; } .chip-r input { position: absolute; opacity: 0; }
.chip-r span { padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); font-size: .88rem; cursor: pointer; }
.chip-r:has(input:checked) span { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip-r:has(input:focus-visible) span { outline: 2px solid var(--accent); }
.checks.three { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 12px; margin: 12px 0; }
.report-doc { max-width: 1100px; }
.report-toc { columns: 2; font-size: .9rem; }
.report-table { font-size: .82rem; } .report-table td, .report-table th { padding: 4px 6px; }
.report-sec h2 small { font-size: .8rem; font-weight: 400; }
.report-foot { margin-top: 20px; }
@media print {
  .report-sec.break { break-before: page; }
  .report-table thead { display: table-header-group; } .report-table tr { break-inside: avoid; }
  .report-doc { max-width: none; padding: 0; box-shadow: none; }
}

/* ================= v7: Studio ================= */
.design-banner { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.design-banner.st-returned { border-left-color: var(--ok); }
.design-banner .note-inline { background: #fcf7dc; padding: 3px 8px; border-radius: 6px; }
.design-send { position: relative; } .design-send > summary { list-style: none; cursor: pointer; } .design-send > summary::-webkit-details-marker { display: none; }
.design-send[open] > .panel, .design-send[open] > form { position: absolute; z-index: 30; right: 0; top: calc(100% + 6px); width: min(520px, 92vw); box-shadow: 0 8px 28px rgba(0,0,0,.18); }
.design-steps-f { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; align-items: center; }
blockquote.note { margin: 8px 0; padding: 8px 12px; background: #fcf7dc; border-left: 3px solid var(--accent); border-radius: 4px; }
.mcard .brief { margin: 0; color: var(--ink-2); }
.mcard .assign select { font-size: .82rem; padding: 4px 6px; }
.planner-wrap.no-prices .tot-big, .planner-wrap.no-prices .tot-lines, .planner-wrap.no-prices .tot-groups b, .planner-wrap.no-prices .tot-groups small { display: none; }
.style-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 12px; }
.style-card { margin: 0; display: block; color: var(--ink); text-decoration: none; cursor: pointer; }
.style-card > span { display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; height: 100%; }
.style-card input { position: absolute; opacity: 0; }
.style-card:has(input:checked) > span { border: 2px solid var(--accent); background: #fcf7dc; }
.style-card:has(input:focus-visible) > span { outline: 2px solid var(--accent); }
.style-card small { color: var(--ink-2); }
.door-svg { width: 100%; max-width: 150px; height: auto; }
.door-editor { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); gap: 14px; align-items: start; }
.door-preview { position: sticky; top: 12px; } .door-preview .door-svg { max-width: 260px; display: block; margin: 0 auto; }
.cons-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; border: 0; padding: 0; margin: 8px 0; }
.cons-pick legend { font-weight: 600; margin-bottom: 4px; }
.photo-grid.small-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); margin-top: 10px; }
@media (max-width: 900px) { .door-editor { grid-template-columns: 1fr; } .door-preview { position: static; } }

/* ================= v9: payments & receipts ================= */
.paid-banner { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: #e9f6ee; border: 1px solid #b9dfc6; border-radius: 10px; padding: 12px 16px; margin-bottom: 14px; }
.paid-banner .pb-ico { font-size: 1.8rem; color: var(--ok); } .paid-banner div { flex: 1; display: flex; flex-direction: column; } .paid-banner small { color: var(--ink-2); }
.method-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; margin-bottom: 12px; }
.method-pick label { margin: 0; } .method-pick input { position: absolute; opacity: 0; }
.method-pick span { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; font-size: .92rem; }
.method-pick label:has(input:checked) span { border: 2px solid var(--accent); background: #fcf7dc; font-weight: 600; }
.method-pick label:has(input:focus-visible) span { outline: 2px solid var(--accent); }
.big-num { font-size: 1.4rem !important; font-family: var(--font-c); font-weight: 700; }
output.big-num { display: block; padding: 6px 0; }
.quick-amts { margin: -4px 0 10px; }
.card-row.voided, tr.voided { opacity: .55; } tr.voided td { text-decoration: line-through; }
.receipt-doc { position: relative; }
.rc-amount { display: flex; justify-content: space-between; align-items: baseline; border: 2px solid var(--ink); border-radius: 8px; padding: 10px 16px; margin: 14px 0; }
.rc-amount b { font-family: var(--font-c); font-size: 2rem; }
.void-stamp { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg); font-size: 5rem; font-weight: 800; color: rgba(180,35,24,.2); border: 8px solid rgba(180,35,24,.2); padding: 0 24px; pointer-events: none; }
body.receipt-ticket .receipt-doc { max-width: 80mm; padding: 4mm; font-size: 11px; box-shadow: none; }
body.receipt-ticket .doc-two { display: block; } body.receipt-ticket .rc-amount b { font-size: 1.4rem; }
body.receipt-ticket .grid td, body.receipt-ticket .grid th { padding: 2px 0; }
.tk-head, .tk-title { text-align: center; margin-bottom: 8px; } .tk-title { border-top: 1px dashed #000; border-bottom: 1px dashed #000; padding: 6px 0; }
.import-box { margin-top: 14px; } .import-form input[type=file] { padding: 8px; }
/* photo render */
.photo-dlg { border: 0; border-radius: 12px; padding: 0; width: min(760px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.photo-dlg::backdrop { background: rgba(15,22,28,.55); }
.pd-opts { padding: 18px 20px; } .pd-opts h2 { margin: 0 0 6px; font-family: var(--font-c); }
.pd-progress { display: flex; gap: 10px; align-items: center; margin: 10px 0; } .pd-progress progress { flex: 1; height: 14px; }
.pd-result { margin: 10px 0; } .pd-result img { width: 100%; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.2); }
.quote-renders { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; margin-bottom: 14px; } .quote-renders.n1 { grid-template-columns: 1fr; }
.quote-renders img { width: 100%; border-radius: 6px; break-inside: avoid; }
.pal-all { display: flex; gap: 6px; align-items: center; font-size: .82rem; margin: 0 0 8px; color: var(--ink-2); flex-direction: row; }
/* v10: room types, wizard, multi-room projects */
.type-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin: 6px 0 10px; }
.type-pick label { margin: 0; } .type-pick input { position: absolute; opacity: 0; }
.type-pick span { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; }
.type-pick span i { color: var(--ply-2); width: 20px; text-align: center; }
.type-pick label:has(input:checked) span { border: 2px solid var(--accent); background: #fcf7dc; font-weight: 600; }
.type-pick label:has(input:focus-visible) span { outline: 2px solid var(--accent); }
.type-pick.big span { flex-direction: column; padding: 18px 10px; font-size: 1rem; } .type-pick.big span i { font-size: 1.8rem; width: auto; }
.wizard fieldset { border: 0; padding: 0; margin: 0 0 10px; } .wizard legend { font-family: var(--font-c); font-size: 1.3rem; font-weight: 700; margin-bottom: 8px; }
.wz-steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 14px; counter-reset: wz; flex-wrap: wrap; }
.wz-steps li { counter-increment: wz; padding: 6px 12px; border-radius: 20px; background: #efede8; color: var(--ink-2); font-size: .88rem; }
.wz-steps li::before { content: counter(wz) " · "; font-weight: 700; } .wz-steps li.on { background: var(--ink); color: #fff; }
.unit-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.unit-card header { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.unit-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; } .unit-form select, .unit-form input { width: auto; }
.unit-name { font-family: var(--font-c); font-size: 1.15rem; font-weight: 700; min-width: 200px; }
.unit-ico { width: 34px; height: 34px; border-radius: 50%; background: #f4efe4; color: var(--ply-2); display: grid; place-items: center; }
.unit-total { font-size: .95rem; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; align-items: start; }
.room-card { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.rc-main { display: flex; flex-direction: column; color: var(--ink); text-decoration: none; } .rc-main small { color: var(--ink-2); }
.rc-ico { font-size: 1.4rem; color: var(--ply-2); }
.rc-acts { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.room-add summary { list-style: none; cursor: pointer; border: 2px dashed var(--line); border-radius: 8px; padding: 22px 10px; text-align: center; color: var(--ink-2); }
.room-add[open] { grid-column: 1 / -1; } .room-add[open] summary { padding: 8px; }
.pd-engine { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.pd-engine label { flex-direction: row; flex-wrap: wrap; gap: 4px 8px; align-items: center; } .pd-engine small { flex-basis: 100%; color: var(--ink-2); font-weight: 400; }
.pd-canvas { width: 100%; height: auto; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.2); }
/* v10: about & help */
.help-link { display: flex; align-items: center; gap: 8px; color: #cfcfcf; text-decoration: none; font-size: .9rem; padding: 4px 6px; border-radius: 6px; }
.help-link small { margin-left: auto; color: #9a9a9a; } .help-link:hover, .help-link.on { background: var(--side-2); color: #fff; }
.guide-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; } .guide-head input { flex: 1 1 260px; }
.guide-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start; }
.guide-toc { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px; max-height: calc(100vh - 40px); overflow-y: auto; }
.guide-toc a { padding: 5px 8px; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: .9rem; } .guide-toc a:hover { background: #fcf7dc; } .guide-toc a.muted { color: var(--ink-2); }
.guide-sec { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; margin-bottom: 12px; scroll-margin-top: 12px; }
.guide-sec h2 { font-family: var(--font-c); font-size: 1.3rem; margin: 0 0 6px; } .guide-sec h2 i { color: var(--ply-2); }
.guide-sec.unavailable { opacity: .7; }
.guide-steps { padding-left: 22px; } .guide-steps li { margin: 4px 0; }
.guide-tip { background: #fff8e6; border-left: 3px solid var(--warn); padding: 6px 10px; border-radius: 4px; font-size: .92rem; } .guide-tip i { color: var(--warn); }
.about-card { max-width: 720px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.about-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; } .about-brand b { font-family: var(--font-c); font-size: 2rem; display: block; } .about-brand span { color: var(--ink-2); }
.ply.big { width: 54px; height: 54px; }
.about-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin: 0; }
.about-facts div { border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 12px; } .about-facts dt { font-size: .78rem; color: var(--ink-2); } .about-facts dd { margin: 0; font-weight: 600; }
.timeline .tl-ico b { font-size: .75rem; }
.guide-doc .guide-sec { border: 0; padding: 0; margin: 0 0 18px; break-inside: avoid-page; }
.guide-cover { text-align: center; padding: 30px 0 20px; break-after: page; } .guide-cover h1 { font-size: 3rem; margin: 8px 0 0; } .guide-sub { color: var(--ink-2); font-size: 1.2rem; }
.guide-index { text-align: left; columns: 2; max-width: 600px; margin: 30px auto 0; }
@media (max-width: 900px) { .guide-layout { grid-template-columns: 1fr; } .guide-toc { position: static; max-height: none; flex-direction: row; flex-wrap: wrap; } }
@media print { .guide-sec h2 small { display: none; } }
.auth label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
.auth label.check input { width: 18px; height: 18px; margin-top: 2px; flex: none; }
.auth label.check span { display: flex; flex-direction: column; gap: 4px; } .auth label.check small { color: var(--ink-2); }
.auth-card form > label:not(.check) > input { padding: 12px 14px; border-radius: 10px; font-size: 1rem; }
.auth-card form > .btn.primary { width: 100%; padding: 13px; border-radius: 10px; font-size: 1.05rem; justify-content: center; }

.auth .auth-top { justify-content: flex-end; }
.auth .in-ico input { padding-left: 42px; padding-right: 44px; }
.auth .auth-help { margin-top: 26px; display: flex; gap: 6px; align-items: flex-start; }
.auth .auth-top .lang { flex: none; } .auth .auth-top .auth-brand { font-size: 1.4rem; line-height: 1.1; }
