/* ═══════════════════════════════════════════════════════════
   Soft Windows Calculator — Main Styles
   Breakpoints:
     iPhone portrait  < 500px
     iPhone landscape 500–768px
     Tablet           768–1024px
     MacBook 13"      1024–1280px
     MacBook 14"      1280–1536px
     MacBook 16"+     1536px+
   ═══════════════════════════════════════════════════════════ */

:root {
  --primary:      #1a3a5c;
  --primary-lt:   #2a5a9c;
  --primary-pale: #e8f0fb;
  --accent:       #e85d04;
  --success:      #2e7d32;
  --danger:       #c62828;
  --bg:           #f4f6f9;
  --card-bg:      #ffffff;
  --border:       #e0e4ea;
  --text:         #1a1a2e;
  --text-muted:   #6b7280;
  --radius:       10px;
  --shadow:       0 2px 12px rgba(0,0,0,0.08);

  /* Safe areas (iPhone notch / Dynamic Island) */
  --safe-top:    env(safe-area-inset-top,    0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left,   0px);
  --safe-right:  env(safe-area-inset-right,  0px);

  /* Editor panel dimensions */
  --sidebar-w:  66px;
  --options-w:  360px;
  --header-h:   50px;
  --tabs-h:     46px;
  --footer-h:   62px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: var(--app-height, 100dvh);
  overflow: hidden;          /* prevent body scroll — app manages its own scroll */
}

.hidden { display: none !important; }

/* ════════════════════════════════════════════════════════════
   SCREENS
   ════════════════════════════════════════════════════════════ */

#app { height: var(--app-height, 100dvh); overflow: hidden; }

.screen {
  display: flex;
  flex-direction: column;
  height: var(--app-height, 100dvh);
  overflow: hidden;
}

/* Non-editor screens scroll normally */
.screen-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

.screen--center {
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-top: calc(20px + var(--safe-top));
  background: var(--primary);
  overflow-y: auto;
}

/* ════════════════════════════════════════════════════════════
   APP HEADER
   ════════════════════════════════════════════════════════════ */

.app-header {
  background: var(--primary);
  color: #fff;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: calc(var(--header-h) + var(--safe-top));
  flex-shrink: 0;
  z-index: 100;
}
.app-header__title {
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header__center  { display: flex; flex-direction: column; align-items: center; flex: 1; }
.app-header__subtitle{ font-size: 0.72rem; color: rgba(255,255,255,0.7); }
.app-header__right   { display: flex; align-items: center; gap: 6px; }

.screen-footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.screen-footer__row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.screen-footer__row .btn--full { flex: 1; }
/* PDF button in row: auto width, not stretched */
.ow-pdf-btn {
  flex: 0 0 auto;
  padding: 0 16px;
  font-size: 0.88rem;
  white-space: nowrap;
}

/* ════════════════════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: none;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:active   { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }

.btn--primary   { background: var(--primary);  color: #fff; }
.btn--primary:hover  { background: var(--primary-lt); }
.btn--secondary { background: #e3eaf4;  color: var(--primary); }
.btn--secondary:hover { background: #ccdcee; }
.btn--ghost     { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn--ghost:hover     { background: var(--bg); }
.btn--danger    { background: #fde8e8; color: var(--danger); }
.btn--success   { background: #e8f5e9; color: var(--success); }
.btn--sm   { padding: 6px 12px; font-size: 0.78rem; border-radius: 7px; }
.btn--xs   { padding: 4px 8px;  font-size: 0.72rem; border-radius: 5px; }
.btn--lg   { padding: 13px 22px; font-size: 0.95rem; }
.btn--full { width: 100%; }
/* Красная кнопка для тёмных хедеров (app-header) */
.btn--header-danger {
  color: #ffcdd2;
  border-color: rgba(239, 154, 154, 0.45);
}
.btn--header-danger:hover { background: rgba(198, 40, 40, 0.25); }

/* ════════════════════════════════════════════════════════════
   FORMS
   ════════════════════════════════════════════════════════════ */

.field-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 11px;
}
.field-label--inline   { flex-direction: row; align-items: center; justify-content: space-between; }
.field-label-inline    { font-size: 0.95rem; color: var(--text-muted); }

.field-input {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text);
  background: #fff;
  width: 100%;
  transition: border 0.15s;
  -webkit-appearance: none;
}
.field-input:focus { outline: none; border-color: var(--primary-lt); box-shadow: 0 0 0 3px rgba(42,90,156,0.1); }
.field-input--sm   { width: 72px; }
textarea.field-input { resize: vertical; min-height: 70px; }
.photo-url-field { display: flex; flex-direction: column; gap: 4px; }
.photo-url-hint  { font-size: 0.76rem; color: var(--text-muted); font-style: italic; }
.photo-url-preview img { border: 1px solid var(--border); }
select.field-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

/* Toggle checkbox */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 0.88rem;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  gap: 10px;
  cursor: pointer;
}
.toggle-row__left { display: flex; flex-direction: column; gap: 2px; }
.toggle-row__hint { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }
.toggle-row--disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.toggle-row--disabled input { cursor: not-allowed; }

input[type=checkbox] {
  width: 40px; height: 22px;
  -webkit-appearance: none; appearance: none;
  background: #ccc; border-radius: 11px;
  position: relative; cursor: pointer; flex-shrink: 0;
  transition: background 0.2s;
}
input[type=checkbox]::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  background: #fff; border-radius: 50%;
  top: 2px; left: 2px;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
