/* QTO-Vision UI: no build step, no external assets (works offline). Light and dark via tokens.
   Palette: slate neutrals, one deep-teal accent, muted semantic colours (sage / ochre / brick / steel blue) and an
   earthy, colour-blind-checked categorical set for the take-off groups. Every text pair meets WCAG AA. */

/* tokens ------------------------------------------------------------------------------------- */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --surface-3: #eef0f3;
  --border: #e1e4e8;
  --border-strong: #c9ced5;
  --text: #1b2330;
  --text-2: #384352;
  --muted: #5a6472;
  --faint: #8b939e;
  --placeholder: #6b7480;
  --accent: #1e6b70;
  --accent-hover: #175559;
  --accent-fg: #ffffff;
  --accent-text: #1a5f64;
  --accent-soft: #e5f0f0;
  --accent-line: #b9d5d5;
  --accent-ring: rgba(30, 107, 112, 0.28);
  --ok: #2e6a45;
  --ok-solid: #4b8a60;
  --ok-soft: #e9f2ec;
  --ok-line: #c3dbc9;
  --half: #87570f;
  --half-solid: #c28c2e;
  --half-soft: #f9f2e2;
  --half-line: #ead6a8;
  --bad: #a03a2c;
  --bad-solid: #b8543f;
  --bad-soft: #f8ebe8;
  --bad-line: #ebc6bf;
  --info: #3b5f86;
  --info-solid: #5a7fa6;
  --info-soft: #e8eff6;
  --extra-soft: #f0f1f3;
  --row-hover: #f5f7f8;
  --row-peek: #edf4f4;
  --row-sel: #e2eeee;
  --viewer-bg: #e9ebee;
  --viewer-dot: rgba(27, 35, 48, 0.06);
  --page-filter: none;
  --sk: #eceef1;
  --sk-hi: #f6f7f8;
  --shadow-xs: 0 1px 2px rgba(27, 35, 48, 0.05);
  --shadow-sm: 0 1px 2px rgba(27, 35, 48, 0.06), 0 1px 3px rgba(27, 35, 48, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(27, 35, 48, 0.08), 0 2px 4px -2px rgba(27, 35, 48, 0.05);
  --shadow-lg: 0 18px 36px -10px rgba(27, 35, 48, 0.18), 0 4px 10px -4px rgba(27, 35, 48, 0.08);
  /* take-off groups (data-driven: group "Cable tray" -> --g-cable-tray; see overlay.js) */
  --g-rooms: #3f8a7e;
  --g-walls: #b35c33;
  --g-slabs: #5577a8;
  --g-columns: #a88c2c;
  --g-steel: #9c4f78;
  --g-ducting: #3a86a8;
  --g-piping: #b8782e;
  --g-cable-tray: #8f5a96;
  --g-busbar: #7a6048;
  --g-conduit: #4a8a5e;
  --g-mep-equipment: #4f5fa0;
  --g-other: #7d8590;
  --ev-fill: 0.16;
  --diff-up: #8a5410;
  --diff-down: #355f8a;
  --kind-vector: #1e6b70;
  --kind-raster: #8f5a96;
  --kind-hybrid: #b8782e;
  --legend-stroke: #3b5f86;
  --focus-ring-stroke: #c28c2e;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;
  --r-sm: 6px; --r: 8px; --r-lg: 12px; --r-xl: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c; --surface: #181d24; --surface-2: #1c222a; --surface-3: #242b34; --border: #2c343e; --border-strong: #3b4450;
    --text: #e6e9ed; --text-2: #c3c9d1; --muted: #9aa3ae; --faint: #6c7581; --placeholder: #8a939e;
    --accent: #5fa8a8; --accent-hover: #78b9b8; --accent-fg: #0f1a1b; --accent-text: #7fc0bf; --accent-soft: #1e2e31; --accent-line: #2f4a4c; --accent-ring: rgba(95, 168, 168, 0.4);
    --ok: #86c49a; --ok-solid: #5e9f72; --ok-soft: #1d2b24; --ok-line: #2f4a38;
    --half: #dcb36a; --half-solid: #c4973f; --half-soft: #2e2a1f; --half-line: #4d4228;
    --bad: #e6907f; --bad-solid: #c46a57; --bad-soft: #33221f; --bad-line: #57342d;
    --info: #93b4d8; --info-solid: #6f92ba; --info-soft: #1e2834;
    --extra-soft: #232a33; --row-hover: #1f252d; --row-peek: #1f2d30; --row-sel: #223538;
    --viewer-bg: #0e1116; --viewer-dot: rgba(255, 255, 255, 0.045);
    --page-filter: invert(0.88) hue-rotate(180deg) contrast(0.92);
    --sk: #1f252d; --sk-hi: #2a313b;
    --shadow-xs: none; --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35); --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 18px 36px -10px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
    --g-rooms: #6fb8aa; --g-walls: #e08d62; --g-slabs: #8eaad6; --g-columns: #d6bb62; --g-steel: #cf8ab0; --g-ducting: #6fb4d4;
    --g-piping: #e0a660; --g-cable-tray: #c094c8; --g-busbar: #b39478; --g-conduit: #80bf92; --g-mep-equipment: #8f9ce0; --g-other: #8e96a0;
    --ev-fill: 0.2;
    --diff-up: #dcb36a; --diff-down: #93b4d8;
    --kind-vector: #5fa8a8; --kind-raster: #c094c8; --kind-hybrid: #e0a660;
    --legend-stroke: #93b4d8; --focus-ring-stroke: #dcb36a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #12161c; --surface: #181d24; --surface-2: #1c222a; --surface-3: #242b34; --border: #2c343e; --border-strong: #3b4450;
  --text: #e6e9ed; --text-2: #c3c9d1; --muted: #9aa3ae; --faint: #6c7581; --placeholder: #8a939e;
  --accent: #5fa8a8; --accent-hover: #78b9b8; --accent-fg: #0f1a1b; --accent-text: #7fc0bf; --accent-soft: #1e2e31; --accent-line: #2f4a4c; --accent-ring: rgba(95, 168, 168, 0.4);
  --ok: #86c49a; --ok-solid: #5e9f72; --ok-soft: #1d2b24; --ok-line: #2f4a38;
  --half: #dcb36a; --half-solid: #c4973f; --half-soft: #2e2a1f; --half-line: #4d4228;
  --bad: #e6907f; --bad-solid: #c46a57; --bad-soft: #33221f; --bad-line: #57342d;
  --info: #93b4d8; --info-solid: #6f92ba; --info-soft: #1e2834;
  --extra-soft: #232a33; --row-hover: #1f252d; --row-peek: #1f2d30; --row-sel: #223538;
  --viewer-bg: #0e1116; --viewer-dot: rgba(255, 255, 255, 0.045);
  --page-filter: invert(0.88) hue-rotate(180deg) contrast(0.92);
  --sk: #1f252d; --sk-hi: #2a313b;
  --shadow-xs: none; --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35); --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 36px -10px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --g-rooms: #6fb8aa; --g-walls: #e08d62; --g-slabs: #8eaad6; --g-columns: #d6bb62; --g-steel: #cf8ab0; --g-ducting: #6fb4d4;
  --g-piping: #e0a660; --g-cable-tray: #c094c8; --g-busbar: #b39478; --g-conduit: #80bf92; --g-mep-equipment: #8f9ce0; --g-other: #8e96a0;
  --ev-fill: 0.2;
  --diff-up: #dcb36a; --diff-down: #93b4d8;
  --kind-vector: #5fa8a8; --kind-raster: #c094c8; --kind-hybrid: #e0a660;
  --legend-stroke: #93b4d8; --focus-ring-stroke: #dcb36a;
  color-scheme: dark;
}

/* base --------------------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text); font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; min-height: 100vh; overflow-x: hidden;
}
code { font-family: var(--mono); font-size: 0.88em; padding: 1px 5px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); }
h1, h2, h3 { margin: 0; color: var(--text); letter-spacing: -0.01em; }
h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
a { color: var(--accent-text); }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.fine { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic {
  width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.skip {
  position: absolute; left: 12px; top: -48px; z-index: 200; padding: 8px 14px; border-radius: var(--r);
  background: var(--accent); color: var(--accent-fg); font-weight: 600; text-decoration: none; transition: top 0.15s;
}
.skip:focus { top: 10px; }
main:focus { outline: none; }
kbd {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface-2); color: var(--text-2);
  font: 600 12px/1 var(--mono);
}

/* app bar ------------------------------------------------------------------------------------ */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.appbar-inner {
  max-width: 1680px; margin: 0 auto; padding: 0 var(--s6); height: 60px;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
}
.brand { display: flex; align-items: center; gap: var(--s3); text-decoration: none; color: inherit; min-width: 0; border-radius: var(--r); }
.mark { width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center; color: #fff; background: var(--accent); }
:root[data-theme="dark"] .mark { color: var(--accent-fg); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mark { color: var(--accent-fg); } }
.mark .ic { width: 20px; height: 20px; stroke-width: 2.1; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.015em; }
.brand-tag { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-right { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.env { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; overflow: hidden; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 12px; font-weight: 500; white-space: nowrap;
}
.chip .ic { width: 14px; height: 14px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--ok-solid); }
.dot.bad { background: var(--bad-solid); }
.dot.pending { animation: pulse 1.2s ease-in-out infinite; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: var(--r); border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s; flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .ic { width: 18px; height: 18px; }
.icon-btn.sm { width: 34px; height: 34px; border-color: transparent; background: transparent; }
.show-dark { display: none; }
:root[data-theme="dark"] .show-dark { display: block; }
:root[data-theme="dark"] .show-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .show-dark { display: block; }
  :root:not([data-theme="light"]) .show-light { display: none; }
}
.net-banner {
  display: flex; align-items: center; justify-content: center; gap: var(--s3); flex-wrap: wrap; padding: 8px var(--s4);
  background: var(--half-soft); color: var(--text); border-top: 1px solid var(--half-line); font-size: 13px; text-align: center;
}
.net-banner > .ic { color: var(--half); }

/* user menu */
.user-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 8px 0 4px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font: inherit; font-size: 13px; font-weight: 550; cursor: pointer;
}
.user-btn:hover { background: var(--surface-3); }
.user-btn .caret { width: 14px; height: 14px; color: var(--muted); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent-text); font-weight: 700; font-size: 12px; letter-spacing: 0.02em; border: 1px solid var(--accent-line);
}
.user-short { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* menus (export, user) */
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 50; min-width: 240px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: pop 0.14s var(--ease);
}
.menu.right { left: auto; right: 0; }
.menu-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; min-width: 0; }
.mh-name { font-weight: 650; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mh-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-label { padding: 8px 10px 4px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.menu-item {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; min-height: 40px; padding: 8px 10px; border: 0; border-radius: var(--r);
  background: transparent; color: var(--text); font: inherit; font-size: 13.5px; text-align: left; text-decoration: none; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-3); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.menu-item > .ic { margin-top: 2px; color: var(--muted); }
.menu-item.disabled { opacity: 0.5; pointer-events: none; }
.mi-t { display: flex; flex-direction: column; min-width: 0; font-weight: 600; }
.mi-d { font-weight: 400; font-size: 12px; color: var(--muted); line-height: 1.35; margin-top: 1px; }
.menu-item .fmt {
  flex: none; width: 44px; height: 22px; margin-top: 1px; display: grid; place-items: center; border-radius: 5px; font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.04em; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border);
}
.export-menu { width: 340px; max-width: calc(100vw - 32px); }

/* page and cards ----------------------------------------------------------------------------- */
.page { max-width: 1680px; margin: 0 auto; padding: var(--s5) var(--s6) var(--s10); }
.view { display: grid; gap: var(--s5); min-width: 0; animation: rise 0.25s var(--ease); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: var(--s5); min-width: 0;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2) var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.card-title { font-size: 15px; font-weight: 650; display: inline-flex; align-items: center; gap: 10px; }
.title-n {
  width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent-line);
}

