/* =========================================================
   СК-ТАКТ — Калькулятор смет
   Палитра под sk-takt.ru
   ========================================================= */

:root {
  --bg:          #FAF9F6;
  --bg-soft:     #F2EFE9;
  --surface:    #FFFFFF;
  --text:        #1A1A1A;
  --text-2:      #2A2A2A;
  --text-muted: #6E6A60;
  --line:        #E5DFD2;
  --line-soft:   #EFEAE0;

  --accent:      #D4B996;
  --accent-2:    #B8975C;
  --accent-soft: #F0E6D2;

  --revenue:     #4A6B3A;
  --revenue-soft:#E8F0E0;
  --cost:        #8B5A3C;
  --cost-soft:   #F4E8DD;
  --margin:      #6B4423;

  --danger:      #B0413E;

  --radius:      8px;
  --radius-sm:   4px;
  --shadow-sm:   0 1px 2px rgba(26,26,26,0.04), 0 1px 3px rgba(26,26,26,0.06);
  --shadow-md:   0 4px 12px rgba(26,26,26,0.08);
  --shadow-lg:   0 12px 32px rgba(26,26,26,0.12);

  --font:        'Montserrat', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  padding-bottom: 120px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* =========================================================
   TOP BAR
   ========================================================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--text);
  color: #FAF9F6;
  border-bottom: 1px solid #000;
}

.topbar__inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar__inner--top {
  padding-bottom: 10px;
}
.topbar__inner--bottom {
  padding-top: 10px;
  padding-bottom: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.02em;
}
.brand__mark {
  background: var(--accent);
  color: var(--text);
  font-weight: 800;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.brand__name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.08em;
}
.brand__sub {
  font-weight: 400;
  opacity: 0.7;
  letter-spacing: 0.04em;
  font-size: 12px;
  margin-left: 4px;
  text-transform: lowercase;
}

.topbar__inner--top .mode-tabs { margin-right: auto; }

.topbar__center {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.topbar__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  flex-shrink: 0;
}
.btn--small { padding: 6px 10px; font-size: 11px; }

.select {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  color: #FAF9F6;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.select:hover, .select:focus {
  border-color: var(--accent);
  background: rgba(255,255,255,0.10);
}
.select--estimate {
  flex: 1 1 auto;
  min-width: 140px;
  max-width: 420px;
}

.topbar__inner--bottom .topbar__center > .btn { flex-shrink: 0; }

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.view-toggle {
  display: flex;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.view-toggle__btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: all 0.15s;
}
.view-toggle__btn:hover { color: #FAF9F6; }
.view-toggle__btn.is-active {
  background: var(--accent);
  color: var(--text);
}

.btn {
  background: var(--accent);
  color: var(--text);
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.btn:hover { background: var(--accent-2); }
.btn--ghost {
  background: transparent;
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.14);
}
.btn--ghost:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(255,255,255,0.04);
}
.btn--icon {
  padding: 8px;
  background: rgba(255,255,255,0.06);
  color: #FAF9F6;
  border: 1px solid rgba(255,255,255,0.14);
}
.btn--icon:hover {
  background: var(--accent);
  color: var(--text);
  border-color: var(--accent);
}
.btn--danger {
  background: var(--danger);
  color: #fff;
}
.btn--danger:hover { background: #8B302D; }
.btn--secondary {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn--secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* =========================================================
   MENU DROPDOWN
   ========================================================= */
.menu {
  position: absolute;
  top: 100%;
  right: 24px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 240px;
  margin-top: 4px;
  z-index: 200;
}
.menu__item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 9px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background 0.1s;
}
.menu__item:hover { background: var(--accent-soft); }
.menu__sep {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

/* =========================================================
   CLIENT HEADER (visible only in print)
   ========================================================= */
.client-header {
  display: none;
}

/* =========================================================
   MAIN — SECTIONS
   ========================================================= */
.main {
  max-width: 1400px;
  margin: 24px auto;
  padding: 0 24px;
}

.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}

.section__title {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  padding: 0;
  flex: 1;
  min-width: 0;
}
.section__title:focus {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

.section__actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}
.icon-btn:hover {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface);
}
.icon-btn--danger:hover {
  color: var(--danger);
  border-color: var(--danger);
}
.icon-btn svg { display: block; }

/* =========================================================
   DIMENSIONS PANEL
   ========================================================= */