input[type=checkbox]:checked { background: var(--primary); }
input[type=checkbox]:checked::after { left: 20px; }

/* ════════════════════════════════════════════════════════════
   AUTH CARD
   ════════════════════════════════════════════════════════════ */

.auth-card {
  background: #fff; border-radius: 16px; padding: 32px 24px;
  width: 100%; max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2); text-align: center;
}
.auth-logo     { color: var(--primary); margin-bottom: 12px; }
.auth-title    { font-size: 1.6rem; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; }
.auth-hint     { font-size: 0.73rem; color: var(--text-muted); margin-top: 14px; line-height: 1.5; }

/* ════════════════════════════════════════════════════════════
   BADGES / MISC
   ════════════════════════════════════════════════════════════ */

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 0.68rem; font-weight: 600; }
.badge--draft     { background: #fff3e0; color: #e65100; }
.badge--submitted { background: #e8f5e9; color: var(--success); }
.badge--muted     { background: var(--bg); color: var(--text-muted); }

.info-row   { display: flex; justify-content: space-between; font-size: 0.85rem; padding: 4px 0; }
.info-row span { color: var(--text-muted); }
.empty-msg  { color: var(--text-muted); text-align: center; padding: 32px 20px; font-size: 0.9rem; }
.disclaimer-text { font-size: 0.72rem; color: rgba(255,255,255,0.65); margin-top: 6px; line-height: 1.4; }
.order-form { max-width: 480px; }
.error-msg  { color: var(--danger); font-size: 0.8rem; margin: 4px 0; min-height: 16px; }
.price-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 6px; }
.toolbar    { display: flex; gap: 10px; margin-bottom: 14px; }

/* ════════════════════════════════════════════════════════════
   ORDERS LIST — «домашний» экран-список. Намеренно отличается от
   экранов ВНУТРИ заказа (плоский primary-хедер + серый фон), чтобы
   визуально сразу понимать, где находишься (по просьбе клиента).
   ════════════════════════════════════════════════════════════ */

/* Тёплый брендовый градиент-хедер + оранжевая акцентная черта снизу */
#screen-orders .app-header {
  background: linear-gradient(120deg, #142d49 0%, #245189 60%, #2a5a9c 100%);
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 4px 16px rgba(20,45,73,0.28);
}
#screen-orders .app-header__title {
  text-align: left;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.2px;
}
/* Лёгкий прохладный фон страницы — отличается от ровно-серого «рабочего» */
#screen-orders .screen-content {
  background:
    radial-gradient(1200px 240px at 18% -40px, rgba(42,90,156,0.10), transparent 70%),
    linear-gradient(180deg, #eaf1fb 0%, var(--bg) 200px);
}

.orders-list { display: flex; flex-direction: column; gap: 12px; }

.order-card {
  position: relative;
  background: var(--card-bg); border-radius: var(--radius);
  padding: 14px 16px 14px 18px; box-shadow: var(--shadow);
  border: 1px solid var(--border); border-left: 4px solid var(--primary-lt);
  transition: box-shadow 0.16s, transform 0.16s, border-color 0.16s;
}
.order-card:hover {
  box-shadow: 0 6px 20px rgba(26,58,92,0.14);
  transform: translateY(-1px);
  border-left-color: var(--accent);
}
.order-card__header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.order-card__number  { font-weight: 700; font-size: 0.95rem; color: var(--primary); }
.order-card__client  { font-size: 0.88rem; margin-bottom: 6px; }
.order-card__meta    { display: flex; gap: 12px; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 10px; }
.order-card__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ════════════════════════════════════════════════════════════
   WINDOW CARDS
   ════════════════════════════════════════════════════════════ */

.windows-list { display: flex; flex-direction: column; gap: 12px; }