/* steps */
.steps { list-style: none; margin: 0 0 var(--s5); padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.steps li { min-width: 0; position: relative; }
.step {
  display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 56px; padding: 8px 12px; border-radius: var(--r-lg);
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); font: inherit; text-align: left; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.step:hover { border-color: var(--border-strong); }
.step[disabled] { cursor: default; }
.step[disabled]:hover { border-color: var(--border); }
.step-n {
  width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: var(--surface-3); color: var(--muted); border: 1px solid var(--border);
}
.step-n .ic { display: none; width: 15px; height: 15px; stroke-width: 2.6; }
.step-t { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.step-name { font-weight: 650; font-size: 13.5px; color: var(--text-2); }
.step-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps li.current .step { border-color: var(--accent-line); background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); box-shadow: inset 0 -2px 0 var(--accent); }
.steps li.current .step-n { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.steps li.current .step-name { color: var(--text); }
.steps li.done .step-n { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.steps li.done .step-n .n { display: none; }
.steps li.done .step-n .ic { display: block; }

/* buttons ------------------------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 38px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2); font: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-xs);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.08s;
}
.btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 12.5px; gap: 6px; }
.btn.sm .ic { width: 14px; height: 14px; }
.btn.lg { height: 46px; font-size: 15px; padding: 0 18px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-fg); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn[disabled], .btn.disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn.primary[disabled] { background: var(--surface-3); border-color: var(--border); color: var(--muted); opacity: 1; }
.btn .caret { width: 14px; height: 14px; margin-left: -2px; }
.btn .spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }

/* pills and badges --------------------------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--muted); white-space: nowrap;
  text-transform: capitalize; letter-spacing: 0; vertical-align: middle;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.queued { color: var(--muted); }
.pill.running { color: var(--info); background: var(--info-soft); }
.pill.running::before { width: 8px; height: 8px; background: none; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
.pill.done { color: var(--ok); background: var(--ok-soft); }
.pill.error { color: var(--bad); background: var(--bad-soft); }
.pill.cached { color: var(--muted); background: var(--surface-3); font-weight: 500; }
.pill.cached::before, .pill.plain::before { display: none; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--r-sm);
  font-weight: 650; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; border: 1px solid transparent;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.badge.half { background: var(--half-soft); color: var(--half); border-color: var(--half-line); }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.badge.zero { background: var(--surface-3); color: var(--muted); border-color: var(--border); }
.badge .pct { font-weight: 500; }

/* upload view -------------------------------------------------------------------------------- */
.hero { max-width: 820px; }
.hero h1 { font-size: clamp(22px, 2.6vw, 28px); line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
.hero p { margin: var(--s2) 0 0; color: var(--muted); font-size: 14.5px; max-width: 720px; }

.upload-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--s5); align-items: start; }
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s2);
  padding: var(--s8) var(--s6); min-height: 200px; border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg);
  background: var(--surface-2); cursor: pointer; text-align: center; transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.dropzone:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface-2)); }
.dropzone:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.dropzone.over { border-style: solid; border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 4px var(--accent-ring); }
.dz-over { display: none; }
.dropzone.over .dz-idle { display: none; }
.dropzone.over .dz-over { display: inline; color: var(--accent-text); }
.dz-icon {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; margin-bottom: var(--s1);
  background: var(--surface); color: var(--accent-text); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: transform 0.25s var(--ease);
}
.dz-icon .ic { width: 24px; height: 24px; }
.dropzone:hover .dz-icon, .dropzone.over .dz-icon { transform: translateY(-3px); }
.dz-title { font-weight: 650; font-size: 16px; color: var(--text); }
.dz-title .link { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.dz-sub { color: var(--muted); font-size: 13px; max-width: 460px; }

.picked { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s5); margin-top: var(--s5); }
.picked-col { min-width: 0; }
.picked-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.opt-tag { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 2px; }
.count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--surface-3); color: var(--text-2); font-size: 11.5px; font-weight: 650; font-variant-numeric: tabular-nums;
}
.count.on { background: var(--accent-soft); color: var(--accent-text); }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.file-list:empty::before {
  content: attr(data-empty); display: block; padding: 10px 12px; border-radius: var(--r); border: 1px dashed var(--border);
  color: var(--muted); font-size: 13px;
}
.file-item {
  display: flex; align-items: center; gap: var(--s3); padding: 8px 6px 8px 10px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface); animation: rise 0.2s var(--ease); min-width: 0;
}
.file-ic { width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center; flex: none; }
.file-ic.pdf { background: var(--surface-3); color: var(--text-2); }
.file-ic.csv { background: var(--ok-soft); color: var(--ok); }
.file-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.35; }
.file-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.match { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; margin-top: 1px; min-width: 0; }
.match .ic { width: 13px; height: 13px; flex: none; }
.match span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match.ok { color: var(--ok); }
.match.none { color: var(--muted); }
.match.warn { color: var(--half); }
.file-x {
  width: 36px; height: 36px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; cursor: pointer; flex: none; transition: background 0.15s, color 0.15s;
}
.file-x:hover { background: var(--bad-soft); color: var(--bad); }
.picked .fine { margin: var(--s2) 0 0; }

.settings-card { display: flex; flex-direction: column; gap: var(--s3); position: sticky; top: 80px; scroll-margin-top: 80px; }
.settings-card .card-head { margin-bottom: 0; }
.setting {
  display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3); border-radius: var(--r);
  border: 1px solid var(--border); cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.setting:hover { background: var(--surface-2); }
.setting:has(input:checked) { border-color: var(--accent-line); }
.setting-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.setting-name { font-weight: 650; font-size: 13.5px; color: var(--text); }
.setting-desc { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.rec { font-size: 11px; font-weight: 600; color: var(--ok); background: var(--ok-soft); border-radius: 4px; padding: 1px 6px; margin-left: 4px; white-space: nowrap; }
.switch { position: relative; flex: none; margin-top: 2px; }
.switch input { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); opacity: 0; margin: 0; cursor: pointer; }
.switch .track { display: block; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); transition: background 0.2s; position: relative; }
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(27, 35, 48, 0.3); transition: transform 0.2s var(--ease);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-ring); }
.run-box { display: grid; gap: var(--s2); padding-top: var(--s1); }
.run-summary { font-size: 13px; color: var(--muted); }
.run-summary b { color: var(--text); font-weight: 650; }

