:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #f2f4f7;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --accent: #e8590c;
  --accent-2: #f97316;
  --accent-soft: #fff4ed;
  --accent-line: #ffd6bd;
  --blue: #1d4ed8;
  --blue-soft: #eff8ff;
  --green: #067647;
  --green-soft: #ecfdf3;
  --red: #b42318;
  --red-soft: #fef3f2;
  --amber: #b54708;
  --amber-soft: #fffaeb;
  --canvas: #0b1220;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, .08);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, .16);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.app { display: flex; flex-direction: column; height: 100vh; min-height: 640px; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  height: 68px;
  flex: 0 0 68px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 290px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--ink);
  display: flex; align-items: flex-end; justify-content: center; gap: 3px;
  padding: 7px 6px;
}
.brand-mark span { display: block; width: 4px; background: var(--accent); border-radius: 1px; }
.brand-mark span:nth-child(1) { height: 9px; }
.brand-mark span:nth-child(2) { height: 15px; }
.brand-mark span:nth-child(3) { height: 12px; }
.brand-text { display: flex; flex-direction: column; line-height: .95; letter-spacing: .02em; }
.brand-text strong { font-size: 15px; font-weight: 900; }
.brand-text span { font-size: 10px; letter-spacing: .28em; color: var(--muted); font-weight: 800; margin-top: 3px; }
.brand-rule { width: 1px; height: 26px; background: var(--line); margin: 0 2px; }
.brand-sub { font-size: 11px; color: var(--muted); max-width: 96px; line-height: 1.25; }
.project-head { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.project-name {
  font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 480px;
}
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 999px; font-size: 10px; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase; border: 1px solid var(--line);
  color: var(--muted); background: var(--surface-2); white-space: nowrap;
}
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); }
.status-pill.ready { color: var(--blue); border-color: #b2ddff; background: var(--blue-soft); }
.status-pill.ready::before { background: var(--blue); }
.status-pill.analyzed { color: var(--green); border-color: #abefc6; background: var(--green-soft); }
.status-pill.analyzed::before { background: var(--green); }
.status-pill.error { color: var(--red); border-color: #fecdca; background: var(--red-soft); }
.status-pill.error::before { background: var(--red); }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.engine-badge {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 6px; padding: 5px 8px; white-space: nowrap;
}

/* ------------------------------------------------------------------ buttons */
.btn {
  border: 1px solid transparent; border-radius: 7px;
  padding: 9px 14px; font-size: 12.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover:not(:disabled) { background: #1d2939; }
.btn.primary.accent { background: var(--accent); border-color: var(--accent); }
.btn.ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line-strong); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: #98a2b3; }
.btn.small { padding: 6px 10px; font-size: 11.5px; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--red); border-color: #fecdca; background: var(--red-soft); }
.link-btn {
  border: 0; background: transparent; color: var(--muted); font-size: 11px;
  font-weight: 700; padding: 2px 4px; border-radius: 4px;
}
.link-btn:hover { color: var(--ink); background: var(--surface-2); }

/* ------------------------------------------------------------------ shell */
.shell { display: flex; flex: 1; min-height: 0; }
.leftbar {
  width: 308px; flex: 0 0 308px; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 14px; display: flex; flex-direction: column; gap: 12px;
}
.stage { flex: 1; min-width: 0; min-height: 0; display: flex; }

/* ------------------------------------------------------------------ panels */
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 13px 14px 10px; }
.panel-head h2 { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); font-weight: 800; }
.panel-note { font-size: 10px; color: var(--muted); }
.mini-actions { display: flex; gap: 2px; }

.setup-form { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 9px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 10.5px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.field > span em { font-style: normal; font-weight: 500; color: var(--muted-2); }
.field input, .field select {
  height: 34px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); color: var(--ink); padding: 0 9px; font-size: 12.5px;
  outline: none; width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232, 89, 12, .1); }
.field input:disabled, .field select:disabled { background: var(--surface-2); color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.calibration-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
#calibrationState { font-size: 10.5px; color: var(--muted); line-height: 1.25; }
.search {
  margin: 0 14px 10px; width: calc(100% - 28px); height: 32px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2);
  padding: 0 9px; font-size: 12px; outline: none;
}
.search:focus { border-color: var(--line-strong); background: #fff; }
.layer-list { padding: 0 8px 10px; max-height: 300px; overflow-y: auto; }
.layer-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px;
  border-radius: 5px; cursor: pointer; user-select: none;
}
.layer-row:hover { background: var(--surface-2); }
.layer-row .eye { width: 16px; color: var(--muted-2); flex: 0 0 16px; display: flex; justify-content: center; }
.layer-row.off .eye { color: var(--line-strong); }
.layer-row.off .layer-name { color: var(--muted-2); text-decoration: line-through; }
.layer-swatch { width: 10px; height: 10px; border-radius: 2px; border: 1px solid rgba(0,0,0,.12); flex: 0 0 10px; }
.layer-name { font-size: 11.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.layer-isolate {
  border: 0; background: transparent; color: var(--muted-2); width: 18px; height: 18px;
  padding: 0; border-radius: 4px; font-size: 12px; line-height: 1; opacity: 0;
}
.layer-row:hover .layer-isolate { opacity: 1; }
.layer-isolate:hover { color: var(--accent); background: var(--accent-soft); }
.layer-count { font-family: var(--mono); font-size: 9.5px; color: var(--muted-2); }
.drawing-summary { padding: 0 14px 14px; }
.kv-list { display: flex; flex-direction: column; gap: 0; }
.kv-list div { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 11px; }
.kv-list div:last-child { border-bottom: 0; }
.kv-list span { color: var(--muted); }
.kv-list b { font-weight: 600; color: var(--ink-2); text-align: right; max-width: 170px; overflow-wrap: anywhere; }
.warn-list { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.warn-item { font-size: 10.5px; line-height: 1.35; color: var(--amber); background: var(--amber-soft); border: 1px solid #fedf89; border-radius: 5px; padding: 6px 7px; }
.empty-note { color: var(--muted-2); font-size: 11.5px; line-height: 1.45; padding: 4px 2px; }

/* ------------------------------------------------------------------ welcome */
.welcome {
  flex: 1; overflow-y: auto; padding: 42px 54px 60px;
  background:
    radial-gradient(circle at 8% 0%, rgba(232, 89, 12, .07), transparent 30%),
    radial-gradient(circle at 92% 12%, rgba(29, 78, 216, .06), transparent 28%),
    var(--bg);
}
.welcome-grid { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: 1.12fr .88fr; gap: 56px; align-items: start; }
.eyebrow { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); font-weight: 900; }
.hero h1 { font-size: clamp(36px, 4.2vw, 58px); line-height: .98; letter-spacing: -.045em; margin: 14px 0 18px; font-weight: 900; }
.hero h1 span { color: var(--muted-2); }
.hero-copy { max-width: 620px; color: var(--ink-2); font-size: 15px; line-height: 1.6; }
.feature-list { margin: 28px 0 22px; display: flex; flex-direction: column; gap: 10px; max-width: 540px; }
.feature-list div { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 9px; }
.feature-list b { font-family: var(--mono); font-size: 10px; color: var(--accent); }
.feature-list span { font-size: 12.5px; color: var(--ink-2); }
.hero-note { max-width: 560px; font-size: 11px; line-height: 1.55; color: var(--muted); border-left: 2px solid var(--accent); padding-left: 12px; }
.hero-note strong { color: var(--ink-2); }

.upload-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-md); padding: 22px; position: sticky; top: 0;
}
.card-head h2 { font-size: 23px; letter-spacing: -.02em; margin-top: 5px; }
.dropzone {
  margin-top: 16px; border: 1.5px dashed var(--line-strong); border-radius: 10px;
  background: var(--surface-2); padding: 24px 18px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px; text-align: center;
  transition: border-color .15s, background .15s;
  outline: none;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon { width: 42px; height: 42px; color: var(--accent); margin-bottom: 4px; }
.drop-icon svg { width: 100%; height: 100%; }
.dropzone strong { font-size: 13px; }
.dropzone span { font-size: 10.5px; color: var(--muted); }
.file-meta { font-size: 10.5px; color: var(--muted); padding: 8px 2px 2px; overflow-wrap: anywhere; }
.file-meta.has-file { color: var(--ink-2); font-weight: 600; }
.upload-fields { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 12px; }
.upload-hint { text-align: center; font-size: 9.5px; color: var(--muted-2); margin-top: 9px; line-height: 1.45; }

.recent-block { max-width: 1180px; margin: 44px auto 0; }
.recent-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 9px; }
.recent-head h2 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.recent-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.project-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  padding: 13px 14px; text-align: left; position: relative; transition: border-color .15s, box-shadow .15s;
  cursor: pointer; min-height: 90px;
}
.project-card:hover { border-color: var(--accent-line); box-shadow: var(--shadow-sm); }
.project-card h3 { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 20px; }
.project-card p { font-size: 10px; color: var(--muted); margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-card .pc-meta { display: flex; gap: 8px; margin-top: 8px; font-size: 9.5px; color: var(--muted-2); font-family: var(--mono); }
.project-card .pc-delete {
  position: absolute; right: 7px; top: 6px; border: 0; background: transparent;
  color: var(--muted-2); font-size: 15px; line-height: 1; padding: 4px 6px; border-radius: 4px;
}
.project-card .pc-delete:hover { color: var(--red); background: var(--red-soft); }
.method-strip { max-width: 1180px; margin: 44px auto 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.method-strip div { border-top: 2px solid var(--ink); padding-top: 11px; }
.method-strip span { font-family: var(--mono); color: var(--accent); font-size: 9px; }
.method-strip b { display: block; font-size: 12px; margin: 4px 0 4px; }
.method-strip p { font-size: 10.5px; color: var(--muted); line-height: 1.5; }

/* ------------------------------------------------------------------ workspace */
.workspace { flex: 1; display: flex; min-width: 0; min-height: 0; }
.canvas-wrap { flex: 1; min-width: 0; min-height: 0; position: relative; background: var(--canvas); overflow: hidden; }
#canvas { display: block; width: 100%; height: 100%; }
.toolbar {
  position: absolute; top: 14px; left: 14px; z-index: 6;
  display: flex; align-items: center; gap: 2px; padding: 4px;
  background: rgba(15, 23, 42, .9); border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.3);
  backdrop-filter: blur(8px);
}
.tool {
  width: 32px; height: 32px; border: 0; border-radius: 5px; background: transparent;
  color: #cbd5e1; display: inline-flex; align-items: center; justify-content: center;
}
.tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool:hover { background: rgba(148, 163, 184, .16); color: #fff; }
.tool.active { background: var(--accent); color: #fff; }
.tool-divider { width: 1px; height: 20px; background: rgba(148, 163, 184, .22); margin: 0 4px; }
.measure-for {
  height: 30px; max-width: 150px; margin-left: 4px; border: 1px solid rgba(148,163,184,.22);
  border-radius: 5px; background: rgba(15,23,42,.5); color: #cbd5e1; font-size: 10px; padding: 0 6px;
}
.measure-for:focus { outline: 1px solid var(--accent); }
.canvas-info {
  position: absolute; top: 64px; right: 16px; z-index: 5; max-width: 420px;
  color: #cbd5e1; font-size: 10px; text-align: right; line-height: 1.5;
  background: rgba(15,23,42,.6); border: 1px solid rgba(148,163,184,.16);
  padding: 7px 10px; border-radius: 6px; backdrop-filter: blur(6px);
}
.canvas-info b { color: #fff; font-weight: 600; display: block; font-size: 11px; }
.tool-hint {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 5;
  color: #fed7aa; background: rgba(15, 23, 42, .9); border: 1px solid rgba(251, 146, 60, .35);
  padding: 7px 12px; border-radius: 6px; font-size: 10.5px; max-width: 560px;
  text-align: center; line-height: 1.4; pointer-events: none; transition: opacity .2s;
}
.tool-hint:empty { display: none; }
.scalebar { position: absolute; left: 16px; bottom: 16px; z-index: 5; color: #94a3b8; font-family: var(--mono); font-size: 9px; }
.scalebar .bar { height: 5px; border: 1px solid #94a3b8; border-top: 0; width: 100px; margin-top: 4px; position: relative; }
.scalebar .bar::before, .scalebar .bar::after { content: ""; position: absolute; top: -2px; width: 1px; height: 7px; background: #94a3b8; }
.scalebar .bar::before { left: 0; }
.scalebar .bar::after { right: 0; }
.coords { position: absolute; right: 16px; bottom: 14px; z-index: 5; color: #94a3b8; font-family: var(--mono); font-size: 9.5px; background: rgba(15,23,42,.55); padding: 4px 7px; border-radius: 4px; }
.busy {
  position: absolute; inset: 0; z-index: 12; background: rgba(11, 18, 32, .76);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  color: #e2e8f0; font-size: 12px; backdrop-filter: blur(3px);
}
.spinner { width: 28px; height: 28px; border: 2px solid rgba(251,146,60,.25); border-top-color: var(--accent-2); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ rightbar */
.rightbar {
  width: 392px; flex: 0 0 392px; background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.right-tabs { display: flex; border-bottom: 1px solid var(--line); flex: 0 0 44px; padding: 0 12px; gap: 4px; align-items: stretch; }
.right-tab {
  border: 0; background: transparent; color: var(--muted); font-size: 11.5px; font-weight: 700;
  padding: 0 10px; border-bottom: 2px solid transparent; display: flex; align-items: center; gap: 6px;
}
.right-tab:hover { color: var(--ink); }
.right-tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.count { font-family: var(--mono); font-size: 9.5px; background: var(--surface-3); color: var(--muted); border-radius: 999px; padding: 2px 6px; }
.pane { flex: 1; overflow-y: auto; padding: 14px; }

/* ------------------------------------------------------------------ checks */
.check-hero { border: 1px solid var(--line); border-radius: 9px; padding: 14px; background: var(--surface-2); }
.check-hero.fail { border-left: 4px solid var(--red); background: var(--red-soft); }
.check-hero.warn { border-left: 4px solid var(--amber); background: var(--amber-soft); }
.check-hero.pass { border-left: 4px solid var(--green); background: var(--green-soft); }
.check-hero.idle { border-left: 4px solid var(--blue); background: var(--blue-soft); }
.check-hero .eyebrow { font-size: 9px; }
.check-hero h3 { font-size: 18px; letter-spacing: -.02em; margin: 4px 0 3px; }
.check-hero p { font-size: 11px; color: var(--muted); line-height: 1.45; }
.summary-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0 12px; }
.summary-box { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 7px 8px; }
.summary-box span { display: block; font-size: 8.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.summary-box b { font-size: 18px; font-family: var(--mono); }
.summary-box.fail b { color: var(--red); }
.summary-box.warn b { color: var(--amber); }
.summary-box.pass b { color: var(--green); }
.summary-box.unverified b { color: var(--blue); }
.check-actions { display: flex; gap: 7px; margin: 10px 0; }
.filter-row { display: flex; flex-wrap: wrap; gap: 5px; margin: 12px 0 9px; }
.filter-chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 4px 8px; font-size: 9.5px; font-weight: 700;
}
.filter-chip:hover { border-color: var(--line-strong); color: var(--ink); }
.filter-chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.finding-card {
  border: 1px solid var(--line); border-left: 3px solid var(--muted-2); border-radius: 7px;
  padding: 11px 11px 10px; margin-bottom: 8px; background: var(--surface);
}
.finding-card.fail { border-left-color: var(--red); }
.finding-card.warn { border-left-color: var(--amber); }
.finding-card.pass { border-left-color: var(--green); }
.finding-card.not_verified { border-left-color: var(--blue); }
.finding-card.info { border-left-color: var(--muted-2); }
.fc-top { display: flex; align-items: center; gap: 7px; }
.fc-id { font-family: var(--mono); font-size: 9px; color: var(--muted); font-weight: 700; }
.fc-sev { font-size: 8px; letter-spacing: .08em; text-transform: uppercase; font-weight: 900; color: var(--muted); margin-left: auto; }
.fc-sev.critical { color: var(--red); }
.fc-sev.high { color: #c4320a; }
.fc-sev.medium { color: var(--amber); }
.fc-sev.low { color: var(--muted); }
.finding-card h4 { font-size: 12.5px; line-height: 1.35; margin: 5px 0 7px; }
.fc-values { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--surface-2); border-radius: 5px; padding: 7px 8px; }
.fc-values span { display: block; font-size: 8.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.fc-values b { font-family: var(--mono); font-size: 12px; font-weight: 700; }
.fc-change { font-size: 10.5px; line-height: 1.45; color: var(--ink-2); margin-top: 8px; }
.fc-actions { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.fc-actions .btn { padding: 5px 8px; font-size: 9.5px; }
.fc-details { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 7px; }
.fc-details summary { cursor: pointer; font-size: 9.5px; color: var(--muted); font-weight: 700; }
.fc-details p { font-size: 10.5px; line-height: 1.5; color: var(--ink-2); margin-top: 6px; }
.criteria-mini { width: 100%; border-collapse: collapse; margin-top: 5px; font-size: 9.5px; }
.criteria-mini th, .criteria-mini td { text-align: left; padding: 4px 3px; border-bottom: 1px solid var(--line); vertical-align: top; }
.criteria-mini th { color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .05em; }
.criteria-mini td.num { font-family: var(--mono); white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--muted-2); }
.status-dot.fail { background: var(--red); }
.status-dot.warn { background: var(--amber); }
.status-dot.pass { background: var(--green); }
.status-dot.not_verified { background: var(--blue); }
.status-dot.info { background: var(--muted-2); }
.empty-state { text-align: center; padding: 26px 12px; color: var(--muted); }
.empty-state h3 { font-size: 14px; color: var(--ink); margin-bottom: 6px; }
.empty-state p { font-size: 11px; line-height: 1.5; }
.inputs-box { border: 1px solid var(--line); border-radius: 7px; margin: 10px 0; overflow: hidden; }
.inputs-box summary { cursor: pointer; padding: 8px 10px; font-size: 10px; font-weight: 700; color: var(--muted); background: var(--surface-2); }
.inputs-grid { padding: 9px 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.inputs-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 9px; color: var(--muted); }
.inputs-grid input { height: 28px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 0 6px; font-size: 11px; width: 100%; }
.unverified-note { font-size: 9px; color: var(--blue); margin-top: 5px; }

/* ------------------------------------------------------------------ measurements */
.measure-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.measure-head h3 { font-size: 12px; }
.measure-head span { font-size: 10px; color: var(--muted); }
.measure-empty { border: 1px dashed var(--line-strong); border-radius: 8px; padding: 20px 14px; text-align: center; }
.measure-empty p { font-size: 11px; color: var(--muted); line-height: 1.5; }
.measure-row { border: 1px solid var(--line); border-radius: 7px; padding: 9px 10px; margin-bottom: 7px; background: var(--surface); }
.measure-row.active { border-color: var(--accent-line); background: var(--accent-soft); }
.mr-top { display: flex; align-items: center; gap: 6px; }
.mr-type { font-size: 8px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.mr-value { font-family: var(--mono); font-size: 12px; font-weight: 700; margin-left: auto; }
.mr-label { font-size: 10.5px; color: var(--ink-2); margin: 4px 0 6px; overflow-wrap: anywhere; }
.mr-controls { display: flex; gap: 5px; align-items: center; }
.mr-controls select { flex: 1; height: 27px; border: 1px solid var(--line); border-radius: 5px; font-size: 10px; padding: 0 5px; background: var(--surface); color: var(--ink-2); min-width: 0; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); color: var(--muted); width: 27px; height: 27px; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 27px; }
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.icon-btn.danger:hover { color: var(--red); border-color: #fecdca; background: var(--red-soft); }
.measure-hint { font-size: 9.5px; color: var(--muted); line-height: 1.45; margin-top: 10px; border-top: 1px solid var(--line); padding-top: 9px; }

/* ------------------------------------------------------------------ toast/modal */
.global-busy {
  position: fixed; inset: 0; z-index: 80; background: rgba(15, 23, 42, .55);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: #f8fafc; font-size: 12px; backdrop-filter: blur(3px);
}
.global-busy .spinner { width: 34px; height: 34px; }
.toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 13px; border-radius: 7px;
  font-size: 11.5px; line-height: 1.45; box-shadow: var(--shadow-lg);
  border-left: 3px solid var(--accent); animation: toast-in .18s ease-out;
}
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: #12b76a; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.modal-backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, .55); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); padding: 20px; }
.modal h3 { font-size: 17px; letter-spacing: -.02em; }
.modal p { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin-top: 6px; }
.modal .field { margin-top: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 18px; }
.modal-close { float: right; border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; padding: 2px 4px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1240px) {
  .brand-sub, .brand-rule { display: none; }
  .brand { min-width: 190px; }
  .welcome { padding: 30px 28px 50px; }
  .welcome-grid { gap: 30px; }
  .rightbar { width: 350px; flex-basis: 350px; }
  .leftbar { width: 280px; flex-basis: 280px; }
}
@media (max-width: 1040px) {
  .welcome-grid { grid-template-columns: 1fr; }
  .upload-card { position: static; }
  .recent-grid { grid-template-columns: 1fr 1fr; }
  .method-strip { grid-template-columns: 1fr; }
  .topbar { gap: 12px; padding: 0 12px; }
  .project-head { display: none; }
  .engine-badge { display: none; }
}
@media (max-width: 860px) {
  .leftbar { display: none; }
  .rightbar { width: 330px; flex-basis: 330px; }
  .welcome { padding: 22px 16px 40px; }
  .recent-grid { grid-template-columns: 1fr; }
  .summary-row { grid-template-columns: 1fr 1fr; }
  .top-actions .btn.ghost:last-child { display: none; }
}
@media (max-width: 640px) {
  .workspace { flex-direction: column; }
  .rightbar { width: 100%; flex-basis: auto; max-height: 46%; border-left: 0; border-top: 1px solid var(--line); }
  .canvas-wrap { min-height: 320px; }
  .toolbar { max-width: calc(100% - 20px); overflow-x: auto; }
  .canvas-info { display: none; }
  .hero h1 { font-size: 36px; }
}

/* ------------------------------------------------------------------ AI / auto-measure */
.modal.wide { max-width: 760px; }
.modal .section-label { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 800; margin: 16px 0 6px; }
.ai-status { display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface-2); }
.ai-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); margin-top: 5px; flex: 0 0 8px; }
.ai-dot.on { background: var(--green); }
.ai-status p { font-size: 10.5px; color: var(--muted); line-height: 1.45; margin-top: 3px; }
.ai-models { font-family: var(--mono); font-size: 9.5px; color: var(--muted-2); margin-top: 4px; }
.ai-result { border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; margin-top: 10px; }
.ai-result h4 { font-size: 12px; margin-bottom: 5px; }
.ai-kv { display: flex; gap: 14px; flex-wrap: wrap; font-size: 10.5px; color: var(--ink-2); }
.ai-kv b { font-family: var(--mono); }
.confidence { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 9.5px; color: var(--muted); }
.confidence .bar { width: 42px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.confidence .bar i { display: block; height: 100%; background: var(--green); }
.role-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 5px 10px; margin-top: 8px; align-items: center; }
.role-grid label { font-size: 10px; color: var(--muted); }
.role-grid select { height: 29px; border: 1px solid var(--line-strong); border-radius: 5px; font-size: 10.5px; background: var(--surface); padding: 0 5px; min-width: 0; }
.candidate-list { display: flex; flex-direction: column; gap: 7px; margin-top: 8px; max-height: 330px; overflow-y: auto; }
.candidate {
  border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: 6px;
  padding: 9px 10px; background: var(--surface);
}
.candidate.high { border-left-color: var(--green); }
.candidate.low { border-left-color: var(--amber); }
.candidate-top { display: flex; align-items: flex-start; gap: 8px; }
.candidate-top input { margin-top: 3px; accent-color: var(--accent); }
.candidate-title { font-size: 11.5px; font-weight: 700; }
.candidate-value { font-family: var(--mono); font-size: 12px; margin-left: auto; white-space: nowrap; }
.candidate-method { font-size: 9.5px; color: var(--muted); line-height: 1.45; margin-top: 3px; }
.candidate-source { font-family: var(--mono); font-size: 8.5px; color: var(--muted-2); margin-top: 4px; }
.ai-warning { font-size: 10px; color: var(--amber); background: var(--amber-soft); border: 1px solid #fedf89; padding: 7px 8px; border-radius: 5px; margin-top: 8px; line-height: 1.45; }
.ai-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.code-inline { font-family: var(--mono); font-size: 9.5px; background: var(--surface-3); border: 1px solid var(--line); padding: 1px 4px; border-radius: 3px; }
