:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1d1d1d;
  --surface-2: #262626;
  --border: #333333;
  --accent: #ed1414;
  --accent-hover: #ff2b2b;
  --white: #f5f5f5;
  --muted: #9a9a9a;
  --text-secondary: #c4c4c4;
  --success: #6fc36f;
  --login-glow: rgba(237, 20, 20, 0.12);
  --grand-highlight: rgba(237, 20, 20, 0.08);
  --overlay-backdrop: rgba(0, 0, 0, 0.65);
  --tour-dim: rgba(0, 0, 0, 0.72);
  --shadow-strong: rgba(0, 0, 0, 0.45);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239a9a9a' d='M1.5 1.5 6 6 10.5 1.5'/%3E%3C/svg%3E");
  --select-chevron-focus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23f5f5f5' d='M1.5 1.5 6 6 10.5 1.5'/%3E%3C/svg%3E");
  --font-display: "Unbounded", sans-serif;
  --font-body: "Onest", sans-serif;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f3f3;
  --surface: #ffffff;
  --surface-2: #f0f0f0;
  --border: #dddddd;
  --accent: #ed1414;
  --accent-hover: #d01010;
  --white: #1d1d1d;
  --muted: #6b6b6b;
  --text-secondary: #444444;
  --success: #2a8a2a;
  --login-glow: rgba(237, 20, 20, 0.08);
  --grand-highlight: rgba(237, 20, 20, 0.06);
  --overlay-backdrop: rgba(0, 0, 0, 0.4);
  --tour-dim: rgba(0, 0, 0, 0.45);
  --shadow-strong: rgba(0, 0, 0, 0.12);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b6b6b' d='M1.5 1.5 6 6 10.5 1.5'/%3E%3C/svg%3E");
  --select-chevron-focus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%231d1d1d' d='M1.5 1.5 6 6 10.5 1.5'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}

h1, h2, h3, .logo-main {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.01em;
}

a { color: inherit; text-decoration: none; }

/* ---------- Top bar ---------- */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.logo { display: flex; flex-direction: column; line-height: 1.2; }
.logo-main { font-size: 15px; color: var(--white); }
.logo-sub {
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.nav-links {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.nav-link {
  padding: 8px 16px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--white); }
.nav-link.active { color: var(--white); background: var(--surface-2); }

.nav-divider {
  flex-shrink: 0;
  align-self: center;
  width: 1px;
  height: 22px;
  margin: 0 2px;
  background: color-mix(in srgb, var(--border) 80%, var(--muted));
}

.logout { color: var(--muted); font-size: 14px; }
.logout:hover { color: var(--accent); }

.theme-toggle {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--white);
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, color .15s, background .15s;
}

.theme-toggle-icon {
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--white);
  color: var(--white);
  background: var(--surface-2);
}

.theme-toggle-login {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
}

/* ---------- Page ---------- */
.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.page-title {
  font-size: 28px;
  margin: 0 0 24px;
  text-transform: uppercase;
}

.muted { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  border: none;
  border-radius: 10px;
  padding: 12px 24px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--white);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--white); }

.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--white);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 11px 14px;
  outline: none;
  transition: border-color .15s;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 40px;
  background-color: var(--surface);
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px auto;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

select:focus {
  background-color: var(--surface);
  background-image: var(--select-chevron-focus);
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.form-error {
  color: var(--accent);
  font-size: 14px;
  margin-bottom: 14px;
}

/* ---------- Login screen ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1000px 500px at 70% -10%, var(--login-glow), transparent 60%),
    var(--bg);
}

.login-card {
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.3;
  margin-bottom: 28px;
  text-align: center;
}
.login-logo .logo-main { font-size: 17px; }
.login-logo .logo-sub {
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

/* ---------- Калькулятор ---------- */
.calc-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
}

.calc-block.grand {
  border-color: var(--accent);
}

.block-title {
  font-size: 18px;
  margin: 0 0 18px;
  text-transform: uppercase;
}

.empty-hint { margin: 0 0 14px; }

.positions { margin-bottom: 14px; }

.pos-row {
  display: grid;
  grid-template-columns: 1.2fr 1.6fr 70px 90px 130px 130px 130px 130px 36px;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
}