/* data tables -------------------------------------------------------------------------------- */
table { border-collapse: separate; border-spacing: 0; width: 100%; }
.table-scroll { overflow: auto; border: 1px solid var(--border); border-radius: var(--r); min-width: 0; }
.data th, .data td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.data thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--muted); font-weight: 600;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr:hover td { background: var(--row-hover); }
.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.data .r { text-align: right; }
.data tr.clickable { cursor: pointer; }
.data tr.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.data td.err { color: var(--text-2); font-size: 12.5px; background: var(--bad-soft); }
.data td.err b { color: var(--bad); }
.data td.err details { margin-top: 4px; }
.data td.err summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.data td.err code { display: block; margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
/* sortable headers */
.th-sort {
  display: inline-flex; align-items: center; gap: 4px; padding: 0; margin: 0; border: 0; background: none; font: inherit; color: inherit;
  text-transform: inherit; letter-spacing: inherit; cursor: pointer; border-radius: 4px;
}
.th-sort .ic { width: 12px; height: 12px; opacity: 0; transition: opacity 0.15s, transform 0.15s; }
.th-sort:hover { color: var(--text); }
.th-sort:hover .ic, .th-sort:focus-visible .ic { opacity: 0.6; }
th[aria-sort] .th-sort { color: var(--text); }
th[aria-sort] .th-sort .ic { opacity: 1; color: var(--accent-text); }
th[aria-sort="descending"] .th-sort .ic { transform: rotate(180deg); }
th.num .th-sort { flex-direction: row-reverse; }

.cell-file { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.cell-file .file-ic { width: 28px; height: 28px; }
.cell-file .file-ic .ic { width: 15px; height: 15px; }
.cell-file .t { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.cell-file .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 340px; }
.cell-file .s { font-size: 12px; color: var(--muted); }
.mini-links { display: inline-flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.mini-link {
  display: inline-flex; align-items: center; height: 28px; padding: 0 9px; border-radius: var(--r-sm); font-size: 12px;
  font-weight: 600; color: var(--text-2); text-decoration: none; border: 1px solid var(--border); background: var(--surface);
}
.mini-link:hover { border-color: var(--accent); color: var(--accent-text); }
.key-name { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-table .names { max-width: 520px; }
.recent-table .names .nm { display: block; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-table .names .jid { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.recent-table .go { color: var(--faint); width: 1%; }
.recent-table tr:hover .go { color: var(--accent-text); }
.empty-mini { display: flex; align-items: center; gap: var(--s4); padding: var(--s4); border: 1px dashed var(--border-strong); border-radius: var(--r); }
.empty-mini > div { display: flex; flex-direction: column; gap: 2px; }
.empty-mini span:not(.em-icon) { color: var(--muted); font-size: 13px; }
.em-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); flex: none; }

/* job view ----------------------------------------------------------------------------------- */
.job-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
.job-head-main { min-width: 0; flex: 1; }
.back { margin: 0 0 var(--s2) -10px; }
.job-title { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; letter-spacing: -0.02em; min-width: 0; }
#jobName { min-width: 0; overflow-wrap: anywhere; }
.job-sub { display: flex; align-items: center; gap: var(--s2); margin-top: 2px; flex-wrap: wrap; }
.job-sub .jid { font-size: 13px; color: var(--muted); }
.job-sub code { font-size: 12.5px; }
.job-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s2); }
.job-meta .chip { height: 26px; font-size: 12px; }
.job-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }

.progress-card { padding: var(--s4) var(--s5); display: grid; gap: var(--s3); }
.progress-top { display: flex; justify-content: space-between; gap: var(--s3); font-size: 14px; color: var(--text); font-weight: 600; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress .bar { height: 100%; width: 0; border-radius: inherit; transition: width 0.5s var(--ease); background: var(--accent); position: relative; overflow: hidden; }
.progress .bar::after {
  content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  transform: translateX(-100%); animation: sweep 1.8s ease-in-out infinite;
}
.file-progress { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fp {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: var(--s3); padding: 8px 10px;
  border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border);
}
.fp-ic { width: 22px; height: 22px; display: grid; place-items: center; color: var(--muted); }
.fp-ic .spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--info); border-right-color: transparent; animation: spin 0.8s linear infinite; }
.fp.done .fp-ic { color: var(--ok); }
.fp.error .fp-ic { color: var(--bad); }
.fp-t { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.fp-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-stage { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp.error .fp-stage { color: var(--bad); }
.fp-time { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.leave-note { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin: 0; font-size: 12.5px; color: var(--muted); }
.leave-note > .ic { color: var(--info); }
.leave-note > span { flex: 1 1 260px; }

.kpis { display: grid; grid-template-columns: 1.25fr repeat(4, minmax(0, 1fr)); gap: var(--s4); }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  padding: var(--s4) var(--s5); display: flex; gap: var(--s4); align-items: center; min-width: 0; min-height: 118px; animation: rise 0.3s var(--ease) both;
}
.kpi-body { min-width: 0; flex: 1; }
.kpi-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-label .ic { width: 14px; height: 14px; }
.kpi-value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); }
.kpi-value small { font-size: 14px; font-weight: 550; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi.score .kpi-value { font-size: 34px; }
.ring { width: 76px; height: 76px; flex: none; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring .bg { stroke: var(--surface-3); }
.ring .fg { stroke-linecap: round; transition: stroke-dashoffset 0.8s var(--ease); }
.ring.ok .fg { stroke: var(--ok-solid); }
.ring.half .fg { stroke: var(--half-solid); }
.ring.bad .fg { stroke: var(--bad-solid); }
.ring .ring-txt { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--text); }
.ring.none .ring-txt { color: var(--muted); font-weight: 600; }
.split-bar { display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--surface-3); margin-top: 8px; gap: 2px; }
.split-bar i { display: block; height: 100%; }
.split-bar .v, .legend-dots .v { background: var(--kind-vector); }
.split-bar .r, .legend-dots .r { background: var(--kind-raster); }
.split-bar .h, .legend-dots .h { background: var(--kind-hybrid); }
.split-bar .e, .legend-dots .e { background: var(--faint); }
.legend-dots { display: flex; gap: var(--s3); flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend-dots span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-dots i { width: 8px; height: 8px; border-radius: 2px; }

/* totals by group */
.totals-card .card-head { margin-bottom: var(--s3); }
.totals { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s3); }
.tot {
  position: relative; display: grid; gap: 2px; padding: var(--s3) var(--s4) var(--s3) calc(var(--s4) + 2px); border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--border); min-width: 0; text-align: left; font: inherit; color: inherit;
}
.tot::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gc, var(--g-other)); }
.tot-g { font-size: 12px; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; display: flex; justify-content: space-between; gap: 8px; }
.tot-g .n { color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; }
.tot-v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tot-v small { font-size: 13px; color: var(--muted); font-weight: 550; margin-left: 3px; }
.tot-more { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.callout {
  display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r);
  border: 1px solid; font-size: 13px;
}
.callout > .ic { margin-top: 2px; }
.callout ul { margin: 4px 0 0; padding-left: 18px; }
.callout.warn { background: var(--half-soft); border-color: var(--half-line); color: var(--text-2); }
.callout.warn > .ic, .callout.warn b { color: var(--half); }
.callout.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--text-2); }
.callout.bad > .ic, .callout.bad b { color: var(--bad); }

.empty-state { text-align: center; padding: var(--s10) var(--s6); }
.empty-state .es-icon { width: 52px; height: 52px; margin: 0 auto var(--s3); border-radius: 14px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.empty-state .es-icon .ic { width: 24px; height: 24px; }
.empty-state h2 { font-size: 17px; }
.empty-state p { color: var(--muted); margin: var(--s2) auto var(--s4); max-width: 460px; }

/* skeletons ---------------------------------------------------------------------------------- */
.sk {
  display: block; border-radius: var(--r-sm); height: 12px;
  background: linear-gradient(90deg, var(--sk) 0%, var(--sk-hi) 50%, var(--sk) 100%); background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.sk.w40 { width: 40px; } .sk.w60 { width: 60px; } .sk.w90 { width: 90px; } .sk.w120 { width: 120px; }
.sk.tall { height: 28px; margin-top: 6px; width: 70%; }
.skeleton-card { display: grid; gap: var(--s4); }
.sk-row { display: flex; gap: var(--s3); }
.sk-row .sk { height: 28px; }
.sk-split { display: grid; grid-template-columns: 1.3fr 1fr; gap: var(--s4); }
.sk-block { height: 420px; border-radius: var(--r); }
.sk-lines { display: grid; gap: var(--s3); align-content: start; }
.sk-lines .sk { height: 30px; }

/* results card ------------------------------------------------------------------------------- */
.results { padding: 0; overflow: hidden; scroll-margin-top: 76px; }
.tabs {
  display: flex; gap: var(--s1); overflow-x: auto; overflow-y: hidden; padding: var(--s2) var(--s3) 0; border-bottom: 1px solid var(--border);
  background: var(--surface-2); scrollbar-width: thin;
}
.tab {
  position: relative; display: inline-flex; align-items: center; gap: var(--s2); min-height: 42px; padding: 8px 14px 10px; border: 0;
  background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  border-radius: var(--r) var(--r) 0 0; transition: color 0.15s, background 0.15s;
}
.tab:hover { color: var(--text); background: var(--surface-3); }
.tab:focus-visible { outline-offset: -2px; }
.tab::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; border-radius: 2px; background: transparent; transition: background 0.2s; }
.tab[aria-selected="true"] { color: var(--text); background: var(--surface); }
.tab[aria-selected="true"]::after { background: var(--accent); }
.tab .k { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: var(--surface-3); color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }
.tab .k.raster { background: color-mix(in srgb, var(--kind-raster) 14%, transparent); color: var(--text-2); }
.tab .lvl { font-size: 12px; color: var(--muted); font-weight: 500; }

.sheet-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s6); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.sheet-title { flex-basis: 100%; display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; }
.sheet-title h2 { font-size: 18px; font-weight: 700; }
.sheet-title .t { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; }
.meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.meta .k { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.meta .v { font-size: 13.5px; font-weight: 600; color: var(--text); display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.meta .v.warn { color: var(--half); }

.split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.pane { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.viewer-pane { border-right: 1px solid var(--border); }
.toolbar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; min-height: 34px; }
.seg { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface); overflow: hidden; box-shadow: var(--shadow-xs); }
.seg-btn {
  width: 36px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; color: var(--text-2);
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn:hover { background: var(--surface-3); color: var(--text); }
.seg-btn:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.seg-label { min-width: 54px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); border-left: 1px solid var(--border); border-right: 1px solid var(--border); line-height: 34px; }
.toggle-chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted); font-size: 12.5px; font-weight: 600;
  cursor: pointer; user-select: none; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.toggle-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-chip .ic { width: 14px; height: 14px; }
.toggle-chip:hover { color: var(--text); }
.toggle-chip:has(input:checked) { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); }
.toggle-chip:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--accent-ring); }

