/* ==========================================================================
   BEME Estimator — styles
   Tokens first (colour, type, spacing, radius, elevation), then the shell,
   shared controls and components, then screen-specific rules.
   The bill document (.doc, table.bill) and the print rules near the end are
   the printed output: change them only on purpose.
   ========================================================================== */
:root {
  /* colour */
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --hover: #eef1f5;
  --ink: #1d2125;
  --muted: #565d65;        /* 6.6:1 on white */
  --faint: #6b7279;        /* 4.8:1 on white — AA for small text */
  --line: #e2e6eb;
  --line-strong: #c5cbd3;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: #eaf1fe;
  --accent-strong: #1e40af;
  --ok: #17703f;
  --ok-soft: #e7f5ee;
  --warn: #8a5c00;
  --warn-soft: #fff6dc;
  --warn-line: #f1d48a;
  --err: #b4232a;
  --err-soft: #fdecec;
  --info: #34529c;
  --info-soft: #ecf0fb;
  --focus: #1d4ed8;
  --typed: #1f4fbf;

  /* type scale */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 24px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, monospace;

  /* spacing scale */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;

  /* radii and elevation */
  --r-sm: 6px;
  --radius: 8px;
  --r-lg: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-pop: 0 12px 32px rgba(16, 24, 40, .18);

  --side-w: 248px;
  --top-h: 60px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font: var(--fs-base)/1.45 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-strong); }