.pos-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.pos-cell.num { text-align: right; font-variant-numeric: tabular-nums; }

.pos-wrap {
  border-bottom: 1px solid var(--border);
  padding: 4px 0 10px;
}

.pos-desc {
  font-size: 12.5px;
  color: var(--muted);
  padding: 2px 4px 0;
  line-height: 1.45;
}

.qty-input { width: 100%; text-align: center; padding: 8px 6px; }

.on-request { color: var(--muted); font-style: italic; }

.btn-add { margin-bottom: 18px; padding: 9px 18px; font-size: 14px; }

.btn-del {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
}
.btn-del:hover { color: var(--accent); background: var(--surface-2); }

/* Итоги блока */
.totals {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 16px 18px;
}

.totals-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 12px;
}

.totals-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.totals-vat { margin-top: 10px; }

.totals-label {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 2px;
}

.totals-value {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.totals-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
}

.grand .totals { background: var(--grand-highlight); }

.loading { color: var(--muted); }

/* Устройство вывода */
.device-controls {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.device-field { flex: 0 0 280px; margin-bottom: 0; }

.totals-grid-3 { grid-template-columns: repeat(3, 1fr); }

/* Финальный блок */
.final-hint { margin: -6px 0 18px; font-size: 13.5px; }

.final-hint-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.final-hint-link:hover { color: var(--accent-hover); }

.final-hours {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.final-hours-label { color: var(--muted); font-size: 14px; }

.final-hours-main {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.final-hours-value { font-weight: 600; font-size: 15px; }

.final-hours-days { color: var(--muted); font-size: 13.5px; }

.final-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.offer-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}

.offer-title {
  font-family: var(--font-display);
  font-size: 13px;
  text-transform: uppercase;
  margin-bottom: 14px;
  color: var(--white);
}

.offer-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.offer-label { color: var(--muted); }

.offer-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.offer-total { border-bottom: none; padding-top: 12px; font-size: 15px; }
.offer-total .offer-label { color: var(--white); }
.offer-total .offer-value { font-size: 17px; }

.offer-total-vat { padding-top: 2px; }
.offer-total-vat .offer-value { color: var(--accent); font-size: 19px; }

@media (max-width: 1000px) {
  .final-cols { grid-template-columns: 1fr; }
}

/* Панель КП и сохранение */
.proposal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  min-height: 36px;
}

.proposal-info { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }

.proposal-name { font-weight: 700; font-size: 16px; }

.proposal-note { color: var(--muted); font-size: 13px; }
.proposal-note-live { color: var(--success); }

.btn-small { padding: 8px 14px; font-size: 13px; }

.save-block { position: sticky; bottom: 12px; }

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

.save-name { flex: 1; }

.save-status { font-size: 14px; }

/* Список сохраненных КП */
.saved-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 20px;
}

.saved-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 0.9fr 0.8fr 40px;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.saved-row:last-child { border-bottom: none; }

.saved-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.saved-cell.num { font-variant-numeric: tabular-nums; }

.saved-link { font-weight: 600; }
.saved-link:hover { color: var(--accent); }

.saved-actions { text-align: right; }

.save-template-note { margin: 0 0 14px; max-width: 640px; }

.template-badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: 2px 10px;
}

/* Шаблоны на экране сохраненных КП */
.saved-section-title {
  font-family: var(--font-display);
  font-size: 16px;
  text-transform: uppercase;
  margin: 32px 0 10px;
}
.saved-section-title:first-child { margin-top: 0; }

.saved-section-hint { margin: 0 0 16px; max-width: 720px; }

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}

.template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.template-card-name {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.35;
}

.template-card-prices {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

.template-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn-icon-text { padding: 8px 12px; font-size: 14px; }

/* ---------- Онбординг ---------- */
.btn-tour {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 18px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 0 0 rgba(237, 20, 20, 0.5);
  animation: tour-pulse 2.2s ease-in-out infinite;
}
.btn-tour:hover { background: var(--accent-hover); }

@keyframes tour-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(237, 20, 20, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(237, 20, 20, 0); }
}

body.tour-active { overflow: hidden; }

.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
}

.tour-spotlight {
  position: fixed;
  z-index: 9001;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px var(--tour-dim);
  pointer-events: none;
  transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
}

