:root {
  --ink: #1f2933;
  --muted: #6b7680;
  --line: #dde2e6;
  --paper: #ffffff;
  --bg: #f4f5f2;
  --accent: #f2b705;
  --usednal: #c62828;
  --neusednal: #262626;
  --nechlen: #1565c0;
  --free: #2e7d32;
  --service: #9aa3ab;
  --radius: 12px;
  font-family: 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%; }
body { background: var(--bg); overflow: hidden; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* ---------- вход ---------- */
body.login {
  align-items: center; justify-content: center; padding: 16px; overflow: auto;
  background:
    radial-gradient(circle at 20% 15%, rgb(242 183 5 / .18), transparent 45%),
    radial-gradient(circle at 85% 90%, rgb(198 40 40 / .16), transparent 45%),
    radial-gradient(rgb(255 255 255 / .07) 1px, transparent 1.4px) 0 0 / 22px 22px,
    #1f2933;
}
.login-box {
  width: 100%; max-width: 360px; background: var(--paper); padding: 36px 28px 30px;
  border-radius: 22px; box-shadow: 0 24px 60px rgb(0 0 0 / .35);
  display: flex; flex-direction: column; gap: 14px; text-align: center;
  animation: rise .35s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.login-box.has-error { animation: shake .4s ease-in-out; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.login-logo { align-self: center; border-radius: 16px; box-shadow: 0 6px 18px rgb(31 41 51 / .25); }
.login-box h1 { font-size: 26px; margin: 6px 0 6px; letter-spacing: -.01em; }
.pw-field { position: relative; }
.pw-field input {
  width: 100%; padding: 15px 50px 15px 16px; border: 1.5px solid var(--line); border-radius: 12px;
  font-size: 17px; background: #f8f9fa; transition: border-color .15s, background .15s, box-shadow .15s;
}
.pw-field input:focus { outline: none; border-color: var(--ink); background: #fff; box-shadow: 0 0 0 4px rgb(242 183 5 / .3); }
.has-error .pw-field input { border-color: var(--usednal); }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px;
  border: 0; background: none; color: var(--muted); border-radius: 10px; display: grid; place-items: center;
}
.pw-toggle:hover, .pw-toggle.on { color: var(--ink); background: var(--bg); }
.login-btn {
  padding: 15px; border: 0; border-radius: 12px; background: var(--accent); color: var(--ink);
  font-size: 17px; font-weight: 700; transition: transform .1s, filter .15s;
}
.login-btn:hover { filter: brightness(1.05); }
.login-btn:active { transform: scale(.98); }
.err { color: var(--usednal); margin: 0; font-size: 14px; }

/* ---------- горна лента ---------- */
.top {
  background: var(--ink); color: #fff; padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  display: flex; flex-direction: column; gap: 8px; z-index: 3;
}
.top .row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.top h1 { font-size: 15px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.logout { color: #aeb8c2; font-size: 13px; text-decoration: none; margin-left: auto; white-space: nowrap; }

.search { position: relative; flex: 1 1 200px; min-width: 0; max-width: 340px; margin-left: auto; }
.search input {
  width: 100%; padding: 7px 10px; border-radius: 8px; border: 0; background: #33404d; color: #fff; font-size: 15px;
}
.search input::placeholder { color: #9aa6b2; }
#results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
  background: var(--paper); color: var(--ink); border-radius: 10px; box-shadow: 0 8px 30px rgb(0 0 0 / .2); z-index: 10;
}
#results li { padding: 9px 10px; border-radius: 6px; display: flex; gap: 8px; align-items: center; cursor: pointer; }
#results li:hover, #results li.on { background: var(--bg); }
#results small { color: var(--muted); margin-left: auto; }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; min-width: 0; }
.chips::-webkit-scrollbar { display: none; }
.chips button {
  border: 0; background: #33404d; color: #dbe2e8; padding: 6px 11px; border-radius: 999px; white-space: nowrap; font-size: 14px;
}
.chips button.on { background: var(--accent); color: var(--ink); font-weight: 600; }
.chips button.soon { opacity: .55; }

.toggle { display: flex; background: #33404d; border-radius: 999px; padding: 2px; flex: none; }
.toggle button { border: 0; background: none; color: #dbe2e8; padding: 5px 10px; border-radius: 999px; font-size: 13px; }
.toggle button.on { background: #fff; color: var(--ink); font-weight: 600; }
.ghost { border: 1px solid #4a5866; background: none; color: #dbe2e8; padding: 5px 10px; border-radius: 999px; font-size: 13px; white-space: nowrap; flex: none; }

@media (max-width: 640px) {
  .top .row:first-child { flex-wrap: wrap; }
  .top h1 { flex: 1 1 auto; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .top .row:last-child { flex-wrap: wrap; }
  .chips { flex-basis: 100%; }
}

/* ---------- карта ---------- */
#map { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; }
#svg { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; }
#bg path { vector-effect: non-scaling-stroke; }
#empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); padding: 24px; text-align: center; }

.stand polygon { stroke: #fff; stroke-width: 1; vector-effect: non-scaling-stroke; cursor: pointer; }
.stand text { pointer-events: none; font-weight: 600; dominant-baseline: central; text-anchor: middle; }
.stand .stripe { pointer-events: none; stroke: none; }
.view-mount .stand polygon.base { stroke: #37474f; stroke-width: 1.5; }
.view-mount .stand.empty polygon.base { stroke: #9aa3ab; stroke-dasharray: 4 3; }
#legend .empty-sw, .p-legend .empty-sw { background: #eef0f2; border: 1.5px dashed #9aa3ab; box-sizing: border-box; }
.stand.sel polygon { stroke: var(--accent); stroke-width: 4; }
.view-mount .stand.sel polygon.base { stroke: var(--accent); stroke-width: 4; }
.stand.dim { opacity: .3; }
#handles circle { fill: #fff; stroke: var(--ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: grab; }
#handles rect { fill: rgb(242 183 5 / .25); stroke: var(--accent); stroke-dasharray: 4 3; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.is-edit .stand.sel polygon { cursor: move; }
.drawing #svg { cursor: crosshair; }

#legend {
  position: absolute; left: 10px; bottom: 10px; background: rgb(255 255 255 / .94); border-radius: 10px;
  padding: 8px 10px; font-size: 12px; display: grid; gap: 4px; box-shadow: 0 2px 10px rgb(0 0 0 / .08);
}
#legend span { display: flex; align-items: center; gap: 6px; }
#legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.zoom { position: absolute; right: 10px; bottom: 10px; display: grid; gap: 6px; }
.zoom button {
  width: 42px; height: 42px; border-radius: 10px; border: 0; background: var(--paper); font-size: 20px;
  box-shadow: 0 2px 10px rgb(0 0 0 / .12);
}

.edit-tools { position: absolute; left: 10px; top: 10px; display: flex; gap: 10px; align-items: center; }
.edit-tools button { border: 0; background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 10px; font-weight: 600; }
.drawing .edit-tools button { background: var(--accent); color: var(--ink); }
#saveState { font-size: 13px; color: var(--muted); background: rgb(255 255 255 / .9); padding: 3px 8px; border-radius: 6px; }
#saveState:empty { display: none; }
#saveState.bad { color: var(--usednal); }

/* ---------- карта на щанд ---------- */
#sheet {
  overflow-x: hidden;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--paper);
  border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgb(0 0 0 / .15);
  max-height: 60vh; overflow-y: auto; padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@media (min-width: 900px) {
  #sheet { left: auto; top: 96px; right: 12px; bottom: 12px; width: 360px; max-height: none; border-radius: var(--radius); }
}
#sheet .close {
  position: absolute; right: 10px; top: 8px; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: var(--bg); font-size: 22px; line-height: 1;
}
.card-head { display: flex; align-items: baseline; gap: 10px; padding-right: 40px; }
.card-num { font-size: 28px; font-weight: 800; }
.card-pub { font-size: 19px; font-weight: 600; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 3px 9px; border-radius: 999px; background: var(--bg); margin: 8px 0 12px; }
.status i { width: 10px; height: 10px; border-radius: 50%; }
.equip { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.equip li { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 16px; }
.equip li.zero { color: var(--muted); }
.equip b { margin-left: auto; font-size: 22px; font-variant-numeric: tabular-nums; }
.equip li.zero b { font-weight: 400; font-size: 18px; }
.equip li.sum { border-bottom: 0; font-weight: 600; }
.sw { width: 26px; height: 16px; border-radius: 4px; flex: none; border: 1px solid rgb(0 0 0 / .15); }
.note { margin: 12px 0 0; padding: 10px 12px; background: #fff8dc; border-radius: 8px; font-size: 15px; white-space: pre-wrap; }
.demo { font-size: 12px; color: var(--muted); margin-top: 12px; }

/* форма в редактора */
.form { display: grid; gap: 10px; }
.form h2 { margin: 0 40px 4px 0; font-size: 17px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form input, .form select, .form textarea { width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; font-size: 15px; }
.form .two { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.form .eq { display: grid; grid-template-columns: auto 1fr 70px; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.form .eq input { text-align: center; }
.form .warn { color: var(--usednal); font-size: 13px; margin: 0; }
.form .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.form .actions button { border: 1px solid var(--line); background: #fff; padding: 7px 10px; border-radius: 8px; font-size: 14px; }
.form .actions .danger { color: var(--usednal); border-color: #f0c4c4; margin-left: auto; }
.form .hint { font-size: 12px; color: var(--muted); margin: 0; }

/* форма за експорт */
.form .chk { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink); }
.form .chk input { width: auto; }
.form .actions .primary { background: var(--ink); color: #fff; border-color: var(--ink); padding: 10px 16px; font-weight: 600; }

/* ---------- печат / PDF ---------- */
#print { display: none; }
@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html, body { height: auto; overflow: visible; display: block; background: #fff; }
  body > *:not(#print) { display: none !important; }
  #print { display: block; color: #000; }
  #print[data-size="A4"] { --ph: 189mm; }
  #print[data-size="A3"] { --ph: 276mm; }

  .p-page { height: var(--ph); display: flex; flex-direction: column; break-after: page; }
  .p-page:last-child { break-after: auto; }
  .p-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #000; padding-bottom: 2mm; }
  .p-head h1 { font-size: 16pt; margin: 0; }
  .p-head span { font-size: 10pt; color: #555; }
  .p-map { flex: 1; min-height: 0; width: 100%; }
  .p-map path { vector-effect: non-scaling-stroke; }
  .p-legend { display: flex; flex-wrap: wrap; gap: 4mm 8mm; font-size: 10pt; padding-top: 2mm; border-top: 1px solid #ccc; }
  .p-legend span { display: flex; align-items: center; gap: 2mm; }
  .p-legend i { width: 4mm; height: 4mm; border-radius: 1mm; display: inline-block; }

  .p-table { break-after: page; }
  .p-table:last-child { break-after: auto; }
  .p-table h2 { font-size: 14pt; margin: 0 0 3mm; }
  .p-table table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
  .p-table th, .p-table td { border: 1px solid #bbb; padding: 1.4mm 2mm; text-align: left; vertical-align: top; }
  .p-table th { background: #eee; }
  .p-table .n { text-align: center; white-space: nowrap; }
  .p-table tr { break-inside: avoid; }
  .p-table tfoot td { font-weight: 700; background: #f4f4f4; }
  .p-table .dot { display: inline-block; width: 3mm; height: 3mm; border-radius: 50%; margin-right: 1.5mm; vertical-align: middle; }
  .p-table .sw { display: inline-block; width: 4mm; height: 2.5mm; border-radius: .5mm; margin-right: 1.5mm; vertical-align: middle; border: 1px solid rgb(0 0 0 / .2); }
}

/* ---------- готово, напредък, без връзка ---------- */
.stand .badge { fill: #00c853; stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: none; }
.stand .check { fill: none; stroke: #fff; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.progress { font-variant-numeric: tabular-nums; }
.progress.all { background: #00c853; border-color: #00c853; color: #fff; }
.done-btn {
  width: 100%; margin-top: 14px; padding: 14px; border: 0; border-radius: 12px;
  background: #00c853; color: #fff; font-size: 17px; font-weight: 700;
}
.done-box {
  margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: #e8f9ee; color: #00873a;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600;
}
.done-box button { border: 1px solid #b7e4c7; background: #fff; color: var(--ink); padding: 6px 12px; border-radius: 8px; font-weight: 400; }
.bar { position: relative; height: 26px; border-radius: 8px; background: var(--bg); overflow: hidden; margin: 4px 0 12px; }
.bar div { position: absolute; inset: 0 auto 0 0; background: #00c853; }
.bar span { position: relative; display: block; line-height: 26px; padding: 0 10px; font-size: 13px; font-weight: 600; }
#offline {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 20px);
  background: #fff3cd; color: #6b4e00; border: 1px solid #f2d27a; border-radius: 10px; padding: 8px 12px;
  font-size: 13px; box-shadow: 0 2px 10px rgb(0 0 0 / .08); z-index: 2;
}
.is-edit #offline { top: 56px; }

/* ---------- площ и калибриране ---------- */
.area-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.area-row button, .calib-row button { border: 1px solid var(--line); background: #fff; padding: 6px 10px; border-radius: 8px; font-size: 13px; }
.calib { display: grid; gap: 6px; padding: 10px; background: var(--bg); border-radius: 10px; }
.calib-row { display: flex; gap: 8px; }
.calib-row input { flex: 1; }

/* ---------- Excel ---------- */
.file-btn {
  display: block !important; text-align: center; padding: 10px 16px; border: 1.5px dashed #b9c2ca; border-radius: 10px;
  color: var(--ink) !important; font-size: 15px !important; font-weight: 600; cursor: pointer; background: #fff;
}
.file-btn:hover { border-color: var(--ink); }
.file-btn input { display: none; }
.imp-sum { margin: 4px 0; font-size: 14px; }
.diff { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.diff li { padding: 7px 10px; border-bottom: 1px solid var(--line); }
.diff li:last-child { border-bottom: 0; }
.diff small { color: var(--muted); }
.imp-err { background: #fff3cd; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.imp-err ul { margin: 4px 0 0; padding-left: 18px; }
.ok { color: #00873a; font-weight: 600; }
.area-row .m2 { display: flex !important; align-items: center; gap: 8px; color: var(--ink) !important; font-size: 14px !important; }
.area-row .m2 input { width: 110px !important; }

/* ---------- номериране ---------- */
#numBox {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 14px; box-shadow: 0 8px 24px rgb(0 0 0 / .25);
  font-size: 15px; max-width: calc(100% - 20px);
}
#numBox b { color: var(--accent); font-size: 18px; }
#numBox button { border: 1px solid #4a5866; background: none; color: #fff; padding: 6px 12px; border-radius: 8px; }
#numBox button.primary { background: var(--accent); color: var(--ink); border-color: var(--accent); font-weight: 700; }
#numBox button:disabled { opacity: .4; }
.numbering #svg { cursor: copy; }
.edit-tools #numBtn { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgb(0 0 0 / .1); }
.numbering .edit-tools #numBtn { background: var(--accent); }

/* ---------- номер в кръгче ---------- */
.stand .num-badge { fill: #fff; stroke: #1f2933; stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: none; }
.stand .num-badge.none { stroke-dasharray: 3 2; }
.stand .num-text { fill: #1f2933; font-weight: 800; letter-spacing: -.02em; }
.stand.sel .num-badge { fill: var(--accent); }

/* ---------- въртене, средни точки, размери ---------- */
#handles .rot { fill: var(--accent); stroke: var(--ink); stroke-width: 1.5; cursor: grab; }
#handles .rot-line { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; pointer-events: none; }
#handles .rot-icon { fill: var(--ink); font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
#handles .mid { fill: #fff; fill-opacity: .75; stroke: var(--ink); stroke-opacity: .6; cursor: copy; }
.dims { display: flex; align-items: center; gap: 6px; font-size: 14px; flex-wrap: wrap; }
.dims input { width: 80px !important; text-align: center; }
.dims button { border: 1px solid var(--ink); background: var(--ink); color: #fff; padding: 7px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; }
.linkbtn { display: block; margin-top: 4px; padding: 0; border: 0; background: none; color: #1565c0; text-decoration: underline; font-size: 12px; text-align: left; }
.merging #svg { cursor: cell; }

/* ---------- знаци ---------- */
.sign { cursor: pointer; }
.sign .sign-bg { stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sign .sign-text { fill: #fff; font-weight: 800; text-anchor: middle; dominant-baseline: central; pointer-events: none; letter-spacing: .02em; }
.sign.sel .sign-bg { stroke: var(--accent); stroke-width: 4; }
.is-edit .sign { cursor: move; }
.placing #svg { cursor: crosshair; }
.sign-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.sign-grid button {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px; text-align: center;
  padding: 10px 6px 8px; font-size: 12.5px; line-height: 1.2; border: 1px solid var(--line); background: #fff; border-radius: 10px; min-width: 0;
}
.sign-grid button span { display: flex; align-items: center; justify-content: center; height: 30px; max-width: 100%; }
.sign-grid button.on { border-color: var(--ink); background: #fff8dc; box-shadow: 0 0 0 2px var(--accent); }
.sign-prev { display: block; max-width: 100%; height: auto; max-height: 30px; }
.card-head .sign-prev { height: 34px; }
.edit-tools #signBtn { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgb(0 0 0 / .1); }
.placing .edit-tools #signBtn { background: var(--accent); }
.form .actions .danger { color: var(--usednal); border-color: #f0c4c4; }

/* ---------- проверка ---------- */
.edit-tools #checkBtn { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgb(0 0 0 / .1); }
#issues { pointer-events: none; }
#issues .issue-line { stroke: #d50000; stroke-width: 3; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
#issues .issue-dot { fill: rgb(213 0 0 / .15); stroke: #d50000; stroke-width: 2.5; vector-effect: non-scaling-stroke; }
#issues .issue-dot.warn { fill: rgb(239 108 0 / .15); stroke: #ef6c00; }
.issues { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.issues li { padding: 8px 10px 8px 30px; border-bottom: 1px solid var(--line); font-size: 13px; cursor: pointer; position: relative; }
.issues li::before { content: '▲'; position: absolute; left: 10px; color: #ef6c00; font-size: 11px; top: 10px; }
.issues li.err::before { content: '●'; color: #d50000; }
.issues li.on { background: #fff8dc; }
.rules summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.rules ul { margin: 6px 0; padding-left: 18px; font-size: 13px; }
.linkbtn.inline { display: inline; margin: 0 0 0 6px; }


/* ---------- подредба по стени ---------- */
.stand .mod { stroke: #fff; stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }
.layout-btn { border: 1px solid var(--ink); background: #fff; padding: 9px 12px; border-radius: 10px; font-weight: 600; font-size: 14px; }
.lay-svg { width: 100%; max-height: 240px; background: #fafafa; border: 1px solid var(--line); border-radius: 10px; }
.lay-svg .d-stand { fill: #fff; stroke: #9aa3ab; stroke-width: 1.5; }
.lay-svg .d-mod { stroke: #fff; stroke-width: 1; }
.lay-svg .d-wall { stroke: transparent; stroke-width: 16; cursor: pointer; }
.lay-svg .d-wall.on { stroke: rgb(242 183 5 / .55); }
.lay-svg .d-no { cursor: pointer; }
.lay-svg .d-no circle { fill: #fff; stroke: var(--ink); stroke-width: 1.5; }
.lay-svg .d-no.on circle { fill: var(--accent); }
.lay-svg .d-no text { font-size: 13px; font-weight: 800; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.lay-h { margin: 4px 0 0; font-size: 15px; }
.lay-rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.lay-rows li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.lay-rows .step { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.lay-rows .step b { min-width: 22px; text-align: center; font-size: 17px; }
.lay-rows .step button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 18px; }
.lay-rows .step button:disabled { opacity: .35; }

/* ---------- стрелка, отстояния, модули ---------- */
.sign .sign-arrow { stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.dim .dim-line { stroke: #1565c0; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.dim .dim-hit { stroke: transparent; stroke-width: 14; vector-effect: non-scaling-stroke; }
.dim .dim-text { fill: #0d47a1; font-weight: 700; text-anchor: middle; dominant-baseline: central;
  paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.dim.auto .dim-line { stroke: #ef6c00; stroke-dasharray: 4 3; }
.dim.auto .dim-text { fill: #b23c00; }
.dim.auto { pointer-events: none; }
.dim.sel .dim-line { stroke: var(--accent); stroke-width: 3; }
.is-edit .dim { cursor: pointer; }
.measuring #svg { cursor: crosshair; }
.edit-tools #measureBtn { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgb(0 0 0 / .1); }
.measuring .edit-tools #measureBtn { background: var(--accent); }
.msize { color: var(--muted); font-size: 11px; font-weight: 400; }
.mod-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mod-table th { text-align: center; color: var(--muted); font-weight: 500; padding: 4px; }
.mod-table td { padding: 4px; }
.mod-table td:first-child { display: flex; align-items: center; gap: 6px; }
.mod-table input { width: 64px !important; text-align: center; }


/* ---------- помощ и водач ---------- */
.help-btn { margin-left: 8px; border-color: var(--accent) !important; color: var(--accent) !important; font-weight: 700; }
#tour { position: fixed; inset: 0; z-index: 50; }
#tour .tour-hole {
  position: fixed; border-radius: 10px; pointer-events: none; transition: all .2s ease;
  box-shadow: 0 0 0 4px var(--accent), 0 0 0 9999px rgb(15 20 25 / .62);
}
#tour .tour-tip {
  position: fixed; background: #fff; color: var(--ink); border-radius: 14px; padding: 14px 16px;
  box-shadow: 0 16px 40px rgb(0 0 0 / .3); transition: top .2s ease, left .2s ease;
}
.tour-count { font-size: 12px; color: var(--muted); }
.tour-tip h3 { margin: 4px 0 6px; font-size: 17px; }
.tour-tip p { margin: 0 0 12px; font-size: 14px; line-height: 1.45; }
.tour-actions { display: flex; gap: 8px; justify-content: flex-end; }
.tour-actions button { border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 9px; font-size: 14px; }
.tour-actions .primary { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
.tour-actions .tour-skip { margin-right: auto; border: 0; color: var(--muted); padding-left: 0; }
#helpMenu { position: fixed; inset: 0; z-index: 40; background: rgb(15 20 25 / .5); display: grid; place-items: center; padding: 16px; }
#helpMenu .help-box { position: relative; background: #fff; border-radius: 16px; width: 100%; max-width: 440px; max-height: 85vh; overflow: auto; padding: 18px 16px; }
#helpMenu h2 { margin: 0 0 4px; }
#helpMenu ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
#helpMenu li button { width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; }
#helpMenu li button:hover { border-color: var(--ink); background: #fffbea; }
#helpMenu li span { font-size: 13px; color: var(--muted); }
#helpMenu .close { position: absolute; right: 10px; top: 8px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--bg); font-size: 22px; }
.help-toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: #fff; padding: 10px 12px 10px 16px; border-radius: 14px; box-shadow: 0 10px 30px rgb(0 0 0 / .3);
  font-size: 14px; max-width: calc(100% - 24px); flex-wrap: wrap;
}
.help-toast button { border: 0; border-radius: 9px; padding: 7px 12px; background: transparent; color: #fff; font-size: 14px; }
.help-toast .primary { background: var(--accent); color: var(--ink); font-weight: 700; }

/* ---------- стени ---------- */
#walls .wall { stroke: #6a1b9a; stroke-width: 3; stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: .75; pointer-events: none; }
#walls .wall.live { stroke-dasharray: 6 4; opacity: .9; }
#walls .wall.sel { stroke: var(--accent); opacity: 1; stroke-width: 5; }
#walls .wall-hit { stroke: transparent; stroke-width: 14; vector-effect: non-scaling-stroke; cursor: pointer; }
#walls .wall-dot { fill: #6a1b9a; pointer-events: none; }
.walling #svg { cursor: crosshair; }
.walling #walls .wall-hit { pointer-events: none; }
.edit-tools #wallBtn { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgb(0 0 0 / .1); }
.walling .edit-tools #wallBtn { background: var(--accent); }
.edit-tools { right: 70px; row-gap: 6px; }
.edit-tools button { white-space: nowrap; padding: 8px 12px; }

/* ---------- списък, издател, проблеми, снимки, история ---------- */
.stand .rep-badge { fill: #d50000; stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: none; }
.stand .rep-text { fill: #fff; font-weight: 900; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.reports-btn { border-color: #ff8a80 !important; color: #ffcdd2 !important; font-weight: 700; }
.stand-list { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--line); }
.stand-list li { display: grid; grid-template-columns: 46px 1fr auto 40px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.stand-list li.is-done { background: #f1fbf4; }
.stand-list .no { font-weight: 800; font-size: 15px; text-align: center; border: 1.5px solid var(--ink); border-radius: 999px; padding: 3px 0; }
.stand-list .who { font-size: 14px; line-height: 1.25; display: grid; }
.stand-list .who small { color: var(--muted); font-size: 12px; }
.stand-list .eqs { display: flex; flex-wrap: wrap; gap: 3px; justify-content: flex-end; max-width: 150px; }
.eqchip { font-size: 11px; font-weight: 700; padding: 2px 5px; border-radius: 5px; background: color-mix(in srgb, var(--c) 18%, #fff); border-left: 4px solid var(--c); white-space: nowrap; }
.muted { color: var(--muted); font-size: 13px; }
.tick { width: 34px; height: 34px; border-radius: 50%; border: 2px solid #b0bec5; background: #fff; color: #b0bec5; font-size: 16px; font-weight: 900; }
.tick.on { background: #00c853; border-color: #00c853; color: #fff; }
#results li.pub-row { background: #fff8dc; }
.extras { margin-top: 12px; display: grid; gap: 8px; }
.extra-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.extra-actions button, .photo-btn { border: 1px solid var(--line); background: #fff; padding: 8px 12px; border-radius: 9px; font-size: 14px; cursor: pointer; }
.report-form { display: grid; gap: 8px; padding: 10px; background: #fff8e1; border-radius: 10px; }
.report-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.report-form textarea, .report-form input { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; color: var(--ink); }
.report-form .primary { background: var(--ink); color: #fff; border: 0; padding: 9px 14px; border-radius: 9px; font-weight: 600; }
.reports { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.reports li { background: #ffebee; border-radius: 10px; padding: 8px 10px; font-size: 14px; display: grid; gap: 2px; }
.reports li.resolved { background: #f1f3f4; color: var(--muted); }
.reports small { color: var(--muted); font-size: 12px; }
.reports.big .actions { display: flex; gap: 6px; margin-top: 6px; }
.reports.big .actions button { border: 1px solid var(--line); background: #fff; padding: 6px 12px; border-radius: 8px; }
.reports.big .actions .primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.photos a { display: grid; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; }
.photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.history { list-style: none; margin: 8px 0 0; padding: 0; }
.history li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; display: grid; gap: 3px; }
.history small { color: var(--muted); font-size: 12px; margin-left: 6px; }
.history .hd { font-size: 13px; color: var(--ink); }

.top .row:last-child { flex-wrap: wrap; row-gap: 6px; }
#floors { flex: 0 0 auto; max-width: 100%; } /* етажите не се свиват — бутоните минават на нов ред */

/* лента при поставяне на знаци */
#placeBar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 14px; box-shadow: 0 8px 24px rgb(0 0 0 / .25);
  font-size: 14px; max-width: calc(100% - 20px);
}
#placeBar .pb-prev { display: flex; background: #fff; border-radius: 8px; padding: 3px 6px; }
#placeBar button { border: 1px solid #4a5866; background: none; color: #fff; padding: 6px 12px; border-radius: 8px; }
#placeBar button.primary { background: var(--accent); color: var(--ink); border-color: var(--accent); font-weight: 700; }

/* ---------- лента с опции за избран щанд / знак ---------- */
#selBar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3;
  display: grid; gap: 6px; background: #fff; color: var(--ink); padding: 10px 12px; border-radius: 14px;
  box-shadow: 0 8px 28px rgb(0 0 0 / .22); width: max-content; max-width: calc(100% - 20px);
}
#selBar .sb-title { font-size: 15px; }
#selBar .sb-hint { font-size: 12px; color: var(--muted); }
#selBar .sb-actions { display: flex; gap: 6px; flex-wrap: wrap; }
#selBar button { border: 1px solid var(--line); background: #fff; padding: 9px 12px; border-radius: 10px; font-size: 14px; }
#selBar button.primary { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
#selBar button.danger { color: var(--usednal); border-color: #f0c4c4; }
/* съобщенията на редактора — под лентата с инструменти */
#saveState { position: absolute; left: 10px; top: 60px; z-index: 2; }
.edit-tools { right: 70px; }
@media (max-width: 640px) {
  /* на телефон лентата с инструменти се плъзга настрани */
  .edit-tools { right: 10px; flex-wrap: nowrap; overflow-x: auto; touch-action: pan-x; scrollbar-width: none; padding-bottom: 4px; }
  .edit-tools::-webkit-scrollbar { display: none; }
  .edit-tools button { flex: none; }
  .is-edit #legend { display: none; }
}
#selBar [data-sb=close] { position: absolute; top: 6px; right: 6px; border: 0; padding: 4px 9px; color: var(--muted); }
#selBar .sb-title { padding-right: 30px; }