[hidden] { display: none !important; }
.skip { position: fixed; left: 8px; top: -60px; z-index: 90; background: var(--ink); color: #fff; border: 0; border-radius: var(--r-sm); padding: 8px 12px; }
.skip:focus { top: 8px; }
#page:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* focus: one visible ring for every control */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }

/* Simple mode hides expert-only material (nothing is removed). */
body.mode-simple .expert-only { display: none !important; }

/* icons */
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.ic.sm { width: 15px; height: 15px; vertical-align: -3px; }
.ic.lg { width: 28px; height: 28px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: var(--s4) var(--s3); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 20; }
.brand { display: flex; gap: 10px; align-items: center; padding: 2px var(--s2) var(--s4); }
.brand-mark { width: 34px; height: 34px; border-radius: var(--radius); background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.brand-mark .ic { width: 20px; height: 20px; stroke-width: 2; }
.brand-name { font-weight: 650; }
.brand-sub { color: var(--muted); font-size: var(--fs-xs); }
.icon-btn.side-close { display: none; margin-left: auto; }

nav a, .nav-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; margin: 1px 0; border: 0; background: transparent; cursor: pointer; text-align: left; }
nav a:hover, .nav-btn:hover { background: var(--hover); }
nav a.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
nav a.active .ic { color: var(--accent); }
nav a.disabled, nav a[aria-disabled="true"] { color: var(--faint); pointer-events: none; }
nav a .ic { color: var(--muted); }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; padding: var(--s4) 10px var(--s1); }
.steps { list-style: none; margin: 0; padding: 0; }
.steps a { align-items: flex-start; }
.steps .step-n { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; font-size: 11.5px; font-weight: 700; flex: none; color: var(--muted); background: var(--panel); margin-top: 1px; }
.steps a.active .step-n { background: var(--accent); border-color: var(--accent); color: #fff; }
.steps a.done .step-n { border-color: var(--ok); color: var(--ok); }
.steps .step-t { display: block; line-height: 1.3; }
.steps .step-t small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.steps a.active .step-t small { color: var(--accent-strong); }
.steps .count { margin-left: auto; }
.step-row { display: flex; align-items: flex-start; }
.step-row > a { flex: 1; min-width: 0; }
.step-row .group-toggle { margin-top: 4px; }
.est-group { list-style: none; margin: 2px 0 6px 21px; padding: 0 0 0 10px; border-left: 1.5px solid var(--line); }
.est-group a { padding: 5px 8px; font-size: var(--fs-sm); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; border: 1.5px solid var(--line-strong); background: transparent; }
.dot.used { background: var(--ok); border-color: var(--ok); }
.dot.check { background: var(--warn); border-color: var(--warn); border-radius: 2px; transform: rotate(45deg); width: 8px; height: 8px; }
.est-group .st { margin-left: auto; font-size: 11px; color: var(--faint); }
.side-foot { margin-top: auto; font-size: 11px; color: var(--faint); padding: var(--s4) 10px 0; }
.nav-scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "proj actions total"; align-items: center; gap: 8px var(--s4); padding: 10px 28px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 15; min-height: 60px; }
.icon-btn.menu-btn { display: none; grid-area: menu; }
.top .proj { grid-area: proj; font-weight: 600; min-width: 0; line-height: 1.3; overflow-wrap: anywhere; }
.top .proj .pname { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.top .proj small { display: block; font-weight: 400; color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .proj small a { color: var(--muted); }
.top .spacer { display: none; }
.top-actions { grid-area: actions; display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.top .total { grid-area: total; text-align: right; min-width: 130px; }
.top .total small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.top .total b { font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.page { padding: var(--s5) 28px 60px; max-width: 1500px; width: 100%; }

h1 { font-size: var(--fs-xl); line-height: 1.25; margin: 0 0 var(--s1); font-weight: 650; }
h2 { font-size: var(--fs-md); margin: 0 0 10px; font-weight: 650; }
h3 { font-size: var(--fs-base); margin: var(--s4) 0 var(--s2); font-weight: 650; }
.lead { color: var(--muted); margin: 0 0 var(--s5); max-width: 80ch; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: var(--fs-xs); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.head-row { display: flex; align-items: flex-end; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s5); }
.head-row .grow { min-width: 240px; }
.head-row .lead { margin: 0; }
.head-actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--panel); padding: 7px 13px; border-radius: var(--r-sm); cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--ink); line-height: 1.3; min-height: 34px; }
.btn:hover { background: var(--hover); }
.btn:active { background: #e3e7ec; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.primary:active { background: #1e3a8a; }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: var(--err-soft); border-color: #e9b4b6; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { padding: 3px 9px; font-size: 12.5px; min-height: 28px; }
.btn.lg { padding: 10px 18px; font-size: 15px; min-height: 42px; }
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn .ic { margin: 0 -1px; }
.icon-btn { display: inline-grid; place-items: center; border: 0; background: transparent; cursor: pointer; width: 30px; height: 30px; border-radius: var(--r-sm); color: var(--muted); line-height: 1; text-decoration: none; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn:active { background: #e3e7ec; }
.icon-btn.danger:hover { color: var(--err); background: var(--err-soft); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
input[type=text], input[type=number], input[type=date], input[type=month], input[type=search], input:not([type]), select, textarea {
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 7px 9px; background: #fff; min-width: 0; min-height: 34px;
}
input:hover, select:hover, textarea:hover { border-color: #aeb5bf; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--focus) 30%, transparent); border-color: var(--focus); }
input:disabled, select:disabled, textarea:disabled { background: var(--panel-2); color: var(--muted); cursor: not-allowed; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--err) !important; background: #fffafa; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
textarea { width: 100%; resize: vertical; min-height: 70px; }
.cell-input { width: 100%; border: 1px solid transparent; background: transparent; padding: 4px 6px; border-radius: 4px; min-height: 30px; }
.cell-input:hover { border-color: var(--line-strong); background: #fff; }
.cell-input:focus { background: #fff; }
.cell-input.num { text-align: right; }
.cell-input.typed, .typed { color: var(--typed); }
input.money { text-align: right; font-variant-numeric: tabular-nums; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span, .field-label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.field .hint, .hint { font-size: var(--fs-xs); color: var(--faint); font-weight: 400; }
.field-error { color: var(--err); font-size: var(--fs-xs); font-weight: 600; margin-top: 3px; display: flex; gap: 4px; align-items: flex-start; }
.field-error .ic { width: 14px; height: 14px; margin-top: 1px; }
.req { color: var(--err); font-weight: 700; margin-left: 2px; }
.tag { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--info); background: var(--info-soft); padding: 1px 6px; border-radius: 4px; margin-left: 6px; vertical-align: 1px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3); }
.card-head h2 { margin: 0; flex: 1; min-width: 200px; }
.card .sub-lead { color: var(--muted); font-size: var(--fs-sm); margin: -4px 0 var(--s3); }
details.card > summary, details.wblock > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
details > summary::-webkit-details-marker { display: none; }
details.card > summary::before, details.strip > summary::before, details.chk-row > summary::before, details.wblock > summary::before, details.more > summary::before {
  content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); flex: none; margin: 0 4px 0 2px; transition: transform .15s; color: var(--muted);
}
details[open] > summary::before { transform: rotate(45deg); }
details.card[open] > summary { margin-bottom: 4px; }

/* segmented control */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden; background: #fff; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; border-right: 1px solid var(--line); min-height: 32px; }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--hover); }
.seg button.on, .seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.seg button:focus-visible { outline-offset: -3px; }
.seg.sm button { padding: 3px 10px; font-size: 12.5px; min-height: 28px; }

/* ---------- badges, banners ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 8px; border-radius: 10px; font-weight: 600; white-space: nowrap; text-decoration: none; line-height: 1.6; }
.badge .ic { width: 12px; height: 12px; stroke-width: 2.2; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.calc { background: #eef3ef; color: #33603f; }
.badge.neutral { background: #eceff3; color: var(--muted); }
button.badge { border: 0; cursor: pointer; }
a.badge:hover, button.badge:hover { filter: brightness(.96); text-decoration: underline; }
.top-badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 12px; font-size: var(--fs-sm); font-weight: 600; border: 1px solid transparent; text-decoration: none; cursor: pointer; min-height: 32px; }
.top-badge.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.top-badge.err { background: var(--err-soft); color: var(--err); border-color: #efc1c3; }
.top-badge:hover { filter: brightness(.97); }
.notes { margin: 6px 0 0; padding: 0; list-style: none; font-size: var(--fs-xs); }
.notes li { margin: 2px 0; }
.notes .cleared { color: var(--faint); text-decoration: line-through; }
.notes .cleared .link-btn { display: inline-block; }
.link-btn { border: 0; background: none; padding: 0; color: var(--info); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.notes .warn { color: var(--warn); } .notes .review { color: var(--faint); } .notes .error { color: var(--err); } .notes .info { color: var(--info); }
.notes .warn::before, .notes .error::before { content: "⚠ "; }

.banner { border-radius: var(--radius); padding: 10px 14px; margin-bottom: var(--s4); font-size: var(--fs-sm); border: 1px solid transparent; }
.banner.ok { background: var(--ok-soft); color: var(--ok); border-color: #c4e6d3; }
.banner.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.banner.info { background: var(--info-soft); color: var(--info); border-color: #d3dcf3; }
.banner.err { background: var(--err-soft); color: var(--err); border-color: #efc1c3; }
.banner a { color: inherit; font-weight: 600; }
.banner.row { display: flex; }

/* collapsible strip (summary line that expands) */
details.strip { border-radius: var(--radius); margin-bottom: var(--s4); font-size: var(--fs-sm); border: 1px solid var(--warn-line); background: var(--warn-soft); color: var(--warn); }
details.strip.ok { border-color: #c4e6d3; background: var(--ok-soft); color: var(--ok); }
details.strip.info { border-color: #d3dcf3; background: var(--info-soft); color: var(--info); }
details.strip > summary { padding: 9px 14px; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; font-weight: 600; }
details.strip > summary .grow { min-width: 0; }
details:not([open]) > summary .when-open, details[open] > summary .when-closed { display: none; }
details.strip .strip-body { padding: 0 14px 10px 34px; color: var(--ink); }
.strip-item { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid rgba(0, 0, 0, .06); }
.strip-item:first-child { border-top: 0; }
.strip-item .n { font-size: 11px; font-weight: 700; color: var(--warn); background: #fff; border: 1px solid var(--warn-line); border-radius: 10px; padding: 0 7px; }

/* empty state */
.empty-state { text-align: center; padding: 36px 20px; background: var(--panel); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); margin-bottom: 18px; }
.empty-state .es-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto 12px; }
.empty-state .es-icon .ic { width: 26px; height: 26px; }
.empty-state h2 { margin: 0 0 4px; }
.empty-state p { color: var(--muted); margin: 0 auto 16px; max-width: 56ch; }
.empty-state .row { justify-content: center; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* help popover */
.help-btn { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line-strong); background: #fff; color: var(--muted); font-size: 11px; font-weight: 700; cursor: pointer; padding: 0; margin-left: 4px; vertical-align: 1px; line-height: 1; }
.help-btn:hover, .help-btn[aria-expanded="true"] { border-color: var(--info); color: var(--info); background: var(--info-soft); }
.popover { position: absolute; z-index: 70; width: min(320px, calc(100vw - 24px)); background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 12px 14px; font-size: var(--fs-sm); color: var(--ink); font-weight: 400; text-transform: none; letter-spacing: 0; text-align: left; }
.popover h3 { margin: 0 0 4px; font-size: var(--fs-sm); }
.popover p { margin: 0 0 8px; }
.popover .row { justify-content: space-between; }

/* dropdown menu */
.menu { position: relative; display: inline-flex; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); min-width: 230px; background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 4px; z-index: 40; }
.menu-list.left { right: auto; left: 0; }
.menu-list button, .menu-list a { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 5px; cursor: pointer; color: var(--ink); text-decoration: none; white-space: nowrap; }
.menu-list button:hover, .menu-list a:hover, .menu-list button:focus-visible, .menu-list a:focus-visible { background: var(--hover); outline: none; }
.menu-list .danger { color: var(--err); }
.menu-list .ic { color: var(--muted); }
.menu-list .danger .ic { color: var(--err); }
.menu-list hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.split { display: inline-flex; }
.split > .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split .menu > .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-color: rgba(255, 255, 255, .35); padding: 7px 8px; }

/* ---------- tables ---------- */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
.table-wrap.open { overflow: visible; }
/* horizontal-scroll cue: shadows on the edges that still have content */
.table-wrap.wide {
  background: linear-gradient(to right, #fff 30%, rgba(255, 255, 255, 0)) left center / 40px 100% no-repeat local,
              linear-gradient(to left, #fff 30%, rgba(255, 255, 255, 0)) right center / 40px 100% no-repeat local,
              radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .16), rgba(0, 0, 0, 0)) left center / 14px 100% no-repeat scroll,
              radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .16), rgba(0, 0, 0, 0)) right center / 14px 100% no-repeat scroll;
  background-color: #fff;
}
.table-wrap.wide table.grid td, .table-wrap.wide table.grid tr:hover td { background-color: transparent; }
.scroll-cue { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); margin: 0 0 6px; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { position: sticky; top: 0; background: var(--panel-2); text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 8px; border-bottom: 1px solid var(--line); z-index: 1; white-space: nowrap; }
table.grid td { padding: 5px 8px; border-bottom: 1px solid #eceff3; vertical-align: top; }
table.grid tr:hover td { background: #fafbfc; }
table.grid tr.group td { background: #f1f4f7; font-weight: 600; padding-top: 9px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
table.grid tr.group td .muted { font-weight: 400; }
.desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 620px; }
.code { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------- checks ---------- */
.chk { padding: 12px 0; border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.card > .chk:first-of-type, .modal-body > .chk, details .chk:first-child, .chk-row .chk { border-top: 0; padding-top: 0; }
.chk.is-cleared { opacity: .9; }
.chk h4 { margin: 10px 0 2px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.chk p { margin: 0; }
.chk ol { margin: 0; padding-left: 20px; }
.chk-actions { margin-top: 10px; align-items: center; }
.chk-line { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.progress { height: 8px; border-radius: 99px; background: #e4e8ed; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.chk-head-card { display: flex; gap: var(--s5); align-items: center; flex-wrap: wrap; }
.chk-head-card .big { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.chk-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
details.chk-row { border-top: 1px solid var(--line); }
details.chk-row:first-child { border-top: 0; }
details.chk-row > summary { padding: 11px 14px; cursor: pointer; list-style: none; display: flex; gap: 10px; align-items: center; }
details.chk-row > summary:hover { background: #fafbfc; }
details.chk-row > summary .t { flex: 1; min-width: 0; }
details.chk-row > summary .src { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
details.chk-row > .chk { padding: 0 16px 16px 40px; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: var(--s3); }

/* ---------- estimators ---------- */
table.lsched td { padding: 3px 3px; border-bottom: 0; }
table.lsched tr.ls-desc td { border-bottom: 1px solid var(--line); padding: 2px 10px 10px; }
table.lsched tr.ls-desc td > * { position: sticky; left: 10px; max-width: min(900px, 80vw); }
table.lsched tr:hover td { background: transparent; }
/* very wide tables keep their first column in view */
table.sticky-first tr:not(.ls-desc):not(.sub) > :first-child { position: sticky; left: 0; z-index: 2; background: #fff; box-shadow: 1px 0 0 var(--line); }
table.sticky-first thead tr:not(.sub) > th:first-child { z-index: 3; background: var(--panel-2); }
table.params td { vertical-align: middle; padding: 4px 8px; }
table.params td:first-child { width: 32%; }
table.params td:nth-child(2) { width: 120px; }
details.wblock > summary .small b { color: var(--ink); }
table.lvsched { min-width: 2300px; }
table.lvsched .cell-input.w { width: 44px; min-width: 44px; padding: 4px 3px; }
table.lvsched th { padding: 6px 4px; }
table.lvsched td.mcb, table.lvsched th.mcb { background: #f7f9fc; }
table.lvsched tr.sub th { font-size: 10.5px; text-transform: none; letter-spacing: 0; font-weight: 500; top: 30px; }
.method { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: var(--panel); }
.method b { font-size: 18px; font-variant-numeric: tabular-nums; display: block; margin: 2px 0 4px; }
.method.chosen { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: var(--accent-soft); }

/* parameter form (label + helper text, input with unit suffix) */
.pform { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 4px 22px; }
.pfield { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; border-bottom: 1px solid #edf0f3; min-width: 0; }
.pfield .pl { font-weight: 600; font-size: var(--fs-sm); display: flex; gap: 6px; align-items: baseline; }
.pfield .pl .pn { font-size: 11px; color: var(--faint); font-weight: 700; min-width: 16px; }
.pfield .pnote { font-size: var(--fs-xs); color: var(--muted); }
.pfield .pnote.long { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pfield .pnote.long.full { display: block; }
.pctl { display: flex; align-items: stretch; max-width: 100%; }
.pctl > input, .pctl > select { flex: 0 1 220px; min-width: 0; }
.pctl > input.wide-in { flex: 1 1 100%; }
.pctl > input.num { text-align: right; }
.pctl .unit { display: inline-flex; align-items: center; padding: 0 9px; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--panel-2); color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.pctl.has-unit > input, .pctl.has-unit > select { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.pctl .after { align-self: center; margin-left: 8px; }
.pfield.filled .pl::after { content: ""; }
.fill-count { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.fill-count .progress { width: 80px; height: 6px; }

/* estimator result summary */
.result { display: grid; grid-template-columns: minmax(180px, auto) 1fr; gap: var(--s4) var(--s5); align-items: center; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.result.warn { border-left-color: var(--warn); }
.result.info { border-left-color: var(--info); }
.result .amt small { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.result .amt b { font-size: 22px; font-variant-numeric: tabular-nums; display: block; line-height: 1.25; }
.result .amt span { font-size: var(--fs-xs); color: var(--muted); }
.result .verdict { font-size: var(--fs-sm); display: flex; gap: 8px; align-items: flex-start; }
.result .verdict .ic { margin-top: 1px; }
.result.ok .verdict .ic { color: var(--ok); } .result.warn .verdict .ic { color: var(--warn); } .result.info .verdict .ic { color: var(--info); }

/* estimators index */
.est-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.est-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); }
.est-card:hover { border-color: var(--accent); }
.est-card .est-top { display: flex; gap: 12px; align-items: flex-start; }
.est-card .est-ic { width: 38px; height: 38px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.est-card .est-ic .ic { width: 21px; height: 21px; }
.est-card b { font-size: 15px; }
.est-card .est-foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #edf0f3; padding-top: 8px; margin-top: auto; font-size: var(--fs-sm); }
.est-card .est-foot b { font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.status.used { color: var(--ok); } .status.check { color: var(--warn); }

/* ---------- take-off ---------- */
.addbar { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: var(--s4); box-shadow: var(--shadow); }
.addbar h2 { flex: 1 0 100%; margin: 0; font-size: var(--fs-base); display: flex; gap: 8px; align-items: center; }
.addbar .f-sec { flex: 1 1 170px; max-width: 260px; }
.addbar .f-item { flex: 3 1 280px; min-width: 0; }
.addbar .f-qty { flex: 1 1 130px; max-width: 200px; }
.addbar .f-loc { flex: 1 1 150px; max-width: 240px; }
.addbar .f-go { flex: 0 0 auto; align-self: flex-end; padding-bottom: 0; }
.addbar .field input, .addbar .field select { width: 100%; }
.addbar .f-go .btn { margin-top: 20px; }
table.grid.takeoff .cell-input.num { min-width: 70px; }
table.grid.takeoff td.c-act { white-space: nowrap; }
table.grid.takeoff thead th { top: var(--top-h); z-index: 4; }
table.grid.takeoff tr.group td { position: sticky; top: calc(var(--top-h) + 33px); z-index: 3; background: #eef1f5; }
table.grid.takeoff tr.group td:first-child { padding-left: 4px; }
.group-toggle { border: 0; background: transparent; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; padding: 2px 4px; border-radius: 4px; color: inherit; text-align: left; }
.group-toggle:hover { background: rgba(0, 0, 0, .05); }
.group-toggle .ic { transition: transform .15s; }
.group-toggle[aria-expanded="false"] .ic { transform: rotate(-90deg); }
.est-badge { font-size: 10.5px; padding: 0 6px; }
.rate-flag { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--warn); background: var(--warn-soft); border-radius: 4px; padding: 0 5px; margin-left: 4px; vertical-align: 1px; white-space: nowrap; }
.toolbar-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar-row input[type=search], .toolbar-row input[type=text] { width: 240px; max-width: 100%; }
.chk-label { display: inline-flex; gap: 6px; align-items: center; font-size: var(--fs-sm); cursor: pointer; }
.only-narrow { display: none !important; }

/* ---------- picker ---------- */
.picker { position: relative; }
.picker input { width: 100%; }
.picker-list { position: absolute; left: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-pop); max-height: 380px; overflow: auto; z-index: 30; width: max(100%, min(560px, calc(100vw - 40px))); }
.picker-item { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid #eff1f4; display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; }
.picker-item.active, .picker-item:hover { background: var(--accent-soft); }
.picker-item .pd { font-size: var(--fs-sm); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.picker-item .pr { font-size: var(--fs-xs); color: var(--muted); text-align: right; white-space: nowrap; }
.picker-empty { padding: 12px; color: var(--muted); }

/* ---------- projects ---------- */
.proj-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 14px; }
.proj-card { display: flex; flex-direction: column; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.proj-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow); }
.proj-card .t { font-weight: 650; font-size: 15px; overflow-wrap: anywhere; }
.proj-card .stats { display: flex; gap: var(--s4); flex-wrap: wrap; align-items: flex-end; }
.proj-card .stats b { font-size: 18px; font-variant-numeric: tabular-nums; }
.proj-card .foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 10px; border-top: 1px solid #edf0f3; }
.welcome { max-width: 980px; margin: 0 auto; }
ul.howto-notes { margin: 0; padding-left: 20px; }
ul.howto-notes li { margin: 0 0 8px; }
.welcome-hero { display: flex; gap: var(--s5); align-items: flex-start; margin: 8px 0 26px; }
.welcome-hero .brand-mark { width: 56px; height: 56px; border-radius: var(--r-lg); }
.welcome-hero .brand-mark .ic { width: 30px; height: 30px; }
.welcome ol.explain { margin: 10px 0 0; padding-left: 20px; color: var(--muted); }
.welcome ol.explain li { margin: 3px 0; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 14px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; cursor: pointer; box-shadow: var(--shadow); color: var(--ink); font: inherit; }
.choice:hover { border-color: var(--accent); }
.choice.primary { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow); }
.choice .es-icon { width: 42px; height: 42px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 4px; }
.choice b { font-size: 15px; }
.choice span { color: var(--muted); font-size: var(--fs-sm); }

/* project details: live money effect */
.effect { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.sum-table { width: 100%; max-width: 520px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sum-table td { padding: 5px 0; border-bottom: 1px solid #edf0f3; }
.sum-table td:last-child { text-align: right; }
.sum-table tr.tot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--ink); font-size: 15px; }

/* bill on-screen summary */
.bill-sum { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(300px, 2fr); gap: var(--s5); }
.bill-sum .big { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; overflow-wrap: anywhere; }
.bars { display: grid; gap: 7px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 210px) 1fr minmax(110px, auto); gap: 10px; align-items: center; font-size: var(--fs-xs); }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar { height: 10px; background: #eceff3; border-radius: 99px; overflow: hidden; }
.bar-row .bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; min-width: 2px; }
.bar-row .v { text-align: right; font-variant-numeric: tabular-nums; }
.blank-prompt a { color: var(--info); font-style: italic; }

/* settings */
.mode-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 12px; }
.mode-card { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; }
.mode-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mode-card input { margin-top: 3px; }
.backup-status { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--radius); margin-bottom: 12px; font-size: var(--fs-sm); }
.backup-status.ok { background: var(--ok-soft); color: var(--ok); }
.backup-status.warn { background: var(--warn-soft); color: var(--warn); }

/* help page */
.glossary dt { font-weight: 650; margin-top: 14px; scroll-margin-top: calc(var(--top-h) + 16px); }
.glossary dd { margin: 2px 0 0; color: var(--muted); max-width: 80ch; }
.glossary dt:target, .glossary dt.flash { color: var(--accent-strong); }
.howto { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.howto li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; }
.howto li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: var(--fs-sm); }
.howto li p { margin: 2px 0 0; color: var(--muted); }
.sec-list { columns: 2 260px; padding-left: 0; list-style: none; margin: 8px 0 0; }
.sec-list li { break-inside: avoid; padding: 3px 0; }
.sec-list b { display: inline-block; width: 22px; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20, 22, 25, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border-radius: var(--r-lg); width: min(760px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: var(--shadow-pop); }
.modal.narrow { width: min(520px, 100%); }
.modal-head { padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-head h2 { margin: 0; flex: 1; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 14px 10px 14px; border-radius: var(--radius); opacity: 0; transition: .2s; pointer-events: none; z-index: 80; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px); box-shadow: var(--shadow-pop); }
.toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.toast.success .t-ic { color: #7ee2a8; }
.toast.error { background: #7f1d1d; }
.toast.error .t-ic { color: #fecaca; }
.toast .btn { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .45); }
.toast .btn:hover { background: rgba(255, 255, 255, .12); }
.toast .icon-btn { color: #ddd; width: 26px; height: 26px; }
.toast .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }

/* ---------- bill document ---------- */
.doc { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 36px 40px; max-width: 1120px; margin: 0 auto; font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #111; }
.doc-head { display: flex; gap: 20px; align-items: flex-start; border-bottom: 2px solid #111; padding-bottom: 12px; margin-bottom: 12px; }
.doc-head img { max-height: 64px; max-width: 180px; }
.doc-head .co { margin-left: auto; text-align: right; font-size: 11px; color: #444; white-space: pre-line; }
.doc-title { font-size: 16px; font-weight: 700; text-transform: uppercase; }
.doc-sub { font-size: 12.5px; margin-top: 2px; }
.doc-meta { font-size: 11px; color: #333; margin-top: 6px; }
.doc-pre { font-size: 11px; font-style: italic; margin: 10px 0 18px; color: #333; }
.doc-sec { margin-top: 22px; break-inside: auto; }
.doc-sec h3 { font-size: 13px; margin: 0 0 4px; text-transform: uppercase; }
.doc-sec .intro { font-size: 11px; color: #333; margin: 0 0 8px; }
table.bill { width: 100%; border-collapse: collapse; }
table.bill th, table.bill td { border: 1px solid #555; padding: 4px 5px; vertical-align: top; }
table.bill th { background: #ececec; font-size: 10px; text-align: center; }
table.bill td.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.bill td.c { text-align: center; }
table.bill tr.sub td { font-weight: 700; background: #f7f7f7; }
table.bill tr.blank td { height: 20px; }
table.bill tr.flag td { background: #fff8e1; }
.carried { font-size: 11px; font-style: italic; margin-top: 3px; }
.doc-sum { margin-top: 30px; break-before: page; }
.doc-sum h3 { text-align: center; font-size: 14px; text-transform: uppercase; }
table.bill tr.total td { font-weight: 700; font-size: 13px; background: #ececec; }
.sign { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 40px; font-size: 12px; }
.sign div { border-top: 1px solid #111; padding-top: 6px; }
.doc-wrap { overflow-x: auto; }

@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body { background: #fff; }
  .shell { display: block; }
  .no-print, .side, .top, .toolbar, .banner, .modal-back, .toast { display: none !important; }
  .page { padding: 0; max-width: none; }
  .doc { border: 0; padding: 0; max-width: none; font-size: 10px; }
  table.bill th { font-size: 8.5px; }
  table.bill thead { display: table-header-group; }
  table.bill tr { break-inside: avoid; }
  table.bill tr.flag td { background: none; }
  .screen-only, .popover, .nav-scrim, details.strip { display: none !important; }
  .doc-wrap { overflow: visible; }
}

/* Bill: amount in words, basis notes, client-summary print (summary only) */
.doc-sum .words { font-size: 12px; margin: 8px 0 0; }
.doc-sum .basis { font-size: 11px; margin-top: 12px; } .doc-sum .basis ol { margin: 4px 0 0; padding-left: 18px; }
@media print { body.print-summary .doc-pre, body.print-summary .doc-sec { display: none !important; } }

/* ---------- licence lock screen ---------- */
#licence-lock { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
#licence-lock .licence-card { width: min(520px, 100%); margin: 0; padding: 24px; }
#licence-lock .brand { padding: 0 0 var(--s4); }
#licence-lock h1 { margin: 0 0 6px; }
#licence-lock #lic-key { font-family: ui-monospace, Consolas, monospace; letter-spacing: .04em; text-transform: uppercase; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .top { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "proj total" "actions actions"; }
}
@media (max-width: 1100px) {
  table.grid.takeoff:not(.show-rates) .c-rate { display: none; }
  .only-narrow { display: inline-flex !important; }
  .table-wrap.open:has(> table.show-rates) { overflow-x: auto; }
  .bill-sum { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow-pop); }
  body.nav-open .side { transform: none; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(20, 22, 25, .35); z-index: 19; }
  .icon-btn.side-close { display: inline-grid; }
  .top { padding: 8px 16px; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "menu proj total" "actions actions actions"; }
  .icon-btn.menu-btn { display: inline-grid; }
  .page { padding: var(--s4) 16px 48px; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .result { grid-template-columns: 1fr; }
}
.loc-inline { display: none; }
@media (max-width: 900px) {
  table.grid.takeoff .c-n, table.grid.takeoff .c-loc { display: none; }
  table.grid.takeoff .loc-inline { display: block; }
  table.grid.takeoff .desc { max-width: none; }
  .bar-row { grid-template-columns: minmax(90px, 140px) 1fr auto; }
}
@media (max-width: 640px) {
  .addbar h2 { flex-wrap: wrap; }
  .addbar h2 .hint { flex: 1 0 100%; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .top .total { min-width: 0; }
  h1 { font-size: var(--fs-lg); }
}
/* Touch screens: bigger tap targets (fingers, not mouse pointers). Layout on desktop is unchanged. */
@media (pointer: coarse) {
  .btn, .top-badge, .seg button { min-height: 40px; }
  .btn.sm, .seg.sm button { min-height: 36px; }
  .icon-btn { width: 40px; height: 40px; }
  .help-btn { position: relative; }
  .help-btn::after { content: ""; position: absolute; inset: -11px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