.tour-tooltip {
  position: fixed;
  z-index: 9002;
  width: min(380px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: 0 12px 40px var(--shadow-strong);
}

.tour-step-num {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 6px;
}

.tour-title {
  font-family: var(--font-display);
  font-size: 16px;
  margin-bottom: 8px;
}

.tour-text {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 16px;
}

.tour-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.tour-skip { margin-right: auto; }

/* Модальные окна */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 420px;
  max-width: calc(100vw - 40px);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 15px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.modal-message {
  color: var(--muted);
  margin-bottom: 22px;
  line-height: 1.5;
}

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

/* ---------- Настройки ---------- */
.settings-hint { margin: -12px 0 24px; max-width: 720px; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 8px;
}

.dev-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr 130px;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
}

.dev-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.comp-editor {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.comp-row {
  display: grid;
  grid-template-columns: 1.2fr 1.6fr 0.7fr 0.9fr 130px;
  gap: 10px;
  align-items: end;
}

.comp-row-2 {
  grid-template-columns: 3.5fr 2.03fr;
  margin-top: 10px;
  align-items: start;
}

.comp-fixed {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.comp-field { margin-bottom: 0; }

.comp-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-bottom: 2px;
}

.comp-current {
  font-size: 12.5px;
  margin-top: 8px;
}

textarea { resize: vertical; }

/* Спойлеры компонентов */
.comp-spoiler > .comp-summary {
  display: flex;
  align-items: baseline;
  gap: 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.comp-summary::-webkit-details-marker { display: none; }

.comp-summary::before {
  content: "▸";
  color: var(--accent);
  font-size: 15px;
  transition: transform .15s;
  display: inline-block;
}

details[open] > .comp-summary::before { transform: rotate(90deg); }

.comp-summary-title { margin: 0; }

.comp-spoiler-body { margin-top: 16px; }

.comp-spoiler-body .btn-add { margin: 16px 0 0; }

/* Вход в настройки */
.settings-auth { max-width: 380px; }
.settings-auth p { margin-top: 0; }

/* ---------- Справка ---------- */
.help-intro { margin: -12px 0 20px; max-width: 760px; }

.help-search {
  max-width: 420px;
  margin-bottom: 24px;
}

.help-group {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 22px 0 4px;
}

.help-item {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.help-item:last-child { border-bottom: none; }

.help-item-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.help-item-name { font-weight: 600; font-size: 15px; }

.help-badge {
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  white-space: nowrap;
}

.help-badge-request { color: var(--accent); border-color: var(--accent); }

.help-item-desc {
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.5;
  margin-top: 5px;
  max-width: 980px;
}

.help-item-boundary {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 4px;
}

/* ========== Адаптив: планшет и мобильные ========== */

.nav-toggle {
  display: none;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--white);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.nav-toggle:hover { border-color: var(--white); background: var(--surface-2); }

@media (max-width: 900px) {
  .topbar-inner {
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 10px 12px;
  }

  .logo { flex: 1 1 auto; min-width: 0; }

  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }

  .nav {
    display: none;
    flex: 1 0 100%;
    flex-direction: column;
    gap: 4px;
    padding: 8px 0 4px;
    border-top: 1px solid var(--border);
  }

  body.nav-open .nav { display: flex; }

  .nav-links {
    flex-direction: column;
    width: 100%;
    gap: 4px;
  }

  .nav-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 8px;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }

  .nav-link {
    padding: 12px 14px;
    border-radius: 10px;
  }

  .nav-divider {
    width: 100%;
    height: 1px;
    margin: 8px 0 0;
  }

  .nav-actions .btn-tour {
    width: 100%;
    font-size: 14px;
    padding: 12px 18px;
    margin-left: 0;
    text-align: center;
  }

  .nav-actions .theme-toggle {
    width: 100%;
    height: auto;
    padding: 12px 18px;
  }

  .nav-actions .logout {
    display: block;
    font-size: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    text-align: center;
  }

  .nav-actions .logout:hover {
    background: var(--surface-2);
  }

  .page {
    padding: 20px 16px 64px;
  }

  .page-title {
    font-size: 22px;
    margin-bottom: 18px;
  }

  .calc-block {
    padding: 16px;
    border-radius: 14px;
    margin-bottom: 16px;
  }

  .block-title { font-size: 16px; margin-bottom: 14px; }

  /* Позиции — карточки вместо таблицы */
  .pos-head { display: none; }

  .pos-wrap {
    margin-bottom: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
  }

  .pos-row:not(.pos-head) {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    padding: 14px 40px 14px 14px;
  }

  .pos-wrap:has(.pos-desc) .pos-row:not(.pos-head) {
    padding-bottom: 10px;
  }

  .pos-cell[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 4px;
  }

  .pos-cell:has(select),
  .pos-cell:has(.qty-input) {
    display: block;
    min-width: 0;
  }

  .pos-cell select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 12px 44px 12px 14px;
    font-size: 16px;
    background-position: right 14px center;
  }

  .pos-cell.num {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    text-align: right;
  }

  .pos-cell.num::before {
    flex: 1;
    text-align: left;
    margin-bottom: 0;
  }

  .pos-cell.num:not(:has(select)):not(:has(input)) {
    font-weight: 600;
  }

  .pos-cell.pos-cell-full {
    justify-content: flex-start;
    font-style: italic;
  }

  .pos-row:not(.pos-head) > .pos-cell:last-child {
    position: absolute;
    top: 8px;
    right: 4px;
    padding: 0;
  }

  .pos-row:not(.pos-head) > .pos-cell:last-child::before { display: none; }

  .pos-desc {
    padding: 10px 14px 14px;
    margin: 0;
    border-top: 1px solid var(--border);
    line-height: 1.45;
  }

  .totals-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .totals-grid-3 { grid-template-columns: 1fr; }

  .totals-value { font-size: 15px; white-space: normal; }
  .totals-sub { white-space: normal; }

  .device-controls {
    flex-direction: column;
    gap: 12px;
  }

  .device-field { flex: 1 1 auto; width: 100%; }

  .device-field select {
    padding: 12px 44px 12px 14px;
    font-size: 16px;
  }

  .proposal-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .save-row {
    flex-direction: column;
    align-items: stretch;
  }

  .save-row .btn { width: 100%; text-align: center; }

  .offer-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .offer-value { white-space: normal; }

  .final-hours {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  /* Сохранённые КП */
  .saved-list { padding: 12px 14px; }

  .saved-head { display: none; }

  .saved-row:not(.saved-head) {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px 0;
  }

  .saved-cell[data-label]:not([data-label=""]) {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
  }

  .saved-cell[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    flex-shrink: 0;
  }

  .saved-cell.saved-actions {
    justify-content: flex-end;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
  }

  .saved-cell.saved-actions::before { display: none; }

  .template-grid { grid-template-columns: 1fr; }

  .template-card-actions {
    flex-direction: column;
  }

  .template-card-actions .btn { width: 100%; text-align: center; }

  /* Настройки */
  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }

  .saved-row:not(.saved-head) .saved-cell:first-child {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .saved-row:not(.saved-head) .saved-cell:first-child .saved-link {
    font-size: 16px;
  }

  .dev-save .btn { width: 100%; }

  .dev-head { display: none; }

  .dev-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 10px;
  }

  .comp-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .comp-row-2 {
    grid-template-columns: 1fr;
  }

  .comp-fixed {
    grid-template-columns: 1fr;
  }

  .comp-actions {
    flex-wrap: wrap;
    padding-bottom: 0;
  }

  /* Модалки и онбординг */
  .modal-box {
    width: auto;
    padding: 22px 18px;
  }

  .tour-tooltip {
    left: 16px !important;
    right: 16px !important;
    width: auto !important;
    max-width: none;
  }

  .tour-actions {
    flex-wrap: wrap;
  }

  .tour-skip { margin-right: 0; width: 100%; margin-bottom: 4px; }
}

@media (max-width: 480px) {
  .page-title { font-size: 20px; }

  .totals-grid { grid-template-columns: 1fr; }

  .settings-grid { grid-template-columns: 1fr; }

  .login-card {
    width: calc(100vw - 32px);
    padding: 28px 22px;
  }

  .btn {
    padding: 11px 18px;
    font-size: 14px;
  }

  .help-search { max-width: none; }
}
