/* SIMTU Furniture Studio. Tokeny 1:1 z DESIGN.md v3.0 (SIMTU-Qt6). Nowy hex = błąd.
   Wyjątek świadomy: tekst główny 13 px zamiast 10 px, bo konfigurator czyta klient końcowy (PDF §14: WCAG 2.2 AA),
   a 16 px w polach na telefonie zapobiega automatycznemu powiększaniu w iOS. */
@font-face {
  font-family: Inter; src: url('../fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900; font-display: swap;
}

:root {
  --bg: #000008;
  --glass: rgba(29, 29, 29, .72);
  --glass-solid: #1D1D1D;
  --glass-deep: #050208;
  --line: rgba(255, 255, 255, .06);
  --line-2: rgba(255, 255, 255, .12);
  --hover: rgba(255, 255, 255, .03);
  --text: #ffffff;
  --muted: #9c9c9c;
  --very-muted: rgba(156, 156, 156, .55);
  --neutral: #e4e4e4;

  --a1: #e5058e; --a2: #824db7; --a3: #00adee; --mint: #00C7BE;
  --s-blue: #3B82F6; --s-amber: #F59E0B; --s-red: #EF4444; --s-green: #22C55E;

  /* White-label: stolarnia może nadpisać akcent CTA (PDF §8.2). */
  --cta: var(--a1);

  --sp1: 4px; --sp2: 8px; --sp3: 12px; --sp4: 16px; --sp6: 24px;
  --r-pill: 9999px; --r-card: 8px; --r-input: 6px; --r-win: 16px;
  --shadow: 0 15px 26px rgba(29, 29, 29, .2);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 400 13px/18px Inter, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--a3); }
