:root {
  color-scheme: light;
  --navy-950: #071b2f;
  --navy-900: #0b2d4f;
  --navy-800: #0b3a67;
  --blue-700: #075fae;
  --blue-600: #0a73cf;
  --blue-100: #dcebfa;
  --blue-50: #eef6fd;
  --ink: #172433;
  --muted: #637282;
  --line: #d6e0e9;
  --line-soft: #e8eef3;
  --surface: #ffffff;
  --canvas: #f6f8fa;
  --danger: #a93232;
  --shadow: 0 10px 35px rgba(17, 50, 79, 0.12);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }

body { background: #eaf0f5; color: var(--ink); }

button, input, select { font: inherit; }

button, .button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--navy-900);
  border-radius: 6px;
  min-height: 34px;
  padding: 0 11px;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

button:hover, .button:hover { border-color: #91afd0; background: var(--blue-50); }
button:active, .button:active { transform: translateY(1px); }
button:focus-visible, input:focus-visible, select:focus-visible, canvas:focus-visible { outline: 2px solid #58a9ef; outline-offset: 2px; }

.app-shell { height: 100%; display: grid; grid-template-rows: 64px minmax(0, 1fr); }

.topbar {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(240px, 360px) auto;
  align-items: center;
  gap: 20px;
  padding: 0 18px;
  background: var(--navy-950);
  color: white;
  border-bottom: 3px solid var(--blue-600);
  box-shadow: 0 3px 12px rgba(4, 20, 35, 0.28);
  z-index: 5;
}

.brand-block { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { width: 36px; height: 36px; border: 1px solid #57a8ea; display: grid; place-items: center; color: #9bd0fb; font-weight: 800; letter-spacing: -1px; }
.brand-block h1 { font-size: 18px; line-height: 1.05; margin: 1px 0 0; font-weight: 650; letter-spacing: .01em; }
.eyebrow, .section-label { margin: 0; font-size: 9px; font-weight: 750; letter-spacing: .15em; color: #7f9db9; }
.gate-badge { margin-left: 8px; border: 1px solid #376686; color: #b8d6eb; font-size: 9px; font-weight: 700; letter-spacing: .08em; padding: 5px 7px; border-radius: 3px; white-space: nowrap; }

.project-block { display: flex; align-items: center; gap: 8px; }
.project-block label { color: #98b3ca; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; }
.project-block input { width: 100%; color: white; background: rgba(255,255,255,.06); border: 1px solid #35536c; height: 34px; border-radius: 5px; padding: 0 10px; }

.action-bar { display: flex; align-items: center; gap: 6px; }
.action-bar button, .action-bar .button { height: 32px; min-height: 32px; display: inline-grid; place-items: center; background: #102f49; color: #dceaf5; border-color: #31516b; font-size: 12px; }
.action-bar button:hover, .action-bar .button:hover { background: #174b73; border-color: #5a8eb6; }
.action-bar .primary-action, .primary-action { background: #0877ce; border-color: #2f9cec; color: white; font-weight: 750; text-transform: uppercase; letter-spacing: .035em; }
.action-bar .primary-action:hover, .primary-action:hover { background: #0b65a8; border-color: #66b6ef; }
.icon-action { min-width: 34px; padding: 0; font-size: 18px; }
.separator { width: 1px; height: 25px; background: #34536d; margin: 0 3px; }

.workspace { min-height: 0; display: grid; grid-template-columns: 178px minmax(420px, 1fr) 292px; }

.tool-rail { background: #f9fbfc; border-right: 1px solid var(--line); overflow-y: auto; padding: 12px 10px 42px; }
.tool-rail section + section { margin-top: 17px; }
.tool-rail .section-label { padding: 0 8px 6px; }
.tool-button { width: 100%; height: 35px; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; text-align: left; padding: 0 8px; border: 1px solid transparent; background: transparent; color: #33475a; font-size: 12px; }
.tool-button > span { color: var(--blue-700); font-weight: 750; font-size: 15px; text-align: center; }
.tool-button[data-tool="indoor-unit"] > span, .tool-button[data-tool="outdoor-unit"] > span { font-size: 9px; color: white; background: var(--blue-700); padding: 4px 3px; border-radius: 2px; }
.tool-button kbd { font: 9px/1 "Segoe UI"; color: #8794a0; }
.tool-button:hover { background: #eef5fb; border-color: #d5e5f2; }
.tool-button.active { color: var(--navy-900); background: var(--blue-100); border-color: #9cc7eb; box-shadow: inset 3px 0 0 var(--blue-600); font-weight: 650; }
.file-tool { cursor: pointer; }
.planimetry-tools { padding: 8px 6px 10px; border: 1px solid #cfdae3; background: #f2f7fb; }
.planimetry-tools .section-label { padding-left: 2px; }
.plan-field { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 7px; color: #53697b; font-size: 9px; font-weight: 700; text-transform: uppercase; }
.plan-field span { display: flex; align-items: center; gap: 2px; color: #344b5e; }
.plan-field input { width: 62px; height: 27px; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; text-align: right; color: var(--ink); background: white; }
.opacity-field { display: grid; gap: 4px; margin-top: 8px; color: #53697b; font-size: 9px; font-weight: 700; text-transform: uppercase; }
.opacity-field input { width: 100%; accent-color: var(--blue-600); }
.plan-status { margin: 8px 0 5px; color: #65798a; font-size: 9px; line-height: 1.35; }
.plan-status.calibrated { color: #2f7652; font-weight: 700; }
.plan-remove { width: 100%; min-height: 28px; color: var(--danger); font-size: 10px; }

.drawing-area { min-width: 0; min-height: 0; display: grid; grid-template-rows: 44px minmax(0, 1fr) 27px; background: var(--canvas); }
.canvas-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px; background: white; border-bottom: 1px solid var(--line); }
.tool-status { display: flex; align-items: center; min-width: 0; gap: 8px; font-size: 11px; }
#activeToolDot { width: 7px; height: 7px; border-radius: 50%; background: var(--blue-600); }
.tool-status strong { color: var(--navy-900); }
.tool-status span:last-child { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-controls { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.view-controls label { display: flex; gap: 4px; align-items: center; }
.view-controls input { accent-color: var(--blue-600); }
.compact { min-width: 28px; min-height: 28px; height: 28px; padding: 0 8px; }
.compact.wide { min-width: 56px; }
#zoomValue { min-width: 38px; text-align: center; color: #3d5368; }

.canvas-wrap { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #f8fafb; }
#floorCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: default; }
.north-indicator { position: absolute; top: 18px; right: 18px; display: flex; flex-direction: column; align-items: center; color: var(--navy-900); pointer-events: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.09)); }
.north-indicator span { font-weight: 800; font-size: 12px; line-height: 1; }
.north-indicator svg { width: 25px; height: 37px; fill: var(--navy-900); stroke: white; stroke-width: 1px; }
.north-indicator small { margin-top: -3px; padding: 2px 4px; color: #526a7c; background: rgba(255,255,255,.9); border: 1px solid #dbe4eb; font-size: 8px; font-weight: 750; white-space: nowrap; }
.scale-indicator { position: absolute; left: 20px; bottom: 17px; color: #344b5e; display: flex; align-items: flex-end; gap: 7px; font-size: 10px; pointer-events: none; }
.scale-indicator span { display: block; width: 72px; height: 8px; border: solid #344b5e; border-width: 0 1px 1px; }
.empty-hint { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 6px; color: var(--muted); pointer-events: none; }
.empty-hint strong { color: var(--navy-900); }

.statusbar { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center; padding: 0 12px; background: #eef3f6; border-top: 1px solid var(--line); color: #67798a; font-size: 10px; }
.statusbar span:nth-child(2) { text-align: center; }
.statusbar span:nth-child(3) { text-align: right; }

.properties-panel { min-height: 0; background: white; border-left: 1px solid var(--line); display: flex; flex-direction: column; padding-bottom: 32px; }
.panel-heading { height: 58px; display: flex; justify-content: space-between; align-items: center; padding: 0 15px; border-bottom: 1px solid var(--line-soft); }
.panel-heading h2 { font-size: 15px; margin: 4px 0 0; color: var(--navy-900); }
.panel-heading .icon-action { background: transparent; border-color: transparent; color: var(--muted); }
.properties-content { min-height: 170px; overflow-y: auto; padding: 13px 15px; }
.blank-properties { min-height: 150px; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.5; }
.blank-properties p { max-width: 210px; }
.blank-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-50); color: var(--blue-700); font-size: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 9px; color: #708090; text-transform: uppercase; font-weight: 700; letter-spacing: .06em; }
.field input, .field select { width: 100%; height: 33px; border: 1px solid var(--line); border-radius: 5px; padding: 0 8px; color: var(--ink); background: white; font-size: 12px; }
.readonly-value { min-height: 33px; border: 1px solid var(--line-soft); background: #f7f9fb; border-radius: 5px; padding: 8px; color: #506274; font-size: 12px; }
.selection-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 10px 15px; border-top: 1px solid var(--line-soft); }
.selection-actions button { font-size: 11px; padding: 0 6px; }
.selection-actions .danger { color: var(--danger); }
.project-metrics { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 15px; }
.metrics-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 11px; }
.saved-state { color: #3e775a; background: #e8f5ed; padding: 3px 6px; border-radius: 3px; font-size: 9px; font-weight: 700; text-transform: uppercase; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.metric-grid div { background: white; padding: 8px; display: grid; gap: 3px; }
.metric-grid span { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.metric-grid strong { color: var(--navy-900); font-size: 13px; }
.margin-control { margin-top: 9px; padding: 7px 8px; border: 1px solid var(--line-soft); background: #f8fafb; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #657789; font-size: 9px; font-weight: 700; text-transform: uppercase; }
.margin-control span { display: flex; align-items: center; gap: 4px; color: #344b5e; }
.margin-control input { width: 48px; height: 26px; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; text-align: right; }
.gate-note { margin-top: 11px; padding: 9px; display: flex; gap: 8px; background: #f1f6fa; color: #516a7e; font-size: 10px; line-height: 1.45; }
.gate-note > span { flex: 0 0 auto; width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-700); color: white; font-size: 9px; font-weight: 800; }
.gate-note p { margin: 0; }

.toast { position: fixed; left: 50%; bottom: 38px; transform: translate(-50%, 16px); background: var(--navy-950); color: white; padding: 10px 14px; border-radius: 5px; box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; z-index: 20; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.version-indicator { position: fixed; right: 8px; bottom: 6px; z-index: 10; color: #677b8d; background: rgba(248,250,251,.92); border: 1px solid #d9e3ea; border-radius: 3px; padding: 3px 6px; font-size: 8px; font-weight: 750; letter-spacing: .06em; pointer-events: none; }

.analysis-shell { position: fixed; inset: 76px 22px 20px 190px; z-index: 15; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; background: #f5f8fa; border: 1px solid #b9cbd9; box-shadow: 0 18px 60px rgba(5, 25, 43, .28); }
.analysis-header { min-height: 74px; display: flex; justify-content: space-between; align-items: center; padding: 13px 18px; color: white; background: linear-gradient(105deg, #071b2f, #0b3a67); border-bottom: 3px solid #0a73cf; }
.analysis-header h2 { margin: 3px 0 1px; font-size: 20px; letter-spacing: .01em; }
.analysis-header p { margin: 0; color: #a8bfd3; font-size: 11px; }
.analysis-header-actions { display: flex; align-items: center; gap: 12px; }
.analysis-header .icon-action { color: white; background: #173d5b; border-color: #416785; }
.local-chip { color: #bde5cd; border: 1px solid #3f7e62; background: rgba(29,91,61,.3); padding: 5px 8px; border-radius: 3px; font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.analysis-metrics { display: grid; grid-template-columns: repeat(5, 1fr); background: white; border-bottom: 1px solid var(--line); }
.analysis-metrics > div { padding: 10px 15px; border-right: 1px solid var(--line-soft); display: grid; gap: 2px; }
.analysis-metrics span { font-size: 9px; color: var(--muted); text-transform: uppercase; font-weight: 700; letter-spacing: .05em; }
.analysis-metrics strong { color: var(--navy-900); font-size: 17px; }
.analysis-tabs { display: flex; gap: 2px; padding: 8px 14px 0; background: white; border-bottom: 1px solid var(--line); }
.analysis-tabs button { border: 0; border-radius: 0; background: transparent; color: #5b6f82; padding: 0 13px; min-height: 35px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-bottom: 3px solid transparent; }
.analysis-tabs button.active { color: #075fae; border-bottom-color: #0a73cf; }
.analysis-content { overflow: auto; padding: 16px; }
.analysis-footer { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 16px; background: white; border-top: 1px solid var(--line); }
.analysis-footer p { margin: 0; font-size: 9px; color: #8a5b18; font-weight: 750; letter-spacing: .05em; }
.analysis-footer > div { display: flex; gap: 7px; }
.analysis-footer button { font-size: 10px; }
.analysis-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.analysis-card { grid-column: span 4; background: white; border: 1px solid var(--line); border-top: 3px solid #0a73cf; box-shadow: 0 3px 10px rgba(14,44,70,.06); padding: 13px; min-width: 0; }
.analysis-card.wide { grid-column: span 8; }
.analysis-card.full { grid-column: 1 / -1; }
.analysis-card h3 { margin: 0 0 9px; color: var(--navy-900); font-size: 13px; }
.analysis-card h4 { margin: 12px 0 6px; color: #38546a; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.analysis-card p { margin: 5px 0; color: #5c7080; font-size: 11px; line-height: 1.45; }
.analysis-card .hero-value { font-size: 27px; color: #075fae; font-weight: 800; letter-spacing: -.03em; }
.analysis-table { width: 100%; border-collapse: collapse; background: white; font-size: 11px; }
.analysis-table th { position: sticky; top: 0; text-align: left; color: #66798b; background: #edf3f7; text-transform: uppercase; font-size: 8px; letter-spacing: .06em; padding: 8px; border: 1px solid #dce5ec; }
.analysis-table td { padding: 8px; border: 1px solid #e1e8ed; color: #344a5d; vertical-align: top; }
.analysis-table strong { color: var(--navy-900); }
.analysis-table tr[data-room-id] { cursor: pointer; }
.analysis-table tr[data-room-id]:hover td { background: #f0f7fc; }
.status-pill { display: inline-block; padding: 3px 6px; border-radius: 10px; font-size: 8px; font-weight: 800; letter-spacing: .04em; background: #e8f5ed; color: #27704a; }
.status-pill.warning { background: #fff0d5; color: #92611b; }
.status-pill.error { background: #fbe1df; color: #a33431; }
.score-bar { height: 7px; background: #e4ebf0; margin-top: 6px; }
.score-bar span { display: block; height: 100%; background: #0a73cf; }
.comparison { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.comparison > div { padding: 12px; border: 1px solid var(--line); background: #f8fafb; }
.comparison .recommended { border-left: 4px solid #2f8b5d; background: #f1f8f4; }
.warning-list { display: grid; gap: 6px; }
.warning-row { display: grid; grid-template-columns: 130px 70px 1fr; gap: 9px; align-items: center; padding: 7px 9px; background: white; border: 1px solid var(--line-soft); font-size: 10px; }
.source-list { display: grid; gap: 8px; }
.source-row { display: grid; grid-template-columns: minmax(150px, .7fr) minmax(240px, 1.3fr) 95px; gap: 10px; padding: 10px; background: white; border: 1px solid var(--line); font-size: 10px; }
.source-row a { color: #075fae; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.data-required { color: #9b6518; font-weight: 750; }

@media (max-width: 1100px) {
  .analysis-shell { inset: 70px 10px 14px 160px; }
  .analysis-card { grid-column: span 6; }
  .analysis-card.wide { grid-column: span 12; }
  .analysis-metrics { grid-template-columns: repeat(5, minmax(100px, 1fr)); overflow-x: auto; }
}

@media print {
  body > * { display: none !important; }
}

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 154px minmax(360px, 1fr) 260px; }
  .topbar { grid-template-columns: minmax(310px, 1fr) 260px auto; gap: 10px; padding: 0 10px; }
  .action-bar button:not(.icon-action), .action-bar .button { padding: 0 7px; font-size: 10px; }
  .gate-badge { display: none; }
}

@media (max-width: 820px) {
  .app-shell { min-width: 720px; }
  .properties-panel { position: absolute; right: 0; top: 64px; bottom: 0; width: 280px; z-index: 4; box-shadow: -8px 0 24px rgba(18,48,74,.12); }
  .workspace { grid-template-columns: 150px 1fr; padding-right: 280px; }
  .topbar { grid-template-columns: 1fr auto; }
  .project-block { display: none; }
}
