/* ═══════════════════════════════════════════════════════
   Вывеска20 · TZ Design System
   ═══════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f0f4f8;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --border:      #dde3ec;
  --border-hover:#b0bec5;
  --text:        #1e293b;
  --text-2:      #475569;
  --muted:       #64748b;
  --placeholder: #94a3b8;

  --blue:        #3b82f6;
  --blue-dark:   #2563eb;
  --blue-soft:   rgba(59,130,246,.10);
  --green:       #10b981;
  --green-soft:  rgba(16,185,129,.10);
  --red:         #ef4444;
  --red-soft:    rgba(239,68,68,.08);
  --orange:      #f59e0b;
  --orange-soft: rgba(245,158,11,.10);
  --purple:      #7c3aed;

  --accent:      var(--blue);
  --accent-dark: var(--blue-dark);
  --accent-soft: var(--blue-soft);

  --radius-sm:   8px;
  --radius:      12px;
  --radius-lg:   16px;
  --radius-xl:   20px;

  --shadow-sm:   0 1px 2px rgba(0,0,0,.05);
  --shadow:      0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.07);
  --shadow-md:   0 4px 8px rgba(0,0,0,.06), 0 12px 28px rgba(0,0,0,.09);
  --shadow-lg:   0 8px 16px rgba(0,0,0,.07), 0 24px 48px rgba(0,0,0,.12);

  --topbar-h:    52px;
  --wrap-max:    640px;
}

/* ── Base ────────────────────────────────────────────── */
html { font-size: 15px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Topbar ──────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-back {
  font-size: 22px;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.topbar-back:hover { background: var(--surface-2); color: var(--text); }
.topbar-logo {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.3px;
}
.topbar-logo span { color: var(--accent); }
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); }
.topbar-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 6px;
  padding: 2px 8px;
  margin-left: 2px;
  white-space: nowrap;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ── Layout ──────────────────────────────────────────── */
.wrap { max-width: var(--wrap-max); margin: 0 auto; padding: 20px 16px 48px; }
.wrap-wide { max-width: 800px; margin: 0 auto; padding: 20px 16px 48px; }

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 16px;
}
.card-section { margin-bottom: 24px; }
.card-section:last-child { margin-bottom: 0; }

/* ── Form fields ─────────────────────────────────────── */
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
  margin-top: 14px;
}
label:first-child, .label-first { margin-top: 0; }

input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 13px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
  border-color: var(--border-hover);
  background: var(--surface);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input[disabled], select[disabled] { opacity: .5; cursor: default; background: #f1f5f9; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
textarea { resize: vertical; min-height: 72px; line-height: 1.6; }

.field-hint { font-size: 11px; color: var(--placeholder); margin-top: 5px; font-weight: 500; }

/* ── Badges (inline labels) ──────────────────────────── */
.badge-auto {
  font-size: 10px; font-weight: 600;
  background: rgba(8,145,178,.1); color: #0891b2;
  border-radius: 5px; padding: 1px 6px;
  margin-left: 5px; vertical-align: middle;
  text-transform: none; letter-spacing: 0;
}
.badge-required { font-size: 11px; color: var(--red); font-weight: 600; margin-left: 6px; }
.badge-optional { font-size: 11px; color: var(--placeholder); font-weight: 500; margin-left: 6px; }
.badge-info {
  font-size: 10px; font-weight: 700;
  background: var(--blue-soft); color: var(--blue);
  border-radius: 5px; padding: 1px 6px; margin-left: 5px; vertical-align: middle;
}

/* ── Grid ────────────────────────────────────────────── */
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media(max-width: 480px) { .row2 { grid-template-columns: 1fr; } }

/* ── Input with mic ──────────────────────────────────── */
.input-row { display: flex; gap: 6px; align-items: flex-start; }
.input-row input,
.input-row textarea,
.input-row select { flex: 1; min-width: 0; }

/* ── Mic button ──────────────────────────────────────── */
.mic-btn {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 5px 9px;
  flex-shrink: 0;
  line-height: 1.5;
  transition: all .2s;
}
.mic-btn:hover { border-color: var(--orange); color: var(--orange); background: var(--orange-soft); }
.mic-btn.recording { border-color: var(--red); color: #fff; background: var(--red); animation: mic-pulse 1s ease-in-out infinite; }
.mic-btn.processing { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); cursor: wait; }
@keyframes mic-pulse { 0%,100%{opacity:1} 50%{opacity:.45} }

/* ── Toggle ──────────────────────────────────────────── */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 14px; font-weight: 500; color: var(--text); }
.toggle { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #cbd5e1; border-radius: 26px; transition: .2s;
}
.slider::before {
  content: ''; position: absolute;
  height: 20px; width: 20px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .2s;
}
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(20px); }

