@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url(vendor/fonts/PlusJakartaSans.woff2) format('woff2');
}

/* Prygenix web theme: black canvas, gold accent (same as prygenix.com and pdf.prygenix.com). */
:root {
  --bg: #000;
  --bg-2: #07080b;
  --panel: #0b0d12;
  --panel-2: #12151c;
  --hover: #1a1e27;
  --border: rgba(255,255,255,.09);
  --border-2: rgba(255,255,255,.18);
  --text: #e5e7eb;
  --ink: #fff;
  --muted: #9ca3af;
  --faint: #6b7280;
  --gold: #d4af37;
  --gold-2: #e8c75a;
  --gold-soft: rgba(212,175,55,.12);
  --gold-mid: rgba(212,175,55,.45);
  --warn: #fbbf24;
  --ok: #86efac;
  --danger: #f87171;
  --canvas-bg: #1a1d24;
  --card: linear-gradient(135deg, rgba(31,41,55,.45), rgba(17,24,39,.45));
  --r: 10px;
  --shadow: 0 12px 40px rgba(0,0,0,.5);
  font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; overflow: hidden; }
body.booting > * { visibility: hidden; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--ink); margin: 0; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.5; }
.gold { color: var(--gold); }
.row { display: flex; align-items: center; gap: 6px; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.view { flex: 1; min-height: 0; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background .12s, border-color .12s;
}
.btn:hover { border-color: var(--border-2); background: var(--hover); }
.btn:focus-visible, .icon-btn:focus-visible, .tool:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #000; font-weight: 600; }
.btn.primary:hover { background: var(--gold-2); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.lg { padding: 11px 16px; font-size: 14px; width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.btn svg { width: 16px; height: 16px; }
select.btn { padding: 6px 8px; }
select.btn.sm { padding: 3px 6px; }
.icon-btn { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px; background: none; border: 1px solid transparent; border-radius: 7px; color: var(--muted); cursor: pointer; font: inherit; font-size: 16px; }
.icon-btn:hover { color: var(--ink); background: var(--hover); }
.icon-btn.on { color: var(--gold); background: var(--gold-soft); border-color: var(--gold-mid); }
.vsep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
kbd { font: 10px ui-monospace, monospace; color: var(--muted); border: 1px solid var(--border-2); border-radius: 3px; padding: 0 4px; }
input, select, textarea { font: inherit; }
.search { display: flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; color: var(--muted); }
.search:focus-within { border-color: var(--gold-mid); }
.search input { background: none; border: none; color: var(--text); padding: 8px 0; outline: none; width: 220px; }
.search.sm { margin: 0 0 8px; }
.search.sm input { padding: 6px 0; width: 100%; }
.search svg { width: 15px; height: 15px; }
.badge { padding: 3px 9px; border-radius: 999px; font-size: 12px; background: var(--panel-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.warn { color: var(--warn); border-color: rgba(251,191,36,.35); }
.badge.ok { color: var(--ok); border-color: rgba(134,239,172,.3); }
.seg { display: flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg .icon-btn { height: 28px; }
input[type=range] { accent-color: var(--gold); }
.note { margin-top: 14px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); font-size: 13px; line-height: 1.5; }
.note.bad { border-color: rgba(248,113,113,.4); color: #fecaca; }
.note.ok { border-color: rgba(134,239,172,.35); color: #bbf7d0; }

/* ---------- menus ---------- */
.menu-wrap { position: relative; }
.menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 50; min-width: 240px; background: var(--panel); border: 1px solid var(--border-2); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; }
.menu.left { right: auto; left: 0; }
.menu button, .menu a { display: flex; align-items: center; gap: 9px; text-align: left; background: none; border: none; color: var(--text); padding: 8px 10px; border-radius: 6px; font: inherit; cursor: pointer; text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--hover); text-decoration: none; }
.menu button.danger { color: var(--danger); }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; flex-direction: column; gap: 2px; }

/* ---------- sign-in ---------- */
.auth { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, 1fr); overflow: auto; }
.auth-brand { padding: 56px 64px; display: flex; flex-direction: column; gap: 22px; background:
  radial-gradient(1200px 600px at -10% -20%, rgba(212,175,55,.16), transparent 60%),
  radial-gradient(800px 500px at 120% 120%, rgba(212,175,55,.08), transparent 60%), var(--bg-2);
  border-right: 1px solid var(--border); }
.brand-row { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; color: var(--ink); }
.logo-lg { width: 40px; height: 40px; border-radius: 9px; outline: 1px solid var(--border-2); }
.auth-brand h1 { font-size: 42px; line-height: 1.12; letter-spacing: -.02em; margin-top: 28px; }
.lead { font-size: 16px; line-height: 1.6; color: #c9ccd3; max-width: 520px; margin: 0; }
.ticks { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 14px; max-width: 520px; }
.ticks li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.5; color: #c9ccd3; }
.ticks li b { color: var(--ink); }
.ticks svg { color: var(--gold); width: 20px; height: 20px; margin-top: 1px; }
.fine { margin-top: auto; color: var(--faint); font-size: 12px; }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; gap: 18px; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--gold-mid); border-radius: 16px; padding: 30px; box-shadow: var(--shadow); }
.auth-card h2 { font-size: 22px; margin-bottom: 8px; }
.auth-card p { line-height: 1.55; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.auth-card input { background: var(--bg); color: var(--ink); border: 1px solid var(--border-2); border-radius: 8px; padding: 11px 12px; font-size: 14px; }
.auth-card input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.code-input { letter-spacing: .5em; font-size: 22px !important; text-align: center; font-variant-numeric: tabular-nums; }
.key-box { margin-top: 16px; font-size: 13px; }
.key-box summary { cursor: pointer; color: var(--muted); }
.key-box .row { margin-top: 8px; }
.key-box input { flex: 1; min-width: 0; padding: 8px 10px !important; font-size: 13px !important; }
.auth-foot a { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 14px; height: 52px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--border); flex: none; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; color: var(--ink); white-space: nowrap; text-decoration: none !important; }
.brand img { width: 28px; height: 28px; border-radius: 7px; outline: 1px solid var(--border-2); }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); text-decoration: none; }
.crumbs b { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs .sep { color: var(--faint); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.plan-badge { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--gold-mid); color: var(--gold); background: var(--gold-soft); white-space: nowrap; }
.plan-badge.ok { color: var(--ok); border-color: rgba(134,239,172,.3); background: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--gold-mid); background: var(--gold-soft); color: var(--gold); font: inherit; font-weight: 700; cursor: pointer; }