.dims {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.dims__head {
  padding: 12px 20px;
  background: var(--text);
  color: #FAF9F6;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}
.dims__title {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.dims__hint {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  font-weight: 400;
}
.dims__inputs {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 18px 20px 14px;
  flex-wrap: wrap;
}
.dims__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dims__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.dims__inputwrap {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  transition: all 0.15s;
}
.dims__inputwrap:focus-within {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.dims__input--narrow {
  width: 52px;
  font-size: 15px;
}

.params-panel .dims__head {
  background: linear-gradient(90deg, var(--text) 0%, #1F1F1F 100%);
}
.params-panel .dims__title {
  color: #B8975C;
}

.dims__input {
  width: 60px;
  background: transparent;
  border: none;
  outline: none;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.dims__input::-webkit-outer-spin-button,
.dims__input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.dims__unit {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.dims__sep {
  font-size: 18px;
  font-weight: 300;
  color: var(--text-muted);
  margin-bottom: 8px;
  user-select: none;
}
.dims__metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
}
.dims__metric {
  background: var(--bg-soft);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dims__metric-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.dims__metric-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.dims__metric-hint {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-2);
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  letter-spacing: 0.02em;
}

/* =========================================================
   FORMULA COLUMN / SELECT
   ========================================================= */
.formula-wrap {
  display: flex;
  align-items: center;
  gap: 2px;
}
.formula-times {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}
.cell-input--mult {
  width: 42px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  text-align: center !important;
  padding: 5px 2px !important;
  border-color: #D4B996 !important;
  background: #F5EFE3 !important;
  color: #B8975C !important;
}
.cell-input--mult:hover, .cell-input--mult:focus {
  border-color: #D4B996 !important;
  background: #fff !important;
  color: var(--text) !important;
}

.cell-select {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-size: 12px;
  color: inherit;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: all 0.12s;
}
.cell-select:hover { border-color: var(--line); background: var(--surface); }
.cell-select:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ── Селектор размера ворот ── */
.gate-wrap { display: flex; flex-direction: column; gap: 3px; }
.gate-size-sel {
  border-color: #D4B996 !important;
  background: #F5EFE3 !important;
  color: #8a6d3b !important;
  font-weight: 700 !important;
}
.gate-size-sel:hover, .gate-size-sel:focus {
  background: #fff !important;
  color: var(--text) !important;
}
.gate-breakdown {
  font-size: 10px;
  line-height: 1.3;
  color: var(--text-muted);
  padding: 0 2px;
}
.gate-breakdown b { color: var(--accent-2); font-weight: 700; white-space: nowrap; }

.cell-input--computed {
  background: var(--accent-soft) !important;
  color: var(--text-2);
  font-weight: 600;
  cursor: not-allowed;
}
.cell-input--computed:hover { border-color: transparent !important; }

.row-computed .col-qty { position: relative; }
.row-computed .col-qty::after {
  content: 'fx';
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  font-size: 9px;
  font-weight: 700;
  font-style: italic;
  color: var(--accent-2);
  pointer-events: none;
  letter-spacing: -0.02em;
}

.row-cost-linked .col-cost { position: relative; }
.row-cost-linked .col-cost::after {
  content: '🔗';
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  font-size: 9px;
  pointer-events: none;
  opacity: 0.6;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  font-size: 13px;
}
.table th {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.is-zero td {
  opacity: 0.45;
}
.table tbody tr.is-zero td:not(.cell-num):not(.cell-actions) { color: var(--text-muted); }

.col-num   { width: 36px;  text-align: center; color: var(--text-muted); font-weight: 500; }
.col-name  { min-width: 200px; }
.col-unit  { width: 75px; }
.col-formula { width: 160px; }
.col-qty   { width: 80px; }
.col-cost  { width: 100px; }
.col-price { width: 100px; }
.col-total-cost    { width: 110px; }
.col-total-revenue { width: 110px; }
.col-margin        { width: 100px; }
.col-margin-pct    { width: 64px; }
.col-actions { width: 36px; }

.cell-cost-num { color: var(--cost); font-weight: 500; }
.cell-revenue-num { color: var(--revenue); font-weight: 600; }
.cell-margin-num { color: var(--margin); font-weight: 500; }
.cell-num { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-strong { font-weight: 600; }

/* Editable inputs in table */
.cell-text { display: none; }
.cell-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 5px 6px;
  font-size: 13px;
  color: inherit;
  font-family: inherit;
  outline: none;
  transition: all 0.12s;
  font-variant-numeric: tabular-nums;
}
.cell-input:hover { border-color: var(--line); background: var(--surface); }
.cell-input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* Принудительно тёмный текст в native OS dropdown (иначе кремовый цвет не читается) */
.select option {
  color: #1A1A1A;
  background: #FFFFFF;
}
/* Числовые инпуты — рамка всегда видна, не только при hover */
.cell-input--num {
  text-align: right;
  border-color: var(--line) !important;
  background: var(--bg-soft) !important;
}
.cell-input--num:focus {
  border-color: var(--accent) !important;
  background: var(--surface) !important;
  box-shadow: 0 0 0 3px var(--accent-soft) !important;
}
.cell-input--num:read-only {
  background: var(--accent-soft) !important;
  cursor: not-allowed;
}
.cell-input--name { font-weight: 500; }

.row-add {
  background: var(--bg-soft);
}
.row-add td {
  padding: 8px 12px;
  border-top: 1px dashed var(--line);
  border-bottom: none;
}
.row-add .icon-btn {
  color: var(--accent-2);
  font-weight: 600;
  font-size: 12px;
  padding: 4px 8px;
}
.row-add .icon-btn:hover {
  color: var(--text);
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* Section subtotal row */
.row-subtotal td {
  background: var(--bg-soft);
  font-weight: 600;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text);
  border-top: 1px solid var(--line);
  border-bottom: none;
}
.row-subtotal .label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  color: var(--text-muted);
}

/* Add section button (bottom of main) */
.add-section-wrap {
  text-align: center;
  margin: 24px 0;
}
.add-section-btn {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--text-muted);
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all 0.15s;
}
.add-section-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  border-style: solid;
  background: var(--accent-soft);
}

/* =========================================================
   TOTALS STRIP
   ========================================================= */
.totals {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--text);
  color: #FAF9F6;
  border-top: 2px solid var(--accent);
  z-index: 90;
}
.totals__inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr 1.4fr;
  gap: 24px;
  align-items: center;
}
.totals__group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}
.totals__label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
}
.totals__val {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.totals__val--big {
  font-size: 22px;
  color: var(--accent);
}
.totals__pct {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(212,185,150,0.15);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}
.totals__group--client {
  border-left: 1px solid rgba(255,255,255,0.14);
  padding-left: 24px;
}
.totals__client-print { display: none; }

/* =========================================================
   MODAL
   ========================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden] { display: none; }
.menu[hidden]  { display: none; }
.toast[hidden] { display: none; }
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26,26,26,0.5);
  backdrop-filter: blur(4px);
}
.modal__panel {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  width: 92%;
  max-width: 440px;
}
.modal__title {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}
.modal__body {
  color: var(--text-2);
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.5;
}
.modal__body input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: all 0.15s;
}
.modal__body input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* =========================================================
   TOAST
   ========================================================= */
.toast {
  position: fixed;
  bottom: 140px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #FAF9F6;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 500;
  animation: toastIn 0.2s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1100px) {
  .col-margin, .col-margin-pct { display: none; }
}

@media (max-width: 860px) {
  .topbar__inner {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
  }
  .topbar__inner--top { padding-bottom: 8px; }
  .topbar__inner--bottom { padding-top: 8px; padding-bottom: 10px; }
  .topbar__inner--top .mode-tabs { margin-right: 0; }
  .brand { order: 1; }
  .topbar__inner--top .topbar__actions { order: 2; margin-left: auto; }
  .topbar__inner--top .mode-tabs { order: 3; width: 100%; }
  .topbar__center {
    width: 100%;
    flex-basis: 100%;
  }
  .select--estimate { flex: 1; min-width: 0; max-width: none; }
  .view-toggle__btn { padding: 7px 10px; font-size: 11px; }
  .brand__sub { display: none; }
  .main { padding: 0 12px; margin: 16px auto; }
  .totals__inner {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 12px 16px;
  }
  .totals__group--client {
    grid-column: 1 / -1;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.14);
    padding-left: 0;
    padding-top: 8px;
  }
  .totals__val { font-size: 15px; }
  .totals__val--big { font-size: 18px; }

  /* Table → card-like rows on mobile */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--line); padding: 10px 4px; }
  .table tr:last-child { border-bottom: none; }
  .table td {
    padding: 4px 8px;
    border: none;
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 8px;
    align-items: center;
  }
  .table td::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
  }
  .table td.col-num { display: none; }
  .table td.col-actions {
    grid-template-columns: 1fr;
    text-align: right;
  }
  .table td.col-actions::before { display: none; }
  .table td.col-name {
    grid-template-columns: 1fr;
    border-bottom: 1px solid var(--line-soft);
    margin-bottom: 6px;
    padding-bottom: 6px;
  }
  .table td.col-name::before { display: none; }
  .table td.col-name .cell-input { font-weight: 600; }

  .row-subtotal td {
    background: var(--bg-soft);
  }
  .row-subtotal td.col-num,
  .row-subtotal td.col-unit,
  .row-subtotal td.col-formula,
  .row-subtotal td.col-qty,
  .row-subtotal td.col-cost,
  .row-subtotal td.col-price,
  .row-subtotal td.col-margin,
  .row-subtotal td.col-margin-pct,
  .row-subtotal td.col-actions { display: none; }

  /* Dimensions panel — stack on mobile */
  .dims__inputs { padding: 14px 14px 10px; gap: 8px; }
  .dims__input { width: 50px; font-size: 16px; }
  .dims__sep { font-size: 14px; }
  .dims__metrics {
    grid-template-columns: repeat(2, 1fr);
  }
  .dims__metric { padding: 6px 12px; }
  .dims__metric-val { font-size: 12px; }
  .dims__hint { display: none; }

  .row-add td {
    grid-template-columns: 1fr;
    display: block;
  }
  .row-add td::before { display: none; }

  body { padding-bottom: 180px; }
}

/* =========================================================
   PRINT — CLIENT VIEW PDF
   ========================================================= */