.viewer {
  position: relative; flex: 1; min-height: 420px; height: clamp(440px, 64vh, 860px); overflow: hidden; border-radius: var(--r);
  background: radial-gradient(circle at 1px 1px, var(--viewer-dot) 1px, transparent 0) 0 0 / 16px 16px, var(--viewer-bg);
  border: 1px solid var(--border); cursor: grab; touch-action: none;
}
.viewer:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.viewer.dragging { cursor: grabbing; }
.viewer-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.viewer .loading-veil { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.viewer .loading-veil span { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-lg); font-size: 12.5px; color: var(--text-2); }
.viewer .loading-veil .spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent); border-right-color: transparent; animation: spin 0.7s linear infinite; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.stage.anim { transition: transform 0.38s var(--ease); }
.stage img {
  position: absolute; left: 0; top: 0; user-select: none; -webkit-user-drag: none; background: #fff; filter: var(--page-filter);
  box-shadow: 0 0 0 1px rgba(27, 35, 48, 0.12), 0 8px 24px rgba(27, 35, 48, 0.16);
}
.stage img:not([src]) { visibility: hidden; }
.stage svg { position: absolute; left: 0; top: 0; overflow: visible; }
.ev {
  fill-opacity: var(--ev-fill); stroke-width: 1.6; stroke-opacity: 0.95; vector-effect: non-scaling-stroke; cursor: pointer;
  transition: fill-opacity 0.18s, stroke-opacity 0.18s, stroke-width 0.18s;
}
.ev:hover, .ev.peek { fill-opacity: 0.34; stroke-width: 2.6; stroke-opacity: 1; }
.ev.dim { fill-opacity: 0.05; stroke-opacity: 0.3; }
.ev.hi { fill-opacity: 0.4; stroke-width: 3; stroke-opacity: 1; animation: evpulse 1.6s ease-in-out 2; }
.ev.hidden { display: none; }
.ev.run { fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; stroke-opacity: 0.9; }
.ev.run:hover, .ev.run.peek { stroke-width: 4; }
.ev.run.dim { stroke-opacity: 0.25; }
.ev.run.hi { stroke-width: 5; }
.legendbox { fill: none; stroke: var(--legend-stroke); stroke-dasharray: 4 3; stroke-width: 1.4; vector-effect: non-scaling-stroke; pointer-events: none; }
.focus-ring { fill: none; stroke: var(--focus-ring-stroke); stroke-width: 3; vector-effect: non-scaling-stroke; pointer-events: none; animation: ringpulse 1.2s ease-in-out infinite; }
.viewer-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.groups-filter { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; min-width: 0; }
.gf-label { font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.layer-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.layer-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px 0 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
.layer-chip i { width: 10px; height: 10px; border-radius: 3px; }
.layer-chip .n { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.layer-chip:hover { background: var(--surface-3); }
.layer-chip[aria-pressed="false"] { color: var(--muted); background: transparent; border-style: dashed; }
.layer-chip[aria-pressed="false"] i { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--faint); }

/* lines table -------------------------------------------------------------------------------- */
.search { position: relative; display: inline-flex; align-items: center; flex: 0 1 260px; min-width: 150px; }
.search .ic { position: absolute; left: 10px; color: var(--muted); width: 15px; height: 15px; pointer-events: none; }
.search input {
  width: 100%; height: 34px; padding: 0 10px 0 32px; border-radius: var(--r); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px; box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search input::placeholder { color: var(--placeholder); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.lines-scroll { max-height: min(64vh, 860px); flex: 1; }
.lines th, .lines td { padding: 7px 8px; }
.lines tbody tr { cursor: pointer; }
.lines tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.lines tbody tr:hover td, .lines tbody tr.peek td { background: var(--row-peek); }
.lines tbody tr.selected td { background: var(--row-sel); }
.lines tbody tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.lines tbody tr.deleted td { text-decoration: line-through; color: var(--muted); }
.lines tbody tr.deleted td.c-status, .lines tbody tr.deleted td.c-x { text-decoration: none; }
.lines tbody tr.edited .e { font-style: italic; }
.lines [contenteditable] { outline: none; border-radius: 4px; transition: box-shadow 0.12s, background 0.12s; }
.lines [contenteditable]:hover { box-shadow: inset 0 0 0 1px var(--border-strong); }
.lines [contenteditable]:focus { box-shadow: inset 0 0 0 2px var(--accent); background: var(--surface) !important; cursor: text; }
.lines .grp-cell { white-space: nowrap; }
.lines .grp-cell [contenteditable] { display: inline-block; min-width: 48px; padding: 2px 4px; margin: -2px -4px; }
.lines td.empty .ic { width: 22px; height: 22px; color: var(--muted); margin-bottom: 6px; }
.lines td.c-status { width: 1%; white-space: nowrap; }
.lines.no-score .c-status { display: none; }
.lines td.item { min-width: 150px; }
.lines td.e.num { font-weight: 650; color: var(--text); white-space: nowrap; }
.lines td.lvl { white-space: nowrap; color: var(--text-2); }
.lines td.unit { color: var(--muted); }
.lines .grp { white-space: nowrap; }
.gdot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 0; flex: none; }
.lines .conf { color: var(--muted); }
.lines .conf.low { color: var(--half); font-weight: 600; }
.lines .hedge { display: inline-block; font-size: 10px; font-weight: 700; color: var(--half); background: var(--half-soft); border-radius: 3px; padding: 0 4px; margin-left: 6px; }
.lines td.c-x { width: 1%; padding: 2px 4px; }
.lines td.c-x button {
  width: 32px; height: 32px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted);
  cursor: pointer; display: grid; place-items: center; opacity: 0.35; transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.lines td.c-x button .ic { width: 14px; height: 14px; }
.lines tbody tr:hover td.c-x button, .lines tbody tr.selected td.c-x button, .lines tbody tr.deleted td.c-x button, .lines td.c-x button:focus-visible { opacity: 1; }
.lines td.c-x button:hover { background: var(--bad-soft); color: var(--bad); }
.lines tr.deleted td.c-x button:hover { background: var(--accent-soft); color: var(--accent-text); }
.st {
  display: inline-flex; align-items: center; justify-content: center; min-width: 54px; height: 20px; padding: 0 7px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.st.ok { background: var(--ok-soft); color: var(--ok); }
.st.half { background: var(--half-soft); color: var(--half); }
.st.wrong, .st.missing { background: var(--bad-soft); color: var(--bad); }
.st.extra { background: var(--extra-soft); color: var(--muted); }
.lines tr.s-wrong td:first-child { box-shadow: inset 3px 0 0 var(--bad-solid); }
.lines tr.s-half td:first-child { box-shadow: inset 3px 0 0 var(--half-solid); }
.lines tr.s-ok td:first-child { box-shadow: inset 3px 0 0 var(--ok-solid); }
.lines tr.s-wrong td { background: color-mix(in srgb, var(--bad-soft) 60%, transparent); }
.lines tr.s-half td { background: color-mix(in srgb, var(--half-soft) 60%, transparent); }
.lines td.empty, .data td.empty { text-align: center; color: var(--muted); padding: var(--s8) var(--s4); cursor: default; }
.data tr.empty-row:hover td { background: transparent; }
.keyq { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.edit-hint { margin: 0; }
.details { font-size: 13px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); }
.details summary { cursor: pointer; color: var(--text-2); font-weight: 600; padding: 10px 12px; list-style: none; display: flex; align-items: center; gap: 6px; border-radius: var(--r); min-height: 40px; }
.details summary::-webkit-details-marker { display: none; }
.details summary:hover { color: var(--text); }
.details .chev { transition: transform 0.2s var(--ease); width: 14px; height: 14px; }
.details[open] .chev { transform: rotate(90deg); }
.details .badge { margin-left: auto; }
.details-body { padding: 0 12px 12px; display: grid; gap: var(--s3); }
.details-body ul { margin: 0; padding-left: 18px; }
.details-body .warn { color: var(--half); }
.details-body h4 { margin: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto auto; justify-content: start; gap: 2px 18px; font-variant-numeric: tabular-nums; }
.kv span:nth-child(odd) { color: var(--muted); }
.kv span:nth-child(even) { text-align: right; }

/* measurement standard (run settings) -------------------------------------------------------- */
.std-block { padding: var(--s3); border: 1px solid var(--border); border-radius: var(--r); display: grid; gap: 10px; min-width: 0; transition: border-color 0.15s; }
.std-block:has(input[value="is1200"]:checked) { border-color: var(--accent-line); }
.std-block > .setting-desc { margin: 0; }
.segmented {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; border-radius: var(--r);
  background: var(--surface-3); border: 1px solid var(--border); min-width: 0;
}
.segmented label, .segmented button {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented label:hover, .segmented button:hover { color: var(--text); }
.segmented label:has(input:checked), .segmented button[aria-selected="true"] {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}
.segmented label:has(input:focus-visible), .segmented button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.segmented .ic { width: 14px; height: 14px; }
.segmented button[aria-selected="true"] .ic { color: var(--accent-text); }
.std-block .segmented { width: 100%; }
.std-opts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); padding-top: var(--s1); animation: rise 0.2s var(--ease); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.input-unit { position: relative; display: flex; align-items: center; }
.input-unit input, .input {
  width: 100%; height: 38px; padding: 0 28px 0 10px; border-radius: var(--r); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px; font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-xs); transition: border-color 0.15s, box-shadow 0.15s; -moz-appearance: textfield; appearance: textfield;
}
.input-unit input::-webkit-outer-spin-button, .input-unit input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-unit input::placeholder, .input::placeholder { color: var(--placeholder); font-size: 12.5px; }
.input-unit input:focus, .input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input-unit input:invalid, .input[aria-invalid="true"] { border-color: var(--bad-solid); }
.input-unit .u { position: absolute; right: 10px; font-size: 12px; color: var(--muted); pointer-events: none; }
.field-help { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.chip.std { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent-line); }
.chip.std .ic { color: var(--accent-text); }
.pill.std { color: var(--accent-text); background: var(--accent-soft); text-transform: none; margin-left: 6px; }
.pill.std::before { display: none; }

/* view switch (Default / IS 1200 / Compare) -------------------------------------------------- */
.std-bar {
  display: flex; align-items: center; gap: var(--s3) var(--s4); flex-wrap: wrap; padding: var(--s3) var(--s5);
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.segmented.sm button { height: 32px; padding: 0 14px; font-size: 12.5px; }
.std-bar-info { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.std-bar-info b { color: var(--text-2); font-weight: 600; }
.pane-body { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; flex: 1; }

/* clause badges ------------------------------------------------------------------------------ */
.vb {
  display: inline-flex; align-items: center; gap: 4px; height: 18px; padding: 0 6px; border-radius: 4px; font-size: 10.5px;
  font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap; vertical-align: 1px; font-style: normal;
}
.vb.ok { background: var(--ok-soft); color: var(--ok); }
.vb.ok::before { content: ""; width: 5px; height: 9px; border: solid currentColor; border-width: 0 1.8px 1.8px 0; transform: rotate(45deg) translate(-1px, -1px); }
.vb.practice { background: var(--surface-3); color: var(--muted); }
.vb.new { background: var(--accent-soft); color: var(--accent-text); }
.vb.drop { background: var(--half-soft); color: var(--half); }
.std-key { display: inline-flex; gap: 6px; }
.clause { display: flex; flex-direction: column; gap: 3px; min-width: 150px; }
.clause .cl { font-size: 12px; color: var(--text-2); }
.clause .vb { align-self: flex-start; }
.std-lines td.qty { font-weight: 650; color: var(--text); white-space: nowrap; }
.std-lines td.unit { color: var(--muted); white-space: nowrap; }
.std-lines td.item .sub { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.std-lines tr.derived td.item::before { content: "+"; display: inline-block; width: 12px; color: var(--accent-text); font-weight: 700; }
.std-foot { margin: 0; }

/* compare panel ------------------------------------------------------------------------------ */
.compare { padding: var(--s4) var(--s5) var(--s5); display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
.cmp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s3); }
.cmp-card {
  position: relative; border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s3) var(--s4) var(--s3) calc(var(--s4) + 2px); background: var(--surface);
  box-shadow: var(--shadow-xs); min-width: 0; display: grid; gap: 4px; overflow: hidden; animation: rise 0.25s var(--ease) both;
}
.cmp-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--gc, var(--g-other)); }
.cmp-card .ch { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); font-size: 12px; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
.cmp-card .ch .g { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-card .ch .g small { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 500; margin-left: 4px; }
.cmp-card .ch .badge { text-transform: none; letter-spacing: 0; height: 20px; font-size: 11.5px; }
.cmp-card .cs .n { color: var(--muted); }
.cmp-card .cv { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.cmp-card .cv small { font-size: 13px; font-weight: 550; color: var(--muted); margin-left: 3px; }
.cmp-card .cs { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.cmp-card.extra { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.cmp-card.extra::before { background: var(--accent); }
.cmp-card .lst { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-scroll { max-height: min(62vh, 760px); }
.cmp th, .cmp td { padding: 8px 12px; }
.cmp td { vertical-align: top; }
.cmp td.num { white-space: nowrap; }
.cmp .it { font-weight: 600; color: var(--text); }
.cmp td:first-child { min-width: 200px; }
.cmp .it-sub { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.cmp .gdot { margin-right: 0; }
.cmp .u { color: var(--muted); font-size: 12px; margin-left: 3px; }
.cmp td.std { font-weight: 650; color: var(--text); }
.d-pos { color: var(--diff-up); font-weight: 650; }
.d-neg { color: var(--diff-down); font-weight: 650; }
.d-zero { color: var(--muted); }
.mag { display: block; position: relative; height: 4px; margin: 5px 0 0 auto; width: 84px; border-radius: 2px; background: var(--surface-3); }
.mag i { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
.mag::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--border-strong); }
.mag i.pos { left: 50%; background: var(--diff-up); }
.mag i.neg { right: 50%; background: var(--diff-down); }
.cmp tr.derived td { background: color-mix(in srgb, var(--accent-soft) 35%, transparent); }
.cmp tbody tr.empty-row td { text-align: center; color: var(--muted); padding: var(--s8) var(--s4); }
.cmp-foot { margin: 0; line-height: 1.9; }
.cmp-foot .vb { margin: 0 2px; }
.d-key { white-space: nowrap; margin-right: 6px; }
.layer-chip.filter[aria-pressed="false"] i { background: transparent !important; }

/* accounts: sign in / create account ------------------------------------------------------- */
.auth-view { min-height: calc(100vh - 160px); align-content: center; }
.auth-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 440px); gap: var(--s10); align-items: center; max-width: 1040px; margin: 0 auto; width: 100%; padding: var(--s6) 0; }
.auth-intro h1 { font-size: clamp(24px, 2.8vw, 32px); line-height: 1.2; letter-spacing: -0.02em; margin-top: var(--s4); }
.auth-intro p { color: var(--muted); font-size: 15px; margin: var(--s3) 0 var(--s5); max-width: 460px; }
.mark.lg { width: 48px; height: 48px; border-radius: 12px; }
.mark.lg .ic { width: 26px; height: 26px; }
.auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; color: var(--text-2); }
.auth-points li { display: flex; align-items: center; gap: 10px; }
.auth-points .ic { color: var(--ok); }
.auth-card { padding: var(--s6); display: grid; gap: var(--s4); box-shadow: var(--shadow-md); }
.auth-tabs { width: 100%; }
.auth-tabs button { height: 38px; }
.auth-notice { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r); background: var(--info-soft); color: var(--text-2); font-size: 13px; }
.auth-notice .ic { color: var(--info); margin-top: 2px; }
.auth-form { display: grid; gap: var(--s4); }
.auth-form .input { height: 42px; padding: 0 12px; font-size: 14px; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.field-err { font-size: 12.5px; color: var(--bad); min-height: 0; }
.field-err:empty { display: none; }
.pw-wrap { position: relative; display: flex; align-items: center; }
.pw-wrap .input { padding-right: 46px; }
.pw-toggle {
  position: absolute; right: 3px; width: 38px; height: 36px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
}
.pw-toggle:hover { color: var(--text); background: var(--surface-3); }
.dialog .pw-wrap .input { padding-right: 46px; }
.strength { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.strength .bars { display: inline-grid; grid-template-columns: repeat(4, 28px); gap: 4px; }
.strength .bars i { height: 4px; border-radius: 2px; background: var(--surface-3); }
.strength[data-score="1"] .bars i:nth-child(-n+1) { background: var(--bad-solid); }
.strength[data-score="2"] .bars i:nth-child(-n+2) { background: var(--half-solid); }
.strength[data-score="3"] .bars i:nth-child(-n+3) { background: var(--ok-solid); }
.strength[data-score="4"] .bars i:nth-child(-n+4) { background: var(--ok-solid); }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text-2); cursor: pointer; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.auth-error { margin: 0; }
.auth-switch { margin: 0; text-align: center; font-size: 13.5px; color: var(--muted); }
.link-btn { border: 0; background: none; padding: 2px; font: inherit; font-weight: 600; color: var(--accent-text); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.btn .label { display: inline-flex; align-items: center; gap: 8px; }
@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; gap: var(--s5); padding: 0; }
  .auth-points { display: none; }
  .auth-intro p { margin-bottom: 0; }
  .auth-card { padding: var(--s5) var(--s4); }
}

/* dialogs ------------------------------------------------------------------------------------ */
.dialog {
  border: 1px solid var(--border); border-radius: var(--r-xl); padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(18, 22, 28, 0.45); }
.dialog[open] { animation: pop 0.16s var(--ease); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s4) var(--s2) var(--s5); }
.dialog-head h2 { font-size: 16px; }
.dialog-body { padding: var(--s2) var(--s5) var(--s5); display: grid; gap: var(--s3); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--s2); padding-top: var(--s2); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0; padding: var(--s2) var(--s5) var(--s5); align-items: center; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; color: var(--text-2); font-size: 13.5px; }