/* ---------- dashboard ---------- */
.dash { overflow-y: auto; padding: 28px 32px 48px; }
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; max-width: 1400px; margin-inline: auto; }
.dash-head h1 { font-size: 26px; letter-spacing: -.01em; }
.dash-head p { margin: 4px 0 0; }
.dash-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; max-width: 1400px; margin: 0 auto; }
.proj-card { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; cursor: pointer; transition: border-color .15s, transform .15s; display: flex; flex-direction: column; }
.proj-card:hover { border-color: var(--gold-mid); transform: translateY(-1px); }
.proj-thumb { aspect-ratio: 16 / 10; background: #fff center / cover no-repeat; border-bottom: 1px solid var(--border); position: relative; }
.proj-thumb.none { background: var(--panel-2); display: grid; place-items: center; color: var(--faint); }
.proj-thumb.none svg { width: 40px; height: 40px; }
.proj-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; }
.proj-body h3 { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 26px; }
.proj-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 18px; }
.proj-stats { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.proj-stats b { color: var(--ink); font-weight: 600; }
.proj-stats .cost { margin-left: auto; color: var(--gold); font-weight: 600; }
.proj-more { position: absolute; right: 8px; bottom: 54px; }
.proj-grid.list { grid-template-columns: 1fr; gap: 0; border: 1px solid var(--border); border-radius: 12px; overflow: visible; }
.proj-grid.list .proj-card { flex-direction: row; align-items: center; border-radius: 0; border: none; border-bottom: 1px solid var(--border); background: none; transform: none; }
.proj-grid.list .proj-card:last-child { border-bottom: none; }
.proj-grid.list .proj-card:hover { background: var(--panel-2); }
.proj-grid.list .proj-thumb { width: 96px; flex: none; border: none; margin: 8px 0 8px 10px; border-radius: 6px; }
.proj-grid.list .proj-body { flex: 1; flex-direction: row; align-items: center; gap: 16px; padding: 10px 50px 10px 14px; }
.proj-grid.list .proj-body > div:first-child { flex: 1; min-width: 0; }
.proj-grid.list .proj-stats { margin: 0; }
.proj-grid.list .proj-more { bottom: auto; top: 50%; transform: translateY(-50%); }
.proj-empty { max-width: 520px; margin: 60px auto; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty-ill { width: 76px; height: 76px; border-radius: 20px; display: grid; place-items: center; background: var(--gold-soft); border: 1px solid var(--gold-mid); color: var(--gold); margin-bottom: 6px; }
.empty-ill svg { width: 34px; height: 34px; }
.proj-empty .row { margin-top: 10px; }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: 74px 220px minmax(0, 1fr) 320px; min-height: 0; }
.rail { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 6px; overflow-y: auto; }
.tool { width: 62px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px 6px; border-radius: 9px; border: 1px solid transparent; background: none; color: var(--muted); font: inherit; font-size: 10.5px; font-weight: 500; cursor: pointer; }
.tool svg { width: 20px; height: 20px; }
.tool:hover { color: var(--ink); background: var(--hover); }
.tool.active { color: var(--ink); background: var(--gold-soft); border-color: var(--gold-mid); }
.tool.ai { color: var(--gold); }
.tool.ai.active { background: var(--gold); color: #000; border-color: var(--gold); }
.rail-sep { width: 36px; height: 1px; background: var(--border); margin: 5px 0; }

.panel { background: var(--panel); overflow-y: auto; padding: 12px; min-height: 0; }
.panel.sheets { border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.panel.side { border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.panel-head h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
.panel.side .panel-head { margin: 4px 0 -4px; }

.page-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; }
.page-item { border: 1px solid var(--border); border-radius: 9px; padding: 6px; cursor: pointer; background: var(--panel-2); position: relative; }
.page-item:hover { border-color: var(--border-2); }
.page-item.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold-mid); }
.page-item canvas { width: 100%; display: block; background: #fff; border-radius: 5px; }
.page-item .meta { display: flex; flex-direction: column; margin-top: 6px; font-size: 12px; gap: 1px; }
.page-item .meta .num { font-weight: 700; color: var(--ink); }
.page-item .meta .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.page-item .meta .cnt { color: var(--muted); font-size: 11px; }
.page-item .del { position: absolute; top: 9px; right: 9px; background: rgba(0,0,0,.75); color: #fff; border: none; border-radius: 6px; width: 24px; height: 24px; display: none; place-items: center; cursor: pointer; }
.page-item:hover .del { display: grid; }
.page-item .del svg { width: 14px; height: 14px; }

.stage-wrap { position: relative; overflow: hidden; background: var(--canvas-bg); display: flex; flex-direction: column; min-width: 0; }
.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--border); flex: none; flex-wrap: wrap; z-index: 2; }
.sheet-title { display: flex; gap: 8px; align-items: baseline; min-width: 0; color: var(--text); }
.sheet-title b { color: var(--gold); }
.sheet-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#stage { display: block; flex: 1; width: 100%; min-height: 0; cursor: crosshair; touch-action: none; }
#stage.tool-select { cursor: default; }
#stage.panning { cursor: grabbing; }
.empty { position: absolute; inset: 44px 0 0; display: grid; place-items: center; padding: 16px; }
.empty-card { text-align: center; padding: 36px 44px; border: 2px dashed rgba(255,255,255,.16); border-radius: 16px; color: var(--muted); max-width: 520px; background: rgba(0,0,0,.3); }
.empty-card .big { width: 40px; height: 40px; color: var(--gold); }
.empty-card h2 { margin: 8px 0; font-size: 19px; }
.link { color: var(--gold); cursor: pointer; text-decoration: underline; }
.stage-wrap.dragover .empty-card, .stage-wrap.dragover { outline: 2px dashed var(--gold); outline-offset: -8px; }
.loading { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); background: var(--panel); padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); }
.hint { position: absolute; left: 12px; bottom: 12px; background: rgba(0,0,0,.82); padding: 6px 10px; border-radius: 8px; color: var(--muted); pointer-events: none; max-width: calc(100% - 280px); }
.toast { position: absolute; top: 56px; right: 12px; background: var(--panel); border: 1px solid var(--gold-mid); padding: 9px 13px; border-radius: 9px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 380px; color: var(--ink); box-shadow: var(--shadow); z-index: 5; }
.toast.show { opacity: 1; }
.zoom-ctrl { position: absolute; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 2px; background: rgba(0,0,0,.82); padding: 3px; border-radius: 10px; border: 1px solid var(--border); }
.zoom-ctrl span { min-width: 46px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.compare-bar { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--gold-mid); padding: 6px 8px 6px 12px; border-radius: 10px; z-index: 4; white-space: nowrap; }
.dotc { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dotc.red { background: #ef4444; } .dotc.blue { background: #3b82f6; }

.estimate { border: 1px solid var(--gold-mid); border-radius: 12px; padding: 12px 14px; background: linear-gradient(135deg, rgba(212,175,55,.1), rgba(17,24,39,.45)); }
.estimate .label { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
.estimate .total { font-size: 24px; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; margin: 4px 0 2px; letter-spacing: -.01em; }
.estimate select { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 2px 4px; font-size: 12px; }

.props { border: 1px solid var(--border-2); border-radius: 12px; padding: 12px; background: var(--panel-2); display: flex; flex-direction: column; gap: 8px; }
.props .head { display: flex; align-items: center; gap: 8px; }
.props .head input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--ink); padding: 5px 8px; font-weight: 600; }
.props select { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 5px 8px; width: 100%; }
.props dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 12px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }

.cond-list { display: flex; flex-direction: column; gap: 6px; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; margin: 8px 2px 0; }
.group-head .gt { color: var(--gold); text-transform: none; letter-spacing: 0; }
.cond { border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); }
.cond.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold-mid) inset; }
.cond-head { display: flex; align-items: center; gap: 8px; padding: 8px; cursor: pointer; }
.cond-head .icon-btn { min-width: 22px; height: 22px; padding: 0; font-size: 12px; }
.cond-head .icon-btn svg { width: 14px; height: 14px; }
.dot { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.cond-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 500; }
.cond-type { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 500; }
.cond-total { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; color: var(--ink); white-space: nowrap; }
.cond-sub { font-size: 11px; color: var(--muted); font-weight: 400; }
.cond-cost { font-size: 11px; color: var(--gold); font-weight: 600; }
.items { list-style: none; margin: 0; padding: 0 6px 6px; max-height: 260px; overflow-y: auto; }
.items li { display: flex; gap: 6px; align-items: center; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.items li:hover { background: var(--hover); }
.items li.sel { background: var(--gold-soft); }
.items li.deduct .nm::before { content: '− '; color: var(--danger); }
.items .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.items .pg { color: var(--muted); }
.items .val { font-variant-numeric: tabular-nums; }
.items .icon-btn { min-width: 20px; height: 20px; padding: 0; font-size: 14px; }

.ai-settings { border-top: 1px solid var(--border); padding-top: 10px; margin-top: auto; }
.ai-settings summary { cursor: pointer; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
.settings { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.settings label { display: flex; flex-direction: column; gap: 4px; }
.settings input[type=number] { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; }

/* ---------- dialogs ---------- */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border-2); border-radius: 14px; padding: 0; width: 420px; max-width: calc(100vw - 32px); box-shadow: var(--shadow); }
dialog.wide { width: 620px; }
dialog::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(2px); }
.dlg { padding: 20px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 40px); overflow-y: auto; }
.dlg h3 { font-size: 17px; }
.dlg h4 { margin: 6px 0 0; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--gold); }
.dlg label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; }
.dlg label.check { flex-direction: row; align-items: center; gap: 7px; font-weight: 400; }
.dlg input, .dlg select { background: var(--bg); color: var(--text); border: 1px solid var(--border-2); border-radius: 7px; padding: 8px 10px; }
.dlg input:focus, .dlg select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.dlg input[type=color] { padding: 2px; height: 37px; }
.dlg input[type=checkbox] { accent-color: var(--gold); }
.dlg .row > * { flex: 1; min-width: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.drop { border: 1.5px dashed var(--border-2); border-radius: 10px; padding: 16px; flex-direction: row !important; align-items: center; justify-content: center; gap: 10px !important; color: var(--muted); cursor: pointer; font-weight: 400 !important; text-align: center; }
.drop:hover, .drop.over { border-color: var(--gold); color: var(--ink); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 0; font-size: 12px; }
.keys dt { white-space: nowrap; color: var(--ink); }
.keys dd { margin: 0; color: var(--muted); }
.steps { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; line-height: 1.5; }

.busy { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--ink); font-size: 14px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--gold-soft); border-top-color: var(--gold); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .editor { grid-template-columns: 70px 180px minmax(0, 1fr) 290px; }
}
@media (max-width: 960px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 32px 24px; border-right: none; border-bottom: 1px solid var(--border); }
  .auth-brand h1 { font-size: 30px; margin-top: 8px; }
  .auth-brand .fine { display: none; }
  .editor { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) 260px; }
  .rail { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 4px; }
  .rail-sep { width: 1px; height: 36px; margin: 0 3px; }
  .tool { width: 58px; flex: none; }
  .panel.sheets { display: none; }
  .panel.side { border-left: none; border-top: 1px solid var(--border); }
  .hint { display: none; }
  .dash { padding: 18px 16px 40px; }
  .search input { width: 140px; }
  .crumbs { display: none; }
  .plan-badge { display: none; }
}

