/* Kreator 3D. Kolory z tokenów; przy publikacji podmieniamy tylko ten blok (barwy firmy). */
:root {
  --brand: #0d3b66;
  --brand-ink: #ffffff;
  --accent: #ff7a1a;
  --accent-ink: #ffffff;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #18212b;
  --muted: #5d6b78;
  --line: #dde3e9;
  --soft: #eef2f6;
  --ok: #1f9d63;
  --err: #d23b3f;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(16, 32, 48, .12);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* Pasek górny */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--brand); color: var(--brand-ink); }
.brand { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 12px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.steps { display: flex; gap: 4px; margin: 0 auto; }
.steps button { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border: 0; border-radius: 999px; background: transparent; color: inherit; opacity: .7; font-weight: 600; }
.steps button span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid currentColor; font-size: 12px; }
.steps button.on { opacity: 1; background: rgba(255, 255, 255, .14); }
.steps button.on span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.top-actions { display: flex; gap: 4px; }
.topbar .icon-btn { color: var(--brand-ink); border-color: rgba(255, 255, 255, .3); }

/* Układ */
.layout { flex: 1; display: grid; grid-template-columns: 380px 1fr; min-height: 0; }
.panel { overflow-y: auto; padding: 16px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.stage { position: relative; min-height: 0; overflow: hidden; }
.canvas-host { position: absolute; inset: 0; }
.canvas-host canvas { display: block; touch-action: none; }
.stage.placing .canvas-host canvas { cursor: crosshair; }

/* Karty i kontrolki */
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--panel); display: flex; flex-direction: column; gap: 10px; }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 122, 26, .12); }
.card h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card h4 { margin: 6px 0 0; font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 13px; margin: 0; }
.fine { font-size: 12px; color: var(--muted); margin: 0; }
.tip { font-size: 13px; color: var(--muted); margin: 0; }
.note { font-size: 13px; background: #fff6e8; border: 1px solid #f6d7a7; padding: 8px 10px; border-radius: 8px; margin: 0; }
.intro h2 { margin: 0 0 6px; font-size: 21px; }
.intro p { margin: 0; color: var(--muted); }
.or { text-align: center; color: var(--muted); font-size: 13px; margin: 0; }

button.primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 11px 14px; font-weight: 700; }
button.primary:hover:not(:disabled) { filter: brightness(1.06); }
button.block { width: 100%; }
.next { margin-top: auto; }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: transparent; font-size: 17px; line-height: 1; }

