:root {
  --ink: #17252a;
  --ink-muted: #637277;
  --paper: #f5f7f6;
  --panel: #ffffff;
  --line: #dbe3e1;
  --line-strong: #c7d2cf;
  --teal: #0b6b68;
  --teal-dark: #074d4b;
  --teal-soft: #e5f2f0;
  --orange: #c45b2c;
  --orange-soft: #fff0e8;
  --yellow: #9a6b00;
  --yellow-soft: #fff8dc;
  --red: #a63332;
  --red-soft: #fcebea;
  --shadow: 0 14px 35px rgba(20, 44, 45, .08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px clamp(16px, 3vw, 42px);
  color: #f7fbfa;
  background: #163b3d;
  border-bottom: 3px solid var(--orange);
}
.brand-mark { width: 37px; height: 37px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.5); color: #fff; font-weight: 800; letter-spacing: 0; }
.brand-copy { display: grid; gap: 2px; min-width: 0; }
.brand-copy strong { font-size: 16px; letter-spacing: 0; }
.brand-copy span { color: #b8cdca; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.status-pill { display: inline-flex; align-items: center; min-height: 29px; padding: 0 10px; border: 1px solid rgba(255,255,255,.28); color: #d4e6e2; font-size: 12px; white-space: nowrap; }
.status-pill.dirty { color: #ffd2bd; border-color: #d57b55; }
.export-links { display: inline-flex; align-items: center; gap: 6px; min-height: 29px; padding-left: 3px; }
.export-links a { color: #d4e6e2; font-size: 11px; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.export-links a:hover { color: #fff; }

.button { border: 1px solid transparent; min-height: 35px; padding: 0 13px; border-radius: 4px; font-size: 13px; font-weight: 650; transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease; }
.button:active { transform: translateY(1px); }
.button.primary { color: #fff; background: var(--orange); border-color: var(--orange); }
.button.primary:hover { background: #a94b26; border-color: #a94b26; }
.button.secondary { color: var(--teal-dark); background: #fff; border-color: var(--line-strong); }
.button.secondary:hover { background: var(--teal-soft); border-color: #91bdb8; }
.button:disabled { cursor: wait; opacity: .58; }

.app-shell { width: min(1560px, 100%); margin: 0 auto; padding: 25px clamp(14px, 3vw, 42px) 48px; }
.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.summary-card { min-height: 92px; padding: 15px 17px; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 3px 10px rgba(19,40,41,.025); }
.summary-card .label { color: var(--ink-muted); font-size: 12px; }
.summary-card .value { margin-top: 7px; font-size: 25px; font-weight: 740; letter-spacing: 0; line-height: 1; }
.summary-card .detail { margin-top: 7px; color: var(--ink-muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-card.accent { border-top: 3px solid var(--teal); }
.summary-card.warn { border-top: 3px solid var(--orange); }
.summary-card.alert { border-top: 3px solid var(--red); }

.layout-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 17px; align-items: start; }
.side-panel { position: sticky; top: 15px; min-height: 520px; padding: 22px 14px 17px; border: 1px solid var(--line); background: #edf3f1; }
.side-heading { padding: 0 9px 22px; border-bottom: 1px solid var(--line); }
.eyebrow { display: block; color: var(--teal); font-size: 10px; font-weight: 760; letter-spacing: .12em; line-height: 1.4; }
.side-heading h1 { margin: 7px 0 0; font-size: 19px; letter-spacing: 0; }
.tabs { display: grid; gap: 4px; padding-top: 16px; }
.tab { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 40px; padding: 0 9px; border: 0; border-left: 2px solid transparent; color: var(--ink-muted); background: transparent; text-align: left; font-size: 13px; }
.tab:hover { color: var(--teal-dark); background: rgba(255,255,255,.6); }
.tab.active { border-left-color: var(--orange); color: var(--ink); background: #fff; font-weight: 700; }
.tab-index { color: #8d9c9c; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.tab.active .tab-index { color: var(--orange); }
.side-note { display: flex; gap: 8px; align-items: flex-start; margin: 27px 9px 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--ink-muted); font-size: 11px; line-height: 1.5; }
.note-dot { flex: 0 0 7px; width: 7px; height: 7px; margin-top: 4px; border-radius: 50%; background: var(--teal); }

.content-panel { min-width: 0; position: relative; }
.view { display: none; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
.view.active { display: block; }
.model-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; padding: 24px 25px 19px; border-bottom: 1px solid var(--line); }
.model-header h2 { margin: 5px 0 4px; font-size: 24px; letter-spacing: 0; }
.model-header p { margin: 0; color: var(--ink-muted); font-size: 12px; }
.model-tools { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.model-search { display: flex; align-items: center; gap: 6px; min-width: 260px; height: 35px; padding: 0 9px; border: 1px solid var(--line-strong); background: #fbfcfc; color: var(--ink-muted); }
.model-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; }
.icon-button { width: 35px; height: 35px; padding: 0; border: 1px solid var(--line-strong); border-radius: 3px; color: var(--teal-dark); background: #fff; font-size: 18px; line-height: 1; }
.icon-button:hover { border-color: var(--teal); background: var(--teal-soft); }
.model-layout { display: grid; grid-template-columns: minmax(0, 1fr) 286px; min-height: 640px; }
.model-stage { position: relative; min-width: 0; min-height: 640px; overflow: hidden; background: #0f1d1f; }
#modelCanvas { display: block; width: 100%; height: 640px; min-height: 520px; touch-action: none; }
.model-loading { position: absolute; inset: 0; display: grid; place-content: center; color: #b7ceca; background: #0f1d1f; font-size: 13px; pointer-events: none; }
.model-loading.error { color: #f0b1a0; }
.model-toolbar { position: absolute; left: 18px; right: 18px; bottom: 48px; display: flex; align-items: center; gap: 5px; pointer-events: none; }
.view-button { min-height: 29px; padding: 0 10px; border: 1px solid rgba(217,240,235,.22); border-radius: 3px; color: #b5c9c6; background: rgba(19, 40, 42, .86); font-size: 11px; pointer-events: auto; }
.view-button:hover, .view-button.active { border-color: #db9e6b; color: #fff4ea; background: rgba(156, 76, 40, .88); }
.model-hint { margin-left: auto; color: #8ba39f; font-size: 10px; }
.model-legend { position: absolute; left: 18px; right: 18px; bottom: 15px; display: flex; flex-wrap: wrap; gap: 12px; color: #a9bfbb; font-size: 10px; pointer-events: none; }
.model-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.model-legend-item i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255,255,255,.25); }
.model-inspector { min-width: 0; border-left: 1px solid var(--line); background: #f8faf9; }
.inspector-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-height: 76px; padding: 18px 16px 14px; border-bottom: 1px solid var(--line); }
.inspector-heading strong { display: block; max-width: 170px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.inspector-heading .type-tag { color: var(--teal-dark); border-color: #a6cbc4; background: var(--teal-soft); }
.inspector-empty { padding: 25px 16px; color: var(--ink-muted); font-size: 12px; line-height: 1.6; }
.selection-id { padding: 13px 16px 0; color: var(--ink); font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.selection-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; padding: 16px; border-bottom: 1px solid var(--line); }
.selection-grid div { min-width: 0; }
.selection-grid .wide { grid-column: span 2; }
.selection-grid span, .property-list span { display: block; color: var(--ink-muted); font-size: 10px; }
.selection-grid strong { display: block; margin-top: 4px; color: var(--ink); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.property-list { display: grid; gap: 10px; padding: 15px 16px; }
.property-list strong { display: block; margin-top: 3px; color: var(--ink); font-size: 11px; font-weight: 560; line-height: 1.35; overflow-wrap: anywhere; }
.model-counts { margin: 0 16px; padding: 13px 0; border-top: 1px solid var(--line); color: var(--ink-muted); font-size: 10px; line-height: 1.6; }
.model-counts strong { display: block; margin-bottom: 3px; color: var(--ink); font-size: 18px; }
.model-counts strong span { color: var(--ink-muted); font-size: 10px; font-weight: 450; }
.view-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; padding: 24px 25px 19px; border-bottom: 1px solid var(--line); }
.view-header h2 { margin: 5px 0 4px; font-size: 22px; letter-spacing: 0; }
.view-header p { margin: 0; color: var(--ink-muted); font-size: 12px; }
.view-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.search-box { display: flex; align-items: center; gap: 6px; min-width: 190px; height: 35px; padding: 0 9px; border: 1px solid var(--line-strong); background: #fbfcfc; color: var(--ink-muted); }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; }
select, input:not([type="checkbox"]) { min-height: 35px; border: 1px solid var(--line-strong); border-radius: 3px; background: #fff; color: var(--ink); outline: none; padding: 0 9px; font-size: 12px; }
select:focus, input:focus { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(11,107,104,.11); }

.evidence-grid { display: grid; grid-template-columns: minmax(420px, 1.16fr) minmax(330px, .84fr); gap: 0; min-height: 560px; }
.table-wrap { min-width: 0; overflow: hidden; }
.layer-wrap { border-right: 1px solid var(--line); }
.data-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.data-table th, .data-table td { padding: 10px 9px; border-bottom: 1px solid #edf1f0; text-align: left; vertical-align: middle; font-size: 12px; }
.data-table th { position: sticky; top: 0; z-index: 1; color: var(--ink-muted); background: #f5f8f7; font-size: 11px; font-weight: 700; }
.data-table th:nth-child(1), .data-table td:nth-child(1) { width: 37px; }
.data-table th:nth-child(2) { width: 37%; }
.data-table th:nth-child(3) { width: 61px; }
.data-table th:nth-child(4) { width: 100px; }
.data-table th:nth-child(5) { width: 112px; }
.data-table tbody tr { transition: background .12s ease; }
.data-table tbody tr:hover, .data-table tbody tr.selected { background: #f1f8f6; }
.data-table tbody tr.layer-active { box-shadow: inset 3px 0 var(--orange); background: #fff5ef; }
.check-col { text-align: center !important; }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--teal); }
.layer-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 610; cursor: pointer; }
.layer-sub { display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-muted); font-size: 10px; }
.type-tag { display: inline-flex; max-width: 100%; padding: 3px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--line); color: var(--ink-muted); background: #f8faf9; font-size: 10px; }
.type-tag.mapped { border-color: #9ac9c2; color: var(--teal-dark); background: var(--teal-soft); }
.type-tag.ignored { border-color: #e2aaa4; color: var(--red); background: var(--red-soft); }
.type-tag.pending { border-color: #ebc28b; color: var(--yellow); background: var(--yellow-soft); }
.layer-select { width: 100%; min-width: 0; height: 31px; min-height: 31px; padding: 0 5px; font-size: 11px; }
.empty-cell { padding: 34px 15px !important; color: var(--ink-muted); text-align: center !important; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 42px; padding: 7px 11px; border-top: 1px solid var(--line); color: var(--ink-muted); font-size: 11px; }
.pager-buttons { display: flex; gap: 4px; }
.pager-button { width: 28px; height: 26px; padding: 0; border: 1px solid var(--line-strong); background: #fff; color: var(--ink-muted); font-size: 12px; }
.pager-button:hover:not(:disabled) { border-color: var(--teal); color: var(--teal-dark); }
.pager-button:disabled { opacity: .4; cursor: default; }

.preview-panel { display: flex; flex-direction: column; min-width: 0; background: #172a2c; color: #eaf4f1; }
.preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 67px; padding: 15px 17px; border-bottom: 1px solid rgba(223,244,239,.13); }
.preview-heading .eyebrow { color: #8fc6bc; }
.preview-heading strong { display: block; max-width: 280px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.muted { color: #8aa09d; font-size: 11px; }
.canvas-frame { position: relative; flex: 1; min-height: 420px; margin: 15px; border: 1px solid rgba(218,242,235,.15); background: #102022; overflow: hidden; }
#cadCanvas { display: block; width: 100%; height: 100%; min-height: 420px; }
.canvas-empty { position: absolute; inset: 0; display: grid; place-content: center; gap: 5px; color: #7e9995; text-align: center; font-size: 13px; pointer-events: none; }
.canvas-empty small { color: #607b77; font-size: 10px; }
.preview-legend { display: flex; gap: 13px; flex-wrap: wrap; min-height: 40px; padding: 0 17px 14px; color: #9fb4b0; font-size: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-swatch { width: 17px; height: 2px; background: #e1a36c; }
.legend-swatch.fill { height: 8px; background: rgba(82,176,162,.38); border: 1px solid #5fb7a8; }

.bulk-bar { display: flex; align-items: center; gap: 9px; min-height: 57px; padding: 10px 14px; border-top: 1px solid var(--line); background: #fbfcfc; }
.bulk-bar > span { margin-right: auto; color: var(--ink-muted); font-size: 11px; }
.bulk-bar select { min-width: 112px; }
.element-bulk { border-top: 0; border-bottom: 1px solid var(--line); }
.element-table th:nth-child(2) { width: 31%; }.element-table th:nth-child(3) { width: 17%; }.element-table th:nth-child(4) { width: 90px; }.element-table th:nth-child(5) { width: 110px; }.element-table th:nth-child(6) { width: 66px; }
.element-id { font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.element-source { margin-top: 3px; color: var(--ink-muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.confidence { color: var(--teal-dark); font-variant-numeric: tabular-nums; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; padding: 24px 25px 27px; }
.form-grid label { display: grid; gap: 6px; color: var(--ink-muted); font-size: 11px; }
.form-grid label.wide { grid-column: span 2; }
.form-grid input { width: 100%; }
.check-field { display: flex !important; align-items: center; gap: 8px !important; color: var(--teal-dark) !important; }
.check-field input { width: 15px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 18px 25px 12px; border-top: 1px solid var(--line); }
.section-heading h3 { margin: 3px 0 0; font-size: 16px; }
.storey-list { display: grid; gap: 10px; padding: 0 25px 28px; }
.storey-card { display: grid; grid-template-columns: minmax(130px, 1.4fr) 90px 120px 120px auto; align-items: end; gap: 10px; padding: 15px; border: 1px solid var(--line); background: #fbfcfc; }
.storey-card label { display: grid; gap: 5px; color: var(--ink-muted); font-size: 11px; }
.storey-card input { width: 100%; }
.storey-card .storey-caption { align-self: center; color: var(--ink-muted); font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; }
.remove-storey { min-height: 31px; padding: 0 8px; border: 1px solid #e2b9aa; color: var(--red); background: #fff; font-size: 11px; }

.finding-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; padding: 20px 25px; border-bottom: 1px solid var(--line); }
.finding-count { padding: 11px 12px; border-left: 3px solid var(--line-strong); background: #f8faf9; }.finding-count strong { display: block; font-size: 20px; }.finding-count span { color: var(--ink-muted); font-size: 11px; }.finding-count.blocking { border-left-color: var(--red); background: var(--red-soft); }.finding-count.high { border-left-color: var(--orange); background: var(--orange-soft); }.finding-count.medium { border-left-color: #d09b27; background: var(--yellow-soft); }.finding-count.info { border-left-color: var(--teal); background: var(--teal-soft); }
.finding-list { padding: 5px 25px 24px; }
.finding-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) 160px; gap: 12px; padding: 14px 0; border-bottom: 1px solid #edf1f0; }
.severity { align-self: start; display: inline-flex; justify-content: center; padding: 4px 5px; font-size: 10px; font-weight: 750; }.severity.BLOCKING { color: var(--red); background: var(--red-soft); }.severity.HIGH { color: #a64c1e; background: var(--orange-soft); }.severity.MEDIUM { color: var(--yellow); background: var(--yellow-soft); }.severity.INFO { color: var(--teal-dark); background: var(--teal-soft); }
.finding-main strong { display: block; font-size: 12px; line-height: 1.45; }.finding-main p { margin: 4px 0 0; color: var(--ink-muted); font-size: 11px; line-height: 1.5; }.finding-path { align-self: start; color: var(--ink-muted); font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.toast { position: fixed; z-index: 10; top: 84px; right: 25px; max-width: min(440px, calc(100vw - 35px)); padding: 10px 13px; border: 1px solid #9ac9c2; color: var(--teal-dark); background: #ecf8f5; box-shadow: var(--shadow); font-size: 12px; opacity: 0; transform: translateY(-7px); pointer-events: none; transition: opacity .18s ease, transform .18s ease; }.toast.show { opacity: 1; transform: translateY(0); }.toast.error { border-color: #e2aaa4; color: var(--red); background: var(--red-soft); }

@media (max-width: 1120px) {
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .model-layout { grid-template-columns: 1fr; }
  .model-inspector { min-height: 250px; border-top: 1px solid var(--line); border-left: 0; }
  .model-counts { padding-bottom: 20px; }
  .evidence-grid { grid-template-columns: 1fr; }
  .layer-wrap { border-right: 0; border-bottom: 1px solid var(--line); }
  .preview-panel { min-height: 500px; }
}
@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-wrap: wrap; padding: 12px 14px; }.top-actions { width: 100%; margin-left: 50px; }.top-actions .button { flex: 1; }.status-pill { margin-right: auto; }
  .app-shell { padding: 14px 10px 30px; }.summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }.summary-card { min-height: 78px; padding: 12px; }.summary-card .value { font-size: 21px; }
  .layout-grid { display: block; }.side-panel { position: static; min-height: 0; margin-bottom: 11px; padding: 12px; }.side-heading { display: flex; align-items: baseline; justify-content: space-between; padding: 0 5px 10px; }.side-heading h1 { margin: 0; font-size: 16px; }.tabs { display: flex; gap: 3px; padding-top: 9px; overflow-x: auto; }.tab { flex: 0 0 auto; width: auto; min-height: 34px; padding: 0 9px; border-left: 0; border-bottom: 2px solid transparent; font-size: 11px; white-space: nowrap; }.tab.active { border-bottom-color: var(--orange); }.tab-index { display: none; }.side-note { display: none; }
  .view-header { display: block; padding: 17px 15px 14px; }.view-header h2 { font-size: 19px; }.view-header p { line-height: 1.5; }.view-tools { justify-content: stretch; margin-top: 13px; }.search-box { flex: 1; min-width: 0; }.view-tools select { flex: 0 0 110px; }
  .model-header { display: block; padding: 17px 15px 14px; }.model-header h2 { font-size: 20px; }.model-header p { line-height: 1.5; }.model-tools { justify-content: stretch; margin-top: 13px; }.model-search { flex: 1 1 100%; min-width: 0; }.model-tools select { flex: 1; min-width: 0; }.model-tools .icon-button { flex: 0 0 35px; }
  .model-stage, #modelCanvas { min-height: 440px; height: 440px; }.model-toolbar { left: 10px; right: 10px; bottom: 45px; }.model-hint { display: none; }.model-legend { left: 10px; right: 10px; bottom: 13px; gap: 8px; }
  .data-table th, .data-table td { padding: 8px 6px; font-size: 11px; }.layer-wrap { overflow-x: auto; }.layer-wrap .data-table { min-width: 570px; }.element-table { min-width: 690px; }.table-wrap:has(.element-table) { overflow-x: auto; }
  .bulk-bar { flex-wrap: wrap; padding: 9px 10px; }.bulk-bar > span { flex: 1 1 100%; }.bulk-bar select { flex: 1; }.bulk-bar .button { flex: 1; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; padding: 17px 15px 21px; }.form-grid label.wide { grid-column: span 2; }.storey-list { padding: 0 15px 20px; }.section-heading { padding: 15px; }.storey-card { grid-template-columns: 1fr 1fr; }.storey-card label:first-of-type { grid-column: span 2; }.storey-card .storey-caption { grid-column: span 2; }.remove-storey { width: 100%; }
  .finding-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 15px; }.finding-list { padding: 4px 15px 20px; }.finding-row { grid-template-columns: 65px minmax(0, 1fr); gap: 9px; }.finding-path { grid-column: 2; }
}