/* ---------- sheet actions, revisions, zones ---------- */
.page-item .del { display: none !important; }
.sheet-acts { position: absolute; top: 9px; right: 9px; display: none; gap: 3px; }
.page-item:hover .sheet-acts { display: flex; }
.sheet-acts button { background: rgba(0,0,0,.78); color: #fff; border: none; border-radius: 6px; width: 24px; height: 24px; display: grid; place-items: center; cursor: pointer; }
.sheet-acts button:hover { background: #000; color: var(--gold); }
.sheet-acts svg { width: 14px; height: 14px; }
.page-item .rev { font-size: 10px; font-weight: 600; color: var(--gold); border: 1px solid var(--gold-mid); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.page-item .zone { font-size: 11px; color: var(--muted); }
.page-item .zone::before { content: '◉ '; color: var(--gold); font-size: 9px; }

/* ---------- drawing / workbook switch ---------- */
.seg.mode button { background: none; border: none; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.seg.mode button.on { background: var(--gold); color: #000; }
.stage-wrap.wb-mode #stage, .stage-wrap.wb-mode .zoom-ctrl, .stage-wrap.wb-mode .hint, .stage-wrap.wb-mode .compare-bar, .stage-wrap.wb-mode .sheet-title,
.stage-wrap.wb-mode #scaleBadge, .stage-wrap.wb-mode #scalePreset, .stage-wrap.wb-mode #compareBtn { display: none !important; }

/* ---------- workbook ---------- */
.workbook { flex: 1; min-height: 0; overflow-y: auto; background: var(--bg-2); padding: 18px 20px 28px; display: flex; flex-direction: column; gap: 16px; }
.workbook > * { flex: none; }
.wb-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.wb-head h2 { font-size: 18px; }
.wb-head p { margin: 3px 0 0; }
.wb-head label { display: flex; align-items: center; gap: 6px; }
.wb-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
table.wb { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.wb th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--border-2); white-space: nowrap; position: sticky; top: 0; background: var(--panel); }
.wb td { padding: 5px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.wb td .dot { display: inline-block; margin-right: 8px; vertical-align: -1px; }
.wb .num { text-align: right; }
.wb tr.grp td { background: var(--panel-2); color: var(--ink); font-weight: 700; padding-top: 8px; padding-bottom: 8px; }
.wb tr.grp td.num { color: var(--gold); }
.wb td.amt { color: var(--ink); font-weight: 600; }
.wb .warn { color: var(--warn); font-size: 11px; }
.wb .up, .up { color: #fca5a5; }
.wb .down, .down { color: var(--ok); }
input.cell { background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--ink); padding: 4px 6px; width: 100%; min-width: 70px; font: inherit; }
input.cell:hover { border-color: var(--border-2); }
input.cell:focus { outline: none; border-color: var(--gold); background: var(--bg); }
input.cell.num { text-align: right; width: 110px; }
input.cell.sm { width: 64px; min-width: 0; }
input.cell.code { width: 80px; }
.wb-bottom { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.wb-card { border: 1px solid var(--border); border-radius: 12px; background: var(--panel); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.wb-card h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.wb.mk td { white-space: normal; }
.wb.mk tr.sub td { color: var(--muted); }
.wb.mk tr.total td { font-size: 16px; font-weight: 700; color: var(--gold); border-top: 1px solid var(--gold-mid); border-bottom: none; padding-top: 9px; }
.carbon { margin: 0; font-size: 13px; }
.issues { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.issues li { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--border); }
.issues li > span:first-child { flex: 1; display: flex; flex-direction: column; }
.issues .num { display: flex; flex-direction: column; align-items: flex-end; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- rate library ---------- */
.lib-list { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px 8px; }
.lib-item { display: grid !important; grid-template-columns: auto auto minmax(0, 1fr) auto auto auto; align-items: center; gap: 9px !important; padding: 6px 6px; border-radius: 7px; font-weight: 400 !important; cursor: pointer; }
.lib-item:hover { background: var(--hover); }
.lib-item.have { opacity: .5; cursor: default; }
.lib-item .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.lib-item .icon-btn { min-width: 22px; height: 22px; padding: 0; }

@media (max-width: 960px) {
  .wb-bottom { grid-template-columns: 1fr; }
  .workbook { padding: 12px; }
}

/* ---------- classification dialog: structure & MEP ---------- */
details.more { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
details.more[open] { padding-bottom: 12px; }
details.more summary { cursor: pointer; color: var(--gold); font-weight: 600; font-size: 12px; }
details.more > .row, details.more > .stack { margin-top: 10px; }
details.more .stack { gap: 10px; }
#condDialog { width: 520px; }
.wb td .derived { font-size: 11px; color: var(--muted); white-space: normal; margin: 1px 0 0 18px; }
.settings label.check-row { flex-direction: row; align-items: flex-start; gap: 8px; } .settings label.check-row input { accent-color: var(--gold); margin-top: 2px; }
