:root {
  color-scheme: light;
  --blue: #0867d1;
  --blue-dark: #0754a8;
  --blue-soft: #eaf4ff;
  --ink: #172238;
  --muted: #6d778a;
  --line: #dce2eb;
  --panel: #ffffff;
  --canvas: #eef3f8;
  --danger: #cf3346;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(32, 49, 77, .14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-width: 0; width: 100%; max-width: 100%; height: 100%; overflow: hidden; background: #f4f7fb; color: var(--ink); }
button, input, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

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

.topbar, .bottombar {
  position: relative; z-index: 20; background: rgba(255,255,255,.98); border-color: var(--line); display: flex; align-items: center;
}
.topbar { padding: 10px 16px; border-bottom: 1px solid #bdcad8; gap: 18px; background: linear-gradient(90deg, #d9e5f1 0%, #e7eef6 38%, #f5f8fb 72%, #ffffff 100%); box-shadow: 0 3px 12px rgba(31,49,75,.08); }
.bottombar { padding: 8px 16px; border-top: 1px solid var(--line); justify-content: space-between; gap: 18px; }

.brand { display: flex; align-items: center; min-width: 214px; gap: 9px; }
.brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; color: white; background: linear-gradient(145deg, #1085ec, #0754a8); border-radius: 12px; font-weight: 900; box-shadow: 0 5px 15px rgba(8,103,209,.28); }
.brand-v { display: block; font-size: 28px; line-height: 1; text-align: center; transform: translateY(-.5px); }
.brand-copy { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.brand-title { color: var(--ink); font-size: 18px; line-height: 1.05; font-weight: 850; letter-spacing: -.02em; white-space: nowrap; }
.brand-copy small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1; white-space: nowrap; }

.global-controls { display: flex; align-items: center; justify-content: center; flex: 1; gap: 8px; min-width: 0; }
.global-controls > label:not(.toggle) { display: flex; align-items: center; gap: 6px; }
.global-controls > label:not(.toggle), .form-grid label { color: var(--muted); font-size: 12px; font-weight: 750; letter-spacing: .02em; text-transform: uppercase; }
.global-controls input, .global-controls select { height: 34px; margin-top: 0; background: #fff; }
.global-controls label > select { display: block; min-width: 110px; margin-top: 0; }
.global-controls .unit-field { margin-top: 0; background: #fff; }
.project-actions, .history-actions, .delivery-actions { display: flex; align-items: center; gap: 7px; }

input, select {
  border: 1px solid #cfd7e3; border-radius: 7px; background: #fff; padding: 0 9px; color: var(--ink); outline: 0; min-width: 0; font-size: 14px;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(8,103,209,.12); }
input[type="number"] { width: 86px; }

.unit-field { display: inline-flex; align-items: center; height: 34px; border: 1px solid #cfd7e3; background: white; border-radius: 7px; overflow: hidden; }
.unit-field:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(8,103,209,.12); }
.unit-field input { border: 0 !important; box-shadow: none !important; height: 100%; margin: 0; }
.unit-field b { color: var(--muted); font-size: 12px; padding-right: 8px; text-transform: none; }

button { border: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
.primary-button, .compact-button, .danger-button { min-height: 36px; padding: 0 14px; border-radius: 8px; font-weight: 750; white-space: nowrap; }
.primary-button { color: white; background: var(--blue); }
.primary-button:hover { background: var(--blue-dark); }
.compact-button { background: #fff; border: 1px solid #cfd7e3; }
.compact-button:hover { border-color: #9eacc0; background: #f8fafc; }
.danger-button { color: white; background: var(--danger); }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid #cfd7e3; background: #fff; border-radius: 8px; font-size: 20px; }

.toggle { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); font-size: 14px; font-weight: 700; white-space: nowrap; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle input + span { position: relative; flex: 0 0 34px; width: 34px; height: 19px; border-radius: 20px; background: #bdc5d1; transition: .2s; }
.toggle input + span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 13px; height: 13px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.toggle input:checked + span { background: var(--blue); }
.toggle input:checked + span::after { transform: translateX(15px); }

.workspace { min-height: 0; display: grid; grid-template-columns: 154px minmax(0, 1fr) 286px; }
.toolbox, .properties { background: var(--panel); min-height: 0; overflow: hidden; }
.toolbox { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.properties { position: relative; border-left: 1px solid var(--line); }
.properties.has-selection { box-shadow: inset 3px 0 0 var(--blue); }
.properties.has-selection .panel-heading { background: linear-gradient(90deg, rgba(8,103,209,.08), rgba(8,103,209,0) 72%); }
.properties.property-panel-attention::after { content:""; position:absolute; inset:0; z-index:8; pointer-events:none; border:3px solid rgba(8,103,209,.72); box-shadow: inset 0 0 0 1px rgba(255,255,255,.7), inset 0 0 28px rgba(8,103,209,.14); animation: property-panel-attention 1.55s ease-out 1; }
.properties.property-panel-attention .panel-heading { animation: property-heading-attention 1.55s ease-out 1; }
.panel-heading { min-height: 54px; padding: 11px 13px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; }
.panel-heading span { font-size: 13px; font-weight: 850; }
.panel-heading small { color: var(--muted); font-size: 12px; margin-top: 2px; }

.tool-list { padding: 9px; display: grid; gap: 7px; }
.tool { min-height: 62px; display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 7px; text-align: left; border: 1px solid var(--line); background: white; border-radius: 9px; padding: 5px 7px; user-select: none; }
.tool:hover, .tool.dragging { border-color: var(--blue); background: var(--blue-soft); transform: translateY(-1px); box-shadow: 0 5px 14px rgba(8,103,209,.11); }
.tool b { font-size: 13px; line-height: 1.25; }
.tool.accent { border-color: #b9d8f7; background: #f2f8ff; }
.tool-icon { position: relative; display: block; width: 42px; height: 42px; border: 1px solid #d9e2ec; border-radius: 7px; background-color: #f5f8fb; background-position: center; background-repeat: no-repeat; background-size: contain; overflow: hidden; }
.icon-glass { background-image: url('thumbnails/glass-section.png'); }
.icon-door { background-image: url('thumbnails/single-door.png'); }
.icon-double-door { background-image: url('thumbnails/double-door.png'); }
.icon-wall::before { content:""; position:absolute; inset:6px 12px; background:repeating-linear-gradient(0deg,#687589 0 6px,#8996a8 6px 7px); border-radius:2px; }
.icon-gap::before { content:""; position:absolute; left:7px; right:7px; top:20px; border-top:2px dashed #7791aa; }
.icon-gap::after { content:"↔"; position:absolute; inset:5px; display:grid; place-items:center; color:#4b6f94; font-size:22px; }
.icon-run::before { content:""; position:absolute; width:25px; height:25px; border-left:4px solid var(--blue); border-bottom:4px solid var(--blue); left:9px; top:7px; }
.icon-run::after { content:"➜"; position:absolute; color:var(--blue); font-size:20px; right:2px; bottom:0; transform:rotate(-90deg); }
.toolbox-help { margin-top: auto; }
.video-help-button { width: calc(100% - 18px); min-height: 40px; margin: 0 9px 7px; padding: 0 13px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--blue-dark); background: linear-gradient(180deg, #ffffff 0%, #f1f7ff 100%); border: 1px solid #b9d8f7; border-radius: 10px; font-size: 12px; font-weight: 800; letter-spacing: .01em; box-shadow: 0 3px 10px rgba(8,103,209,.10); cursor: pointer; transition: color .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.video-help-icon { width: 17px; height: 17px; flex: 0 0 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.video-help-button:hover { color: #fff; background: linear-gradient(180deg, #167ce4 0%, var(--blue) 100%); border-color: var(--blue); box-shadow: 0 6px 15px rgba(8,103,209,.20); transform: translateY(-1px); }
.video-help-button:active { transform: translateY(0); box-shadow: 0 2px 7px rgba(8,103,209,.14); }
.video-help-button:focus-visible { outline: 3px solid rgba(8,103,209,.18); outline-offset: 2px; }
.toolbox-tip { margin: 0 9px 10px; padding: 9px; color: #52647b; background: #f4f7fa; border-radius: 8px; font-size: 11px; line-height: 1.45; }

.stage { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(260px, 1fr) 146px; background: var(--canvas); }
.viewport { position: relative; min-height: 0; overflow: hidden; background: radial-gradient(circle at 50% 43%, #f8fafc 0, #e9f0f6 52%, #d8e2ec 100%); }
#scene { display: block; width: 100%; height: 100%; outline: 0; }
.view-toolbar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; padding: 3px; gap: 2px; border: 1px solid rgba(185,197,211,.85); background: rgba(255,255,255,.9); border-radius: 9px; box-shadow: 0 5px 18px rgba(31,49,75,.12); backdrop-filter: blur(8px); }
.view-toolbar button { min-height: 29px; padding: 0 10px; background: transparent; border-radius: 6px; color: #536176; font-size: 13px; font-weight: 750; }
.view-toolbar button:hover, .view-toolbar button.active { background: var(--blue); color: white; }
.view-toolbar .camera-button { width: 31px; min-width: 31px; padding: 0; display: grid; place-items: center; }
.view-toolbar .camera-button svg { width: 17px; height: 17px; display: block; }
.view-toolbar .camera-button:disabled { opacity: .55; cursor: wait; }
.view-clean-toggle { min-height: 29px; padding: 0 7px; display: inline-flex; align-items: center; gap: 5px; color: #536176; border-radius: 6px; font-size: 11px; font-weight: 750; white-space: nowrap; cursor: pointer; user-select: none; }
.view-clean-toggle:hover { background: #eef5fd; color: var(--blue-dark); }
.view-clean-toggle input { width: 14px; height: 14px; margin: 0; accent-color: var(--blue); cursor: pointer; }
.view-clean-toggle span { line-height: 1; }
.view-help { position: absolute; bottom: 10px; left: 12px; padding: 5px 8px; color: #68768b; background: rgba(255,255,255,.76); border-radius: 6px; font-size: 11px; pointer-events: none; }
.empty-state { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; pointer-events: none; color: #53647a; text-align: center; }
.empty-state h2 { margin: 10px 0 3px; font-size: 17px; }
.empty-state p { margin: 0; font-size: 11px; }
.empty-illustration { width: 80px; height: 56px; border: 4px solid #98a8bb; background: rgba(116,196,236,.14); box-shadow: 25px 11px 0 -8px #fff, 25px 11px 0 -4px #b6c2d1; transform: perspective(180px) rotateY(-22deg); }
.toast { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); padding: 9px 13px; border-radius: 8px; background: #172238; color: #fff; font-size: 11px; box-shadow: var(--shadow); }

.assembly-panel { min-width: 0; border-top: 1px solid var(--line); background: #fff; display: grid; grid-template-rows: 38px minmax(0, 1fr); }
.assembly-heading { display: flex; align-items: center; justify-content: space-between; padding: 5px 12px; border-bottom: 1px solid #edf0f4; gap: 10px; }
.assembly-heading > div:first-child { display: flex; gap: 9px; align-items: baseline; }
.assembly-heading strong { font-size: 13px; }
.assembly-heading span { color: var(--muted); font-size: 11px; }
.run-tabs { display: flex; gap: 4px; overflow-x: auto; }
.run-tab { min-height: 26px; padding: 0 7px 0 10px; border-radius: 6px; background: #f0f3f7; color: #5f6d80; font-size: 11px; font-weight: 750; white-space: nowrap; display:flex; align-items:center; gap:5px; cursor:pointer; }
.run-tab.active { color: white; background: var(--blue); }
.run-tab > button { width:17px; height:17px; padding:0; border-radius:5px; color:inherit; background:rgba(255,255,255,.22); line-height:1; }
.assembly { min-width: 0; display: flex; align-items: center; overflow-x: auto; padding: 8px 12px; gap: 0; }
.assembly::-webkit-scrollbar, .property-form::-webkit-scrollbar { height: 7px; width: 7px; }
.assembly::-webkit-scrollbar-thumb, .property-form::-webkit-scrollbar-thumb { background: #c9d2de; border-radius: 10px; }
.insert-zone { flex: 0 0 22px; align-self: stretch; min-height: 62px; display: grid; place-items: center; border-radius: 7px; color: var(--blue); font-size: 18px; font-weight: 400; }
.insert-zone::before { content:"+"; display:grid; place-items:center; width:18px; height:32px; border:1px dashed #9ec5ec; border-radius:8px; background:#f4f9ff; opacity:.45; }
.insert-zone:hover::before, .insert-zone.drag-over::before { opacity:1; background:#ddecff; border:2px solid var(--blue); }
.assembly-item { position: relative; flex: 0 0 auto; min-width: 82px; max-width: 145px; height: 72px; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 5px 10px; border: 1px solid #cdd6e1; background: #fff; border-radius: 8px; cursor: grab; user-select:none; }
.assembly-item:hover, .assembly-item.selected { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(8,103,209,.12); }
.assembly-item.selected { background: var(--blue-soft); }
.assembly-item .mini-icon { width: 43px; height: 34px; position: relative; border: 1px solid #d9e2ec; border-radius: 4px; background-color: #f5f8fb; background-position: center; background-repeat: no-repeat; background-size: contain; }
.assembly-item[data-type="glass"] .mini-icon { background-image: url('thumbnails/glass-section.png'); }
.assembly-item[data-type="door"] .mini-icon { background-image: url('thumbnails/single-door.png'); }
.assembly-item[data-type="doubleDoor"] .mini-icon { background-image: url('thumbnails/double-door.png'); }
.assembly-item[data-type="wall"] .mini-icon { background:#7c8797; border-color:#647184; width:18px; }
.assembly-item[data-type="gap"] .mini-icon { border-style:dashed; background:transparent; }
.assembly-item b { max-width: 120px; margin-top: 3px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size: 11px; }
.assembly-item small { color:var(--muted); font-size:10px; }

.property-empty { height: calc(100% - 54px); display: grid; place-content: center; justify-items:center; padding: 24px; color: var(--muted); text-align:center; }
.property-empty-icon { display:grid; place-items:center; width:48px; height:48px; border-radius:50%; background:#f0f4f8; font-size:22px; }
.property-empty p { max-width:190px; font-size:13px; line-height:1.5; }
.property-form { height: calc(100% - 54px); overflow-y:auto; padding: 12px; }
.property-selection-hint { margin: 0 0 12px; padding: 8px 10px; border: 1px solid #c9def5; border-radius: 7px; color: #315f8d; background: #eef6ff; font-size: 11px; line-height: 1.4; }
.property-section { display:grid; grid-template-columns:1fr 1fr; gap:9px; margin-bottom:14px; }
.property-section h3 { grid-column:1/-1; margin:0; padding-bottom:6px; border-bottom:1px solid #edf0f4; font-size:13px; }
.property-section h3.property-run-heading { color: var(--blue); font-size: 14px; font-weight: 800; border-bottom-color: #c9def5; }
.property-section.compact-readout-section { gap: 6px; margin-bottom: 10px; }
.property-readout { grid-column:1/-1; display:flex; align-items:baseline; justify-content:space-between; gap:8px; color:#52647b; font-size:11px; line-height:1.35; }
.property-readout span { color:var(--muted); }
.property-readout strong { color:var(--ink); font-size:12px; font-weight:750; text-align:right; }
.compact-readout-section .property-readout { justify-content:flex-start; }
.compact-readout-section .property-readout strong { text-align:left; }
.property-form label { display:flex; flex-direction:column; gap:4px; color:var(--muted); font-size:11px; font-weight:750; text-transform:uppercase; }
.property-form label.wide, .form-grid .wide { grid-column:1/-1; }
.property-form input, .property-form select { width:100%; height:34px; }
.property-form.has-selected-item input:not([type="checkbox"]):not(:disabled),
.property-form.has-selected-item select:not(:disabled),
.property-form.has-selected-item .unit-field { border-color: #b9d4f1; background: #f5faff; }
.property-form.has-selected-item .unit-field input:not(:disabled) { background: transparent; }
.property-form input:disabled, .property-form select:disabled { color: #7c8798; background: #f1f3f6; }
.property-primary-field > input,
.property-primary-field > select,
.property-primary-field > .unit-field { transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease; }
.property-primary-field.property-attention-pulse > input,
.property-primary-field.property-attention-pulse > select,
.property-primary-field.property-attention-pulse > .unit-field { animation: property-attention-pulse 1.65s ease-out 1; }
.property-form .toggle { flex-direction:row; align-items:center; color:var(--ink); font-size:12px; text-transform:none; }

@keyframes property-attention-pulse {
  0%, 16%, 32%, 48%, 64%, 100% { border-color: #b9d4f1; box-shadow: 0 0 0 0 rgba(8,103,209,0); background: #f5faff; }
  8%, 24%, 40%, 56% { border-color: #d99600; box-shadow: 0 0 0 5px rgba(255,193,7,.31); background: #fff0a8; }
}

@keyframes property-panel-attention {
  0% { opacity: 0; }
  12%, 52% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes property-heading-attention {
  0%, 100% { background: linear-gradient(90deg, rgba(8,103,209,.08), rgba(8,103,209,0) 72%); }
  20%, 55% { background: linear-gradient(90deg, rgba(8,103,209,.22), rgba(8,103,209,.04) 80%); }
}

@media (prefers-reduced-motion: reduce) {
  .properties.property-panel-attention::after { animation: none; opacity: 1; }
  .properties.property-panel-attention .panel-heading { animation: none; background: linear-gradient(90deg, rgba(8,103,209,.22), rgba(8,103,209,.04) 80%); }
  .property-primary-field.property-attention-pulse > input,
  .property-primary-field.property-attention-pulse > select,
  .property-primary-field.property-attention-pulse > .unit-field { animation: none; border-color: #e0a000; box-shadow: 0 0 0 3px rgba(255,193,7,.24); background: #fff3b8; }
}
.property-actions { display:grid; grid-template-columns:1fr 1fr; gap:7px; }
.property-actions button { min-height:34px; border-radius:7px; background:#f0f3f7; font-size:12px; font-weight:750; }
.property-actions .delete { color:var(--danger); background:#fff0f2; }

.history-actions { min-width: 245px; }
.save-state { color: var(--muted); font-size: 11px; }
.totals { display: flex; justify-content: center; flex: 1; gap: 26px; }
.totals span { display: flex; flex-direction: column; align-items: center; }
.totals small { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.totals strong { margin-top: 2px; font-size: 15px; }

.backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(18,29,46,.45); backdrop-filter: blur(2px); }
.dialog { position: fixed; z-index: 100; top: 50%; left: 50%; transform: translate(-50%,-50%); width: min(92vw, 620px); max-height: min(82dvh, 720px); overflow:hidden; background:#fff; border-radius:13px; box-shadow:0 24px 80px rgba(16,28,47,.28); }
.side-dialog { left: auto; right: 18px; top: 84px; bottom: 76px; transform:none; width:350px; max-height:none; }
.small-dialog { width:min(92vw, 430px); }
.wide-dialog { width:min(92vw, 720px); }
.dialog > header { min-height:64px; display:flex; align-items:center; justify-content:space-between; gap:15px; padding:12px 16px; border-bottom:1px solid var(--line); }
.dialog h2 { margin:0; font-size:18px; }
.dialog header p { margin:3px 0 0; color:var(--muted); font-size:12px; }
.dialog-close { width:32px; height:32px; border-radius:8px; background:#f0f3f7; font-size:20px; }
.dialog-content { max-height:calc(82dvh - 130px); padding:16px; overflow-y:auto; }
.side-dialog .dialog-content { max-height:calc(100% - 121px); }
.dialog > footer { min-height:57px; display:flex; align-items:center; justify-content:flex-end; gap:8px; padding:10px 16px; border-top:1px solid var(--line); }
.dialog footer .dialog-close { width:auto; height:36px; }
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:13px; }
.form-grid label { display:flex; flex-direction:column; gap:5px; }
.form-grid input, .form-grid select { width:100%; height:38px; margin:0; }
.form-grid .toggle { flex-direction:row; align-items:center; color:var(--ink); font-size:13px; text-transform:none; }
.info-card { grid-column:1/-1; padding:11px; border-radius:8px; color:#496178; background:#eef6ff; font-size:12px; line-height:1.5; }
.placement-offset-box { grid-column:1/-1; padding:10px; border:1px solid #d8e2ef; border-radius:8px; background:#f8fbff; display:grid; gap:9px; }
.placement-offset-box > label { margin:0; }
.placement-reference-row { display:flex; align-items:center; flex-wrap:wrap; gap:8px 14px; color:var(--ink); font-size:12px; text-transform:none; }
.placement-reference-row > b { color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.02em; }
.form-grid .placement-reference-choice { display:inline-flex; flex-direction:row; align-items:center; gap:6px; margin:0; color:var(--ink); font-size:12px; font-weight:700; text-transform:none; cursor:pointer; }
.placement-reference-choice input { width:auto; height:auto; min-height:0; margin:0; accent-color:var(--blue); }
.placement-reference-choice input:disabled + * { opacity:.55; }
.saved-project-list { display:grid; gap:8px; }
.saved-project { display:grid; grid-template-columns:1fr auto; gap:10px; padding:11px 12px; border:1px solid var(--line); border-radius:9px; }
.saved-project strong, .saved-project small { display:block; }
.saved-project-title { display:flex; align-items:center; gap:6px; min-width:0; }
.saved-project-title strong { min-width:0; }
.offer-lock-icon { display:inline-flex; align-items:center; justify-content:center; flex:0 0 auto; font-size:12px; line-height:1; }
.saved-project small { color:var(--muted); margin-top:3px; font-size:11px; }
.saved-project-actions { display:flex; gap:6px; align-items:center; }
.saved-project-actions button { min-height:30px; padding:0 10px; border-radius:6px; background:#edf3f8; font-size:11px; font-weight:750; }
.saved-project-actions .delete { color:var(--danger); background:#fff0f2; }
.empty-list { padding:30px; text-align:center; color:var(--muted); font-size:13px; }
.quote-table { width:100%; border-collapse:collapse; font-size:12px; }
.quote-table th, .quote-table td { padding:8px 7px; border-bottom:1px solid #edf0f4; text-align:left; }
.quote-table th:last-child, .quote-table td:last-child { text-align:right; }
.quote-table th { color:var(--muted); font-size:10px; text-transform:uppercase; }
.quote-warning { margin-top:14px; padding:11px; border:1px solid #f1d28d; border-radius:8px; background:#fff8e8; color:#6b5421; font-size:12px; line-height:1.5; }

@media (max-height: 760px) {
  .app-shell { grid-template-rows: 64px minmax(0,1fr) 58px; }
  .topbar { padding-block: 7px; }
  .brand-mark { width:38px; height:38px; }
  .brand-title { font-size:17px; }
  .stage { grid-template-rows:minmax(230px,1fr) 126px; }
  .tool { min-height:54px; }
  .tool-icon { width:36px; height:36px; }
  .toolbox-tip { display:none; }
  .side-dialog { top:74px; bottom:68px; }
}

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 138px minmax(0,1fr) 260px; }
  .brand { min-width:194px; }
  .brand-copy small { font-size:9px; }
  .save-state { display:none; }
  .history-actions { min-width:0; }
  .global-controls { gap:5px; }
  .global-controls .compact-button { padding-inline:8px; }
  .delivery-actions .compact-button { padding-inline:9px; }
}

.footer-price{display:inline-flex;align-items:baseline;gap:5px;padding:0 8px;white-space:nowrap}.footer-price small{opacity:.72}.footer-price strong{font-size:1rem}.footer-price b{font-size:.82rem;font-weight:600}

/* Sparad offert ar last tills den aktivt lases upp. */
.project-readonly .insert-zone { pointer-events: none; opacity: .2; }
.project-readonly .assembly-item { cursor: pointer; }
.project-locked .properties { background: #f7f9fc; }
.project-locked .property-form input:disabled,
.project-locked .property-form select:disabled { opacity: .78; }

/* v65.4: riktig mobil/tablet-layout. Touch-enheter far mobilayout aven om webblasaren rapporterar desktopbredd. */
@media (max-width: 1023px), (hover: none) and (pointer: coarse) and (max-width: 1366px) {
  html, body {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-text-size-adjust: 100%;
  }

  body { background: #f4f7fb; }

  .app-shell {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 100dvh;
    grid-template-rows: auto auto auto;
    overflow: visible;
  }

  .topbar {
    position: relative;
    top: auto;
    z-index: 40;
    width: 100%;
    max-width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) 10px 9px;
    overflow: visible;
  }

  .brand {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    justify-content: flex-start;
    gap: 8px;
  }

  .brand-mark { width: 38px; height: 38px; border-radius: 10px; }
  .brand-v { font-size: 25px; }
  .brand-title { font-size: 17px; }
  .brand-copy small { margin-top: 3px; font-size: 9px; }

  .global-controls {
    width: 100%;
    max-width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    justify-content: stretch;
    gap: 7px;
  }

  .global-controls > * { min-width: 0; max-width: 100%; }

  .global-controls > label:not(.toggle) {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(118px, 42%) minmax(0, 1fr);
    align-items: center;
    gap: 7px;
    font-size: 10px;
  }

  .global-controls > label:not(.toggle) .unit-field,
  .global-controls > label:not(.toggle) > select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .global-controls input,
  .global-controls select,
  .global-controls .unit-field { width: 100%; max-width: 100%; height: 42px; }
  .global-controls input[type="number"] { width: 100%; }
  .global-controls label > select { min-width: 0; }

  .global-controls .toggle,
  .global-controls .compact-button {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 42px;
    justify-content: flex-start;
    font-size: 12px;
  }

  .global-controls .compact-button { justify-content: center; }

  .workspace {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: visible;
  }

  .workspace > .toolbox,
  .workspace > .stage,
  .workspace > .properties {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .toolbox {
    order: 1;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }

  .toolbox .panel-heading {
    min-height: 46px;
    padding: 8px 10px 6px;
  }

  .tool-list {
    width: 100%;
    max-width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 7px 10px 9px;
    overflow: visible;
  }

  .tool {
    width: 100%;
    min-width: 0;
    max-width: none;
    min-height: 58px;
    grid-template-columns: 38px minmax(0, 1fr);
    padding: 5px 7px;
  }

  .tool-icon { width: 36px; height: 36px; }
  .tool b { min-width: 0; font-size: 12px; line-height: 1.2; overflow-wrap: anywhere; }
  .toolbox-tip { display: block; margin: 0 10px 10px; padding: 7px 9px; font-size: 10px; }

  .stage {
    order: 2;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    grid-template-rows: clamp(340px, 58dvh, 520px) 146px;
    overflow: hidden;
  }

  .viewport {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 340px;
    overflow: hidden;
  }

  #scene {
    display: block;
    width: 100% !important;
    max-width: 100%;
    height: 100% !important;
    touch-action: none;
  }

  .view-toolbar {
    top: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    transform: none;
    justify-content: center;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .view-toolbar::-webkit-scrollbar { display: none; }
  .view-toolbar button { min-height: 36px; padding-inline: 10px; }
  .view-help { display: none; }

  .assembly-panel,
  .assembly-heading,
  .assembly {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .assembly-heading {
    gap: 8px;
    overflow: hidden;
  }

  .run-tabs {
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .assembly {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .properties {
    order: 3;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 210px;
    border-left: 0;
    border-top: 1px solid var(--line);
    overflow: visible;
    scroll-margin-top: 12px;
  }

  .properties .panel-heading { min-height: 50px; }
  .property-empty { height: auto; min-height: 150px; }
  .property-form { width: 100%; height: auto; max-height: none; overflow: visible; padding: 12px 10px 16px; }
  .property-form input,
  .property-form select,
  .property-actions button { min-height: 44px; }

  .property-section { gap: 9px; }

  .bottombar {
    position: relative;
    z-index: 20;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
    overflow: visible;
  }

  .history-actions {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    justify-content: center;
  }

  .icon-button { width: 44px; height: 44px; }

  .delivery-actions {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .delivery-actions > button {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 46px;
    padding-inline: 10px;
    white-space: normal;
    line-height: 1.2;
  }

  .footer-price {
    width: 100%;
    max-width: 100%;
    grid-column: 1;
    justify-content: center;
    min-height: 38px;
    padding: 4px 8px;
  }

  .dialog,
  .small-dialog,
  .wide-dialog,
  .side-dialog {
    left: 8px;
    right: 8px;
    top: 8px;
    bottom: auto;
    width: auto;
    max-width: none;
    max-height: calc(100dvh - 16px);
    transform: none;
    border-radius: 11px;
  }

  .dialog > header { min-height: 58px; padding: 10px 12px; }
  .dialog-content,
  .side-dialog .dialog-content { max-height: calc(100dvh - 132px); padding: 12px; }
  .dialog > footer { min-height: 56px; padding: 8px 12px; }
  .dialog-close { min-width: 40px; min-height: 40px; }

  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .form-grid .wide,
  .info-card { grid-column: 1; }
  .form-grid input,
  .form-grid select { min-height: 44px; }

  .saved-project { grid-template-columns: 1fr; }
  .saved-project-actions { width: 100%; flex-wrap: wrap; }
  .saved-project-actions button { min-height: 40px; }
}

@media (max-width: 440px) {
  .topbar { padding-inline: 8px; }
  .global-controls > label:not(.toggle) { grid-template-columns: 112px minmax(0, 1fr); }
  .stage { grid-template-rows: clamp(330px, 56dvh, 460px) 136px; }
  .viewport { min-height: 330px; }
  .property-section { grid-template-columns: 1fr; }
  .property-section h3,
  .property-form label.wide { grid-column: 1; }
  .property-readout { grid-column: 1; }
  .property-actions { grid-template-columns: 1fr 1fr; }
}

/* v65.6: blockera kalkylatorn tydligt när kundinloggning saknas */
.login-required-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 31, 49, .72);
  backdrop-filter: blur(5px);
}
.login-required-card {
  width: min(620px, 100%);
  padding: 34px 30px 30px;
  border: 2px solid rgba(8, 103, 209, .28);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
  text-align: center;
}
.login-required-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 38px;
  line-height: 1;
  font-weight: 900;
}
.login-required-card h1 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.05;
}
.login-required-card p {
  max-width: 520px;
  margin: 0 auto 24px;
  color: #4d5b70;
  font-size: clamp(16px, 2.4vw, 20px);
  line-height: 1.45;
}
.login-required-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 50px;
  margin-top: 10px;
  text-decoration: none;
  font-size: 16px;
}
body.login-required #app {
  pointer-events: none;
  user-select: none;
}
@media (max-width: 600px) {
  .login-required-overlay { padding: 12px; }
  .login-required-card { padding: 26px 18px 20px; border-radius: 14px; }
  .login-required-mark { width: 56px; height: 56px; font-size: 32px; }
}

/* v69.10: instruktionsfilmen fyller tillganglig skarmyta utan intern scrollning. */
.video-dialog {
  left: 50%;
  right: auto;
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: min(98vw, 1800px, calc(153.6vh - 102.4px));
  width: min(98vw, 1800px, calc(153.6dvh - 102.4px));
  height: auto;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  max-height: calc(100dvh - 16px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.video-dialog > header {
  flex: 0 0 64px;
  min-height: 64px;
}
.video-dialog .video-dialog-content {
  flex: 0 1 auto;
  width: 100%;
  min-height: 0;
  max-height: calc(96vh - 64px);
  max-height: calc(96dvh - 64px);
  aspect-ratio: 8 / 5;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
.video-dialog video {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #000;
}

