[x-cloak] { display: none !important; }
.print-only { display: none; }
.notes-editor:empty:before {
  content: attr(data-placeholder);
  color: #9ca3af;
  pointer-events: none;
}

html, body { -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
body {
  padding-bottom: env(safe-area-inset-bottom);
  background:
    radial-gradient(1200px 600px at 15% -5%, rgba(229,169,59,0.06), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, rgba(176,28,28,0.05), transparent 60%),
    #FAFAFA;
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  letter-spacing: -0.01em;
  color: #141414;
  min-height: 100vh;
}
.font-brand { font-family: 'Merriweather', Georgia, serif; letter-spacing: -0.02em; }

.conf-low { background-color: #FEF3C7 !important; border-color: #E5A93B !important; }

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

@keyframes fadeInUp { from { opacity:0; transform: translateY(6px);} to { opacity:1; transform: translateY(0);} }
.fade-in { animation: fadeInUp .3s ease both; }

@keyframes pulseRed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.35); }
  50%      { box-shadow: 0 0 0 10px rgba(16,185,129,0); }
}
.near-address { animation: pulseRed 1.8s ease-in-out infinite; }

@keyframes softPop { 0% { transform: scale(0.97);} 100% { transform: scale(1);} }
.pop { animation: softPop .18s ease; }