.ic { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: -3px; }
.ic-14 { width: 14px; height: 14px; }
.ic-20 { width: 20px; height: 20px; }
:focus-visible { outline: 2px solid var(--a3); outline-offset: 1px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Szyba: każdy panel, karta i modal. Nigdy płaski solid. */
.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

/* ---------- Pasek górny ---------- */
.app { height: 100%; display: flex; flex-direction: column; padding: var(--sp1); gap: var(--sp1); }
.topbar { display: flex; align-items: center; gap: var(--sp3); min-height: 44px; padding: 0 var(--sp3); flex: none; }
.brand { display: flex; align-items: center; gap: var(--sp2); min-width: 0; text-decoration: none; }
.brand img { height: 18px; display: block; }
.brand .tenant { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: var(--sp2); border-left: 1px solid var(--line-2); }
.steps { display: flex; gap: 2px; margin: 0 auto; list-style: none; padding: 0; }
.steps button {
  background: none; border: 0; color: var(--muted); padding: 5px 10px; border-radius: var(--r-input);
  font-weight: 500; font-size: 11px; line-height: 14px; cursor: pointer; display: flex; gap: 6px; align-items: center; white-space: nowrap;
}
.steps button .n { width: 14px; height: 14px; border-radius: 4px; background: rgba(255, 255, 255, .08); display: inline-flex; align-items: center; justify-content: center; font-size: 9px; }
.steps button:hover:not(:disabled) { color: var(--text); }
.steps button[aria-current='step'] { background: var(--glass-solid); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.steps button.done .n { background: var(--s-green); color: #000008; }
.steps button:disabled { color: var(--very-muted); cursor: default; }
.top-actions { display: flex; gap: var(--sp1); align-items: center; }
.save-state { color: var(--very-muted); font-size: 10px; white-space: nowrap; }

/* ---------- Przyciski i kontrolki ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 30px; padding: 5px 10px;
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--r-input);
  color: var(--muted); font-weight: 500; font-size: 12px; line-height: 16px; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { color: var(--text); border-color: var(--line-2); }
.btn:disabled { color: var(--very-muted); cursor: default; }
.btn.primary { background: var(--cta); border-color: transparent; color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(.9); color: #fff; }
.btn.primary:disabled { opacity: .4; }
.btn.lg { min-height: 40px; padding: 8px 16px; font-size: 13px; }
.btn.icon { padding: 5px; min-width: 30px; }
.btn.danger:hover:not(:disabled) { color: var(--s-red); }
.btn.on { color: var(--text); background: var(--glass-solid); border-color: var(--line-2); }

.seg { display: inline-flex; background: var(--glass); border: 1px solid var(--line); border-radius: var(--r-input); padding: 2px; gap: 2px; }
.seg button { background: none; border: 0; color: var(--muted); padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; line-height: 16px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.seg button:hover:not(:disabled) { color: var(--text); }
.seg button[aria-pressed='true'] { background: var(--glass-solid); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg button:disabled { color: var(--very-muted); cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: var(--sp1); min-width: 0; }
.field > span, .lbl { color: var(--muted); font-size: 11px; font-weight: 500; line-height: 14px; }
.input, select.input, textarea.input {
  width: 100%; background: rgba(5, 2, 8, .6); border: 1px solid var(--line-2); border-radius: var(--r-input);
  padding: 6px 8px; color: var(--text); min-height: 30px; outline: none;
}
.input::placeholder { color: var(--muted); }
.input:focus { border-color: rgba(229, 5, 142, .4); box-shadow: 0 0 0 1px rgba(229, 5, 142, .4); }
.input[aria-invalid='true'] { border-color: var(--s-red); }
select.input option { background: var(--glass-solid); }
.hint { color: var(--muted); font-size: 11px; line-height: 14px; }
.err { color: var(--s-red); font-size: 11px; line-height: 14px; }

.check { display: flex; gap: var(--sp2); align-items: flex-start; cursor: pointer; color: var(--neutral); }
.check input { accent-color: var(--a3); margin: 2px 0 0; width: 14px; height: 14px; flex: none; }

/* Suwak + pole liczbowe: ta sama komenda domenowa (PDF §6.3). */
.ctl { display: grid; grid-template-columns: 1fr 76px; gap: 2px var(--sp2); align-items: center; }
.ctl .ctl-l { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: var(--sp2); color: var(--muted); font-size: 11px; font-weight: 500; line-height: 14px; }
.ctl input[type='range'] { width: 100%; accent-color: var(--a3); height: 18px; margin: 0; }
.num { position: relative; }
.num input { width: 100%; background: rgba(5, 2, 8, .6); border: 1px solid var(--line-2); border-radius: var(--r-input); padding: 3px 22px 3px 6px; min-height: 26px; text-align: right; font-variant-numeric: tabular-nums; outline: none; appearance: textfield; -moz-appearance: textfield; }
.num input::-webkit-outer-spin-button, .num input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num input:focus { border-color: rgba(229, 5, 142, .4); }
.num i { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--very-muted); font-size: 10px; pointer-events: none; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: var(--r-pill); font-size: 10px; font-weight: 500; line-height: 14px; white-space: nowrap; }
.pill.amber { background: var(--s-amber); color: #000008; }
.pill.red { background: var(--s-red); color: #fff; }
.pill.green { background: var(--s-green); color: #000008; }
.pill.blue { background: var(--s-blue); color: #fff; }
.pill.grey { background: rgba(156, 156, 156, .24); color: var(--neutral); }

/* ---------- Strony formularzy ---------- */
.main { flex: 1; min-height: 0; display: flex; }
.page { flex: 1; overflow: auto; padding: var(--sp4) var(--sp3) var(--sp6); }
.page-in { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--sp3); }
.page-head { display: flex; flex-direction: column; gap: var(--sp1); padding: var(--sp2) 0; }
.page-head h1 { font-size: 22px; line-height: 28px; font-weight: 600; letter-spacing: -.01em; }
.page-head p { color: var(--muted); max-width: 720px; }
.eyebrow { color: var(--a3); font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; line-height: 14px; }
.card { padding: var(--sp3); display: flex; flex-direction: column; gap: var(--sp3); }
.card > h2 { font-size: 13px; line-height: 18px; font-weight: 500; }
.grid { display: grid; gap: var(--sp1); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid { display: grid; gap: var(--sp3); grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.page-actions { display: flex; justify-content: space-between; gap: var(--sp2); align-items: center; padding-top: var(--sp2); flex-wrap: wrap; }

.tpl {
  text-align: left; padding: 0; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; color: var(--text);
  transition: border-color .12s;
}
.tpl:hover { border-color: var(--line-2); }
.tpl-plan { background: #f5f4f1; aspect-ratio: 4 / 3; display: block; border-radius: 6px 6px 0 0; }
.tpl-plan svg { display: block; width: 100%; height: 100%; }
.tpl-b { padding: var(--sp2) var(--sp3) var(--sp3); display: flex; flex-direction: column; gap: 2px; }
.tpl-b b { font-weight: 500; }
.tpl-b span { color: var(--muted); font-size: 11px; line-height: 14px; }

.choice { display: flex; flex-wrap: wrap; gap: var(--sp1); }
.choice button { background: var(--glass); border: 1px solid var(--line); border-radius: var(--r-input); color: var(--muted); padding: 5px 10px; cursor: pointer; font-size: 12px; font-weight: 500; line-height: 16px; }
.choice button:hover { color: var(--text); }
.choice button[aria-pressed='true'] { color: var(--text); background: var(--glass-solid); border-color: var(--a3); }

.dim-row { display: grid; grid-template-columns: 1fr auto; gap: var(--sp2); align-items: end; }

/* ---------- Przestrzeń robocza ---------- */
.work { flex: 1; min-height: 0; display: grid; gap: var(--sp1); grid-template-columns: 276px minmax(0, 1fr) 276px; }
.side { overflow: auto; display: flex; flex-direction: column; gap: var(--sp1); min-height: 0; }
.panel { padding: var(--sp3); display: flex; flex-direction: column; gap: var(--sp3); }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: var(--sp2); }
.panel-h h2, .panel-h h3 { font-size: 13px; line-height: 18px; font-weight: 500; }
.stack { display: flex; flex-direction: column; gap: var(--sp2); }
.row { display: flex; gap: var(--sp1); align-items: center; flex-wrap: wrap; }
.row.tight { gap: 2px; }
details.panel > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; font-weight: 500; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: '+'; color: var(--muted); }
details.panel[open] > summary::after { content: '−'; }

.stage-col { display: flex; flex-direction: column; gap: var(--sp1); min-height: 0; min-width: 0; }
.stage-bar { display: flex; align-items: center; gap: var(--sp1); flex-wrap: wrap; padding: var(--sp1); }
.stage-bar .gap { flex: 1; }
.stage {
  position: relative; flex: 1; min-height: 240px; border-radius: var(--r-card); overflow: hidden; border: 1px solid var(--line);
  background: var(--glass-deep); touch-action: none;
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage svg.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; font-family: Inter, sans-serif; }
.overlay .dim line { stroke: #141416; stroke-width: 1.25; }
.overlay .arw { fill: #141416; }
.overlay .dim-t { font-size: 12px; font-weight: 600; fill: #000008; paint-order: stroke; stroke: rgba(255, 255, 255, .9); stroke-width: 3.5px; stroke-linejoin: round; }
.overlay .dim-sub { font-size: 10px; fill: #2a2a2e; paint-order: stroke; stroke: rgba(255, 255, 255, .85); stroke-width: 3px; }
.overlay .sel { fill: rgba(0, 173, 238, .14); stroke: var(--a3); stroke-width: 2; }
.overlay .grip { pointer-events: auto; cursor: grab; }
.overlay .grip-hit { stroke: transparent; stroke-width: 12; }
.overlay .grip-knob { fill: #fff; stroke: #141416; stroke-width: 1; opacity: 0; transition: opacity .1s; }
.overlay .grip:hover .grip-knob, .overlay .grip:focus .grip-knob { opacity: 1; }
.overlay .grip:hover .grip-hit, .overlay .grip:focus .grip-hit { stroke: rgba(0, 173, 238, .5); stroke-width: 3; }
.overlay .grip:focus { outline: none; }
.plan2d { position: absolute; inset: 0; background: #f5f4f1; }
.plan2d text { user-select: none; }
.sheet-host { position: absolute; inset: 0; overflow: auto; background: var(--glass-deep); padding: var(--sp3); touch-action: pan-x pan-y; }
.sheet-host svg { display: block; margin: 0 auto; max-width: 100%; height: auto; border-radius: var(--r-card); box-shadow: var(--shadow); }
.stage-tip { position: absolute; left: var(--sp2); bottom: var(--sp2); color: #141416; font-size: 10px; line-height: 14px; background: rgba(255, 255, 255, .72); padding: 2px 6px; border-radius: 4px; pointer-events: none; }
.busy { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp2); background: rgba(0, 0, 8, .82); color: var(--muted); font-size: 12px; z-index: 3; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--a3); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } * { transition: none !important; scroll-behavior: auto !important; } }

.assistant { padding: var(--sp1); display: flex; flex-direction: column; gap: var(--sp1); }
.assistant form { display: flex; gap: var(--sp1); }
.assistant .tag { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 10px; padding: 0 var(--sp1); white-space: nowrap; }
.chips { display: flex; gap: 2px; flex-wrap: wrap; padding: 0 var(--sp1); }
.chip { background: none; border: 1px solid var(--line); border-radius: var(--r-pill); color: var(--muted); padding: 0 7px; font-size: 10px; line-height: 16px; cursor: pointer; }
.chip:hover { color: var(--text); border-color: var(--line-2); }
.diff { padding: var(--sp2); display: flex; flex-direction: column; gap: var(--sp1); background: rgba(5, 2, 8, .7); border-radius: var(--r-input); border: 1px solid var(--line-2); }
.diff ul { margin: 0; padding-left: 16px; color: var(--neutral); }

/* Materiały */
.swatches { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--sp1); }
.swatch { aspect-ratio: 1; border-radius: var(--r-input); border: 1px solid var(--line-2); cursor: pointer; padding: 0; position: relative; }
.swatch[aria-pressed='true'] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--a3); }
.swatch-name { display: flex; justify-content: space-between; gap: var(--sp2); font-size: 11px; line-height: 14px; }
.swatch-name span { color: var(--muted); }

/* Układy */
.layout { padding: var(--sp3); display: flex; flex-direction: column; gap: var(--sp2); cursor: pointer; text-align: left; color: var(--text); }
.layout:hover { border-color: var(--line-2); }
.layout[aria-pressed='true'] { border-left: 2px solid var(--a3); background: rgba(29, 29, 29, .92); }
.layout .t { font-size: 13px; font-weight: 500; }
.layout p { color: var(--muted); font-size: 11px; line-height: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp1); }
.stat b { display: block; font-size: 14px; line-height: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 10px; line-height: 14px; }

/* Ostrzeżenia */
.issues { display: flex; flex-direction: column; gap: 2px; }
.issue { display: flex; gap: var(--sp2); padding: var(--sp1) 0; font-size: 11px; line-height: 14px; color: var(--neutral); text-align: left; background: none; border: 0; }
.issue[data-node] { cursor: pointer; }
.issue .ic { margin-top: 0; }
.issue.error .ic { color: var(--s-red); }
.issue.warn .ic { color: var(--s-amber); }
.issue.info .ic { color: var(--muted); }

/* Cena */
.price b { font-size: 22px; line-height: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.price small { color: var(--muted); font-size: 11px; line-height: 14px; display: block; }
.reason { display: flex; justify-content: space-between; gap: var(--sp2); font-size: 11px; line-height: 14px; color: var(--muted); padding: 2px 0; }

/* Zapytanie */
.lead-grid { display: grid; gap: var(--sp1); grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
.lead-preview { background: #f5f4f1; border-radius: var(--r-input); overflow: hidden; display: block; }
.lead-preview img, .lead-preview svg { display: block; width: 100%; height: auto; }
.summary { display: grid; grid-template-columns: auto 1fr; gap: 2px var(--sp3); font-size: 12px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; }
.ok-box { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp2); padding: var(--sp4); }
.ok-box .ic { color: var(--s-green); width: 28px; height: 28px; }

.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); padding: 8px 12px; z-index: 20; display: flex; gap: var(--sp2); align-items: center; max-width: calc(100vw - 24px); background: var(--glass-solid); }
.toast.bad { border-color: var(--s-red); }
.banner { padding: var(--sp2) var(--sp3); display: flex; gap: var(--sp2); align-items: center; color: var(--neutral); font-size: 11px; line-height: 14px; }
.banner .ic { color: var(--s-amber); }

/* ---------- Mobile-first odwrotnie: poniżej 980 px układ pionowy ---------- */
@media (max-width: 980px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100%; }
  .topbar { flex-wrap: wrap; padding: var(--sp2); }
  .topbar nav { order: 3; width: 100%; min-width: 0; overflow-x: auto; }
  .steps { margin: 0; width: max-content; }
  .steps button { padding: 6px 8px; }
  .save-state { display: none; }
  .main { display: block; }
  .page { overflow: visible; padding: var(--sp2) var(--sp1) var(--sp4); }
  .work { display: flex; flex-direction: column; }
  .side { overflow: visible; }
  .stage { min-height: 62vh; flex: none; height: 62vh; }
  .stage-col { order: -1; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: minmax(0, 1fr); }
  .lead-grid { grid-template-columns: minmax(0, 1fr); }
  .input, .num input, select.input, textarea.input { font-size: 16px; }
  .btn { min-height: 36px; }
  .seg button { padding: 6px 9px; }
}
@media (max-width: 420px) {
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .brand .tenant { display: none; }
}

@media print {
  body { background: #fff; overflow: visible; }
  body > *:not(.print-host) { display: none !important; }
  .print-host { display: block !important; }
  .print-host svg { width: 100%; height: auto; }
  @page { margin: 8mm; }
}
.print-host { display: none; }