/* ── Tab switcher ────────────────────────────────────── */
.tab-switcher {
  display: flex; gap: 4px;
  background: #f1f5f9; border-radius: 10px; padding: 4px;
  margin-bottom: 14px;
}
.tab-switcher button {
  flex: 1; padding: 8px; border: none; border-radius: 7px;
  cursor: pointer; font-size: 13px; font-weight: 600;
  background: transparent; color: var(--muted); transition: all .2s;
}
.tab-switcher button.active {
  background: var(--surface); color: var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,.10);
}

/* ── Type selector ───────────────────────────────────── */
.type-selector { display: flex; gap: 8px; flex-wrap: wrap; }
.type-btn {
  border: 1.5px solid var(--border); border-radius: 9px;
  background: var(--surface-2); color: var(--muted);
  font-size: 13px; font-weight: 600; padding: 8px 14px;
  cursor: pointer; transition: all .15s;
}
.type-btn:hover:not(.active) { border-color: var(--border-hover); background: var(--surface); }
.type-btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ── Photo upload ────────────────────────────────────── */
.photo-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 24px; text-align: center; cursor: pointer;
  transition: all .2s; background: var(--surface-2); position: relative;
}
.photo-zone:hover { border-color: var(--accent); background: var(--accent-soft); }
.photo-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.photo-zone-icon { font-size: 32px; margin-bottom: 8px; }
.photo-zone-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.photo-zone-sub { font-size: 11px; color: var(--placeholder); margin-top: 4px; }
.photo-preview {
  display: none; margin-top: 10px;
  border-radius: var(--radius); overflow: hidden;
  border: 1.5px solid var(--border); position: relative;
}
.photo-preview img { width: 100%; max-height: 280px; object-fit: cover; display: block; }
.photo-remove {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,.55); color: #fff;
  border: none; border-radius: 6px; padding: 4px 10px;
  cursor: pointer; font-size: 12px; font-weight: 700;
}