/* toasts ------------------------------------------------------------------------------------- */
.toasts { position: fixed; right: var(--s5); bottom: var(--s5); z-index: 100; display: flex; flex-direction: column; gap: var(--s2); width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) var(--s3) var(--s3) var(--s4);
  border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-size: 13px; color: var(--text-2); animation: toastin 0.28s var(--ease); position: relative; overflow: hidden;
}
.toast::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--info-solid); }
.toast.ok::before { background: var(--ok-solid); }
.toast.error::before { background: var(--bad-solid); }
.toast.warn::before { background: var(--half-solid); }
.toast > .ic { margin-top: 1px; color: var(--info); width: 18px; height: 18px; }
.toast.ok > .ic { color: var(--ok); }
.toast.error > .ic { color: var(--bad); }
.toast.warn > .ic { color: var(--half); }
.toast .tb { flex: 1; min-width: 0; }
.toast .tt { font-weight: 650; color: var(--text); }
.toast .tm { margin-top: 2px; word-break: break-word; }
.toast .ta { margin-top: 8px; }
.toast .tx { border: 0; background: transparent; color: var(--muted); cursor: pointer; width: 32px; height: 32px; margin: -4px -4px 0 0; border-radius: var(--r-sm); display: grid; place-items: center; flex: none; }
.toast .tx:hover { background: var(--surface-3); color: var(--text); }
.toast.out { animation: toastout 0.2s ease-in forwards; }

/* motion ------------------------------------------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes sweep { to { transform: translateX(100%); } }
@keyframes toastin { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toastout { to { opacity: 0; transform: translateX(16px); } }
@keyframes evpulse { 50% { fill-opacity: 0.55; } }
@keyframes ringpulse { 50% { stroke-opacity: 0.35; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* touch: 40 px+ targets ---------------------------------------------------------------------- */
@media (pointer: coarse) {
  .btn, .btn.sm, .toggle-chip, .search input, .seg-btn, .segmented label, .segmented button, .segmented.sm button { min-height: 44px; }
  .seg-btn { width: 44px; }
  .seg-label { line-height: 44px; }
  .layer-chip, .mini-link { min-height: 40px; }
  .tab { min-height: 48px; }
}