.window-card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  display: grid; grid-template-columns: 110px 1fr;
  cursor: pointer; transition: border 0.15s;
}
.window-card:hover { border-color: var(--primary-lt); }
.window-card__thumb {
  padding: 8px; background: #f8fafc;
  border-right: 1px solid var(--border);
  border-radius: var(--radius) 0 0 var(--radius);
  display: flex; align-items: center; justify-content: center;
  min-height: 100px; min-width: 111px;
}
.window-card__thumb svg { max-width: 95px; max-height: 90px; }
/* Плейсхолдер пока SVG не отрисован (ленивый рендеринг) */
.window-card__thumb--lazy .svg-placeholder {
  width: 72px; height: 72px;
  border-radius: 6px;
  background: linear-gradient(90deg, #e8f0f8 25%, #d0e0ef 50%, #e8f0f8 75%);
  background-size: 200% 100%;
  animation: svg-shimmer 1.2s infinite;
}
@keyframes svg-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.window-card__info    { padding: 10px 12px; }
.window-card__title   { font-weight: 700; font-size: 0.88rem; margin-bottom: 2px; }
.window-card__shape, .window-card__dims,
.window-card__material { font-size: 0.77rem; color: var(--text-muted); }
.window-card__price   { font-weight: 700; font-size: 1rem; color: var(--primary); margin-top: 4px; }
.window-card__area    { font-size: 0.73rem; color: var(--text-muted); }
.window-card__actions { padding: 6px 12px 10px; display: flex; gap: 8px; flex-wrap: wrap; grid-column: 2; }

.order-summary-bar {
  background: var(--primary); color: #fff; padding: 12px 16px;
  border-radius: var(--radius); margin-top: 8px;
}
.summary-bar__total { font-size: 1.05rem; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.summary-bar__total strong { font-size: 1.25rem; }

/* Редактируемый итог заказа */
.ow-total-edit {
  display: inline-flex; align-items: baseline; gap: 4px;
  background: rgba(255,255,255,0.14); border-radius: 8px; padding: 2px 8px;
}
.ow-total-input {
  width: 7ch; min-width: 5ch; max-width: 12ch;
  background: transparent; border: none; outline: none;
  color: #fff; font-size: 1.25rem; font-weight: 700; text-align: right;
  font-family: inherit; padding: 2px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.45);
}
.ow-total-input:focus { border-bottom-color: #fff; }
.ow-total-input--manual { color: #ffd97a; border-bottom-color: #ffd97a; }
.ow-total-cur { font-size: 1.1rem; font-weight: 700; }
.ow-total-reset {
  background: rgba(255,255,255,0.18); color: #fff; border: none;
  border-radius: 6px; padding: 3px 9px; font-size: 0.8rem; cursor: pointer;
}
.ow-total-reset:hover { background: rgba(255,255,255,0.3); }

/* Submit */
.submit-card {
  background: var(--card-bg); border-radius: 16px; padding: 32px 24px;
  max-width: 400px; width: 100%; text-align: center; box-shadow: var(--shadow);
}
.submit-icon { font-size: 3rem; color: var(--success); margin-bottom: 8px; }
.submit-card h2 { font-size: 1.4rem; margin-bottom: 16px; }
.submit-info    { text-align: left; margin-bottom: 16px; background: var(--bg); border-radius: 8px; padding: 12px; }
.submit-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.screen-content--center { display: flex; align-items: center; justify-content: center; }

/* ════════════════════════════════════════════════════════════
   TOAST
   ════════════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  top: calc(14px + var(--safe-top));
  right: 14px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--text); color: #fff; padding: 10px 16px;
  border-radius: var(--radius); font-size: 0.85rem; max-width: 280px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  opacity: 0; transform: translateX(16px);
  transition: all 0.22s ease; pointer-events: auto;
}
.toast.show      { opacity: 1; transform: translateX(0); }
.toast-success   { background: var(--success); }
.toast-error     { background: var(--danger); }

/* ════════════════════════════════════════════════════════════
   EDITOR — BASE
   ════════════════════════════════════════════════════════════ */

.screen--editor {
  background: #f0f2f5;
  display: flex;
  flex-direction: column;
  height: var(--app-height, 100dvh);
  overflow: hidden;
}

/* ── Editor header ─────────────────────────────────────────── */
.editor-header {
  background: var(--primary);
  color: #fff;
  padding: calc(8px + var(--safe-top)) 12px 8px
           calc(8px + var(--safe-left));
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: calc(var(--header-h) + var(--safe-top));
  flex-shrink: 0;
  z-index: 10;
}
.editor-header__info {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  overflow: hidden;
}
.editor-window-title {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.editor-counter        { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.editor-counter__btn   {
  background: rgba(255,255,255,0.15); border: none; color: #fff;
  padding: 3px 8px; border-radius: 5px; cursor: pointer; font-size: 1rem;
  transition: background 0.15s;
}
.editor-counter__btn:hover    { background: rgba(255,255,255,0.3); }
.editor-counter__btn:disabled { opacity: 0.3; pointer-events: none; }
.editor-counter__text  { font-size: 0.8rem; color: rgba(255,255,255,0.8); min-width: 40px; text-align: center; }
.editor-header__total  { font-size: 0.8rem; color: rgba(255,255,255,0.85); white-space: nowrap; flex-shrink: 0; }
.editor-header__total strong { font-size: 0.92rem; color: #fff; }

/* ── Tab bar ──────────────────────────────────────────────── */
.editor-tabs {
  background: var(--primary);
  display: flex;
  border-bottom: 2px solid rgba(255,255,255,0.12);
  overflow-x: auto;
  flex-shrink: 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.editor-tabs::-webkit-scrollbar { display: none; }

.editor-tab {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 7px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: rgba(255,255,255,0.55);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.editor-tab:hover  { color: rgba(255,255,255,0.9); }
.editor-tab.active { color: #fff; border-bottom-color: #fff; }

/* ── Editor body (3-column desktop default) ──────────────── */
.editor-body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--options-w);
  flex: 1;
  min-height: 0;     /* crucial: lets grid children shrink below natural height */
  overflow: hidden;
}

/* ── Left sidebar ─────────────────────────────────────────── */
.editor-sidebar {
  background: #e8ecf3;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0;
  gap: 2px;
  overflow-y: auto;
  flex-shrink: 0;
}
.editor-sidebar__label {
  font-size: 0.5rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
  padding: 4px 2px 6px;
  text-transform: uppercase;
}
.sidebar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
  border: none;
  padding: 7px 4px;
  cursor: pointer;
  border-radius: 8px;
  width: 58px;
  color: var(--text-muted);
  font-size: 0.48rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-item:hover   { background: #d0d9ee; color: var(--primary); }
.sidebar-item.active  { background: var(--primary); color: #fff; }
.sidebar-item.has-data svg { color: var(--accent); }

/* ── Drawing area ─────────────────────────────────────────── */
.editor-drawing {
  background: #fff;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--border);
  position: relative;
}

/* SVG viewport — fills the drawing area, clips when zoomed */
.svg-viewport {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  touch-action: none;   /* allow JS to handle all touch events for pinch */
  cursor: grab;
  user-select: none;
}
.svg-viewport.is-panning { cursor: grabbing; }

/* SVG container — scale is applied here by zoom.js */
.editor-svg-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  /* transform: scale(X) added by JS */
}

/* The actual SVG — always fits container */
.editor-svg-wrap svg {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

.drawing-error {
  color: var(--danger);
  font-size: 0.85rem;
  padding: 24px;
  text-align: center;
}

/* ── Zoom bar ──────────────────────────────────────────────── */
.zoom-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #f5f6f8;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.zoom-btn {
  width: 28px; height: 28px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.zoom-btn:hover    { background: #e8ecf3; }
.zoom-btn:active   { background: #d0d9ee; }
.zoom-btn:disabled { opacity: 0.35; pointer-events: none; }
.zoom-btn--reset   { font-size: 0.85rem; }
.zoom-label        { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); min-width: 34px; text-align: center; }

.drawing-detail-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(255,255,255,0.92);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  box-shadow: 0 3px 12px rgba(0,0,0,0.12);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.drawing-detail-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Drawing footer ────────────────────────────────────────── */
.editor-drawing__footer {
  padding: 5px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8f9fb;
  flex-shrink: 0;
}
.editor-area-label { font-size: 0.8rem; font-weight: 600; color: var(--primary); }

/* ── Resize handle (desktop): drag to resize options panel ── */
.editor-resize-handle {
  display: none;
  width: 6px;
  flex-shrink: 0;
  cursor: col-resize;
  background: var(--border);
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.editor-resize-handle::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: -3px; right: -3px;
}
.editor-resize-handle:hover,
.editor-resize-handle.is-dragging {
  background: var(--primary);
}

/* ── Options panel ─────────────────────────────────────────── */
.editor-options {
  background: var(--bg);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
  min-height: 0;
}
.options-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  margin-bottom: 6px;
}
.options-title { font-size: 1.06rem; font-weight: 700; color: var(--primary); margin-bottom: 9px; }
.options-hint  { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 11px; }
.extra-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }

/* ── Editor footer ─────────────────────────────────────────── */
.editor-footer {
  background: var(--card-bg);
  border-top: 2px solid var(--border);
  padding: 10px 16px calc(10px + var(--safe-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  min-height: var(--footer-h);
}
.editor-footer__cost  { display: flex; flex-direction: column; gap: 2px; }
.editor-cost-main     { display: flex; align-items: baseline; gap: 10px; }
.editor-cost-value    { font-size: 1.3rem; font-weight: 700; color: var(--primary); line-height: 1; }
.editor-cost-label    { font-size: 0.7rem; color: var(--text-muted); }
.editor-area-badge {
  font-size: 0.77rem; font-weight: 500; color: var(--text-muted);
  background: var(--bg); border-radius: 20px;
  padding: 1px 8px; line-height: 1.5;
}
.editor-area-badge--valid { color: var(--primary-lt); background: var(--primary-pale); }
.editor-dims-info {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.editor-dims-info strong { color: var(--text); font-weight: 600; }

/* ════════════════════════════════════════════════════════════
   SHAPE / MATERIAL / EDGING / HARDWARE / INSTALL TABS
   ════════════════════════════════════════════════════════════ */

.shape-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  gap: 6px;
  margin-bottom: 10px;
  width: 100%;
  max-width: 100%;
}
.shape-btn {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; transition: all 0.15s;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.shape-btn:hover    { border-color: var(--primary-lt); background: var(--primary-pale); }
.shape-btn.selected { border-color: var(--primary);    background: var(--primary-pale); }
.shape-btn__icon { width: min(44px, 100%); height: 38px; }
.shape-btn__icon svg { width: 100%; height: 100%; }
.shape-btn__label {
  max-width: 100%;
  font-size: 0.62rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.dims-info { background: #f0f4fb; border-radius: 8px; padding: 10px 12px; margin-top: 8px; }

/* Material */
.material-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.material-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border 0.15s;
}
.material-card:hover    { border-color: var(--primary-lt); }
.material-card.selected { border-color: #1565C0; }
.material-card__photo   {
  height: 72px; background: #e8f0f8;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.material-card__photo img { width: 100%; height: 100%; object-fit: cover; }
.material-card__photo--placeholder { background: linear-gradient(135deg, #e3eaf4, #d0ddf0); }
.material-card__body  { padding: 7px 9px; }
.material-card__name  { font-weight: 700; font-size: 0.8rem; margin-bottom: 1px; }
.material-card__mfr   { font-size: 0.67rem; color: var(--text-muted); }
.material-card__desc  { font-size: 0.68rem; color: var(--text-muted); }
.material-card__price { font-weight: 600; color: var(--primary); font-size: 0.8rem; margin-top: 3px; }
.video-btn { margin-top: 3px; }
.material-video-wrap { margin-top: 10px; border-radius: 8px; overflow: hidden; }
.material-video-iframe, .material-video-player { width: 100%; height: 185px; display: block; border: none; }

/* Edging */
.edging-presets { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.edging-custom-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.edging-per-edge-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.edging-per-edge-list .field-label { margin-bottom: 0; }
.edge-row {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.edge-label { font-size: 0.82rem; color: var(--text); font-weight: 500; }
.edging-zones-fields,
.edge-zone-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.edge-zone-toggle-row { margin: 0; }
.edging-zones-fields .price-hint,
.edge-zone-controls .price-hint,
.edge-zone-controls .error-msg { grid-column: 1 / -1; margin-top: 0; }

.corner-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(44px, 1fr));
  gap: 8px;
}
.corner-btn {
  min-height: 44px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--primary);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
}
.corner-btn.active {
  background: var(--primary-pale);
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.corner-diagram {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.corner-diagram svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 180px;
}
.corner-diagram__mark {
  cursor: pointer;
  outline: none;
}
.corner-diagram__mark:hover circle,
.corner-diagram__mark:focus-visible circle {
  stroke-width: 3;
}

/* Custom color / RAL button */
.color-swatch--custom {
  display: flex; align-items: center; justify-content: center;
}

/* RAL palette panel */
.ral-panel {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  overflow: hidden;
}
.ral-search-row {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.ral-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 2px;
  padding: 8px;
  max-height: 260px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.ral-swatch {
  height: 48px;
  border: 2px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 3px;
  transition: border 0.12s, transform 0.1s;
}
.ral-swatch:hover    { border-color: var(--primary); transform: scale(1.06); z-index: 1; }
.ral-swatch.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.preset-circle {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--card-bg);
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.preset-circle:hover  { border-color: var(--primary); color: var(--primary); }
.preset-circle.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.color-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.color-swatch {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2.5px solid rgba(0,0,0,0.06);
  cursor: pointer; transition: transform 0.12s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.color-swatch:hover  { transform: scale(1.12); }
.color-swatch.selected { box-shadow: 0 0 0 3px var(--primary), 0 0 0 5px #fff; }
.color-name-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 6px; }

/* Hardware */
.hardware-list { display: flex; flex-direction: column; }
.hw-item {
  display: grid; grid-template-columns: 54px 1fr auto;
  gap: 8px; align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.12s; background: var(--card-bg);
}
.hw-item:hover    { background: var(--primary-pale); }
.hw-item.selected { background: var(--primary-pale); border-left: 3px solid var(--primary); }
.hw-item__photo {
  width: 50px; height: 50px; border-radius: 50%; overflow: hidden;
  border: 2px solid var(--border); background: #e8f0f8;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.hw-item.selected .hw-item__photo { border-color: #1565C0; }
.hw-item__photo img { width: 100%; height: 100%; object-fit: cover; }

.hw-item-variants {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px 12px;
  background: var(--primary-pale);
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--primary);
}
.hw-item-variants .field-label { font-size: 0.78rem; font-weight: 600; color: var(--text); }
.hw-item-variants .field-input { margin-top: 4px; }
.hw-item__photo-placeholder { font-weight: 700; color: var(--primary-lt); font-size: 1.1rem; }
.hw-item__photo-placeholder--shape {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.hw-item__photo-placeholder--shape svg { display: block; width: 44px; height: 44px; }
.hw-item__name  { font-weight: 600; font-size: 0.83rem; }
.hw-item__desc  { font-size: 0.7rem; color: var(--text-muted); line-height: 1.3; margin: 1px 0; }
.hw-item__price { font-size: 0.73rem; color: var(--accent); }
.hw-video-btn   { flex-shrink: 0; }

/* Install */
.install-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.install-card {
  background: var(--card-bg); border: 2px solid var(--border); border-radius: 8px;
  padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; transition: all 0.15s; font-size: 0.7rem; font-weight: 500; text-align: center;
}
.install-card:hover    { border-color: var(--primary-lt); }
.install-card.selected { border-color: var(--primary); background: var(--primary-pale); color: var(--primary); }
.install-card__icon { font-size: 1.3rem; }
.step-circles { display: flex; gap: 10px; align-items: center; }

/* ════════════════════════════════════════════════════════════
   WINDOW POPUP MODAL
   ════════════════════════════════════════════════════════════ */

.win-popup-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.win-popup {
  background: var(--card-bg); border-radius: 14px;
  width: 100%; max-width: 820px; max-height: 92dvh;
  overflow: hidden; display: grid; grid-template-columns: 1fr 1fr;
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
}
.win-popup__drawing {
  background: #f8fafc; padding: 16px;
  display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.win-popup__drawing svg { max-width: 100%; max-height: 400px; }
.win-popup__info { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.win-popup__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.win-popup__header h2 { font-size: 1.05rem; color: var(--primary); }
.wp-specs { flex: 1; overflow-y: auto; padding: 12px 16px; }
.wp-spec-row { display: flex; justify-content: space-between; font-size: 0.83rem; padding: 5px 0; border-bottom: 1px solid var(--bg); }
.wp-spec-row span:first-child { color: var(--text-muted); }
.wp-spec-price { display: flex; justify-content: space-between; padding: 10px 0; font-size: 1rem; }
.wp-spec-price strong { font-size: 1.15rem; color: var(--primary); }
.wp-actions { padding: 12px 16px calc(12px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); flex-shrink: 0; }

/* ════════════════════════════════════════════════════════════
   MACBOOK RESPONSIVE
   ════════════════════════════════════════════════════════════ */

/* Desktop (≥1024px): show drag handle to resize options panel */
@media (min-width: 1024px) {
  .editor-body { grid-template-columns: var(--sidebar-w) 1fr 6px var(--options-w); }
  .editor-resize-handle { display: block; }
}

/* MacBook Air 13" / small laptop (~1024–1280px) */
@media (min-width: 1024px) and (max-width: 1280px) {
  :root { --options-w: 300px; --sidebar-w: 60px; }
  .editor-tab span { font-size: 0.55rem; }
}

/* MacBook 13" large / 14" (~1280–1440px) */
@media (min-width: 1280px) and (max-width: 1440px) {
  :root { --options-w: 330px; }
}

/* MacBook 14" Pro+ (≥1440px) */
@media (min-width: 1440px) {
  :root { --options-w: 380px; }
}

/* MacBook Pro 16" (≥1536px) */
@media (min-width: 1536px) {
  :root { --options-w: 420px; }
  .material-grid { grid-template-columns: repeat(2, 1fr); }
  .options-section { padding: 14px 18px; }
}

/* ════════════════════════════════════════════════════════════
   TABLET (768–1024px)
   ════════════════════════════════════════════════════════════ */

@media (min-width: 768px) and (max-width: 1023px) {
  :root { --options-w: 260px; --sidebar-w: 54px; }
  .editor-tab span { font-size: 0.52rem; }
  .editor-sidebar__label { display: none; }
}

/* ════════════════════════════════════════════════════════════
   MOBILE LANDSCAPE (500–768px wide, landscape orientation)
   ════════════════════════════════════════════════════════════ */

@media (max-width: 768px) and (orientation: landscape) {
  :root { --options-w: 240px; --sidebar-w: 50px; }
  .editor-body { grid-template-columns: var(--sidebar-w) 1fr var(--options-w); }
  .editor-tab span { font-size: 0; width: 0; overflow: hidden; }
  .editor-sidebar__label { display: none; }
  .sidebar-item span { display: none; }
  .sidebar-item { width: 48px; }
}

/* ════════════════════════════════════════════════════════════
   MOBILE — общие улучшения (≤ 767px)
   ════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* Prevent iOS Safari zoom on input focus — must be 16px+ */
  .field-input { font-size: 16px !important; }

  /* Larger touch targets */
  .btn        { min-height: 44px; }
  .btn--sm    { min-height: 36px; padding: 7px 14px; }
  .btn--xs    { min-height: 30px; }
  .btn--lg    { min-height: 52px; font-size: 1rem; }

  /* Slightly larger form labels */
  .field-label { font-size: 0.88rem; gap: 6px; }

  /* Toggle rows — taller for touch */
  .toggle-row { min-height: 52px; padding: 12px 0; }

  /* Hardware items — taller */
  .hw-item { padding: 13px 12px; }

  /* Order cards — slightly larger text */
  .order-card__number { font-size: 1rem; }
  .order-card__client { font-size: 0.92rem; }
}

/* ════════════════════════════════════════════════════════════
   IPHONE / SMALL MOBILE PORTRAIT (< 500px wide)
   ════════════════════════════════════════════════════════════ */

@media (max-width: 499px) {

  /* ── EDITOR: reorder to bottom-nav pattern ────────────────── */

  /* Tab bar moves to the bottom for thumb reachability */
  .editor-header { order: 1; }
  .editor-body   { order: 2; }
  .editor-footer { order: 3; }
  .editor-tabs   { order: 4; }

  /* ── Tab bar: native bottom nav style ── */
  .editor-tabs {
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    border-bottom: none;
    padding-bottom: var(--safe-bottom);
    min-height: 56px;
  }
  .editor-tab {
    padding: 6px 6px 8px;
    gap: 3px;
    font-size: 0.62rem;
    letter-spacing: 0;
    color: var(--text-muted);
    border-bottom: none;
    border-top: 2.5px solid transparent;
    margin-bottom: 0;
    margin-top: -1px;
  }
  .editor-tab svg { width: 22px; height: 22px; }
  .editor-tab span { font-size: 0.6rem; }
  .editor-tab:hover { color: var(--primary); }
  .editor-tab.active {
    color: var(--primary);
    border-top-color: var(--primary);
    border-bottom-color: transparent;
  }

  /* ── Editor body: vertical stack ── */
  .editor-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* ── Drawing: bigger, top of content ── */
  .editor-drawing {
    height: 38dvh;
    min-height: 200px;
    max-height: none;
    flex-shrink: 0;
    order: 1;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  /* Zoom bar — usable touch targets */
  .zoom-bar   { padding: 5px 10px; gap: 6px; }
  .zoom-btn   { width: 34px; height: 34px; font-size: 1rem; }
  .zoom-label { font-size: 0.72rem; min-width: 36px; }

  /* Drawing footer removed from HTML — no rule needed */

  /* ── Extras sidebar: horizontal strip ── */
  .editor-sidebar {
    flex-direction: row;
    justify-content: space-evenly;
    align-items: center;
    padding: 4px 6px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    order: 2;
    min-height: 52px;
    max-height: 52px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
  }
  .editor-sidebar__label { display: none; }
  .sidebar-item {
    flex-direction: column;
    width: auto;
    min-width: 54px;
    padding: 4px 8px;
    gap: 2px;
    font-size: 0.62rem;
    border-radius: 8px;
  }
  .sidebar-item svg { width: 20px; height: 20px; }

  /* ── Options: fills remaining space, scrollable ── */
  .editor-options {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    order: 3;
  }

  /* ── Options: compact cards ── */
  .options-section {
    padding: 10px 14px;
    margin-bottom: 3px;
    border-bottom: none;
  }
  .options-title {
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border);
  }
  .options-hint { font-size: 0.77rem; margin-bottom: 8px; }
  .field-label  { font-size: 0.82rem; margin-bottom: 8px; }
  .field-input  { padding: 8px 10px; }

  /* ── Editor footer: compact cost block + smaller save button ── */
  .editor-footer {
    order: 3;
    padding: 6px 10px 6px;
    min-height: 50px;
    gap: 8px;
    border-top: 1.5px solid var(--border);
    background: var(--card-bg);
    align-items: center;
  }
  .editor-footer__cost {
    flex: 1;
    min-width: 0;
    background: rgba(26, 58, 92, 0.06);
    border: 1.5px solid rgba(26, 58, 92, 0.13);
    border-radius: 10px;
    padding: 4px 10px;
    gap: 0;
  }
  .editor-cost-main {
    flex-wrap: nowrap;
    gap: 6px;
  }
  .editor-cost-value { font-size: 0.96rem; white-space: nowrap; }
  .editor-cost-label { font-size: 0.58rem; }
  .editor-area-badge {
    font-size: 0.62rem; padding: 0 5px; border-radius: 8px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .editor-dims-info {
    font-size: 0.56rem;
    line-height: 1.25;
  }
  .editor-dims-info span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
  }
  /* Save button: fixed compact size, not full-width */
  .editor-footer .btn--lg {
    flex: 0 0 auto;
    width: 84px;
    min-height: 40px;
    padding: 0 8px;
    font-size: 0.8rem;
    font-weight: 600;
  }

  /* ── Editor header ── */
  .editor-header {
    padding: calc(8px + var(--safe-top)) 12px 8px;
    gap: 8px;
    min-height: calc(50px + var(--safe-top));
  }
  .editor-window-title { font-size: 0.9rem; }
  .editor-header__total { display: none; }

  /* ── Shape grid ── */
  .shape-grid { gap: 6px; }
  .shape-btn  { padding: 8px 4px; }
  .shape-btn__icon  { width: 42px; height: 36px; }
  .shape-btn__label { font-size: 0.62rem; }

  /* ── Material cards ── */
  .material-card__photo  { height: 80px; }
  .material-card__name   { font-size: 0.85rem; }
  .material-card__price  { font-size: 0.85rem; }

  /* ── Install cards ── */
  .install-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .install-card  { padding: 12px 8px; font-size: 0.78rem; }

  /* ── App header on list screens ── */
  .app-header {
    min-height: calc(54px + var(--safe-top));
    padding: calc(10px + var(--safe-top)) 14px 10px;
  }
  .app-header__title { font-size: 1.1rem; }

  /* ── Screen footer (windows list) ── */
  .screen-footer { padding: 12px 14px calc(14px + var(--safe-bottom)); gap: 10px; }
  .screen-footer .btn { min-height: 50px; font-size: 0.95rem; }

  /* ── Toolbar (no longer used on orders screen — btn moved to screen-footer) ── */
  .toolbar .btn { min-height: 46px; font-size: 0.92rem; padding: 10px 18px; }

  /* ── Popup: single column ── */
  .win-popup {
    grid-template-columns: 1fr;
    max-height: 95dvh;
    overflow-y: auto;
  }
  .win-popup__drawing {
    min-height: 220px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  /* ── Order form ── */
  .order-form { max-width: 100%; }

  /* ── Empty & disclaimer text ── */
  .empty-msg { font-size: 0.95rem; padding: 40px 20px; }
}

/* ════════════════════════════════════════════════════════════
   VERY SMALL (iPhone SE, < 376px)
   ════════════════════════════════════════════════════════════ */

@media (max-width: 375px) {
  .editor-drawing { height: 34dvh; min-height: 180px; }
  .editor-tab span { font-size: 0.55rem; }
  .editor-tab svg  { width: 20px; height: 20px; }
  .shape-grid { gap: 4px; }
  .shape-btn__label { font-size: 0; }  /* icon only on tiny screens */
  .shape-btn__icon  { width: 36px; height: 30px; }
  .editor-footer .btn--lg { font-size: 0.86rem; width: 96px; }
  .editor-cost-value { font-size: 1rem; }
}

/* ════════════════════════════════════════════════════════════
   KEYBOARD DISMISS BUTTON
   ════════════════════════════════════════════════════════════ */

#kb-dismiss-btn {
  position: fixed;
  right: 12px;
  bottom: 8px;
  z-index: 9998;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(10, 10, 10, 0.58);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  cursor: pointer;
  padding: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#kb-dismiss-btn.active {
  opacity: 1;
  pointer-events: auto;
}

/* ── Interactive fastener editing (double-tap a fastener on the drawing) ── */
.editor-svg-wrap .hw-fastener { cursor: pointer; }
.fastener-editor {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1400;
  width: min(340px, calc(100vw - 24px));
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.35);
  padding: 14px 16px 16px;
}
.fastener-editor.hidden { display: none; }
.fastener-editor__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}
.fastener-editor__title { font-weight: 700; color: var(--text); }
.fastener-editor__close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted, #888);
  padding: 0 4px;
}
.fastener-editor__hint { margin: 0 0 8px; font-size: 12px; color: var(--text-muted, #888); }
.fastener-editor__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 8px;
}
.fastener-editor__row .field-input { width: 92px; text-align: right; }
.fastener-editor__actions { display: flex; gap: 8px; margin-top: 4px; }
.fastener-editor__actions .btn { flex: 1; }

/* ── Данные для договора (доп. поля в форме заказа) ── */
.order-form__group {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px 4px;
  margin: 6px 0 4px;
}
.order-form__group > legend {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  padding: 0 6px;
}
.field-hint { font-weight: 400; font-size: 11px; color: var(--text-muted, #888); }

/* ── Доп. элементы редактора крепления (#2) ── */
.fastener-editor__err { font-size: 12px; min-height: 14px; margin: -4px 0 8px; color: var(--danger, #c62828); }
.fastener-editor__max { color: var(--text-muted, #8a8a8a); font-weight: 500; }
.field-input--error { border-color: var(--danger, #c62828) !important; color: var(--danger, #c62828); }
.fastener-editor__orientation-row { align-items: flex-start; }
.fastener-orientation {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 210px;
  min-height: 36px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #eef1f5;
  color: var(--text-muted, #777);
  cursor: pointer;
  overflow: hidden;
}
.fastener-orientation::before {
  content: '';
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 3px);
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.18);
  transition: transform 0.18s ease;
}
.fastener-orientation--horizontal::before { transform: translateX(100%); }
.fastener-orientation__option {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 7px;
  font-size: 11px;
  font-weight: 600;
  transition: color 0.18s ease;
}
.fastener-orientation:not(.fastener-orientation--horizontal) [data-orientation="vertical"],
.fastener-orientation--horizontal [data-orientation="horizontal"] { color: var(--primary); }
.fastener-orientation:disabled {
  opacity: 0.48;
  filter: grayscale(1);
  cursor: not-allowed;
}

/* ── Модальное окно договора (#1) ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1300;
  background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; padding-top: calc(16px + var(--safe-top));
}
.modal {
  background: #fff; border-radius: 16px; width: min(480px, 100%);
  max-height: calc(100dvh - 40px); display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35); overflow: hidden;
}
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal__title { font-size: 1.15rem; font-weight: 700; color: var(--primary); }
.modal__close { border: none; background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: var(--text-muted); }
.modal__body { padding: 16px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal__foot { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); }
.modal__foot .btn { flex: 1; }
.contract-modal__row2 { display: flex; gap: 12px; }
.contract-modal__row2 .field-label { flex: 1; }
.contract-modal__summary {
  margin-top: 8px; padding: 10px 12px; background: var(--primary-pale);
  border-radius: 10px;
}
.contract-modal__summary .info-row { font-size: 0.95rem; }

/* ── Мобильные степперы для числовых полей: [±] [−] [значение] [+] ── */
.stepper { display: inline-flex; align-items: stretch; width: 100%; }
.stepper .field-input { flex: 1 1 auto; min-width: 0; text-align: center; border-radius: 0; }
.stepper__btn {
  flex: 0 0 auto; width: 40px; padding: 0;
  border: 1.5px solid var(--border); background: #eef2f8; color: var(--primary);
  font-size: 22px; font-weight: 600; line-height: 1; cursor: pointer;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.stepper__btn:active { background: #d8e2f1; }
.stepper__sign  { border-radius: 8px 0 0 8px; border-right: none; font-size: 18px; }
.stepper__minus { border-right: none; }
.stepper__minus:not(.stepper__minus--mid) { border-radius: 8px 0 0 8px; }
.stepper__plus  { border-radius: 0 8px 8px 0; border-left: none; }
/* На десктопе (точный указатель) степперы не нужны — нативные стрелки + клавиатура */
@media (pointer: fine) and (min-width: 1024px) {
  .stepper__btn { display: none; }
  .stepper .field-input { border-radius: 8px; }
}

/* ── Профиль дилера: загрузка лого/печати/подписи ── */
.dealer-brand {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-top: 12px;
}
.brand-field {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px; border: 1px dashed var(--border); border-radius: 10px;
  text-align: center;
}
.brand-field__label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }
.brand-preview {
  max-width: 100%; max-height: 64px; display: none;
  border-radius: 6px; background: #fff;
}
.brand-field input[type="file"] { font-size: 0.72rem; width: 100%; }
@media (max-width: 480px) {
  .dealer-brand { grid-template-columns: 1fr; }
}

/* ── Список заплаток/вырезов (несколько) ── */
.extra-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #fbfcfe;
}
.extra-item__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.extra-item__head strong { font-size: 14px; color: var(--primary); }
.extra-item__del {
  border: none; background: #fde8e8; color: var(--danger);
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-size: 15px; line-height: 1;
}
.extra-item__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.extra-item__grid .field-label { margin-bottom: 0; }

/* ── «Убрать крепление» в редакторе крепления (#2) ── */
.fastener-editor__remove {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 6px 0 10px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
  font-size: 14px; font-weight: 600; color: var(--danger); cursor: pointer;
}
.fastener-editor--removed .fastener-editor__row { opacity: 0.4; }
.fastener-editor--removed .fastener-editor__remove { background: #fde8e8; border-color: #f3b6b6; }
