:root {
  --bg: #0c0c0c;
  --panel: #121212;
  --panel-2: #171717;
  --line: #2a2a2a;
  --text: #f4f4f4;
  --muted: #9a9a9a;
  --orange: #ff5a1f;
  --orange-dim: #c43d10;
  --ok: #3dba7a;
  --warn: #e3b341;
  --info: #6ea8ff;
  --bad: #e07a5f;
  --member: #ff5a1f;
  --dim: #3ee0c0;
  --plate: #b388ff;
  --auto-measure: #14a7a0;
  --auto-measure-adjusted: #e0902f;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  color: var(--text);
  font: 14px/1.45 Inter, system-ui, sans-serif;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 28px 28px;
}
body { display: flex; flex-direction: column; }
button, input, select { font: inherit; }
.hidden { display: none !important; }
.v1-hidden-primary { display: none !important; }

.nav {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(12,12,12,0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
}
.logo {
  background: none;
  border: 0;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.14em;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dot {
  width: 8px;
  height: 8px;
  background: var(--orange);
  display: inline-block;
}
.nav-links { display: flex; gap: 8px; flex: 1; }
.nav-link {
  background: none;
  border: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 600;
  padding: 8px 10px;
  cursor: pointer;
}
.nav-link.on, .nav-link:hover { color: #fff; }
.nav-link:disabled { opacity: 0.35; cursor: default; }
.nav-actions { margin-left: auto; }

.btn-primary, .file {
  background: var(--orange);
  color: #111;
  border: 0;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  padding: 10px 14px;
  cursor: pointer;
}
.file input { display: none; }
.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 8px 10px;
  cursor: pointer;
}
.ghost:hover { border-color: #555; }

.sheet-tag {
  color: var(--orange);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 0 0 10px;
}
.screen { flex: 1; min-height: 0; }
#screen-projects { overflow: auto; }
#screen-workspace { display: flex; flex-direction: column; }
#screen-workspace.hidden { display: none !important; }
.projects-head { max-width: 820px; padding: 48px 32px 12px; }
.projects-head h1 {
  font-size: clamp(36px, 6vw, 64px);
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  font-weight: 800;
  margin: 0 0 16px;
}
.lede { color: var(--muted); max-width: 560px; margin: 0; }

.drop {
  margin: 12px 32px 28px;
  border: 1px dashed #3a3a3a;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  cursor: pointer;
  background: rgba(255,90,31,0.04);
}
.drop.over { border-color: var(--orange); color: #fff; }
.drop strong { color: #fff; letter-spacing: 0.08em; text-transform: uppercase; font-size: 13px; }

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  padding: 0 32px 48px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 16px;
  cursor: pointer;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card:hover { border-color: var(--orange); }
.card h3 { margin: 0; font-size: 15px; }
.card .meta { color: var(--muted); font-size: 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid var(--line);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  width: fit-content;
}
.pill.ready { color: var(--ok); border-color: #245c3d; }
.pill.processing { color: var(--warn); }
.pill.error { color: var(--bad); }
.ai-classification-status {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}
.ai-classification-status.failed { color: var(--warn); cursor: pointer; }

.work-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.work-bar select, .board-bar select, .filters select, .filters input, .editor input, .editor select {
  background: #0e0e0e;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 7px 8px;
}
.unit-settings {
  padding: 5px 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #0e0e0e;
  cursor: pointer;
  font-size: 11px;
}
.unit-settings:hover { color: #fff; border-color: #555; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,0.72);
}
.unit-modal-card {
  width: min(390px, 100%);
  padding: 20px;
  border: 1px solid #444;
  background: var(--panel-2);
  box-shadow: 0 18px 60px rgba(0,0,0,0.65);
}
.unit-modal-card h2 { margin: 0 0 6px; font-size: 20px; }
.unit-option {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  cursor: pointer;
  background: #101010;
}
.unit-option:has(input:checked) { border-color: var(--orange); background: rgba(255,90,31,0.08); }
.unit-option input { accent-color: var(--orange); }
.unit-option span { display: flex; flex-direction: column; }
.unit-option small { color: var(--muted); }
.unit-modal-error { margin: 10px 0 0; color: var(--bad); font-size: 12px; }
.unit-modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.steps {
  display: flex;
  gap: 0;
  list-style: none;
  margin: 0 0 0 auto;
  padding: 0;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #666;
}
.steps li {
  padding: 6px 10px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 5px;
}
.steps li span {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 9px;
}
.steps li.complete { color: var(--ok); }
.steps li.current { color: #111; background: var(--orange); border-color: var(--orange); font-weight: 700; }
.steps li.available { color: #d9d9d9; }
.steps li.blocked { color: #666; background: #0f0f0f; }

.workflow-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #101010;
  flex-shrink: 0;
}
.workflow-panel h3 { margin: 0 0 3px; font-size: 15px; }
.workflow-panel p { margin: 0; color: var(--muted); font-size: 12px; }
.workflow-panel.current { border-left: 3px solid var(--orange); }
.workflow-panel.blocked { border-left: 3px solid var(--warn); }
.workflow-panel.complete { border-left: 3px solid var(--ok); }
.workflow-error { color: var(--warn) !important; margin-top: 4px !important; }
.workflow-metrics {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.workflow-metrics span {
  border: 1px solid var(--line);
  padding: 4px 7px;
  color: var(--muted);
  font-size: 11px;
}
.workflow-metrics b { color: #fff; margin-right: 5px; font-variant-numeric: tabular-nums; }
.workflow-action { white-space: nowrap; padding: 8px 10px; font-size: 10px; }
.proceed-takeoff-btn:disabled {
  opacity: .38;
  cursor: not-allowed;
}

.kpis {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  background: var(--panel-2);
  flex-shrink: 0;
}
.kpis span {
  border: 1px solid var(--line);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}
.kpis b { color: #fff; font-size: 16px; margin-right: 6px; font-variant-numeric: tabular-nums; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) auto minmax(360px, 420px);
  flex: 1;
  min-height: 0;
}
.board {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: #090909;
}
.board-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  flex-wrap: wrap;
}
.board-bar button { background: #151515; color: #fff; border: 1px solid var(--line); padding: 6px 10px; cursor: pointer; }
.check { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.thumbs {
  display: flex;
  gap: 6px;
  padding: 0 10px 8px;
  overflow-x: auto;
}
.thumbs button {
  border: 1px solid var(--line);
  background: #111;
  padding: 0;
  cursor: pointer;
}
.thumbs button.on { border-color: var(--orange); }
.thumbs img { display: block; height: 56px; width: auto; background: #fff; }
.canvas-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  cursor: grab;
  background: #d7d7d7;
  isolation: isolate;
}
.canvas-wrap:active { cursor: grabbing; }
.canvas-wrap.manual-mode, .canvas-wrap.manual-mode:active,
.canvas-wrap.dimension-mode, .canvas-wrap.dimension-mode:active,
.canvas-wrap.calibration-mode, .canvas-wrap.calibration-mode:active,
.canvas-wrap.measure-member-mode, .canvas-wrap.measure-member-mode:active,
.canvas-wrap.repeat-mode, .canvas-wrap.repeat-mode:active { cursor: crosshair; }
.canvas-wrap.auto-measure-dragging, .canvas-wrap.auto-measure-dragging:active { cursor: crosshair; }
#drawing-canvas, #canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: auto; }
#drawing-canvas { z-index: 0; background: #fff; opacity: 1; filter: none; mix-blend-mode: normal; }
#canvas { z-index: 1; background: transparent; pointer-events: none; }
.add-member-btn.on, .add-dimension-btn.on, .calibrate-btn.on, .repeat-member-btn.on,
.measure-member-btn.on,
.auto-measure-btn.on, .auto-measure-sheet-btn.on {
  color: #111;
  background: var(--orange);
  border-color: var(--orange);
}
.board-bar button:disabled { opacity: .42; cursor: default; }
.repeat-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  display: grid;
  gap: 2px;
  min-width: 150px;
  padding: 9px 10px;
  border: 1px solid #4a4a4a;
  color: #ddd;
  background: rgba(20,20,20,0.94);
  box-shadow: 0 8px 24px rgba(0,0,0,0.38);
  font-size: 11px;
}
.repeat-indicator strong { color: #fff; font: 700 12px "IBM Plex Mono", monospace; }
.repeat-indicator button {
  margin-top: 5px;
  padding: 5px 8px;
  border: 1px solid #555;
  color: #fff;
  background: #222;
  cursor: pointer;
}
.auto-measure-card {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 13;
  width: min(292px, calc(100% - 20px));
  padding: 10px;
  border: 1px solid #326d6a;
  border-radius: 7px;
  color: #ddd;
  background: rgba(18, 24, 24, .96);
  box-shadow: 0 10px 28px rgba(0,0,0,.46);
  font-size: 11px;
}
.auto-measure-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.auto-measure-card-head strong { color: #fff; font: 700 12px "IBM Plex Mono", monospace; }
.auto-measure-status {
  padding: 2px 6px;
  border-radius: 4px;
  color: #8de4df;
  background: #153f3c;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .06em;
}
.auto-measure-status.adjusted { color: #ffd098; background: #4c3216; }
.auto-measure-status.confirmed { color: #8fe1b9; background: #183e2b; }
.auto-measure-status.needs_review { color: #f4cb73; background: #463612; }
.auto-measure-status.rejected { color: #ffad9d; background: #48241f; }
.auto-measure-length {
  display: block;
  margin-top: 7px;
  color: #fff;
  font: 700 17px "IBM Plex Mono", monospace;
}
.auto-measure-meta, .auto-measure-error { margin: 5px 0 0; line-height: 1.35; }
.auto-measure-meta { color: #aab9b8; }
.auto-measure-error { color: #ff9a82; }
.auto-measure-calibration {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  color: #cbd7d6;
  font-size: 10px;
}
.auto-measure-calibration select {
  width: 100%;
  padding: 5px 7px;
  border: 1px solid #4a5e5d;
  border-radius: 4px;
  color: #fff;
  background: #1d2928;
  font: 11px "IBM Plex Mono", monospace;
}
.auto-measure-actions { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 9px; }
.auto-measure-actions button {
  padding: 5px 7px;
  border: 1px solid #4a5e5d;
  border-radius: 4px;
  color: #fff;
  background: #1d2928;
  cursor: pointer;
  font-size: 10px;
}
.auto-measure-actions button:disabled { opacity: .42; cursor: default; }
.auto-measure-actions button.danger { color: #ffad9d; }
.drawing-context-menu {
  position: absolute;
  z-index: 12;
  min-width: 174px;
  padding: 5px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #181818;
  box-shadow: 0 10px 28px rgba(0,0,0,0.48);
}
.drawing-context-menu button {
  display: block;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 4px;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.drawing-context-menu button:hover { background: #292929; }
.drawing-context-menu button:disabled { color: #666; cursor: default; background: transparent; }
.drawing-context-menu button.danger { color: #ff9a82; }
.manual-member-card {
  position: absolute;
  z-index: 11;
  width: 226px;
  padding: 11px;
  border: 1px solid #4a4a4a;
  border-radius: 7px;
  color: var(--text);
  background: rgba(24,24,24,0.97);
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
}
.manual-member-card.add-item-card {
  width: min(520px, calc(100% - 20px));
  padding: 10px 12px;
}
.add-item-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, .72fr);
  gap: 7px 10px;
}
.add-item-grid label { margin-top: 0; }
.manual-ai-status {
  display: flex;
  min-height: 29px;
  margin-top: 3px;
  padding: 6px 7px;
  align-items: center;
  border: 1px solid #444;
  border-radius: 4px;
  font-size: 11px;
  background: #0f0f0f;
}
.manual-save-error {
  margin: 8px 0 0;
  padding: 7px 8px;
  border: 1px solid #a94747;
  border-radius: 4px;
  color: #ffd5d5;
  background: rgba(126, 31, 31, .34);
  font-size: 11px;
  line-height: 1.35;
}
.manual-item-details { margin-top: 7px; padding-top: 7px; border-top: 1px solid #3d3d3d; }
.add-item-dimensions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.add-item-dimensions label { margin-top: 0; }
.add-item-card .manual-card-actions { justify-content: flex-end; margin-top: 8px; }
@media (max-width: 700px), (max-height: 760px) {
  .manual-member-card.add-item-card { width: min(480px, calc(100% - 16px)); padding: 8px 10px; }
  .add-item-grid { gap: 5px 8px; }
  .manual-member-card.add-item-card input,
  .manual-member-card.add-item-card select { padding: 4px 6px; }
  .manual-ai-status { min-height: 25px; padding: 4px 6px; }
}
.manual-member-card strong {
  display: block;
  margin-bottom: 8px;
  color: #fff;
  font: 700 12px/1.2 "IBM Plex Mono", ui-monospace, monospace;
}
.manual-member-card label {
  display: block;
  margin-top: 7px;
  color: #bbb;
  font-size: 11px;
}
.manual-member-card input, .manual-member-card select {
  width: 100%;
  margin-top: 3px;
  padding: 6px 7px;
  border: 1px solid #444;
  border-radius: 4px;
  color: #fff;
  background: #0f0f0f;
}
.manual-ocr-meta, .manual-ocr-raw {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.35;
}
.manual-ocr-meta { color: #bbb; }
.manual-ocr-raw {
  color: #8f8f8f;
  white-space: pre-wrap;
  word-break: break-word;
}
.manual-card-actions { display: flex; gap: 7px; margin-top: 10px; }
.manual-card-actions button { padding: 6px 10px; font-size: 11px; }
.manual-measure-card {
  border-color: #087f6b;
  width: min(270px, calc(100% - 20px));
}
.manual-measure-member {
  margin: 6px 0 8px;
  color: #cbd7d6;
  font: 600 11px "IBM Plex Mono", monospace;
}
.manual-measure-calibration {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  color: #cbd7d6;
  font-size: 10px;
}
.manual-measure-calibration select {
  width: 100%;
  padding: 5px 7px;
  border: 1px solid #4a5e5d;
  border-radius: 4px;
  color: #fff;
  background: #1d2928;
  font: 11px "IBM Plex Mono", monospace;
}
.member-chip {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92%, 520px);
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(10, 10, 10, 0.92);
  border: 1px solid #333;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  pointer-events: none;
  font-size: 13px;
}
.member-chip .chip-section {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  white-space: nowrap;
}
.member-chip .chip-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.member-chip .chip-badge.conf { background: #1e3d2a; color: var(--ok); }
.member-chip .chip-badge.kind { background: #1a2a3a; color: var(--info); }
.member-chip .chip-badge.st-trusted { background: #1e3d2a; color: var(--ok); }
.member-chip .chip-badge.st-needs_review { background: #3a3014; color: var(--warn); }
.member-chip .chip-badge.st-unmeasured { background: #2a2220; color: #c9a99a; }
.member-chip .chip-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.swatch { display: inline-block; width: 10px; height: 10px; margin-right: 4px; vertical-align: -1px; }
.swatch.trusted { background: var(--ok); }
.swatch.needs_review { background: var(--warn); }
.swatch.unmeasured { background: #c9a99a; }
.swatch.sel { background: #ffd166; }
.swatch.intelligence { background: #7ef0ff; }
.swatch.member { background: #2878a8; }
.swatch.dimension { background: #7656b5; }
.swatch.manual { background: #087f6b; }
.swatch.manual-measure { background: #18a884; }
.swatch.ai { background: #735dd0; }
.swatch.vision { background: #a64a9f; }
.swatch.finalized { background: #00a879; }
.swatch.auto-measure { background: var(--auto-measure); }

.side { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
  font-weight: 700;
  padding: 12px 8px;
  cursor: pointer;
}
.tabs button.on { border-bottom-color: var(--orange); color: #fff; }
.tab { display: none; flex: 1; min-height: 0; flex-direction: column; }
.tab.on { display: flex; }

.bom-head, .bom-row, .det-row {
  display: grid;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  font-size: 12px;
}
.bom-tag { padding: 10px 12px 0; margin: 0; }
.bom-head {
  grid-template-columns: 34px minmax(0, 1fr) 48px 28px;
  gap: 5px;
  padding: 6px 8px;
  color: var(--muted);
  letter-spacing: 0.1em;
  font-size: 10px;
  border-bottom: 1px solid var(--line);
}
.bom-row {
  grid-template-columns: 34px minmax(0, 1fr) 48px 28px;
  gap: 5px;
  min-height: 34px;
  padding: 4px 8px;
  cursor: pointer;
  border-bottom: 1px solid #1d1d1d;
}
.bom-row:hover, .det-row:hover { background: #1a1a1a; }
.bom-row.sel, .det-row.sel { background: #2a160e; outline: 1px solid var(--orange); }
.bom-row .mark, .bom-row .section {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 600;
}
.member-finalization-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 10px;
  border-bottom: 1px solid var(--line);
}
.member-finalization-actions { display: flex; align-items: center; gap: 8px; }
.member-mark-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.member-mark-tools select { min-width: 105px; padding: 4px 5px; background: #111; color: var(--text); border: 1px solid #383838; }
.member-finalization-row.excluded { opacity: 0.55; }
.bom-head, .bom-row.member-finalization-row {
  grid-template-columns: 28px minmax(48px, .7fr) minmax(70px, 1fr) 34px 82px 30px 18px;
  gap: 4px;
}
.member-drawing-mark { font: 700 10px "IBM Plex Mono", monospace; color: #d4dce4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.member-drawing-mark { padding: 3px 2px; border: 1px solid transparent; background: transparent; text-align: left; cursor: pointer; }
button.member-drawing-mark:hover, button.member-drawing-mark:focus { border-color: currentColor; outline: none; }
.member-drawing-mark.suggested { color: #d09a26; }
.member-drawing-mark.conflict { color: #e07070; }
.member-length { font: 11px "IBM Plex Mono", monospace; white-space: nowrap; text-align: right; }
.member-group-badge { font: 10px "IBM Plex Mono", monospace; color: #95aec6; text-align: center; }
.member-measurement-group {
  padding: 6px 8px;
  background: #17202a;
  border-left: 2px solid #6285a6;
  font: 10px "IBM Plex Mono", monospace;
  color: #c1d0de;
}
.member-finalization-row .member-no {
  font: 700 12px "IBM Plex Mono", ui-monospace, monospace;
  color: var(--orange);
  text-align: center;
}
.member-family-group {
  padding: 7px 9px 5px;
  border-bottom: 1px solid #252525;
  color: #b8b8b8;
  background: #111;
  font: 700 10px "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.member-section-select {
  min-width: 0;
  width: 100%;
  padding: 5px 7px;
  border: 1px solid #383838;
  border-radius: 3px;
  color: var(--text);
  background: #101010;
  font: 600 11px "IBM Plex Mono", ui-monospace, monospace;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.member-section-select:hover, .member-section-select:focus { border-color: var(--orange); outline: none; }
.member-finalization-row.needs-review .member-section-select { border-color: #8b6c25; }
.member-confirm-toggle {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #555;
  border-radius: 50%;
  color: #888;
  background: #151515;
  cursor: pointer;
  font-size: 15px;
  line-height: 26px;
}
.member-confirm-toggle:hover { border-color: var(--orange); color: #fff; }
.member-confirm-toggle.confirmed {
  border-color: #2b9b70;
  color: #9be4c3;
  background: #173b2d;
}
.member-confirm-toggle.needs-review { border-color: #8b6c25; color: #e9c465; }
.member-row-menu { position: relative; }
.member-row-menu summary {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 3px;
  color: #aaa;
  cursor: pointer;
  list-style: none;
  font-size: 16px;
}
.member-row-menu summary::-webkit-details-marker { display: none; }
.member-row-menu summary:hover { border-color: #555; color: #fff; }
.member-row-menu-options {
  position: absolute;
  z-index: 24;
  top: 29px;
  right: 0;
  min-width: 176px;
  padding: 4px;
  border: 1px solid #4a4a4a;
  border-radius: 4px;
  background: #181818;
  box-shadow: 0 8px 22px rgba(0,0,0,.5);
}
.member-row-menu-options button {
  width: 100%;
  padding: 6px 8px;
  border: 0;
  color: #ddd;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 10px;
}
.member-row-menu-options button:hover { color: #fff; background: #292929; }
.member-row-menu-options button.danger { color: #ff9f98; }
.member-section-picker {
  position: fixed;
  z-index: 80;
  width: min(290px, calc(100vw - 20px));
  padding: 8px;
  border: 1px solid #454545;
  border-radius: 6px;
  color: var(--text);
  background: #171717;
  box-shadow: 0 12px 32px rgba(0,0,0,.58);
}
.member-section-picker-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.member-section-picker-head strong { font-size: 11px; }
.member-section-picker-head button {
  width: 25px;
  height: 25px;
  padding: 0;
  border: 0;
  color: #aaa;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
}
.member-section-picker input {
  width: 100%;
  margin-top: 7px;
  padding: 6px 7px;
  border: 1px solid #444;
  border-radius: 3px;
  color: #fff;
  background: #0e0e0e;
  font: 600 11px "IBM Plex Mono", ui-monospace, monospace;
}
.member-section-picker input:focus { border-color: var(--orange); outline: none; }
.member-section-picker-note { min-height: 14px; margin: 5px 1px 3px; font-size: 9px; }
.member-section-results {
  max-height: 240px;
  overflow: auto;
  border-top: 1px solid #303030;
}
.member-section-option {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 7px;
  border: 0;
  border-bottom: 1px solid #272727;
  color: #eee;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: 600 11px "IBM Plex Mono", ui-monospace, monospace;
}
.member-section-option:hover, .member-section-option.current { background: #292019; }
.member-section-option small { color: var(--muted); font: 9px "IBM Plex Mono", monospace; }
.member-section-empty { padding: 10px 7px; color: var(--muted); font-size: 10px; }
.member-final-actions { display: flex; gap: 4px; }
.member-final-actions button {
  padding: 4px 6px;
  border: 1px solid #454545;
  border-radius: 3px;
  color: #ddd;
  background: #181818;
  font-size: 9px;
  cursor: pointer;
}
.member-final-actions button:hover { border-color: var(--orange); color: #fff; }
.member-final-actions button.danger:hover { border-color: #ad4a42; color: #ff9f98; }
.manual-row-edit {
  padding: 3px 7px;
  border: 1px solid #454545;
  border-radius: 4px;
  color: #ddd;
  background: #1a1a1a;
  font-size: 10px;
  cursor: pointer;
}
.manual-row-edit:hover { border-color: var(--orange); color: #fff; }
.det-row {
  grid-template-columns: 92px 1fr auto;
  cursor: pointer;
  border-bottom: 1px solid #1d1d1d;
}
.group-h {
  padding: 8px 12px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  background: #101010;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.filters {
  display: grid;
  grid-template-columns: 1fr 130px 110px;
  gap: 6px;
  padding: 8px;
}
.table-wrap { overflow: auto; flex: 1; }
.intelligence-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  width: 360px;
  border-right: 1px solid var(--line);
  background: var(--panel-2);
}
.intelligence-panel.collapsed {
  width: 42px;
}
.intelligence-toggle {
  flex: 0 0 42px;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  background: #101010;
  cursor: pointer;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
  font-weight: 700;
}
.intelligence-panel:not(.collapsed) .intelligence-toggle {
  color: #fff;
  border-right-color: var(--orange);
}
.intelligence-body {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}
.intelligence-panel.collapsed .intelligence-body {
  display: none;
}
.intelligence-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--line);
}
.intelligence-head .bom-tag {
  padding: 0;
  margin-bottom: 4px;
}
.intelligence-head .muted {
  margin: 0;
}
.intelligence-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 62px;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}
.intelligence-tools input {
  min-width: 0;
  background: #0e0e0e;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 7px 8px;
}
.intelligence-tools button {
  grid-column: 1 / -1;
  padding: 6px 8px;
}
.intelligence-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}
.intelligence-tabs button {
  padding: 5px 7px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #101010;
  cursor: pointer;
  font-size: 10px;
}
.intelligence-tabs button.on {
  color: #111;
  border-color: var(--orange);
  background: var(--orange);
  font-weight: 700;
}
.intelligence-count {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}
.intelligence-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.intelligence-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  padding: 9px 10px;
  border-bottom: 1px solid #222;
  cursor: pointer;
  font-size: 12px;
}
.intelligence-row:hover {
  background: #1a1a1a;
}
.intelligence-row.sel {
  background: #2a160e;
  outline: 1px solid var(--orange);
}
.intelligence-row strong {
  min-width: 0;
  color: #fff;
  font: 700 12px "IBM Plex Mono", ui-monospace, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.intelligence-row .confidence {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.intelligence-row .raw,
.intelligence-row .meta {
  grid-column: 1 / -1;
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.intelligence-row .meta {
  color: #8f8f8f;
  font-size: 11px;
}
.st {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.st.trusted, .st.confirmed, .st.manual_confirmed { color: var(--ok); }
.st.needs_review { color: var(--warn); }
.st.user_verified { color: var(--info); }
.st.unmeasured, .st.incomplete { color: #c9a99a; }
.st.calculated { color: var(--warn); }
.st.ready { color: var(--info); }
.st.finalized { color: #35d49f; }
.st.rejected { color: var(--bad); }

.final-takeoff-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--line);
}
.final-takeoff-head .bom-tag { padding: 0; }
.final-takeoff-head p { margin-bottom: 4px; }
.final-takeoff-head-actions { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.final-takeoff-head-actions button { padding: 5px 7px; font-size: 10px; }
.final-takeoff-head-actions select {
  max-width: 112px;
  padding: 5px 6px;
  border: 1px solid #3a3a3a;
  color: #fff;
  background: #0e0e0e;
  font-size: 10px;
}
.final-takeoff-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}
.final-takeoff-tools input,
.final-takeoff-tools select,
.final-takeoff-editor input,
.final-takeoff-editor select {
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid #3a3a3a;
  color: #fff;
  background: #0e0e0e;
}
.final-takeoff-columns,
.final-takeoff-row {
  display: grid;
  grid-template-columns: 52px minmax(96px, 1.4fr) 30px minmax(68px, .8fr) minmax(64px, .75fr) 70px;
  gap: 5px;
  align-items: center;
}
.final-takeoff-columns {
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.final-takeoff-list { flex: 1; min-height: 90px; overflow: auto; }
.final-takeoff-empty { padding: 12px; }
.final-takeoff-row {
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-bottom: 1px solid #222;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 10px;
}
.final-takeoff-row:hover { background: #1a1a1a; }
.final-takeoff-row.sel { background: #173229; outline: 1px solid #00a879; }
.final-takeoff-row.rejected { opacity: .6; }
.final-takeoff-row strong,
.final-takeoff-row .takeoff-section {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}
.takeoff-mark-section { min-width: 0; display: grid; }
.takeoff-mark-section small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.takeoff-length-cell { min-width: 0; display: grid; }
.takeoff-length-cell small {
  overflow: hidden;
  color: #79c9c4;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.final-takeoff-editor {
  max-height: 49%;
  padding: 10px;
  border-top: 1px solid #3a3a3a;
  overflow: auto;
  background: #141414;
}
.final-takeoff-editor label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10px;
}
.final-editor-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.final-editor-title strong { color: #fff; font: 700 12px "IBM Plex Mono", monospace; }
.final-editor-title button { padding: 4px 8px; }
.final-takeoff-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.final-takeoff-actions button { padding: 6px 8px; font-size: 10px; }
.takeoff-suggestions {
  margin: 2px 0 7px;
  padding: 7px;
  border-left: 2px solid var(--info);
  background: #10222b;
  line-height: 1.4;
}
.takeoff-key-hint { margin: 4px 0 8px; font-size: 10px; }
.takeoff-error { margin: 5px 0 8px; color: #ff9a82; font-size: 11px; }

.editor { display: flex; flex-direction: column; gap: 8px; padding: 12px; overflow: auto; }
.editor label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.verify-actions { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 8px; margin-top: 6px; }
.qa { margin: 0; padding: 8px 14px; overflow: auto; list-style: none; }
.qa li { margin: 0 0 12px; cursor: pointer; font-size: 13px; }
.export {
  display: flex;
  gap: 16px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
  font-weight: 700;
}
.export a { color: var(--orange); text-decoration: none; }
.muted { color: var(--muted); font-size: 12px; }

.busy {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: grid;
  place-items: center;
  z-index: 40;
}
.busy-card {
  background: #111;
  border: 1px solid var(--line);
  padding: 28px 32px;
  max-width: 420px;
}
.busy-card h2 { margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.04em; }
.progress-wrap {
  margin-top: 16px;
  height: 8px;
  background: #1a1a1a;
  border: 1px solid var(--line);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--orange);
  transition: width 0.35s ease;
}
#busy-pct { margin: 8px 0 0; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .board { height: auto; min-height: max(52vh, 560px); }
  .canvas-wrap { flex: 1 0 280px; min-height: 280px; }
  .intelligence-panel,
  .intelligence-panel.collapsed {
    width: auto;
    min-height: 220px;
    border-top: 1px solid var(--line);
    border-right: 0;
  }
  .intelligence-toggle {
    writing-mode: horizontal-tb;
    flex-basis: 44px;
    border-right: 1px solid var(--line);
  }
  .steps { display: none; }
}

/* Member QA: callouts that did not become members (explicit, never silent). */
.member-qa-group { color: #8a5a00; border-top: 1px dashed #b77900; margin-top: 10px; }
.member-qa-row { display: block; width: 100%; text-align: left; font: 12px 'IBM Plex Mono', monospace;
  padding: 4px 10px; border: 0; border-bottom: 1px solid #f0e2c4; background: #fffaf0; color: #5f4200; cursor: pointer; }
.member-qa-row:hover, .member-qa-row:focus-visible { background: #fdf0d2; }

/* S1 drawing profile: standard -> unit -> calibration (compact). */
.drawing-profile-card { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; align-items: start;
  margin: 0 0 8px; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; background: #f8fafc; font-size: 12px; }
.drawing-profile-card.compact { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; }
.drawing-profile-card.attention { border-color: #b77900; box-shadow: 0 0 0 3px rgba(183,121,0,.18); }
.drawing-profile-card .dp-step { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.drawing-profile-card .dp-step.locked { opacity: .55; }
.drawing-profile-card .dp-kicker { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #475569; }
.drawing-profile-card .dp-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.drawing-profile-card select { max-width: 100%; }
.drawing-profile-card .dp-hint { color: #64748b; }
.drawing-profile-card .dp-warning { grid-column: 1 / -1; margin: 0; padding: 5px 8px; border-radius: 6px; background: #fff7e6; color: #7a4d00; }
.drawing-profile-card .dp-message { grid-column: 1 / -1; margin: 0; color: #9a3412; min-height: 0; }
.drawing-profile-card .dp-catalog-READY { color: #15803d; }
.drawing-profile-card .dp-catalog-CATALOG_NOT_INSTALLED, .drawing-profile-card .dp-catalog-NO_CATALOG { color: #b45309; }
@media (max-width: 900px) { .drawing-profile-card { grid-template-columns: 1fr 1fr; } }

/* Pre-upload drawing standard chooser: unit follows the standard (read-only). */
.standard-unit-label { margin: 6px 0 0; font-weight: 600; min-height: 1.2em; }
.standard-planned { font-size: 12px; margin: 4px 0 0; }

/* A1 Visible Agent / Auto Cursor panel: compact; the drawing stays primary. */
.agent-panel { position: absolute; top: 10px; right: 10px; z-index: 30; width: 280px; max-height: min(calc(100% - 20px), 70%);
  overflow: auto; background: rgba(255, 255, 255, 0.97); border: 1px solid #e5b567; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); font-size: 12px; color: #1f2937; }
.agent-panel.hidden { display: none; }
.agent-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; background: #fffbeb;
  border-bottom: 1px solid #f3d9a4; border-radius: 8px 8px 0 0; }
.agent-head strong { color: #92400e; letter-spacing: 0.04em; }
.agent-state { font-weight: 600; }
.agent-units { margin-left: auto; color: #6b7280; font-size: 11px; }
.agent-chip { padding: 1px 6px; border-radius: 10px; font-size: 10px; font-weight: 700; }
.agent-high { background: #dcfce7; color: #166534; }
.agent-review { background: #fef3c7; color: #92400e; }
.agent-no_proposal { background: #fee2e2; color: #991b1b; }
.agent-body { padding: 8px 10px; }
.agent-row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.agent-row span { color: #6b7280; }
.agent-row b { text-align: right; font-weight: 600; }
.agent-scan-bar { height: 6px; margin: 4px 0 6px; border-radius: 3px; background: #e5e7eb; overflow: hidden; }
.agent-scan-bar i { display: block; height: 100%; background: #2563eb; transition: width .4s ease; }
.agent-reason { margin: 6px 0; color: #374151; }
.agent-actions, .agent-suggest, .agent-controls { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.agent-actions button, .agent-controls button, .agent-suggest button, .agent-actions a { font-size: 11px; padding: 4px 7px; }
.agent-section form { display: flex; gap: 4px; margin-top: 6px; }
.agent-section input { flex: 1; min-width: 0; font-size: 12px; padding: 3px 5px; }
.agent-controls { padding: 6px 10px 8px; border-top: 1px solid #f1f1f1; align-items: center; }
.agent-controls small { color: #92400e; }
.agent-message { min-height: 1em; margin: 4px 0 0; color: #b45309; }
.agent-panel.collapsed .agent-body, .agent-panel.collapsed .agent-controls { display: none; }
.agent-panel.collapsed { width: auto; max-width: 300px; }
.agent-toggle { border: 0; background: transparent; padding: 0 2px; cursor: pointer; color: #92400e; font-size: 12px; }

/* Guided motion (Auto Cursor): step text and pace control - calm, no flashing. */
.agent-step { margin: 6px 0 0; min-height: 1em; color: #92400e; font-style: italic; }
.agent-step.working::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%;
  background: #d97706; vertical-align: middle; animation: agent-pulse 1.6s ease-in-out infinite; }
@keyframes agent-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .agent-step.working::before { animation: none; } }
.agent-pace { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; }
.agent-pace button { font-size: 10px; padding: 2px 6px; border: 1px solid #e5b567; background: #fff; color: #92400e; border-radius: 10px; cursor: pointer; }
.agent-pace button.on { background: #d97706; color: #fff; border-color: #d97706; }

/* Drawing Processing card: per-sheet list, overall % and estimate */
.busy-sheets { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 4px; }
.busy-sheet { display: flex; justify-content: space-between; gap: 12px; padding: 4px 8px; border: 1px solid var(--line); font-size: 13px; }
.busy-sheet.complete b { color: #34d399; }
.busy-sheet.processing b { color: var(--orange); }
.busy-sheet.waiting b { color: #9ca3af; }
.busy-foot { display: flex; justify-content: space-between; gap: 12px; }
.drawing-context-menu button:disabled { opacity: 0.75; font-weight: 600; }
