:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #647180;
  --line: #d9e0e7;
  --brand: #183a5a;
  --brand-2: #f28c28;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(22, 34, 46, .08);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 76px; padding: 10px 18px; background: var(--brand); color: white; display: flex; align-items: center; justify-content: space-between; box-shadow: var(--shadow); z-index: 10; }
.topbar h1 { margin: 0; font-size: 24px; }
.eyebrow { font-size: 10px; letter-spacing: .14em; opacity: .72; font-weight: 700; }
.header-actions { display: flex; gap: 8px; }
button, .file-button { border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); padding: 8px 11px; font-weight: 650; transition: .15s ease; }
button:hover, .file-button:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,.08); }
.primary { background: var(--brand-2); border-color: var(--brand-2); color: #171717; }
.ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.35); }
.workspace { min-height: 0; flex: 1; display: grid; grid-template-columns: 250px minmax(540px, 1fr) 320px; }
.sidebar { background: var(--panel); overflow: auto; border-right: 1px solid var(--line); }
.right-panel { border-right: 0; border-left: 1px solid var(--line); }
.panel-section { padding: 16px; border-bottom: 1px solid var(--line); }
.panel-section h2 { font-size: 14px; margin: 0 0 12px; }
.section-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-row h2 { margin: 0; }
label { display: grid; gap: 5px; font-size: 11px; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
input, select { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: white; }
.mini { padding: 5px 7px; border-radius: 6px; font-size: 11px; }
.danger { color: var(--danger); }
.help-card ol { padding-left: 18px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.plan-area { display: flex; flex-direction: column; min-width: 0; }
.plan-toolbar, .measure-toolbar { height: 48px; background: white; display: flex; align-items: center; gap: 7px; padding: 7px 10px; border-bottom: 1px solid var(--line); overflow-x: auto; white-space: nowrap; }
.measure-toolbar { height: 46px; }
.plan-toolbar button, .measure-toolbar button, .file-button { padding: 7px 9px; font-size: 12px; }
.file-button { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; background: var(--brand); color: white; border-color: var(--brand); }
.file-button.large { padding: 10px 16px; }
.divider { width: 1px; height: 25px; background: var(--line); margin: 0 2px; }
.tool.active { background: var(--brand); color: white; border-color: var(--brand); }
.tool.emphasis { background: var(--brand-2); border-color: var(--brand-2); }
.scale-status { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--muted); padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; }
.canvas-scroller { flex: 1; min-height: 0; overflow: auto; padding: 24px; background: #c9d0d7; }
.canvas-stage { position: relative; width: max-content; min-width: 100%; min-height: 100%; display: flex; align-items: flex-start; justify-content: center; }
.canvas-stage canvas { position: absolute; left: 50%; top: 0; transform: translateX(-50%); box-shadow: 0 8px 30px rgba(0,0,0,.22); }
#overlayCanvas { z-index: 2; cursor: crosshair; }
.empty-state { margin: 13vh auto 0; width: min(420px, 80%); text-align: center; background: rgba(255,255,255,.92); padding: 38px; border-radius: 16px; box-shadow: var(--shadow); }
.empty-state h3 { margin: 14px 0 5px; }
.empty-state p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.empty-icon { width: 66px; height: 66px; border-radius: 14px; margin: 0 auto; display: grid; place-items: center; background: var(--brand); color: white; font-weight: 900; }
.conditions-list, .measurement-list, .totals-list { display: grid; gap: 7px; }
.condition-row, .measurement-row, .total-row { border: 1px solid var(--line); border-radius: 8px; padding: 9px; background: #fbfcfd; }
.condition-row { display: grid; grid-template-columns: 1fr auto; gap: 5px; }
.condition-name { font-size: 12px; font-weight: 800; }
.condition-meta { font-size: 10px; color: var(--muted); }
.icon-btn { border: 0; background: transparent; padding: 2px 5px; color: var(--danger); box-shadow: none; }
.measurement-row { display: grid; grid-template-columns: 1fr auto; gap: 5px; }
.measurement-title { font-size: 11px; font-weight: 800; }
.measurement-value { font-size: 12px; font-weight: 850; color: var(--brand); }
.measurement-meta { grid-column: 1 / -1; font-size: 10px; color: var(--muted); }
.total-row { display: grid; grid-template-columns: 1fr auto; gap: 3px; }
.total-name { font-size: 11px; font-weight: 800; }
.total-qty { font-size: 12px; font-weight: 850; }
.total-price { grid-column: 1 / -1; font-size: 10px; color: var(--muted); }
.grand-total { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--ink); font-size: 12px; }
.grand-total strong { font-size: 16px; }
.empty-list { color: var(--muted); font-size: 11px; text-align: center; padding: 12px 4px; }
dialog { border: 0; border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.3); width: min(430px, calc(100vw - 30px)); }
dialog::backdrop { background: rgba(18,26,34,.55); }
dialog h2 { margin-top: 0; }
dialog p { color: var(--muted); font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
dialog .ghost { color: var(--ink); border-color: var(--line); }
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 220px minmax(480px,1fr); }
  .right-panel { display: none; }
}
@media (max-width: 760px) {
  .workspace { display: block; }
  .left-panel { display: none; }
  .plan-area { height: calc(100vh - 76px); }
  .header-actions button:not(#saveBtn) { display: none; }
}

/* v0.3 editing + perimeter workflow */
.hidden-tool { display: none !important; }
.drawing-status { display: none; font-size: 11px; font-weight: 750; color: #0e6f7c; padding: 5px 8px; border: 1px solid #b8dfe4; background: #eefbfd; border-radius: 6px; }
.drawing-status.active { display: inline-flex; }
#overlayCanvas.select-cursor { cursor: default; }
.measurement-row.selected { border-color: #1493a5; box-shadow: 0 0 0 2px rgba(20,147,165,.12); background: #f2fbfc; }
.measurement-actions { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.measurement-actions .mini { font-size: 10px; padding: 4px 6px; }
.measurement-actions .deduction { color: #8a2b22; border-color: #efc8c3; background: #fff8f7; }
.deduction-list { grid-column: 1 / -1; display: flex; gap: 5px; flex-wrap: wrap; }
.deduction-chip { font-size: 9px; padding: 3px 6px; border-radius: 999px; border-color: #efc8c3; color: #8a2b22; background: #fff8f7; }

/* v1.0 productivity + project safety */
.title-row { display: flex; align-items: center; gap: 8px; }
.version-badge { font-size: 10px; font-weight: 850; letter-spacing: .04em; padding: 3px 6px; border-radius: 999px; background: rgba(255,255,255,.14); color: rgba(255,255,255,.9); }
.header-actions .header-file { background: transparent; color: white; border-color: rgba(255,255,255,.35); }
.condition-actions { display: flex; align-items: flex-start; gap: 1px; }
.icon-btn.edit { color: var(--brand); }
.page-jump { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; }
.page-jump input { width: 52px; padding: 5px 5px; text-align: center; font-size: 12px; border-radius: 6px; }
#undoBtn:disabled, #redoBtn:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }
#overlayCanvas.pan-cursor { cursor: grab; }
#overlayCanvas.grabbing-cursor { cursor: grabbing; }
.measurement-condition-label { grid-column: 1 / -1; margin: 3px 0 0; display: flex; align-items: center; gap: 6px; font-size: 9px; }
.measurement-condition-select { width: auto; min-width: 135px; max-width: 100%; padding: 4px 6px; font-size: 10px; border-radius: 5px; }
@media (max-width: 1250px) {
  .header-actions #backupBtn, .header-actions .header-file { display: none; }
}