/* responsive --------------------------------------------------------------------------------- */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi.score { grid-column: span 1; }
}
@media (min-width: 1101px) and (max-width: 1560px) {
  .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .lines th, .lines td { padding: 6px 6px; }
  .lines td.item { min-width: 120px; }
  .lines .st { min-width: 0; }
}
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .viewer-pane { border-right: 0; border-bottom: 1px solid var(--border); }
  .viewer { height: 58vh; min-height: 340px; }
  .lines-scroll { max-height: 60vh; }
  .upload-grid { grid-template-columns: 1fr; }
  .settings-card { position: static; }
  .sk-split { grid-template-columns: 1fr; }
  .sk-block { height: 280px; }
}
@media (max-width: 760px) {
  .appbar-inner { padding: 0 var(--s4); height: 56px; gap: var(--s2); }
  .page { padding: var(--s4) var(--s4) var(--s8); }
  .env .chip.opt, .hide-sm, .user-short { display: none; }
  .brand-tag { display: none; }
  .steps { gap: 6px; margin-bottom: var(--s4); }
  .step { flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 8px 4px; min-height: 64px; }
  .step-name { font-size: 12px; }
  .step-sub { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
  .kpi { padding: var(--s3) var(--s4); min-height: 100px; }
  .kpi.score { grid-column: 1 / -1; }
  .kpi-value { font-size: 24px; }
  .picked { grid-template-columns: 1fr; }
  .card { padding: var(--s4); }
  .results { padding: 0; }
  .pane { padding: var(--s3); }
  .sheet-head { padding: var(--s3) var(--s4); gap: var(--s2) var(--s4); }
  .job-head { align-items: stretch; }
  .job-actions, .job-actions .menu-wrap, #exportBtn { width: 100%; }
  .job-title { font-size: 19px; }
  .files th:nth-child(3), .files td:nth-child(3), .files th:nth-child(5), .files td:nth-child(5) { display: none; }
  .recent-table th:nth-child(5), .recent-table td:nth-child(5) { display: none; }
  .viewer-foot .hint-line, .edit-hint { display: none; }
  .std-bar { padding: var(--s3) var(--s4); }
  .std-bar .segmented { width: 100%; }
  .compare { padding: var(--s3) var(--s4) var(--s4); }
  .cmp-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .cmp-card .cv { font-size: 18px; }
  .cmp th:nth-child(3), .cmp td:nth-child(3) { display: none; }
  .dropzone { min-height: 170px; padding: var(--s6) var(--s4); }
  .toasts { right: var(--s4); bottom: var(--s4); }
  .totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tot-v { font-size: 17px; }
}
@media (max-width: 460px) {
  .env .chip:not(:first-child) { display: none; }
  .env .chip { padding: 0 8px; }
  .kpi-value { font-size: 22px; }
  .ring { width: 62px; height: 62px; }
  .search { flex: 1 1 100%; }
  .cell-file .n { max-width: 150px; }
  .cmp-cards { grid-template-columns: 1fr; }
  .tot { padding: var(--s2) var(--s3) var(--s2) calc(var(--s3) + 2px); }
  .std-opts { grid-template-columns: 1fr; }
  .lines th, .lines td { padding: 6px 8px; }
  .recent-table th:nth-child(4), .recent-table td:nth-child(4) { display: none; }
  .brand-name { font-size: 15px; }
}

/* projects ----------------------------------------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
.page-head-main { min-width: 0; flex: 1 1 420px; }
.page-head h1 { font-size: clamp(22px, 2.4vw, 28px); line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.lede { margin: 6px 0 0; color: var(--muted); font-size: 14.5px; max-width: 720px; }
.page-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 6px; min-width: 0; }
.crumbs a { color: var(--accent-text); text-decoration: none; font-weight: 600; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .ic { width: 13px; height: 13px; color: var(--faint); }
.crumbs span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-toolbar { margin-bottom: calc(-1 * var(--s2)); }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: var(--s4); }
.proj-card {
  position: relative; display: flex; flex-direction: column; gap: 10px; padding: var(--s4) var(--s5); min-width: 0; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.2s, transform 0.2s var(--ease); animation: rise 0.25s var(--ease) both;
}
.proj-card:hover { border-color: var(--accent-line); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.proj-card:focus-within { border-color: var(--accent-line); }
.pc-top { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.pc-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent-line); }
.pc-name { flex: 1; min-width: 0; font-size: 15.5px; font-weight: 650; }
.pc-link { color: var(--text); text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 4px; }
.pc-link:hover { color: var(--accent-text); }
.pc-actions { display: flex; gap: 2px; flex: none; opacity: 0.55; transition: opacity 0.15s; }
.proj-card:hover .pc-actions, .proj-card:focus-within .pc-actions { opacity: 1; }
.icon-btn.del:hover { background: var(--bad-soft); color: var(--bad); }
.pc-desc { margin: 0; font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.pc-stats { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pc-stats > span:not(.pill) { display: inline-flex; align-items: center; gap: 5px; }
.pc-stats .ic { width: 14px; height: 14px; color: var(--muted); }
.pc-stats .pill { margin-left: auto; }
.pc-foot { font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 8px; }
.sk-card { cursor: default; gap: 12px; }
.sk-card:hover { transform: none; box-shadow: var(--shadow-sm); border-color: var(--border); }
.proj-empty { grid-column: 1 / -1; }
.btn.danger:hover { background: var(--bad-soft); color: var(--bad); }
.btn.danger-solid { background: var(--bad-solid); border-color: var(--bad-solid); color: #fff; }
.btn.danger-solid:hover { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.cf-text { margin: 0; color: var(--text-2); }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; font-variant-numeric: normal; }
.dialog .input { padding-right: 10px; }

.dropzone.compact { min-height: 132px; padding: var(--s5) var(--s4); }
.dropzone.compact .dz-icon { width: 42px; height: 42px; }
.upload-list { list-style: none; margin: var(--s3) 0 0; padding: 0; display: grid; gap: 6px; }
.upload-list:empty { display: none; }
.up-item { display: flex; align-items: center; gap: var(--s3); padding: 8px 6px 8px 10px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); animation: rise 0.2s var(--ease); min-width: 0; }
.up-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.up-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-st { font-size: 12px; color: var(--muted); }
.up-item .progress { height: 4px; }
.up-item.done .bar { background: var(--ok-solid); }
.up-item.done .up-st { color: var(--ok); }
.up-item.error { background: var(--bad-soft); border-color: var(--bad-line); }
.up-item.error .up-st { color: var(--bad); }
.up-item.error .progress { display: none; }
.pf-scroll { margin-top: var(--s4); max-height: 420px; }
.pfiles .c-sel { width: 1%; padding-right: 0; }
.pfiles .c-sel input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; vertical-align: middle; cursor: pointer; }
.pfiles .c-x { width: 1%; padding: 2px 6px; }
.pfiles .file-x { width: 32px; height: 32px; }
.pfiles tr.unsel td:not(.c-sel) { opacity: 0.55; }
.pfiles .cell-file .n { max-width: 260px; }
.kind { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); }
.kind.k-vector { background: color-mix(in srgb, var(--kind-vector) 14%, transparent); }
.kind.k-scan { background: color-mix(in srgb, var(--kind-raster) 16%, transparent); }

.std-checks { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); min-width: 0; }
.std-checks legend { padding: 0; margin-bottom: var(--s2); }
.std-checks > p, .std-checks .std-opts { grid-column: 1 / -1; margin: 0; }
.std-check {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r);
  cursor: pointer; transition: border-color 0.15s, background 0.15s; min-width: 0;
}
.std-check:hover { background: var(--surface-2); }
.std-check:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); }
.std-check:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--accent-ring); }
.std-check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; cursor: pointer; }
.sc-t { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.sc-name { font-weight: 650; font-size: 13.5px; color: var(--text); }
.sc-desc { font-size: 12px; color: var(--muted); }

.runs-table td { vertical-align: middle; }
.run-when { display: block; font-weight: 600; color: var(--text); }
.runs-table .jid { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.std-pills { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.std-pills .pill.std { margin-left: 0; }
.pill.std.def { color: var(--text-2); background: var(--surface-3); }
.run-err { display: block; font-size: 11.5px; color: var(--bad); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.row-actions { display: inline-flex; align-items: center; gap: 4px; }
.row-actions .btn .ic { width: 13px; height: 13px; }
.kpi.std-kpi .kpi-value { font-size: 24px; }
.menu-group { display: block; }

/* compare: rows where IS 1200 differs from the converted default */
.cmp tr.differs td { background: color-mix(in srgb, var(--half-soft) 45%, transparent); }
.cmp tr.differs td:first-child { box-shadow: inset 3px 0 0 var(--half-solid); }

/* footer: docs / status links */
.site-foot {
  max-width: 1680px; margin: 0 auto; padding: var(--s4) var(--s6) var(--s6); display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); flex-wrap: wrap; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border);
}
.foot-links { display: flex; gap: var(--s4); }
.foot-links a { color: var(--text-2); text-decoration: none; font-weight: 600; }
.foot-links a:hover { color: var(--accent-text); text-decoration: underline; }
@media (max-width: 760px) {
  .std-checks { grid-template-columns: 1fr; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .proj-grid { grid-template-columns: 1fr; gap: var(--s3); }
  .pfiles th:nth-child(4), .pfiles td:nth-child(4), .pfiles th:nth-child(6), .pfiles td:nth-child(6) { display: none; }
  .runs-table th:nth-child(3), .runs-table td:nth-child(3), .runs-table th:nth-child(5), .runs-table td:nth-child(5) { display: none; }
  .site-foot { padding: var(--s4); }
}
@media (max-width: 460px) {
  .pfiles th:nth-child(3), .pfiles td:nth-child(3) { display: none; }
  .pfiles .cell-file .n { max-width: 140px; }
  .runs-table .row-actions .btn { display: none; }
}


/* product tour (tour.js) ------------------------------------------------------------------------ */
:root { --tour-dim: rgba(16, 21, 28, 0.56); }
:root[data-theme="dark"] { --tour-dim: rgba(0, 0, 0, 0.66); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --tour-dim: rgba(0, 0, 0, 0.66); } }
.tour-root { position: fixed; inset: 0; z-index: 110; } /* above the toasts */
.tour-root[hidden] { display: none; }
.tour-block { position: absolute; inset: 0; cursor: default; }
.tour-spot {
  position: fixed; border-radius: var(--r-lg); pointer-events: none; opacity: 0;
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 6px var(--accent-ring), 0 0 0 200vmax var(--tour-dim);
  transition: top 0.38s var(--ease), left 0.38s var(--ease), width 0.38s var(--ease), height 0.38s var(--ease), opacity 0.22s, box-shadow 0.22s;
}
.tour-root.centred .tour-spot { box-shadow: 0 0 0 0 transparent, 0 0 0 0 transparent, 0 0 0 200vmax var(--tour-dim); }
.tour-card {
  position: fixed; top: 50%; left: 50%; width: min(404px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto;
  padding: var(--s4) var(--s5) var(--s4); background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(6px);
  transition: top 0.38s var(--ease), left 0.38s var(--ease), opacity 0.2s, transform 0.2s var(--ease);
}
.tour-card:focus { outline: none; }
.tour-card.wide { width: min(500px, calc(100vw - 24px)); }
.tour-on .tour-spot, .tour-on .tour-card { opacity: 1; }
.tour-on .tour-card { transform: none; }
.tour-on .tour-card.tour-swap { opacity: 0.35; transform: translateY(3px); transition-duration: 0s; }
.tour-head { display: flex; align-items: center; gap: var(--s3); }
.tour-ic {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent-line);
}
.tour-ic .ic { width: 18px; height: 18px; }
.tour-title { flex: 1; min-width: 0; margin: 0; font-size: 16.5px; line-height: 1.3; letter-spacing: -0.01em; }
.tour-x { margin: -4px -8px 0 0; align-self: flex-start; }
.tour-text { margin: var(--s3) 0 var(--s4); font-size: 14px; line-height: 1.55; color: var(--text-2); }
.tour-text b { color: var(--text); font-weight: 650; }
.tour-text kbd { height: 20px; min-width: 20px; font-size: 11px; }
.tour-art {
  display: flex; align-items: center; justify-content: center; gap: var(--s2); margin-top: var(--s4); padding: var(--s4) var(--s3);
  border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border);
}
.ta-step { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; text-align: center; }
.ta-step .ic {
  width: 44px; height: 44px; padding: 11px; border-radius: 12px; background: var(--surface); color: var(--accent-text);
  border: 1px solid var(--accent-line); box-shadow: var(--shadow-sm);
}
.ta-step b { font-size: 12px; font-weight: 600; color: var(--text-2); }
.ta-arrow .ic { width: 16px; height: 16px; color: var(--faint); margin-bottom: 20px; }
.tour-optout { margin: calc(-1 * var(--s2)) 0 var(--s3); font-size: 13px; }
.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s2) var(--s3); flex-wrap: wrap; }
.tour-progress { display: flex; align-items: center; gap: var(--s2); }
.tour-dots { display: flex; align-items: center; gap: 4px; }
.tour-dots i { display: block; width: 6px; height: 6px; border-radius: 3px; background: var(--border-strong); transition: width 0.25s var(--ease), background 0.25s; }
.tour-dots i.done { background: var(--accent-line); }
.tour-dots i.on { width: 18px; background: var(--accent); }
.tour-count { font-size: 12px; color: var(--muted); font-weight: 600; }
.tour-btns { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.tour-btns [hidden] { display: none; }
.tour-btns .tour-cta { order: 1; } /* the call to action goes last, after "Maybe later" */
.tour-btns .btn .ic { width: 14px; height: 14px; }
.foot-tour { font-size: inherit; text-decoration: none; color: var(--text-2); }
.foot-tour:hover { color: var(--accent-text); text-decoration: underline; }
/* phones: the card docks to the bottom, the spotlight stays above it */
.tour-card.docked {
  top: auto; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); width: auto; max-height: 72vh;
  border-radius: var(--r-xl);
}
.tour-card.docked.docked-top { top: calc(8px + env(safe-area-inset-top, 0px)); bottom: auto; }
.tour-card.docked .tour-art { display: none; } /* phones: the words carry it, the buttons stay in view */
.tour-card.docked .tour-text { margin: var(--s2) 0 var(--s3); }
@media (max-width: 400px) {
  .tour-card { padding: var(--s3) var(--s4); }
  .tour-btns [data-tour="skip"].btn { padding: 0 6px; }
  .tour-text { font-size: 13.5px; }
}