@media print {
  @page {
    size: A4;
    margin: 7mm 9mm;
  }

  body {
    background: white;
    padding-bottom: 0;
    font-size: 8.5px;
    line-height: 1.25;
  }

  .topbar, .totals, .menu, .modal, .toast,
  .section__actions, .row-add,
  .col-num, .col-cost, .col-total-cost, .col-margin, .col-margin-pct,
  .col-formula, .col-actions,
  .dims, .params-panel,
  .add-section-wrap {
    display: none !important;
  }
  .section--no-client { display: none !important; }

  /* Override mobile layout — force table */
  .table { display: table !important; width: 100% !important; table-layout: fixed; }
  .table thead { display: table-header-group !important; }
  .table tbody { display: table-row-group !important; }
  .table tr { display: table-row !important; padding: 0 !important; border: none !important; }
  .table td, .table th {
    display: table-cell !important;
    grid-template-columns: none !important;
    padding: 2px 5px !important;
    font-size: 8.5px !important;
    border-bottom: 0.5px solid #DDD;
    background: transparent !important;
    overflow: hidden;
  }
  .table td::before { display: none !important; }
  .table td.col-name {
    white-space: normal !important;
    word-break: break-word;
    border-bottom: 0.5px solid #DDD !important;
    padding-bottom: 2px !important;
  }

  /* Column widths */
  .col-unit           { width: 8% !important; }
  .col-qty            { width: 9% !important; }
  .col-price          { width: 13% !important; }
  .col-total-revenue  { width: 15% !important; }

  /* Hidden zero-qty rows */
  .table tr.is-zero { display: none !important; }

  /* Hide internal columns */
  .table td.col-num,   .table th.col-num,
  .table td.col-cost,  .table th.col-cost,
  .table td.col-total-cost, .table th.col-total-cost,
  .table td.col-margin,.table th.col-margin,
  .table td.col-margin-pct, .table th.col-margin-pct,
  .table td.col-formula, .table th.col-formula,
  .table td.col-actions, .table th.col-actions {
    display: none !important;
  }

  /* Swap inputs → plain text */
  .cell-text { display: inline !important; }
  .cell-input { display: none !important; }
  .cell-text--name { font-weight: 500; }

  /* Client header */
  .client-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 6px;
    margin-bottom: 6px;
    border-bottom: 1.5px solid #1A1A1A;
  }
  .client-header__title { font-weight: 800; font-size: 15px; letter-spacing: 0.05em; }
  .client-header__sub { font-size: 7.5px; color: #6E6A60; margin-top: 1px; }
  .client-header__doc { text-align: right; }
  .client-header__label { font-size: 7.5px; text-transform: uppercase; letter-spacing: 0.1em; color: #6E6A60; }
  .client-header__name { font-weight: 700; font-size: 10px; margin: 1px 0; }
  .client-header__date { font-size: 7.5px; color: #6E6A60; }

  .main { margin: 0; padding: 0; max-width: none; }

  .section {
    box-shadow: none;
    border: none;
    border-radius: 0;
    margin-bottom: 4px;
    page-break-inside: avoid;
  }
  .section__head {
    background: transparent;
    border-bottom: 0.8px solid #1A1A1A;
    padding: 2px 0;
  }
  .section__title { color: #1A1A1A; font-size: 8px; letter-spacing: 0.09em; }

  .table th {
    background: transparent !important;
    border-bottom: 0.5px solid #1A1A1A !important;
    font-size: 7.5px !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 5px !important;
    color: #6E6A60;
  }

  .row-subtotal td {
    background: transparent !important;
    border-top: 0.5px solid #CCC !important;
    font-weight: 700;
    padding: 2px 5px !important;
    font-size: 8.5px !important;
  }

  /* ИТОГО */
  .totals__client-print {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    padding: 6px 8px;
    background: #1A1A1A !important;
    color: white !important;
    font-weight: 700;
    font-size: 9px;
    letter-spacing: 0.03em;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .totals__client-print-val {
    font-size: 13px;
    color: #D4B996 !important;
    font-variant-numeric: tabular-nums;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* Default: hide the print-only total on screen */
.totals__client-print { display: none; }

/* Режим Каркас: при печати не показывать элементы сметы
   (шапка клиента, ИТОГО) — они принадлежат смете, а не каркасу */
@media print {
  body.mode-karkas .client-header,
  body.mode-karkas .totals__client-print {
    display: none !important;
  }
}



/* =========================================================
   CLIENT VIEW (in-app, no print)
   ========================================================= */
body.view-client .col-cost,
body.view-client .col-total-cost,
body.view-client .col-margin,
body.view-client .col-margin-pct,
body.view-client .col-formula,
body.view-client .col-actions,
body.view-client .row-add,
body.view-client .section__actions,
body.view-client .add-section-wrap,
body.view-client .dims,
body.view-client .totals__group--cost,
body.view-client .totals__group--margin {
  display: none !important;
}
body.view-client .table tr.is-zero { display: none; }
body.view-client .section--no-client { display: none; }
body.view-client .totals__inner {
  grid-template-columns: 1fr 1fr;
}
body.view-client .totals__group--revenue { display: none; }
body.view-client .totals__group--client {
  border-left: none;
  padding-left: 0;
  grid-column: 1 / -1;
  text-align: center;
  align-items: center;
}

/* When sections have no items (empty state) */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: 14px;
}
.empty-state strong { color: var(--text); font-weight: 600; }

/* =========================================================
   MENU ACCENT ITEM
   ========================================================= */
.menu__item--accent {
  color: var(--accent-2);
  font-weight: 600;
}
.menu__item--accent:hover {
  background: var(--accent-soft);
  color: var(--text);
}

/* =========================================================
   CONTRACT MODAL
   ========================================================= */
.contract-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.contract-modal[hidden] { display: none; }

.contract-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26,26,26,0.6);
  backdrop-filter: blur(4px);
}

.contract-modal__panel {
  position: relative;
  background: var(--bg);
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.contract-modal__head {
  background: var(--text);
  color: #FAF9F6;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.contract-modal__title {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.contract-modal__sub {
  font-size: 12px;
  opacity: 0.6;
  margin-top: 2px;
}

.contract-modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* ===== CFORM ===== */
.cform {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.cform__section {
  margin-bottom: 24px;
}
.cform__section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.cform__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.cform__row--passport {
  grid-template-columns: 80px 100px 1fr 130px;
}

.cform__field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cform__field--full { grid-column: 1 / -1; }
.cform__field--wide { flex: 2; }

.cform__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.cform__inputwrap {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cform__inputwrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.cform__prefix {
  padding: 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg-soft);
  align-self: stretch;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--line);
}

.cform__input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: all 0.15s;
}
.cform__inputwrap .cform__input {
  border: none;
  background: transparent;
  border-radius: 0;
}
.cform__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.cform__inputwrap .cform__input:focus { box-shadow: none; }
.cform__select { cursor: pointer; }
.cform__select option { color: #1A1A1A; background: #FFF; }

.cform__summary {
  background: var(--text);
  color: #FAF9F6;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cform__summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  opacity: 0.85;
}
.cform__summary-row strong { color: var(--accent); font-size: 15px; }
.cform__summary-words {
  font-size: 11px;
  opacity: 0.55;
  margin-top: 4px;
  font-style: italic;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 8px;
  line-height: 1.5;
}

.cform__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* =========================================================
   CONTRACT PRINT AREA
   ========================================================= */
#contractPrintArea { display: none; }

/* CONTRACT DOCUMENT TYPOGRAPHY */
.cp {
  font-family: 'Times New Roman', Times, serif;
  font-size: 11pt;
  line-height: 1.5;
  color: #000;
  background: #fff;
  max-width: 740px;
  margin: 0 auto;
  padding: 0;
}
.cp-letterhead {
  text-align: right;
  font-size: 9.5pt;
  margin-bottom: 18pt;
  border-bottom: 0.5px solid #888;
  padding-bottom: 8pt;
  line-height: 1.6;
}
.cp-letterhead a { color: inherit; }
.cp-doctype {
  text-align: center;
  font-weight: bold;
  font-size: 13pt;
  margin-bottom: 4pt;
  letter-spacing: 0.03em;
}
.cp-subtitle {
  text-align: center;
  font-size: 11pt;
  margin-bottom: 4pt;
}
.cp-docinfo {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16pt;
  font-size: 10.5pt;
}
.cp-parties {
  margin-bottom: 14pt;
  text-align: justify;
  text-indent: 28pt;
}
.cp-section-title {
  font-weight: bold;
  text-align: center;
  margin: 14pt 0 6pt;
  font-size: 11pt;
  letter-spacing: 0.04em;
}
.cp p {
  margin: 0 0 5pt 0;
  text-align: justify;
  text-indent: 28pt;
}
.cp p.no-indent { text-indent: 0; }
.cp-table {
  width: 100%;
  border-collapse: collapse;
  margin: 6pt 0;
  font-size: 10pt;
}
.cp-table th, .cp-table td {
  border: 0.5px solid #888;
  padding: 4pt 6pt;
  vertical-align: top;
}
.cp-table th {
  background: #f0f0f0;
  font-weight: bold;
  text-align: center;
}
.cp-table td { text-align: left; }
.cp-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.cp-table td.center { text-align: center; }
.cp-sign-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20pt;
  margin-top: 16pt;
}
.cp-sign-col { }
.cp-sign-title { font-weight: bold; margin-bottom: 4pt; }
.cp-sign-line {
  border-bottom: 0.5px solid #000;
  margin: 4pt 0;
  height: 18pt;
}
.cp-sign-label { font-size: 9pt; color: #555; margin-top: 2pt; }
.cp-pagebreak { page-break-after: always; }
.cp-appendix-head {
  text-align: center;
  margin-bottom: 10pt;
}
.cp-appendix-head .title { font-weight: bold; font-size: 12pt; }
.cp-appendix-head .subtitle { font-weight: bold; }
.cp-appendix-meta {
  margin-bottom: 8pt;
  font-size: 10.5pt;
}
.cp-total-line {
  font-weight: bold;
  font-size: 12pt;
  text-align: right;
  margin-top: 8pt;
  padding: 6pt;
  border-top: 1px solid #000;
}
.cp-notes { font-size: 9.5pt; margin-top: 10pt; }
.cp-notes p { text-indent: 0; font-size: 9.5pt; margin-bottom: 4pt; }

/* =========================================================
   PRINT: CONTRACT MODE
   ========================================================= */
@media print {
  body.print-contract .topbar,
  body.print-contract .main,
  body.print-contract .totals,
  body.print-contract footer,
  body.print-contract .totals__client-print,
  body.print-contract .client-header,
  body.print-contract .contract-modal,
  body.print-contract .modal,
  body.print-contract .toast,
  body.print-contract #importInput {
    display: none !important;
  }
  body.print-contract #contractPrintArea {
    display: block !important;
  }
  body.print-contract {
    background: white;
    padding: 0;
  }
  .cp { max-width: none; }
  @page { size: A4; margin: 15mm 18mm; }
}

@media (max-width: 640px) {
  .contract-modal__panel { max-width: 100%; }
  .cform { padding: 16px; }
  .cform__row { grid-template-columns: 1fr; }
  .cform__row--passport { grid-template-columns: 1fr 1fr; }
}

/* =========================================================
   DIMS: ROOF TYPE TOGGLE + GABLE METRIC
   ========================================================= */
.dims__roof-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dims__roof-toggle {
  display: flex;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(255,255,255,0.06);
}
.dims__roof-btn {
  background: transparent;
  border: none;
  border-right: 1px solid rgba(255,255,255,0.2);
  color: #FAF9F6;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.dims__roof-btn:last-child { border-right: none; }
.dims__roof-btn:not(.is-active):hover {
  background: rgba(255,255,255,0.15);
}
.dims__roof-btn.is-active {
  background: var(--accent);
  color: var(--text);
  font-weight: 700;
}
.dims__metric--accent {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
}
.dims__metric-sub {
  font-size: 9px;
  color: var(--accent-2);
  margin-top: 2px;
  font-weight: 500;
}

/* =========================================================
   SHOW/HIDE QTY FROM CLIENT
   ========================================================= */
.col-qty { position: relative; }

/* Eye button — absolute so it doesn't affect cell width */
.qty-vis-btn {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: none;
  padding: 2px;
  border-radius: 3px;
  color: var(--line);
  cursor: pointer;
  transition: color 0.15s;
  opacity: 0;
  line-height: 1;
}
.table tr:hover .qty-vis-btn,
.qty-vis-btn--off {
  opacity: 1;
}
.qty-vis-btn:hover { color: var(--accent-2); }
.qty-vis-btn--off { color: #c0392b; }

/* Hidden qty: show crossed-out in internal view */
.row-qty-hidden .col-qty .cell-input {
  color: var(--text-muted);
  text-decoration: line-through;
}

/* Client view: show "—" for hidden-qty items */
body.view-client .row-qty-hidden .col-qty .cell-input { visibility: hidden; }
body.view-client .row-qty-hidden .col-qty::after {
  content: '—';
  font-size: 13px;
  color: var(--text-muted);
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
}

/* Print: qty shows as "—" for hidden items (cell-text handles this) */

/* =========================================================
   DIMS PANEL: PANEL COUNT ROW
   ========================================================= */
.dims__panels {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: rgba(255,255,255,0.04);
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-wrap: wrap;
}
.dims__panels-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  flex-shrink: 0;
}
.dims__panels-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dims__panels-field .dims__label {
  white-space: nowrap;
  font-size: 10px;
  opacity: 0.7;
}
.dims__inputwrap--small .dims__input {
  width: 44px;
  font-size: 17px;
}
.dims__panels-hint {
  font-size: 10px;
  color: var(--accent);
  opacity: 0.8;
  margin-left: auto;
  white-space: nowrap;
}

/* =========================================================
   PANEL TYPE SELECTORS
   ========================================================= */
.dims__panels-selectors {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: rgba(255,255,255,0.04);
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-wrap: wrap;
}
.dims__panel-select {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.25);
  color: #FAF9F6;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}
.dims__panel-select:focus { border-color: var(--accent); }
.dims__panel-select option { color: #1A1A1A; background: #fff; }

/* =========================================================
   GLOBAL MARKUP STRIP
   ========================================================= */
.totals__markup {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  background: rgba(255,255,255,0.05);
  border-top: 1px solid rgba(255,255,255,0.1);
  flex-wrap: wrap;
}
.totals__markup-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
}
.totals__markup-btns {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.markup-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.8);
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.markup-btn:hover { background: rgba(255,255,255,0.15); color: #FAF9F6; }
.markup-btn.is-active { background: var(--accent); color: var(--text); border-color: var(--accent); }
.markup-btn--reset { background: transparent; border-color: rgba(255,255,255,0.15); font-size: 11px; color: rgba(255,255,255,0.45); }
.markup-btn--reset:hover { color: #FAF9F6; border-color: rgba(255,255,255,0.3); }
.markup-custom-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
  color: rgba(255,255,255,0.6);
  font-size: 12px;
}
.markup-custom-inp {
  width: 50px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: #FAF9F6;
  padding: 4px 6px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  outline: none;
  text-align: center;
  -moz-appearance: textfield;
}
.markup-custom-inp::-webkit-outer-spin-button,
.markup-custom-inp::-webkit-inner-spin-button { -webkit-appearance: none; }
.markup-custom-inp:focus { border-color: var(--accent); }
.totals__markup-result {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  margin-left: 4px;
}

/* =========================================================
   FIX: ROOF TYPE TOGGLE — inactive button always visible
   ========================================================= */
.dims__roof-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dims__roof-toggle {
  display: flex;
  border: 1.5px solid rgba(255,255,255,0.4);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(0,0,0,0.25);
}
.dims__roof-btn {
  background: transparent;
  border: none;
  border-right: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.9);
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.dims__roof-btn:last-child { border-right: none; }
.dims__roof-btn:not(.is-active):hover { background: rgba(255,255,255,0.12); }
.dims__roof-btn.is-active {
  background: var(--accent);
  color: var(--text);
  font-weight: 700;
  text-shadow: none;
}

/* =========================================================
   MARKUP ACTIVE: price cells highlighted
   ========================================================= */
.markup-price {
  background: #F5EFE3 !important;
  color: #B8975C !important;
  border-color: #D4B996 !important;
  font-weight: 700 !important;
}
.markup-price:read-only { cursor: not-allowed; }

/* Key metric (roof purchase area) — slightly highlighted */
.dims__metric--key {
  background: var(--accentbg, #F0E6D2);
  border: 1px solid var(--accent, #D4B996);
}
.dims__metric--key .dims__metric-label { color: var(--accent-2, #B8975C); font-weight: 700; }
.dims__metric-sub {
  font-size: 9px;
  color: var(--muted, #6E6A60);
  margin-top: 2px;
}

/* =====================================================
   LOGIN OVERLAY
   ===================================================== */
.login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg-dark, #1A1A1A);
  display: flex; align-items: center; justify-content: center;
}
.login-overlay.hidden { display: none; }
.login-box {
  background: #242424; border: 1px solid rgba(212,185,150,.2);
  border-radius: 16px; padding: 48px 56px; text-align: center;
  min-width: 340px; box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.login-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; background: var(--accent,#D4B996); color: #1A1A1A;
  font-weight: 800; font-size: 18px; border-radius: 12px; margin-bottom: 16px;
}
.login-title { color: #FAF9F6; font-size: 28px; font-weight: 800; letter-spacing: .06em; }
.login-sub { color: rgba(255,255,255,.4); font-size: 12px; margin: 4px 0 32px; }
.login-input {
  width: 100%; background: rgba(255,255,255,.06); border: 1.5px solid rgba(212,185,150,.25);
  border-radius: 8px; padding: 14px 16px; color: #FAF9F6; font-size: 16px;
  font-family: inherit; outline: none; margin-bottom: 12px;
  transition: border-color .2s;
}
.login-input:focus { border-color: var(--accent,#D4B996); }
.login-btn {
  width: 100%; background: var(--accent,#D4B996); color: #1A1A1A;
  border: none; border-radius: 8px; padding: 14px; font-size: 15px;
  font-weight: 700; font-family: inherit; cursor: pointer;
  transition: opacity .15s;
}
.login-btn:hover { opacity: .9; }
.login-err { color: #E05555; font-size: 12px; margin-top: 10px; min-height: 18px; }

/* =====================================================
   MODE TABS (Смета / Каркас)
   ===================================================== */
.mode-tabs {
  display: flex; gap: 4px;
  background: rgba(255,255,255,.06); border-radius: 8px; padding: 3px;
}
.mode-tab {
  background: transparent; border: none; color: rgba(255,255,255,.55);
  padding: 7px 16px; border-radius: 6px; font-size: 12px; font-weight: 700;
  font-family: inherit; cursor: pointer; transition: all .15s;
  letter-spacing: .04em;
}
.mode-tab:hover { color: #FAF9F6; background: rgba(255,255,255,.08); }
.mode-tab.is-active { background: var(--accent,#D4B996); color: #1A1A1A; }

/* =====================================================
   FRAME AREA
   ===================================================== */
.frame-area { padding: 0 0 80px; }

.frame-dims-bar {
  background: #1A1A1A; padding: 14px 24px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  border-bottom: 1px solid rgba(212,185,150,.15);
}
.frame-dim-group { display: flex; flex-direction: column; gap: 3px; }
.frame-dim-label { font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.4); }
.frame-dim-val { color: #FAF9F6; font-size: 15px; font-weight: 700; }
.frame-dim-badge { background: rgba(212,185,150,.15); color: var(--accent,#D4B996); border: 1px solid rgba(212,185,150,.3); border-radius: 4px; padding: 2px 7px; font-size: 11px; font-weight: 600; }
.frame-dims-extra { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.frame-sel { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2); color: #FAF9F6; border-radius: 6px; padding: 6px 8px; font-size: 11px; font-weight: 600; font-family: inherit; outline: none; cursor: pointer; }
.frame-sel option { color: #1A1A1A; background: #fff; }

.frame-summary {
  display: grid; grid-template-columns: repeat(5, 1fr);
  border-bottom: 1px solid var(--border-color, #E8E3D9);
  background: var(--surface, #fff);
}
.frame-sum-item { padding: 12px 18px; border-right: 1px solid var(--border-color, #E8E3D9); }
.frame-sum-item:last-child { border-right: none; }
.frame-sum-label { font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted, #6E6A60); margin-bottom: 3px; }
.frame-sum-val { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text, #1A1A1A); }
.frame-sum-val.accent { color: var(--accent2, #B8975C); }
.frame-sum-sub { font-size: 10px; color: var(--text-muted, #6E6A60); margin-top: 1px; }

.frame-tabs-nav { display: flex; gap: 0; padding: 0 24px; background: var(--surface, #fff); border-bottom: 1px solid var(--border-color, #E8E3D9); }
.frame-tab-btn { background: transparent; border: none; border-bottom: 2px solid transparent; padding: 12px 18px; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted, #6E6A60); font-family: inherit; cursor: pointer; transition: all .15s; }
.frame-tab-btn:hover { color: var(--text, #1A1A1A); }
.frame-tab-btn.is-active { color: var(--text, #1A1A1A); border-bottom-color: var(--accent, #D4B996); }
.frame-tab-body { padding: 20px 24px; }

/* Frame BOM table */
.frame-bom-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.frame-bom-table th { font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted, #6E6A60); padding: 6px 10px; border-bottom: 2px solid var(--border-color, #E8E3D9); background: #F5F2EC; text-align: left; }
.frame-bom-table th:not(:first-child) { text-align: right; }
.frame-bom-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-color, #E8E3D9); vertical-align: middle; }
.frame-bom-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.frame-bom-grp td { background: #1A1A1A; color: #FAF9F6; font-weight: 700; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; padding: 5px 10px; }
.frame-bom-grp:hover td { background: #1A1A1A !important; }
.frame-bom-table tr:hover td { background: #F5F2EC; }
.frame-bom-total td { background: #F0E6D2; font-weight: 700; border-top: 2px solid #D4B996; }
.prof-badge { background: #F5F2EC; border: 1px solid #E8E3D9; border-radius: 4px; padding: 2px 7px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.wt-val { font-weight: 700; color: #B8975C; }
.frame-note { background: #F0E6D2; border: 1px solid #D4B996; border-radius: 6px; padding: 12px 14px; font-size: 11px; color: #2A2A2A; line-height: 1.6; margin-top: 14px; }

/* Frame drawings */
.td-card { background: #fff; border: 1px solid #D8D0C0; border-radius: 6px; overflow: hidden; }
.td-head { background: #1A1A1A; color: #D4B996; font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; padding: 8px 14px; }

/* ── Panel chips ─────────────────────────────────────── */
.dims__panels-group { margin: 8px 0; }
.dims__panels-grouplabel {
  font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 5px;
}
.dims__panels-chips {
  display: flex; flex-wrap: wrap; gap: 5px;
}
.dims__panel-chip {
  background: var(--surface-alt, #F5F2EC); border: 1.5px solid var(--border-color);
  border-radius: 6px; padding: 5px 10px; cursor: pointer;
  font-size: 11px; font-weight: 600; font-family: inherit;
  color: var(--text-muted); transition: all .15s; line-height: 1.4;
  display: flex; flex-direction: column; align-items: flex-start;
}
.dims__panel-chip:hover { border-color: var(--accent); color: var(--text); }
.dims__panel-chip.is-active {
  background: var(--accent); border-color: var(--accent);
  color: #1A1A1A;
}
.dims__chip-price {
  font-size: 10px; font-weight: 700; opacity: .75; margin-top: 1px;
}
.dims__panel-chip.is-active .dims__chip-price { opacity: .85; }

/* =====================================================
   PRINT — FRAME (КАРКАС) ВЕДОМОСТЬ И РАСКЛАДКА
   ===================================================== */
@media print {
  .mode-tabs, .frame-tabs-nav, .frame-dims-extra,
  .frame-note button, #framePrintBtn,
  .frame-summary { display: none !important; }

  /* Скрыть баннер защиты сметы при печати */
  body.estimate-locked #main::before { display: none !important; }

  .frame-area { padding: 0 !important; }
  .frame-dims-bar {
    background: #fff !important; color: #1A1A1A !important;
    border-bottom: 2px solid #1A1A1A !important;
    padding: 4mm 0 !important;
  }
  .frame-dim-label, .frame-dim-val { color: #1A1A1A !important; }
  .frame-dim-badge { background: #F0E6D2 !important; color: #1A1A1A !important; border-color: #B8975C !important; }

  .frame-tab-body { padding: 4mm 0 !important; display: block !important; }
  .frame-tab-body[hidden] { display: none !important; }
  .frame-bom-table { font-size: 8px !important; }
  .frame-bom-table th, .frame-bom-table td { padding: 3px 6px !important; }
  .frame-bom-grp td { background: #1A1A1A !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .frame-bom-total td { background: #F0E6D2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .frame-note { border: 1px solid #999 !important; background: #fafafa !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .panel-layout-card { break-inside: avoid; page-break-inside: avoid; border: 1px solid #ccc !important; }
  .panel-layout-grid { display: block !important; }
  .panel-layout-grid > * { margin-bottom: 6mm; }

  /* Заголовки разделов — видны только при печати */
  .print-section-title {
    display: block !important;
    font-size: 13px; font-weight: 800; letter-spacing: .04em;
    color: #1A1A1A; border-bottom: 2px solid #1A1A1A;
    padding-bottom: 3mm; margin-bottom: 4mm;
  }

  /* ── ПЕЧАТЬ ПОЛНОГО КОМПЛЕКТА: выделенная область #framePrintArea ──
     JS собирает плоские «листы» .psheet — 1 лист = 1 страница.
     Никаких флексов/гридов/overflow:hidden внутри: только block-поток,
     иначе Chrome ломает страницы криво (рамка на одной, контент на другой). */
  body.print-frame-area > *:not(#framePrintArea) { display: none !important; }
  body.print-frame-area #framePrintArea { display: block !important; }

  .psheet {
    break-after: page;
    page-break-after: always;
    font-size: 10px;
  }
  #framePrintArea .psheet:last-child {
    break-after: auto;
    page-break-after: auto;
  }
  /* Лист с одним чертежом — целиком на странице, не разрезать */
  .psheet--draw {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .psheet__title {
    font-size: 13px; font-weight: 800; letter-spacing: .04em;
    color: #1A1A1A; border-bottom: 2px solid #1A1A1A;
    padding-bottom: 3mm; margin-bottom: 5mm;
  }

  .psheet svg {
    width: 100%; height: auto; display: block;
    max-height: 250mm;
  }

  /* Карточки в печати: overflow:hidden ЗАПРЕЩЁН — ломает фрагментацию */
  .psheet .panel-layout-card {
    overflow: visible !important;
    border: 1px solid #ccc !important;
    border-radius: 0 !important;
    break-inside: avoid; page-break-inside: avoid;
  }
  .psheet .panel-layout-head {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }

  /* Таблицы: шапка повторяется на каждой странице, строки не режутся пополам */
  .psheet table { width: 100%; border-collapse: collapse; }
  .psheet thead { display: table-header-group; }
  .psheet tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .psheet .frame-bom-table { font-size: 8.5px !important; }
  .psheet .frame-bom-table th, .psheet .frame-bom-table td { padding: 3px 6px !important; }
  .psheet .frame-bom-grp td { background: #1A1A1A !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .psheet .frame-bom-total td { background: #F0E6D2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .psheet .frame-note {
    border: 1px solid #999 !important; background: #fafafa !important;
    margin-top: 4mm;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}

/* На экране заголовки разделов для печати не показываем */
.print-section-title { display: none; }

/* =====================================================
   PANEL LAYOUT VISUALIZATION (РАСКЛАДКА ПАНЕЛЕЙ)
   ===================================================== */
.panel-layout-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px;
}
.panel-layout-grid--full { grid-template-columns: 1fr; }
.panel-layout-card {
  background: #fff; border: 1px solid #E8E3D9; border-radius: 8px; overflow: hidden;
}
.panel-layout-head {
  background: #1A1A1A; color: #D4B996; font-size: 10px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; padding: 8px 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.panel-layout-head .pl-count { color: #FAF9F6; font-weight: 800; font-size: 13px; letter-spacing: 0; }
.panel-layout-body { padding: 10px; }
.pl-seg { fill: rgba(212,185,150,.18); stroke: #B8975C; stroke-width: 1.5; }
.pl-seg-alt { fill: rgba(180,200,220,.18); stroke: #6B8CAE; stroke-width: 1.5; }
.pl-seg-reserve { fill: rgba(230,230,230,.5); stroke: #AAA; stroke-dasharray: 4,3; stroke-width: 1.2; }
.pl-label { font-family: Montserrat, sans-serif; font-size: 10px; fill: #555; text-anchor: middle; dominant-baseline: middle; font-weight: 600; }
.pl-dim { font-family: Montserrat, sans-serif; font-size: 9px; fill: #B8975C; text-anchor: middle; font-weight: 700; }

/* =====================================================
   SYNC STATUS INDICATOR — компактная точка возле логотипа
   ===================================================== */
.sync-status {
  display: inline-flex; align-items: center;
  margin-left: 2px; cursor: default;
}
.sync-status__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #888; transition: background .25s;
  display: block; box-shadow: 0 0 0 2px rgba(0,0,0,.25);
}
.sync-status.is-synced .sync-status__dot { background: #5CB85C; }
.sync-status.is-syncing .sync-status__dot {
  background: #D4B996;
  animation: sync-pulse 1s ease-in-out infinite;
}
.sync-status.is-error .sync-status__dot { background: #D9534F; }
.sync-status.is-offline .sync-status__dot { background: #888; }
@keyframes sync-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

/* =====================================================
   ЗАЩИТА СМЕТЫ ОТ РЕДАКТИРОВАНИЯ (lock)
   ===================================================== */
.lock-btn { transition: color .15s, background .15s; }
.lock-btn.is-locked {
  color: #D4B996;
  background: rgba(212,185,150,.12);
}

/* Когда смета защищена — все поля ввода в #main и #frameArea
   становятся недоступны для редактирования, но видны (read-only вид) */
body.estimate-locked #main input,
body.estimate-locked #main select,
body.estimate-locked #main textarea,
body.estimate-locked #main button,
body.estimate-locked #frameArea input,
body.estimate-locked #frameArea select,
body.estimate-locked #frameArea button,
body.estimate-locked #totals .totals__markup button,
body.estimate-locked #totals .totals__markup input {
  pointer-events: none !important;
}
body.estimate-locked #totals .totals__markup {
  opacity: .45;
}
body.estimate-locked #main input,
body.estimate-locked #main select,
body.estimate-locked #main textarea {
  background: rgba(0,0,0,.03) !important;
  color: var(--text-muted) !important;
  cursor: not-allowed;
}
/* Бейдж "Защищено" над сметой */
body.estimate-locked #main::before {
  content: '🔒 Смета защищена — снимите защиту значком замка в шапке, чтобы редактировать';
  display: block;
  background: #F0E6D2;
  border: 1px solid #D4B996;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 600;
  color: #6B5530;
}

/* =====================================================
   ПЕЧАТНАЯ ОБЛАСТЬ КАРКАСА — на экране всегда скрыта
   ===================================================== */
#framePrintArea { display: none; }
@media print {
  body.print-frame-area #framePrintArea * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* =====================================================
   РЕЕСТР СДЕЛОК (CRM)
   ===================================================== */
.registry-area { max-width: 1400px; margin: 24px auto; padding: 0 24px 80px; }
.registry-area[hidden] { display: none; }

.reg-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.reg-head__title {
  font-size: 20px; font-weight: 800; letter-spacing: .02em; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.reg-head__count {
  font-size: 12px; font-weight: 700; color: var(--accent-2);
  background: var(--accent-soft); border-radius: 20px; padding: 2px 10px;
}

/* ── Сводка ── */
.reg-summary {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px;
}
.reg-sum-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; border-left: 3px solid var(--line);
}
.reg-sum-card--work { border-left-color: #3A7AB5; }
.reg-sum-card--hot  { border-left-color: #5BA86B; }
.reg-sum-card--prod { border-left-color: #2E8B57; }
.reg-sum-card--done { border-left-color: #1A6B3A; }
.reg-sum-card__label {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 6px;
}
.reg-sum-card__val { font-size: 19px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.reg-sum-card__sub { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ── Тулбар: чипы стадий + поиск ── */
.reg-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 14px; flex-wrap: wrap;
}
.reg-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.reg-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 20px; padding: 5px 12px; font-size: 12px; font-weight: 600;
  color: var(--text-2); cursor: pointer; transition: all .12s;
}
.reg-chip:hover { border-color: var(--chip); }
.reg-chip.is-active {
  background: var(--chip); border-color: var(--chip); color: #fff;
}
.reg-chip__n {
  font-size: 10px; font-weight: 700; opacity: .7;
  background: rgba(0,0,0,.08); border-radius: 10px; padding: 1px 6px;
}
.reg-chip.is-active .reg-chip__n { background: rgba(255,255,255,.25); opacity: .9; }

.reg-search {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); padding: 6px 12px; min-width: 280px;
  color: var(--text-muted);
}
.reg-search input {
  border: none; outline: none; background: transparent; font-size: 13px;
  color: var(--text); width: 100%; font-family: inherit;
}

/* ── Таблица ── */
.reg-table-wrap {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
}
.reg-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.reg-table thead th {
  text-align: left; font-size: 10px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 12px 14px; border-bottom: 1.5px solid var(--line);
  background: var(--bg-soft);
}
.reg-table td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.reg-table tbody tr:last-child td { border-bottom: none; }

/* ── Подсветка строки по статусу: полоса слева + оттенок ── */
.reg-row { position: relative; }
.reg-row > td { transition: background .12s; }
.reg-row > td:first-child {
  box-shadow: inset 5px 0 0 0 var(--row-stage, transparent);
}
/* Основной способ — фоновый тон ячейки (текст остаётся поверх, читаем) */
.reg-row > td { background: color-mix(in srgb, var(--row-stage) 12%, transparent); }
.reg-table tbody tr.reg-row:hover > td { background: color-mix(in srgb, var(--row-stage) 22%, transparent); }

/* Фолбэк для старых браузеров без color-mix — лёгкий слой-оверлей */
@supports not (background: color-mix(in srgb, red 9%, transparent)) {
  .reg-row > td { background: transparent; position: relative; }
  .reg-row > td::before {
    content: ""; position: absolute; inset: 0;
    background: var(--row-stage, transparent); opacity: 0.10; pointer-events: none;
  }
  .reg-table tbody tr.reg-row:hover > td::before { opacity: 0.18; }
  .reg-row > td > * { position: relative; z-index: 1; }
}

/* Ширины колонок (table-layout: fixed) */
.reg-c-num { width: 44px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.reg-c-obj { width: 22%; }
.reg-c-contact { width: 15%; }
.reg-c-stage { width: 118px; }
.reg-c-note { width: 20%; }
.reg-c-sum { width: 110px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.reg-c-date { width: 86px; white-space: nowrap; color: var(--text-muted); font-size: 12px; }
.reg-c-act { width: 196px; white-space: nowrap; text-align: right; }

.reg-obj-name {
  font-weight: 600; color: var(--text); cursor: pointer; display: flex; gap: 6px; align-items: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.reg-obj-name:hover { color: var(--accent-2); text-decoration: underline; }
.reg-obj-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reg-lock { font-size: 11px; flex-shrink: 0; }

.reg-contact-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reg-contact-phone { font-size: 12px; color: var(--accent-2); text-decoration: none; white-space: nowrap; }
.reg-contact-phone:hover { text-decoration: underline; }
.reg-contact-empty { font-size: 12px; color: var(--text-muted); opacity: .6; }

/* ── Бейдж статуса + селектор ── */
.reg-stage-wrap { position: relative; display: inline-block; }
.reg-badge {
  display: inline-block; padding: 3px 10px; border-radius: 14px;
  font-size: 11px; font-weight: 700; color: #fff; background: var(--badge);
  white-space: nowrap; pointer-events: none;
}
.reg-stage-sel {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; border: none;
}

/* ── Кнопки действий ── */
.reg-act {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--radius-sm); padding: 5px 9px; font-size: 11px; font-weight: 600;
  color: var(--text-2); cursor: pointer; margin-left: 4px; transition: all .12s;
  font-family: inherit;
}
.reg-act:hover { background: var(--accent-soft); border-color: var(--accent); }
.reg-act--open { background: var(--text); color: var(--accent); border-color: var(--text); }
.reg-act--open:hover { background: #000; color: var(--accent); }
.reg-act--icon { padding: 5px 9px; font-weight: 800; }

.reg-empty { text-align: center; color: var(--text-muted); padding: 40px 0; }

/* ── Меню строки (в модалке) ── */
.reg-rowmenu { display: flex; flex-direction: column; gap: 4px; }
.reg-rowmenu__item {
  text-align: left; border: none; background: transparent;
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px;
  color: var(--text); cursor: pointer; font-family: inherit;
}
.reg-rowmenu__item:hover { background: var(--accent-soft); }
.reg-rowmenu__item.is-danger { color: #B05A52; }
.reg-rowmenu__item.is-danger:hover { background: rgba(176,90,82,.1); }

/* ── CRM-поля в панели «Параметры объекта» ── */
.dims__crm {
  display: grid;
  grid-template-columns: 2.2fr 1.4fr 1.4fr 1.2fr;
  gap: 14px;
  align-items: end;
  padding: 14px 16px;
  margin: 0 0 18px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.dims__crm-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dims__crm .dims__label { line-height: 1; }
.dims__crm-input {
  box-sizing: border-box;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  width: 100%;
}
.dims__crm-input::placeholder { color: var(--text-muted); opacity: .55; }
.dims__crm-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.dims__crm-select {
  cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236E6A60' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

@media (max-width: 720px) {
  .reg-summary { grid-template-columns: 1fr 1fr; }
  .dims__crm { grid-template-columns: 1fr 1fr; }
  .reg-search { min-width: 100%; }
  .reg-table-wrap { overflow-x: auto; }
  .reg-table { min-width: 920px; }
}

/* В режиме реестра прячем нижнюю полосу итогов и пр. */
body.mode-registry .totals,
body.mode-registry .totals__client-print { display: none !important; }

@media print {
  body.mode-registry .topbar,
  body.mode-registry .reg-toolbar,
  body.mode-registry .reg-act,
  body.mode-registry .reg-stage-sel,
  body.mode-registry #regNewBtn { display: none !important; }
  body.mode-registry .registry-area { margin: 0; padding: 0; }
}

/* =====================================================
   ЛИДЫ + КОЛОНКА КОММЕНТАРИЙ
   ===================================================== */
.reg-head__btns { display: flex; gap: 8px; align-items: center; }

/* Колонка комментарий */
.reg-c-note { width: 20%; }
.reg-note-input {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 30px;
  max-height: 84px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 5px 8px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text);
  resize: none;
  outline: none;
  line-height: 1.35;
  transition: border-color .12s, background .12s;
  overflow-y: auto;
  overflow-x: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.reg-note-input::placeholder { color: var(--text-muted); opacity: .5; }
.reg-note-input:hover { border-color: var(--line); }
.reg-note-input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Модалка лидов */
.leads-loading, .leads-empty { padding: 24px 4px; text-align: center; color: var(--text-2); }
.leads-empty__sub { display: block; margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.leads-manual p { font-size: 13px; color: var(--text-2); line-height: 1.5; margin: 0 0 10px; }
.leads-manual a { color: var(--accent-2); font-weight: 600; }
.leads-paste {
  width: 100%; height: 160px; resize: vertical;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px; font-family: ui-monospace, Menlo, monospace; font-size: 11px;
  color: var(--text); background: var(--bg-soft); outline: none;
}
.leads-paste:focus { border-color: var(--accent); }

.leads-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 12px; color: var(--text-muted); margin-bottom: 10px; flex-wrap: wrap;
}
.leads-head__bulk { display: flex; gap: 6px; }
.leads-list { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }

.lead-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; transition: border-color .12s, background .12s;
}
.lead-row:hover { border-color: var(--accent); background: var(--accent-soft); }
.lead-cb { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent-2); flex-shrink: 0; }
.lead-row__main { flex: 1; min-width: 0; }
.lead-row__top { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.lead-row__name { font-weight: 700; color: var(--text); }
.lead-row__phone { font-size: 13px; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.lead-row__date { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.lead-row__quiz { font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }

@media (max-width: 720px) {
  .reg-c-note { min-width: 140px; }
}

/* =====================================================
   КАНБАН
   ===================================================== */
.reg-viewtoggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}
.reg-vt-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: none;
  padding: 7px 12px; font-size: 12px; font-weight: 600;
  color: var(--text-2); cursor: pointer; font-family: inherit;
  transition: background .12s, color .12s;
}
.reg-vt-btn + .reg-vt-btn { border-left: 1px solid var(--line); }
.reg-vt-btn:hover { background: var(--bg-soft); }
.reg-vt-btn.is-active { background: var(--text); color: var(--accent); }
.reg-chips-spacer { flex: 1; }

/* Доска */
.kb-wrap { width: 100%; overflow-x: auto; padding-bottom: 8px; }
.kb-board {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: 240px;
}
.kb-col {
  flex: 0 0 244px;
  width: 244px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-top: 3px solid var(--col-stage);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 360px);
  min-height: 160px;
}
.kb-col__head {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg-soft); border-radius: var(--radius) var(--radius) 0 0;
}
.kb-col__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--col-stage); flex-shrink: 0; }
.kb-col__title { font-size: 12px; font-weight: 700; color: var(--text); letter-spacing: .02em; }
.kb-col__count {
  font-size: 10px; font-weight: 700; color: var(--text-2);
  background: rgba(0,0,0,.06); border-radius: 10px; padding: 1px 7px;
}
.kb-col__sum { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.kb-col__body {
  flex: 1; overflow-y: auto; padding: 8px;
  display: flex; flex-direction: column; gap: 8px;
  transition: background .12s;
}
.kb-col__body.is-over { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); border-radius: 0 0 var(--radius) var(--radius); }
.kb-col__empty {
  text-align: center; color: var(--text-muted); opacity: .5;
  font-size: 11px; padding: 18px 6px; border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

/* Карточка */
.kb-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--card-stage);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  cursor: grab;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .12s, transform .06s, opacity .12s;
}
.kb-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,.10); }
.kb-card:active { cursor: grabbing; }
.kb-card.is-dragging { opacity: .45; transform: scale(.98); }
.kb-card__obj {
  font-weight: 700; font-size: 13px; color: var(--text); cursor: pointer;
  display: flex; gap: 5px; align-items: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kb-card__obj:hover { color: var(--accent-2); }
.kb-card__lock { font-size: 10px; flex-shrink: 0; }
.kb-card__client { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.kb-card__phone { font-size: 12px; color: var(--accent-2); text-decoration: none; display: inline-block; margin-top: 1px; }
.kb-card__phone:hover { text-decoration: underline; }
.kb-card__foot {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-top: 6px;
}
.kb-card__sum { font-weight: 800; font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.kb-card__date { font-size: 10px; color: var(--text-muted); }
.kb-card__note {
  margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line);
  font-size: 11px; color: var(--text-muted); line-height: 1.35;
  overflow-wrap: anywhere; word-break: break-word;
  max-height: 54px; overflow-y: auto;
}

/* Холодная зона (Отказ / Перенёс) */
.kb-cold { display: flex; align-items: stretch; gap: 12px; }
.kb-cold__toggle {
  flex: 0 0 auto;
  writing-mode: vertical-rl;
  background: var(--bg-soft); border: 1px dashed var(--line);
  border-radius: var(--radius); padding: 12px 8px;
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  cursor: pointer; font-family: inherit;
  display: flex; align-items: center; gap: 8px;
  transition: background .12s, color .12s;
}
.kb-cold__toggle:hover { background: var(--accent-soft); color: var(--text); }
.kb-cold__count {
  writing-mode: horizontal-tb;
  font-size: 10px; background: rgba(0,0,0,.08); border-radius: 10px; padding: 1px 6px;
}
.kb-cold__cols { display: flex; gap: 12px; }
.kb-cold:not(.is-open) .kb-cold__cols { display: none; }

@media (max-width: 720px) {
  .reg-viewtoggle { order: -1; }
  .kb-col { flex-basis: 200px; width: 200px; }
}

/* =====================================================
   КАРКАС — базовые классы (заменили инлайн-стили)
   ===================================================== */
.td-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.pl-summary { display: flex; gap: 16px; margin-bottom: 18px; }
.pl-summary__count {
  background: #1A1A1A; border-radius: 8px; padding: 12px 20px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex: 1;
}
.pl-summary__count-label { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.5); }
.pl-summary__count-val { font-size: 26px; font-weight: 800; color: #D4B996; white-space: nowrap; }
.pl-summary__meta {
  background: #F5F2EC; border: 1px solid #E8E3D9; border-radius: 8px;
  padding: 12px 20px; font-size: 11px; color: #555; flex: 2; line-height: 1.7;
}

.frame-tablescroll { width: 100%; overflow-x: auto; margin-bottom: 16px; -webkit-overflow-scrolling: touch; }
.pl-order-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.pl-order-table thead tr { background: #1A1A1A; }
.pl-th { padding: 8px 12px; font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: #D4B996; white-space: nowrap; }
.pl-th--l { text-align: left; }
.pl-th--c { text-align: center; }
.pl-tr { border-bottom: 1px solid #E8E3D9; }
.pl-tr--alt { background: #F5F2EC; }
.pl-td { padding: 8px 12px; }
.pl-td--name { font-weight: 600; }
.pl-td--qty { text-align: center; font-size: 18px; font-weight: 800; color: #B8975C; }
.pl-td--dim { font-family: ui-monospace, monospace; font-size: 11px; white-space: nowrap; }
.pl-td--note { font-size: 11px; color: #6E6A60; }
.pl-vis-title { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); margin: 18px 0 4px; }

/* =====================================================
   МОБИЛЬНАЯ АДАПТАЦИЯ — единый блок
   ===================================================== */
@media (max-width: 720px) {
  /* — Каркас: вкладки прокручиваются, ничего не уезжает за экран — */
  .frame-dims-bar { padding: 12px 14px; gap: 14px; }
  .frame-dims-extra { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .frame-sel { flex: 1; min-width: 120px; }

  .frame-summary { grid-template-columns: repeat(2, 1fr); }
  .frame-sum-item { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .frame-sum-item:nth-child(2n) { border-right: none; }
  .frame-sum-val { font-size: 17px; }

  .frame-tabs-nav {
    padding: 0 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .frame-tabs-nav::-webkit-scrollbar { display: none; }
  .frame-tab-btn { padding: 13px 14px; font-size: 11px; white-space: nowrap; flex: 0 0 auto; }
  .frame-tab-body { padding: 14px; }

  /* Чертежи и раскладка — в одну колонку */
  .td-grid { grid-template-columns: 1fr; }
  .pl-summary { flex-direction: column; gap: 10px; }
  .panel-layout-grid { grid-template-columns: 1fr; }
  .pl-summary__count-val { font-size: 22px; }

  /* Широкие таблицы каркаса — горизонтальная прокрутка (как канбан) */
  .frame-tablescroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .frame-bom-table { min-width: 540px; }
  .pl-order-table { min-width: 480px; }

  /* — Реестр: шапка/тулбар стопкой — */
  .reg-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .reg-head__btns { width: 100%; }
  .reg-head__btns .btn { flex: 1; justify-content: center; }
  .reg-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .reg-viewtoggle { width: 100%; }
  .reg-vt-btn { flex: 1; justify-content: center; }
  .reg-chips-spacer { display: none; }
  .kb-wrap { -webkit-overflow-scrolling: touch; }

  /* — Договор: поля в столбик — */
  .cform__row { grid-template-columns: 1fr !important; }

  /* — iOS: запрет авто-зума при фокусе (нужен размер шрифта ≥16px) — */
  input[type="text"], input[type="number"], input[type="password"],
  input[type="date"], input[type="tel"], select, textarea,
  .cell-input, .cell-select, .frame-sel, .reg-note-input,
  .dims__crm-input, .gate-size-sel, .markup-custom-inp {
    font-size: 16px;
  }

  /* — Крупнее тач-цели — */
  .btn, .mode-tab, .view-toggle__btn, .reg-act, .reg-vt-btn { min-height: 40px; }
}

@media (max-width: 480px) {
  .frame-summary { grid-template-columns: 1fr; }
  .frame-sum-item:nth-child(2n) { border-right: 1px solid var(--line); }
  .dims__crm { grid-template-columns: 1fr; }
  .reg-summary { grid-template-columns: 1fr; }
  .pl-summary__count { padding: 10px 14px; }
}

/* Мягкая подсветка тапа на тач-устройствах */
* { -webkit-tap-highlight-color: rgba(212, 185, 150, .25); }

/* ── Корзина ── */
.reg-trash-badge {
  font-size: 10px; font-weight: 700; background: rgba(176,90,82,.15); color: #B05A52;
  border-radius: 10px; padding: 1px 6px; margin-left: 2px;
}
.trash-head { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.trash-list { display: flex; flex-direction: column; gap: 8px; max-height: 56vh; overflow-y: auto; }
.trash-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface);
}
.trash-row__main { flex: 1; min-width: 0; }
.trash-row__name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-row__meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.trash-restore { flex-shrink: 0; }