/* ── Deal header ─────────────────────────────────────── */
.deal-header {
  display: none;
  border-radius: var(--radius); padding: 12px 16px; margin-top: 12px;
  border: 1.5px solid;
}
.deal-name { font-size: 15px; font-weight: 700; margin-bottom: 3px; }
.deal-meta { font-size: 12px; color: var(--muted); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--radius); padding: 10px 18px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: all .15s; white-space: nowrap;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,.25);
}
.btn-primary:hover { background: var(--accent-dark); box-shadow: 0 4px 12px rgba(59,130,246,.35); transform: translateY(-1px); }
.btn-ghost { background: #f1f5f9; color: var(--muted); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: #e2e8f0; color: var(--text); border-color: var(--border-hover); }
.btn-danger { background: var(--red-soft); color: var(--red); border: 1.5px solid #fecaca; }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn:active { transform: translateY(0) !important; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-submit {
  width: 100%; border: none; border-radius: var(--radius); padding: 15px;
  color: #fff; font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 4px 14px rgba(59,130,246,.3);
  transition: all .2s; font-family: inherit;
}
.btn-submit:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(59,130,246,.4); }
.btn-submit:active { transform: translateY(0); }
.btn-submit:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-add {
  width: 100%; background: none; border: 2px dashed #d1dbe8;
  border-radius: var(--radius-sm); color: var(--muted);
  padding: 10px; cursor: pointer; font-size: 13px; font-weight: 600;
  margin-top: 10px; transition: all .15s; font-family: inherit;
}
.btn-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ── Status messages ─────────────────────────────────── */
.status {
  text-align: center; padding: 14px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; margin-top: 12px; display: none;
}
.status.ok  { background: #f0fdf4; border: 1.5px solid #86efac; color: #15803d; }
.status.err { background: #fef2f2; border: 1.5px solid #fca5a5; color: #dc2626; }

/* ── Alerts ──────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 500; margin-bottom: 12px; }
.alert-info    { background: #eff6ff; border: 1.5px solid #bfdbfe; color: #1d4ed8; }
.alert-warn    { background: #fffbeb; border: 1.5px solid #fde68a; color: #92400e; }
.alert-success { background: #f0fdf4; border: 1.5px solid #86efac; color: #15803d; }
.alert-error   { background: #fef2f2; border: 1.5px solid #fca5a5; color: #dc2626; }

/* ── Footer ──────────────────────────────────────────── */
.footer-link {
  margin-top: 28px; padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center; display: flex; justify-content: center; gap: 20px;
}
.footer-link a { color: var(--muted); font-size: 12px; text-decoration: none; font-weight: 500; transition: color .15s; }
.footer-link a:hover { color: var(--accent); }

/* ── User avatar ─────────────────────────────────────── */
.avatar {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #fff; font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ── Loading ─────────────────────────────────────────── */
.loading { text-align: center; padding: 48px; color: var(--muted); font-size: 14px; }
.empty   { text-align: center; padding: 32px; color: var(--muted); font-size: 14px; }

/* ── Viz images (montazh) ────────────────────────────── */
.viz-images { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.viz-images img {
  max-height: 160px; max-width: 100%;
  border-radius: 10px; border: 2px solid var(--border);
  object-fit: contain; cursor: pointer; transition: all .2s;
}
.viz-images img:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: scale(1.02); }

/* ── Construction items (montazh) ────────────────────── */
.construction-list { display: flex; flex-direction: column; gap: 10px; }
.construction-item {
  border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.construction-item:focus-within { border-color: #bfdbfe; box-shadow: 0 0 0 3px rgba(59,130,246,.07); }
.ci-header { display: flex; align-items: center; gap: 8px; }
.ci-name {
  flex: 1; font-size: 14px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ci-collapse {
  background: none; border: none; color: #94a3b8; font-size: 15px;
  cursor: pointer; padding: 2px 4px; border-radius: 6px; transition: all .2s;
}
.ci-collapse:hover { color: var(--accent); background: var(--accent-soft); }
.ci-collapsed .ci-collapse { transform: rotate(-90deg); }
.ci-collapsed .ci-body { display: none !important; }
.btn-remove {
  background: none; border: none; color: #cbd5e1;
  font-size: 16px; cursor: pointer; padding: 2px 6px;
  border-radius: 6px; transition: all .15s;
}
.btn-remove:hover { color: var(--red); background: var(--red-soft); }

/* ── Parse status ────────────────────────────────────── */
.parse-status { font-size: 12px; margin-top: 8px; color: var(--muted); font-weight: 500; }
.parse-status.ok  { color: var(--green); }
.parse-status.err { color: var(--red); }

/* ── Note items ──────────────────────────────────────── */
.note-item { background: #fffbf0; border: 1.5px solid #fde68a; border-radius: 10px; padding: 10px 14px; cursor: pointer; transition: background .15s; }
.note-item:hover { background: #fff8e1; }
.note-meta { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.note-collapsed .note-meta { margin-bottom: 0; }
.note-item:not(.note-collapsed) .note-meta { margin-bottom: 8px; }
.note-badge { background: #fef3c7; color: #92400e; border-radius: 5px; padding: 1px 6px; font-size: 10px; font-weight: 600; }
.note-preview { color: var(--text); font-size: 12px; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.note-chevron { font-size: 11px; color: var(--muted); margin-left: auto; flex-shrink: 0; }
.note-text { font-size: 13px; line-height: 1.6; white-space: pre-wrap; color: var(--text); }
.note-collapsed .note-text { display: none; }