/* Timeline dots for order stages */
.dot   { width:10px; height:10px; border-radius:999px; background:#E5E7EB; }
.dot.done    { background:#B01C1C; }
.dot.current { background:#B01C1C; box-shadow:0 0 0 4px rgba(176,28,28,0.18); }
.line        { flex:1; height:2px; background:#E5E7EB; }
.line.done   { background:#B01C1C; }

.pill {
  display:inline-flex; align-items:center; gap:4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
  white-space: nowrap;
}

.divider { height:1px; background:#E5E7EB; }

/* GPS banner "hit" state */
.geo-hit { border-color:#10B981 !important; background:#ECFDF5 !important; }

/* ─── Tape measure (в нампаде) ────────────────────────────────────────────── */
.numpad-tape { position: relative; background: #FEFBF3; border-top: 1px solid #E5A93B33; border-bottom: 1px solid #E5A93B33; padding: 8px 0 4px; overflow: hidden; }
.tape-needle {
  position: absolute; left: 50%; top: 6px;
  width: 2px; height: 60px;
  background: #B01C1C;
  z-index: 2; pointer-events: none;
  transform: translateX(-50%);
}
.tape-needle::before {
  content: ''; position: absolute;
  left: 50%; top: -1px;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid #B01C1C;
}
.tape-wrap {
  overflow-x: scroll; overflow-y: hidden;
  height: 70px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-behavior: auto;
  /* половина viewport с обеих сторон, чтобы 0 и max могли встать под иглу */
  padding: 0 50%;
}
.tape-wrap::-webkit-scrollbar { display: none; }
.tape-svg { display: inline-block; height: 68px; }
.tape-svg svg { display: block; }
.tape-hint {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 9px; color: #6B7280; padding-top: 2px;
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}

/* ─── Contract preview (screen + print) ───────────────────────────────────── */
.printable-contract { padding: 16px; font-family: 'Inter', sans-serif; color: #000; }
.contract-page { max-width: 800px; margin: 0 auto; background: white; padding: 24px; }

.contract-table td { padding: 3px 6px; border: 1px solid #D1D5DB; font-size: 11px; }
.contract-table td.label { background:#F9FAFB; font-weight:700; width: 90px; color:#374151; }

.contract-positions { border-collapse: collapse; }
.contract-positions th,
.contract-positions td {
  border: 1px solid #D1D5DB;
  padding: 4px 6px;
  font-size: 10px;
  text-align: center;
  vertical-align: middle;
}
.contract-positions th {
  background: #FAF3E7;
  font-weight: 800;
  color: #141414;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.contract-positions td:nth-child(2) { text-align: left; }
.contract-positions td:nth-child(3) { text-align: left; font-family: 'Merriweather', serif; font-size: 10px; }
.contract-positions tbody tr:nth-child(even) { background: #FAFAFA; }

.contract-finance td { padding: 4px 8px; border: 1px solid #D1D5DB; font-size: 11px; }
.contract-finance td.label { background: #F9FAFB; font-weight: 600; }
.contract-finance td.right { text-align: right; font-variant-numeric: tabular-nums; }
.contract-finance tr.subtotal-row td { background: #EFF6FF; border-top: 2px solid #93C5FD; font-size: 11.5px; }
.contract-finance tr.total-row td { background: #FAF3E7; border-top: 2px solid #D97706; font-size: 12px; }
.contract-finance tr.total-row td b { color: #B01C1C; }

/* Header quote-meta table (Nordenseal-style) */
.contract-quote-meta td { padding: 1px 4px; font-size: 10px; vertical-align: top; }
.contract-quote-meta td.label { color: #4B5563; font-weight: 600; text-align: right; padding-right: 6px; }

/* Per-item block on Nordenseal-style contract */
.contract-section {
  break-inside: avoid;
  page-break-inside: avoid;
}
.contract-section-head {
  break-after: avoid;
  page-break-after: avoid;
}
.contract-item {
  display: flex;
  border: 1px solid #111;
  padding: 10px 12px;
  page-break-inside: avoid;
  break-inside: avoid;
  background: #fff;
  gap: 12px;
}
.contract-item-body { flex: 1 1 auto; min-width: 0; }
.contract-item-head {
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-bottom: 1px solid #111;
  padding-bottom: 4px;
  margin-bottom: 6px;
}
.contract-item-side {
  flex: 0 0 210px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
}
.contract-item-sketch {
  width: 100%;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1px;
  background: #fff;
}
.contract-item-price {
  text-align: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  margin-top: 4px;
}
.contract-item-price b { color: #B01C1C; }

/* ─── Warranty page ─────────────────────────────────────────────────────── */
.warranty-list { list-style: decimal; padding-left: 22px; }
.warranty-list li { padding-left: 4px; break-inside: avoid; page-break-inside: avoid; }
.warranty-block { break-inside: avoid; page-break-inside: avoid; }
.warranty-section-head { break-after: avoid; page-break-after: avoid; }

.window-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  padding: 4px;
}
.window-cell {
  border: 1px solid #D1D5DB;
  border-radius: 4px;
  padding: 5px 3px 4px;
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; background: #FEFCF7;
}
.window-cell .window-svg { display: block; }
.window-cell .window-label {
  font-size: 8px; font-weight: 700; text-align: center; color: #141414;
  line-height: 1.15;
}
@media (max-width: 480px) {
  .window-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ─── Voice assistant ────────────────────────────────────────────────────── */
.voice-fab {
  width: 58px; height: 58px;
  /* Внутри контентной колонки (max-w-800), не улетает к краю экрана */
  right: max(16px, calc(50vw - 400px + 16px));
  bottom: calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(135deg, #7c3aed 0%, #B01C1C 55%, #f59e0b 100%);
  box-shadow: 0 8px 26px rgba(124,58,237,0.35), 0 2px 8px rgba(176,28,28,0.25);
  position: fixed;
}
.voice-fab::before {
  /* Тонкое «свечение» вокруг кнопки — эффект AI */
  content: '';
  position: absolute; inset: -3px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #7c3aed, #B01C1C, #f59e0b, #7c3aed);
  filter: blur(6px); opacity: .55; z-index: -1;
  animation: aiSpin 6s linear infinite;
}
@keyframes aiSpin { to { transform: rotate(360deg); } }
.voice-fab .ai-dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 999px; background: #34d399;
  box-shadow: 0 0 0 2px #fff, 0 0 10px rgba(52, 211, 153, .9);
}

/* ─── ChatGPT-style composer ─────────────────────────────────────────────── */
.composer { max-width: 800px; margin: 0 auto; }
.composer-btn { width: 80px; height: 80px; }
.composer-btn svg { width: 40px; height: 40px; }
.composer textarea { line-height: 1.35; }
.composer textarea::-webkit-scrollbar { width: 0; }
@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.45); }
  50%      { box-shadow: 0 0 0 12px rgba(220,38,38,0); }
}
.rec-pulse { animation: recPulse 1.2s ease-in-out infinite; }
@keyframes recBlink { 0%, 60% { opacity: 1;} 80%, 100% { opacity: 0.2;} }
.rec-blink { animation: recBlink 1s ease-in-out infinite; }
@keyframes dotBlink { 0%, 80%, 100% { opacity: 0.25;} 40% { opacity: 1;} }
.dot-blink { animation: dotBlink 1.2s ease-in-out infinite; }

/* ═══════ v02 · Composite window configurator ═══════ */
/* Общие свойства resizer'а — применяются в обоих контейнерах (canvas и preview) */
.composite-resizer {
  width: 18px;
  min-width: 18px;
  cursor: col-resize;
  flex-shrink: 0;
  z-index: 20;
  touch-action: none;
  align-self: stretch;
  position: relative;
}

.grid-canvas {
  display: flex;
  flex-direction: column;
  border: 1px solid #cbd5e1;
  overflow: hidden;
}
.grid-canvas .grid-row {
  display: flex;
  border-bottom: 2px solid #8B6F52;
  min-height: 0;
}
.grid-canvas .grid-row:last-child { border-bottom: 0; }
.grid-canvas .composite-cell {
  background: #f8fafc;
  border-right: 2px solid #8B6F52;
  overflow: hidden;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.grid-canvas .composite-cell:last-of-type { border-right: 0; }
.grid-canvas .composite-cell.cell-err {
  background: #fef2f2;
  outline: 2px solid #dc2626;
  outline-offset: -2px;
}
.grid-canvas .composite-cell.cell-warn {
  background: #fffbeb;
  outline: 2px solid #f59e0b;
  outline-offset: -2px;
}
.grid-canvas .composite-resizer {
  width: 8px;
  cursor: col-resize;
  background: linear-gradient(to right, transparent 0%, #64748b 40%, #64748b 60%, transparent 100%);
  flex-shrink: 0;
  z-index: 5;
  touch-action: none;
}
.grid-canvas .composite-resizer:hover { background: #dc2626; }
.grid-canvas .composite-resizer.resizer-disabled {
  cursor: not-allowed;
  background: linear-gradient(to right, transparent 0%, #cbd5e1 40%, #cbd5e1 60%, transparent 100%);
}
.grid-canvas .composite-resizer.resizer-disabled:hover { background: linear-gradient(to right, transparent 0%, #cbd5e1 40%, #cbd5e1 60%, transparent 100%); }

/* Круглый серый + для добавления рядов/модулей */
.composite-plus-btn {
  min-width: 36px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
  border: 1px dashed #94a3b8;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.composite-plus-btn:hover {
  background: #cbd5e1;
  color: #0f172a;
  border-color: #64748b;
  border-style: solid;
}
.composite-plus-side {
  width: 18px;
  min-width: 18px;
  align-self: stretch;
  background: #e2e8f0;
  color: #64748b;
  border: 1px dashed #94a3b8;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.composite-plus-side:hover {
  background: #94a3b8;
  color: #ffffff;
  border-style: solid;
}
.composite-plus-side-l { border-right: 0; border-radius: 4px 0 0 4px; }
.composite-plus-side-r { border-left: 0; border-radius: 0 4px 4px 0; }

/* Overlay-ячейка поверх SVG-preview: прозрачная, кликабельная, с ободком */
.composite-preview .composite-overlay-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  cursor: pointer;
  transition: outline-color 0.15s, background 0.15s;
  outline: 2px dashed transparent;
  outline-offset: -6px;   /* обводка внутри ячейки, чтобы был видимый зазор от рамы */
}
.composite-preview .composite-overlay-cell:hover {
  outline-color: rgba(56, 189, 248, 0.7);   /* sky-400 */
  background: rgba(56, 189, 248, 0.05);
}
.composite-preview .composite-overlay-cell.overlay-selected {
  outline: 2.5px solid #0284c7;             /* sky-600 */
  outline-offset: -6px;
  background: rgba(56, 189, 248, 0.08);
}
.composite-preview .composite-overlay-cell.overlay-err {
  outline: 2.5px solid #dc2626;             /* red-600 */
  outline-offset: -6px;
  background: rgba(220, 38, 38, 0.06);
}
.composite-preview .composite-overlay-cell.overlay-warn {
  outline: 2.5px solid #f59e0b;             /* amber-500 */
  outline-offset: -6px;
  background: rgba(245, 158, 11, 0.06);
}
/* Resizer в overlay-режиме — по-прежнему col-resize, но чуть темнее */
.composite-preview .composite-resizer {
  background: rgba(30, 41, 59, 0.65);
  border-left: 1px solid rgba(255, 255, 255, 0.7);
  border-right: 1px solid rgba(255, 255, 255, 0.7);
  position: relative;
}
/* «Ушки» на резизере — визуальный якорь для drag */
.composite-preview .composite-resizer::before {
  content: '⇔';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 11px;
  font-weight: bold;
  pointer-events: none;
  text-shadow: 0 0 3px rgba(0,0,0,0.8);
}
.composite-preview .composite-resizer:hover {
  background: #dc2626;
}
.composite-preview .composite-resizer.resizer-disabled {
  background: rgba(148, 163, 184, 0.5);
  cursor: not-allowed;
}
.composite-preview .composite-resizer.resizer-disabled::before { content: '🔒'; font-size: 9px; }

/* Editable per-window price inside contract preview.
 * Screen: тонкий подчёркнутый input с моно-tabular цифрами.
 * Print: чистый жирный текст — визуально как <b>. */
.contract-price-input {
  width: 90px;
  text-align: right;
  padding: 0 2px;
  border: none;
  border-bottom: 1px dashed #cbd5e1;
  background: transparent;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #b91c1c;
  font-family: inherit;
  font-size: inherit;
  outline: none;
  transition: border-color 150ms ease-out, background 150ms ease-out;
}
.contract-price-input:hover { border-bottom-color: #94a3b8; background: #f8fafc; }
.contract-price-input:focus { border-bottom-color: #b91c1c; background: #fef2f2; }
.contract-price-input.contract-price-override { color: #1d4ed8; border-bottom-color: #93c5fd; }
.contract-price-reset {
  width: 16px; height: 16px; border-radius: 999px;
  display: inline-grid; place-items: center;
  background: #f1f5f9; color: #64748b;
  font-size: 12px; line-height: 1; font-weight: 700;
  cursor: pointer; border: none;
  transition: background 150ms ease-out, color 150ms ease-out;
}
.contract-price-reset:hover { background: #fee2e2; color: #b91c1c; }
/* Hide number spinner arrows */
.contract-price-input::-webkit-outer-spin-button,
.contract-price-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.contract-price-input[type="number"] { -moz-appearance: textfield; }

@media print {
  .contract-price-input {
    border: none !important;
    background: transparent !important;
    color: #000 !important;
    padding: 0 !important;
    width: auto !important;
    min-width: 0 !important;
    -webkit-appearance: none;
  }
  .contract-price-input.contract-price-override { color: #000 !important; }
  html, body { background: white !important; overflow: visible !important; visibility: visible !important; }
  /* Hide header and all non-printable sections. Keep <main> visible so
   * the .printable-contract inside actually renders. */
  header, .no-print, .print-hidden { display: none !important; }
  .print-only { display: block !important; }
  main > section:not(.printable-contract) { display: none !important; }
  main {
    padding: 0 !important;
    padding-bottom: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }
  .printable-contract { display: block !important; padding: 0; }
  .contract-page { padding: 12mm; max-width: none; }
  .window-grid { grid-template-columns: repeat(6, 1fr); }
  /* Alpine sets `display: none` inline for x-show=false — enforce contract visible. */
  section.printable-contract[style*="display"] { display: block !important; }
  @page { size: A4; margin: 10mm 0 0 0; }
  @page :first { margin-top: 0; }
}