/* mobile ----------------------------------------------------------------------------------------
   Phones (<= 600 px), small tablets (601-900 px) and landscape phones (short + touch). Safe areas for notches
   (viewport-fit=cover), 44 px touch targets, 16 px inputs (no iOS focus zoom), menus and dialogs as bottom
   sheets, the wide tables as stacked cards, and the primary action (Run / Export) docked at the bottom. */
:root { --sa-t: env(safe-area-inset-top, 0px); --sa-r: env(safe-area-inset-right, 0px); --sa-b: env(safe-area-inset-bottom, 0px); --sa-l: env(safe-area-inset-left, 0px); }
html, body { overflow-x: clip; }
.appbar { padding-top: var(--sa-t); }
.appbar-inner { padding-left: max(var(--s6), var(--sa-l)); padding-right: max(var(--s6), var(--sa-r)); }
.page { padding-left: max(var(--s6), var(--sa-l)); padding-right: max(var(--s6), var(--sa-r)); }
.site-foot { padding-bottom: max(var(--s6), var(--sa-b)); }
.toasts { bottom: max(var(--s5), var(--sa-b)); }
.dz-touch, .hint-touch { display: none; }
.view { grid-template-columns: minmax(0, 1fr); } /* a long name or a wide table never widens the page */
.job-head-main { min-width: 0; }
.btn.back { max-width: 100%; }
.btn.back #newJobLabel { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.data td[data-label]::before { display: none; } /* labels only show on the phone cards */
.dropzone { -webkit-tap-highlight-color: transparent; }

/* tables kept as tables (tablets, landscape): the first column stays in view while scrolling sideways */
.cmp th:first-child, .cmp td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.cmp thead th:first-child { z-index: 2; background: var(--surface-2); }
.cmp tr.differs td:first-child { background: color-mix(in srgb, var(--half-soft) 45%, var(--surface)); }
.cmp tr.derived td:first-child { background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface)); }

/* touch devices: drag-and-drop text becomes "tap", 44 px targets, 16 px inputs */
@media (pointer: coarse) {
  .dropzone .dz-idle { display: none; }
  .dropzone .dz-touch { display: inline; }
  .dropzone.over .dz-touch { display: none; }
  .viewer-foot .hint-line { display: none; }
  .viewer-foot .hint-touch { display: inline; }
  .icon-btn, .user-btn { min-width: 44px; height: 44px; }
  .icon-btn.sm { width: 44px; height: 44px; }
  .menu-item { min-height: 48px; align-items: center; }
  .menu-item > .ic { margin-top: 0; }
  .file-x, .pfiles .file-x, .lines td.c-x button, .toast .tx { min-width: 44px; min-height: 44px; }
  .lines td.c-x button { opacity: 1; }
  .check, .std-check, .setting { min-height: 44px; }
  .mini-link { min-height: 40px; display: inline-flex; align-items: center; }
  .link-btn, .foot-links a, .crumbs a { display: inline-flex; align-items: center; min-height: 44px; }
  .pw-toggle { min-width: 44px; min-height: 44px; }
  .input, .auth-form .input, .input-unit input, .search input, textarea, select { font-size: 16px; }
  .input:not(textarea), .auth-form .input, .input-unit input { min-height: 44px; }
  .layer-chip { min-height: 44px; }
  .details summary { min-height: 44px; display: flex; align-items: center; }
  .input::placeholder, .input-unit input::placeholder { font-size: 15px; }
  .pfiles .c-sel input { width: 22px; height: 22px; }
  .step { min-height: 56px; }
}
@media (max-width: 900px) {
  .input, .auth-form .input, .input-unit input, .search input, textarea, select { font-size: 16px; }
}

/* landscape phones: no sticky bar eating a third of the height, a shorter viewer */
@media (max-height: 500px) and (orientation: landscape) {
  .appbar { position: static; }
  .viewer { height: calc(100dvh - 24px); min-height: 260px; }
  .lines-scroll { max-height: none; }
  .tour-card { max-height: calc(100dvh - 16px); }
  .tour-card .tour-art { display: none; }
  .dialog { max-height: calc(100dvh - 16px); }
}