.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions button { flex: 1 1 auto; padding: 7px 10px; border: 1px solid var(--line); background: var(--soft); border-radius: 8px; font-size: 13px; font-weight: 600; }
.row-actions button.danger { color: var(--err); }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
input, select, textarea { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 400; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.two input, .two select { width: 100%; }
.check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 400; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.check span { display: flex; flex-direction: column; }
.check small { color: var(--muted); }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 700; font-size: 14px; }
.pill small { font-weight: 400; color: var(--muted); font-size: 11px; }
.pill.on { border-color: var(--accent); background: #fff3ea; box-shadow: inset 0 0 0 1px var(--accent); }

.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.type-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.type-card.on { border-color: var(--accent); background: #fff3ea; box-shadow: inset 0 0 0 1px var(--accent); }
.type-ico { width: 44px; height: 32px; flex: none; }
.card h3 .type-ico { width: 32px; height: 23px; }

/* Szablony */
.templates { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tpl { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 4px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.tpl:hover { border-color: var(--accent); }
.tpl small { color: var(--muted); font-size: 12px; }
.tpl-meta { font-size: 11px; color: var(--brand); font-weight: 700; }
.plan { width: 100%; height: 70px; background: var(--soft); border-radius: 6px; margin-bottom: 4px; }
.plan rect { stroke: #fff; stroke-width: 1.2; }
.plan-office { fill: #3a7bd5; } .plan-sanitary { fill: #16a394; } .plan-corridor { fill: #c58b1b; }
.plan-empty { fill: none; stroke: #9aa7b3 !important; stroke-dasharray: 4 3; }
.plan text { font-size: 22px; fill: #9aa7b3; }
.plan .plan-lv { font-size: 9px; fill: var(--brand); font-weight: 700; }

/* Ściany */
.walls { display: flex; flex-direction: column; gap: 6px; }
.wall-row { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 6px; }
.wall-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.slots { display: flex; gap: 3px; }
.slot { display: grid; place-items: center; min-width: 0; height: 42px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.slot:hover { border-color: var(--accent); }
.slot.active { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.slot.internal { background: repeating-linear-gradient(45deg, #f1f3f5, #f1f3f5 4px, #e3e7eb 4px, #e3e7eb 8px); cursor: help; }
.slot.internal span { font-size: 10px; color: var(--muted); }
.el-ico { height: 30px; max-width: 100%; }
.el-ico .p { fill: #f4f4f1; stroke: #9aa5ae; }
.el-ico .g { fill: #bcd6ea; stroke: #6c7a86; }
.el-ico .sh { fill: #d9d9d4; }
.el-ico .d { fill: #8b98a3; stroke: #56626c; }
.el-ico .k { fill: #fff; }
.el-ico .l { stroke: #6c7a86; }

/* Kolory */
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; background: var(--c); box-shadow: 0 0 0 1px var(--line); }
.sw.on { box-shadow: 0 0 0 2px var(--accent); }
.extras { display: grid; grid-template-columns: 1fr; gap: 8px; }

/* Podsumowanie */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stats div { background: var(--soft); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; }
.stats b { font-size: 16px; }
.stats span { font-size: 11px; color: var(--muted); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl td { padding: 5px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl td:first-child { width: 34%; color: var(--muted); }
.tbl:not(.spec) td:first-child { width: 44px; color: var(--ink); font-weight: 700; }
.tbl tr.sub td { color: var(--muted); font-weight: 400; }
.price { display: flex; flex-direction: column; background: var(--brand); color: var(--brand-ink); border-radius: 8px; padding: 10px 12px; }
.price b { font-size: 22px; }
.price small { opacity: .8; }
.form-error { color: var(--err); font-size: 13px; margin: 0; }
#enquiry { display: flex; flex-direction: column; gap: 10px; }
.card.done { text-align: center; }

/* Scena: narzędzia */
.stage-tools { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.stage-tools > * { pointer-events: auto; }
.seg { display: flex; background: rgba(255, 255, 255, .92); border-radius: 8px; box-shadow: var(--shadow); padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 11px; border-radius: 6px; font-weight: 600; font-size: 13px; }
.seg button.on { background: var(--brand); color: var(--brand-ink); }
.tool-btn { border: 0; background: rgba(255, 255, 255, .92); box-shadow: var(--shadow); padding: 7px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; }
.placing-bar { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; background: var(--ink); color: #fff; padding: 8px 10px 8px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; max-width: calc(100% - 24px); }
.placing-bar[hidden] { display: none; }
.placing-bar .tool-btn { box-shadow: none; color: var(--ink); }
.placing-hint { color: #9ff0c4; }
.placing-hint.err { color: #ffb3b5; }
.placing-hint:empty { display: none; }
kbd { font-size: 11px; border: 1px solid #aaa; border-radius: 4px; padding: 0 4px; margin-left: 4px; color: var(--muted); }
.hud { position: absolute; left: 12px; bottom: 12px; background: rgba(255, 255, 255, .92); padding: 7px 12px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; }
.help { position: absolute; right: 12px; bottom: 12px; font-size: 12px; color: var(--muted); background: rgba(255, 255, 255, .75); padding: 5px 9px; border-radius: 6px; }
.hint { position: absolute; left: 50%; bottom: 60px; transform: translate(-50%, 10px); background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 8px; font-size: 13px; opacity: 0; transition: .2s; pointer-events: none; max-width: calc(100% - 32px); text-align: center; }
.hint.show { opacity: 1; transform: translate(-50%, 0); }

/* Wybór elementu ściany */
.popover { position: fixed; z-index: 20; width: 270px; max-height: 70vh; overflow-y: auto; background: #fff; border-radius: 10px; box-shadow: 0 10px 40px rgba(16, 32, 48, .25); padding: 6px; }
.popover[hidden] { display: none; }
.pop-head { font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; }
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; padding: 6px 8px; border-radius: 7px; }
.pop-item:hover { background: var(--soft); }
.pop-item.on { background: #fff3ea; }
.pop-item .el-ico { flex: none; }
.pop-item span { display: flex; flex-direction: column; font-size: 13px; }
.pop-item small { color: var(--muted); font-size: 11px; }

/* Telefon */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .steps { order: 3; width: 100%; justify-content: space-between; }
  .steps button { padding: 6px 8px; font-size: 13px; }
  .layout { grid-template-columns: 1fr; grid-template-rows: 46vh 1fr; }
  .stage { order: 1; }
  .panel { order: 2; border-right: 0; border-top: 1px solid var(--line); padding: 12px 16px; }
  .help { display: none; }
  .templates { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* Wydruk / PDF */
.print-only { display: none; }
@media print {
  .app, .popover { display: none !important; }
  .print-only { display: block; font-size: 12px; }
  .print-only img { width: 100%; border: 1px solid #ccc; margin: 8px 0; }
  .print-only table { border-collapse: collapse; margin: 6px 0 12px; }
  .print-only td { padding: 3px 12px 3px 0; border-bottom: 1px solid #ddd; }
  .print-only h1 { font-size: 20px; margin: 0; }
}

/* ---------- Etap 2 ---------- */
.variants { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.variant { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.variant b { font-size: 13px; }
.variant small { font-size: 11px; color: var(--muted); line-height: 1.3; }
.variant.on { border-color: var(--accent); background: #fff3ea; box-shadow: inset 0 0 0 1px var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { flex-direction: row; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; font-weight: 600; font-size: 12px; cursor: pointer; background: #fff; }
.chip input { accent-color: var(--accent); margin: 0; }
.chip.on { border-color: var(--accent); background: #fff3ea; }
textarea[data-notes] { width: 100%; resize: vertical; }
.ref { font-size: 12px; font-weight: 700; color: var(--brand); background: var(--soft); padding: 3px 8px; border-radius: 6px; }
.notes { margin: 0; padding-left: 18px; font-size: 13px; }
.el-ico .pt { fill: #d6dadf; stroke: #8a949c; }
.el-ico .id { fill: #f4f4f1; stroke: #8a949c; }
.el-ico .dk { fill: #555; }
.el-ico .op { fill: none; stroke: #9aa5ae; stroke-dasharray: 3 3; }
.slot.internal { background: repeating-linear-gradient(45deg, #f1f3f5, #f1f3f5 4px, #e3e7eb 4px, #e3e7eb 8px); cursor: pointer; }
.tool-btn.on { background: var(--brand); color: var(--brand-ink); }

/* Rzut 2D */
.plan-host { position: absolute; inset: 0; background: #fbfbf8; display: grid; place-items: stretch; }
.plan-host svg { width: 100%; height: 100%; }
.stage.plan-mode .compass, .stage.plan-mode .help { display: none; }
.pl-mod { fill: #eef3f8; stroke: #1d2a36; stroke-width: 3; cursor: pointer; }
.pl-office { fill: #eaf1fb; } .pl-sanitary { fill: #e6f6f3; } .pl-corridor { fill: #fbf3e3; }
.pl-mod.pl-sel { stroke: var(--accent); stroke-width: 4; }
.pl-label { font: 600 13px system-ui, sans-serif; fill: #1d2a36; pointer-events: none; }
.pl-sub { font: 11px system-ui, sans-serif; fill: #5d6b78; pointer-events: none; }
.pl-empty { font: 15px system-ui, sans-serif; fill: #5d6b78; }
.pl-gap { stroke: #fbfbf8; stroke-width: 5; }
.pl-win { stroke: #3b82c4; stroke-width: 2.5; }
.pl-door { stroke: #1d2a36; stroke-width: 1.5; }
.pl-swing { fill: none; stroke: #1d2a36; stroke-width: 1; stroke-dasharray: 3 3; }
.pl-open { stroke: #fbfbf8; stroke-width: 5; stroke-dasharray: 6 4; }
.pl-wall { stroke: #1d2a36; stroke-width: 4; }
.pl-dim { stroke: #5d6b78; stroke-width: 1; }
.pl-dimt { font: 600 12px system-ui, sans-serif; fill: #1d2a36; }
.pl-north { fill: var(--accent); }

/* Kompas */
.compass { position: absolute; right: 14px; top: 60px; width: 46px; height: 46px; background: rgba(255, 255, 255, .92); border-radius: 50%; box-shadow: var(--shadow); pointer-events: none; }
.compass svg { width: 100%; height: 100%; }
.c-ring { fill: none; stroke: var(--line); stroke-width: 1.5; }
.c-n { fill: var(--accent); }
.c-t { font: 700 8px system-ui, sans-serif; fill: var(--ink); }
#compassNeedle { transform-box: view-box; transform-origin: 0 0; }

@media print {
  .print-only .plan-svg { width: 100%; height: auto; border: 1px solid #ccc; margin-bottom: 8px; }
  .print-plans h3 { margin: 10px 0 4px; font-size: 14px; }
  .print-plans { break-before: page; }
}
/* Pole-pułapka na boty: człowiek go nie widzi. */
.hp { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