/* small tablets */
@media (min-width: 601px) and (max-width: 900px) {
  .proj-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cmp-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* phones ----------------------------------------------------------------------------------------- */
@media (max-width: 600px) {
  .appbar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface); } /* else fixed sheets inside it get clipped */
  .appbar-inner { padding-left: max(var(--s4), var(--sa-l)); padding-right: max(var(--s4), var(--sa-r)); height: 56px; }
  .appbar-right { gap: 6px; }
  .user-btn { padding: 0 6px; }
  .user-btn .caret { display: none; }
  .page { padding-left: max(var(--s3), var(--sa-l)); padding-right: max(var(--s3), var(--sa-r)); }
  .card { padding: var(--s4) var(--s3); border-radius: var(--r); }
  .view { gap: var(--s4); }
  .page-head h1, .hero h1 { font-size: 22px; }
  .site-foot { flex-direction: column; align-items: flex-start; gap: 4px; padding-left: max(var(--s4), var(--sa-l)); padding-right: max(var(--s4), var(--sa-r)); }
  .foot-links { flex-wrap: wrap; gap: 0 var(--s4); }

  /* menus (user, export) become bottom sheets over a dimmed page */
  .menu-wrap:has(> .menu:not([hidden]))::after { content: ""; position: fixed; inset: 0; z-index: 48; background: var(--tour-dim); animation: fade 0.18s ease-out; }
  .menu, .menu.right, .export-menu {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 49; width: auto; min-width: 0; max-width: none;
    max-height: calc(100dvh - 72px); overflow-y: auto; overscroll-behavior: contain;
    padding: 18px max(10px, var(--sa-r)) calc(10px + var(--sa-b)) max(10px, var(--sa-l));
    border-radius: 18px 18px 0 0; border-bottom: 0; box-shadow: 0 -12px 32px -8px rgba(16, 21, 28, 0.3); animation: sheetup 0.22s var(--ease);
  }
  .menu::before { content: ""; position: absolute; top: 7px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--border-strong); }
  .menu-item { min-height: 50px; font-size: 15px; }

  /* dialogs become full-width bottom sheets */
  .dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; border-bottom: 0; max-height: calc(100dvh - 24px); padding-bottom: var(--sa-b); }
  .dialog[open] { animation: sheetup 0.22s var(--ease); }
  .dialog-head { padding: var(--s4) var(--s3) var(--s2) var(--s4); }
  .dialog-body { padding: var(--s2) var(--s4) var(--s4); }
  .dialog-actions { position: sticky; bottom: 0; background: var(--surface); padding: var(--s3) 0 var(--s1); }
  .dialog-actions .btn { flex: 1; height: 46px; }
  .keys { padding: var(--s2) var(--s4) var(--s5); }

  /* toasts: full width above the docked action bar */
  .toasts { left: max(var(--s3), var(--sa-l)); right: max(var(--s3), var(--sa-r)); width: auto; bottom: calc(80px + var(--sa-b)); }

  /* primary action docked at the bottom: Run take-off (project, quick take-off) and Export (results) */
  #projectView, #uploadView, #jobView { padding-bottom: 76px; }
  #projectView #runStart, #uploadView #runBtn, #jobView .job-actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 29; margin: 0;
  }
  #projectView #runStart, #uploadView #runBtn {
    left: max(var(--s3), var(--sa-l)); right: max(var(--s3), var(--sa-r)); bottom: calc(var(--s3) + var(--sa-b)); width: auto; height: 52px;
    box-shadow: 0 8px 24px -6px rgba(16, 21, 28, 0.35), 0 0 0 6px var(--bg);
  }
  #jobView .job-actions {
    padding: 10px max(var(--s3), var(--sa-r)) calc(10px + var(--sa-b)) max(var(--s3), var(--sa-l));
    background: color-mix(in srgb, var(--surface) 96%, transparent); border-top: 1px solid var(--border); box-shadow: 0 -6px 18px -10px rgba(16, 21, 28, 0.25);
  }
  #jobView .job-actions .menu-wrap { position: static; width: 100%; }
  #exportBtn { width: 100%; height: 48px; font-size: 15px; }

  /* upload */
  .dropzone, .dropzone.compact { min-height: 150px; padding: var(--s5) var(--s3); }
  .dz-title { font-size: 16px; }

  /* results: viewer fits the drawing width, the line list follows below */
  .viewer { flex: none; height: clamp(260px, 78vw, 62vh); min-height: 0; }
  .viewer-pane .toolbar { gap: 6px; }
  .viewer-foot .hint-touch { display: block; width: 100%; }
  .lines-scroll { max-height: none; }
  .pane { padding: var(--s3) var(--s2); }
  .sheet-head { padding: var(--s3); }
  .tabs { overflow-x: auto; scrollbar-width: none; }

  /* stacked cards: shared */
  .lines, .std-lines, .cmp, .files { display: block; }
  .lines thead, .std-lines thead, .cmp thead, .files thead { display: none; }
  .lines tbody, .std-lines tbody, .cmp tbody, .files tbody { display: grid; gap: 8px; padding: 8px 0; }
  .lines-scroll, .cmp-scroll, .files-card .table-scroll { border: 0; overflow: visible; }
  .lines tbody tr, .std-lines tbody tr, .cmp tbody tr, .files tbody tr {
    display: grid; gap: 0; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; background: var(--surface);
  }
  .lines tbody tr td, .std-lines tbody tr td, .cmp tbody tr td, .files tbody tr td {
    display: block; min-width: 0; padding: 6px 10px; border: 0; text-align: left; white-space: normal; overflow-wrap: anywhere;
  }
  .data.lines tbody td.num, .data.std-lines tbody td.num, .data.cmp tbody td.num, .data.files tbody td.num { text-align: left; }
  .lines td[data-label]::before, .std-lines td[data-label]::before, .cmp td[data-label]::before, .files td[data-label]::before {
    display: block; content: attr(data-label); font-size: 10.5px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
    margin-bottom: 1px; pointer-events: none; user-select: none; -webkit-user-select: none;
  }
  .lines tbody tr.empty-row, .std-lines tbody tr.empty-row, .cmp tbody tr.empty-row, .files tbody tr.empty-row { display: block; border-style: dashed; }
  .lines tbody tr.empty-row td, .std-lines tbody tr.empty-row td, .cmp tbody tr.empty-row td, .files tbody tr.empty-row td { text-align: center; }
  .lines tbody tr[hidden], .std-lines tbody tr[hidden] { display: none; }

  /* Default lines (editable): item on top, then level / group / qty / unit, then score / conf / evidence */
  .lines tbody tr { grid-template-columns: repeat(4, minmax(0, 1fr)) auto; grid-template-areas: "item item item item x" "lvl grp qty unit x" "st conf ev ev x"; }
  .lines td:nth-child(1) { grid-area: st; }
  .lines td:nth-child(2) { grid-area: lvl; }
  .lines td:nth-child(3) { grid-area: grp; }
  .lines td:nth-child(4) { grid-area: item; font-weight: 650; font-size: 14px; padding-top: 10px; }
  .lines td:nth-child(5) { grid-area: unit; }
  .lines td:nth-child(6) { grid-area: qty; text-align: left; font-size: 15px; }
  .lines td:nth-child(7) { grid-area: conf; text-align: left; }
  .lines td:nth-child(8) { grid-area: ev; text-align: left; }
  .lines td:nth-child(9) { grid-area: x; display: flex; align-items: flex-start; padding: 4px; }
  .lines td.item::before, .lines td.c-x::before { display: none !important; }
  .lines td.item { min-width: 0; }
  .lines .grp-cell [contenteditable] { min-width: 0; display: inline; margin: 0; padding: 0; }
  .lines.no-score td:nth-child(1) { display: none; }
  .lines.no-score tbody tr { grid-template-areas: "item item item item x" "lvl grp qty unit x" "conf ev ev ev x"; }
  .lines tbody tr.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
  .lines tbody tr.s-wrong { border-left: 3px solid var(--bad-solid); }
  .lines tbody tr.s-half { border-left: 3px solid var(--half-solid); }
  .lines tbody tr.s-ok { border-left: 3px solid var(--ok-solid); }
  .lines tr.s-wrong td:first-child, .lines tr.s-half td:first-child, .lines tr.s-ok td:first-child, .lines tbody tr.selected td:first-child { box-shadow: none; }

  /* IS 1200 lines */
  .std-lines tbody tr { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-areas: "item item item item" "lvl grp qty unit" "cl cl cl cl"; }
  .std-lines td:nth-child(1) { grid-area: lvl; }
  .std-lines td:nth-child(2) { grid-area: grp; }
  .std-lines td:nth-child(3) { grid-area: item; font-weight: 650; font-size: 14px; padding-top: 10px; }
  .std-lines td:nth-child(4) { grid-area: qty; font-size: 15px; }
  .std-lines td:nth-child(5) { grid-area: unit; }
  .std-lines td:nth-child(6) { grid-area: cl; padding-bottom: 10px; }
  .std-lines td.item::before { display: none !important; }
  .std-lines tbody tr.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

  /* Compare: one card per item, Default (metric) | IS 1200 | difference side by side */
  .cmp tbody tr { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-areas: "item item item" "def std diff" "pct cl cl"; }
  .cmp th:first-child, .cmp td:first-child { position: static; }
  .cmp td:nth-child(1) { grid-area: item; padding-top: 10px; min-width: 0; }
  .cmp td:nth-child(1)::before { display: none !important; }
  .cmp td:nth-child(2) { display: none !important; }
  .cmp td:nth-child(3) { grid-area: def; display: block !important; }
  .cmp td:nth-child(4) { grid-area: std; }
  .cmp td:nth-child(5) { grid-area: diff; }
  .cmp td:nth-child(6) { grid-area: pct; padding-bottom: 10px; }
  .cmp td:nth-child(7) { grid-area: cl; padding-bottom: 10px; }
  .cmp td.num { font-size: 14px; }
  .cmp tr.differs { border-left: 3px solid var(--half-solid); }
  .cmp tr.differs td:first-child { box-shadow: none; }
  .cmp tr.differs td, .cmp tr.derived td { background: transparent; }
  .cmp tr.differs { background: color-mix(in srgb, var(--half-soft) 45%, var(--surface)); }
  .cmp tr.derived { background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface)); }
  .cmp .clause { min-width: 0; }
  .cmp-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* job files */
  .files tbody tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .files td:nth-child(1) { grid-column: 1 / -1; padding-top: 10px; }
  .files td:nth-child(1)::before, .files td:nth-child(7)::before { display: none !important; }
  .files th:nth-child(3), .files td:nth-child(3), .files th:nth-child(5), .files td:nth-child(5) { display: block; }
  .files td:nth-child(7) { grid-column: 1 / -1; padding-bottom: 10px; }
  .files .mini-links { justify-content: flex-start; }
  .cell-file .n, .pfiles .cell-file .n { max-width: none; white-space: normal; overflow-wrap: anywhere; }

  .runs-table td, .runs-table th, .pfiles td, .pfiles th, .recent-table td, .recent-table th { padding-left: 8px; padding-right: 8px; }
}
@media (max-width: 480px) {
  .cmp-cards { grid-template-columns: 1fr; }
}
@media (max-width: 360px) {
  .brand-name { font-size: 14px; }
  .mark { width: 30px; height: 30px; }
  .appbar-right { gap: 4px; }
  .lines tbody tr { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; grid-template-areas: "item item item x" "lvl grp grp x" "qty unit st x" "conf ev ev x"; }
  .lines.no-score tbody tr { grid-template-areas: "item item item x" "lvl grp grp x" "qty unit unit x" "conf ev ev x"; }
  .cmp-cards { grid-template-columns: 1fr; }
}
@keyframes sheetup { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } }
