/* Панель «Кузов в цвет» — мобильный-first интерфейс (стиль сайта). */
:root {
  --bg: #f4f6fa; --surface: #fff; --ink: #101828; --muted: #5a6b7e; --line: #e4e9f1;
  --dark: #0d1420; --dark-2: #131d2e; --accent: #1f6bff; --accent-dark: #0f56db;
  --ok: #12b76a; --warn: #b97a00; --danger: #d92d20;
  --lime: #cfe6a3;
  --radius: 16px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15.5px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ---------- каркас ---------- */
#app { min-height: 100vh; }
.app-shell { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--dark); color: #fff; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.app-header .logo-mini { width: 34px; height: 34px; border-radius: 50%; background: #fff; flex: none; }
.app-header .title { font-weight: 800; font-size: 16px; line-height: 1.15; }
.app-header .title small { display: block; font-weight: 600; color: #93a4bd; font-size: 11px; }
.app-header .spacer { flex: 1; }
.icon-btn {
  background: rgba(255,255,255,.08); color: #fff; border: 0; border-radius: 10px;
  width: 38px; height: 38px; display: grid; place-items: center; font-size: 17px;
}
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; background: rgba(13,20,32,.98); border-top: 1px solid rgba(255,255,255,.1);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; background: transparent; border: 0; color: #93a4bd; padding: 9px 4px 8px;
  font-size: 11px; font-weight: 700; display: grid; place-items: center; gap: 3px;
}
.tabbar button .ic { font-size: 19px; line-height: 1; }
.tabbar button.is-active { color: #fff; }
.main { padding: 14px 14px 20px; max-width: 760px; margin: 0 auto; }

@media (min-width: 900px) {
  .tabbar { position: static; margin: 0; padding: 0; background: var(--dark); border-top: 0; }
  .tabbar button { padding: 6px 14px; font-size: 13px; }
  .tabbar button .ic { display: none; }
  .app-shell { padding-bottom: 20px; }
  .app-top { display: flex; background: var(--dark); }
  .app-top .app-header { flex: 1; }
  .app-top .tabbar { flex: none; }
  .main { max-width: 980px; }
}

/* ---------- карточки/строки ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.row-item {
  display: flex; gap: 12px; align-items: center; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-bottom: 10px;
  box-shadow: var(--shadow); cursor: pointer;
}
.row-item:active { background: #f7f9fd; }
.thumb {
  width: 58px; height: 58px; border-radius: 10px; background: linear-gradient(180deg,#eef2f8,#e3e9f2);
  object-fit: cover; flex: none; display: grid; place-items: center; color: #9aa8bc; font-size: 20px; overflow: hidden;
}
.row-item .mid { flex: 1; min-width: 0; }
.row-item .mid b { display: block; font-size: 14.5px; line-height: 1.25; }
.row-item .mid .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-item .end { text-align: right; flex: none; }
.price { font-weight: 800; font-size: 15px; }

/* ---------- бейджи ---------- */
.badge { display: inline-block; font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; letter-spacing: .02em; }
.badge--in { background: #e7f8ef; color: #0e9f52; }
.badge--order { background: #fff4dc; color: #966400; }
.badge--off { background: #f2f4f7; color: #667085; }
.badge--draft { background: #eef2f8; color: #475467; }
.badge--hidden { background: #fee4e2; color: #b42318; }
.badge--blue { background: #e8f0ff; color: #0f56db; }

/* ---------- формы ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: #fbfcfe; font-size: 15.5px;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,107,255,.15); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.hint { color: var(--muted); font-size: 12.5px; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; font-size: 15px;
  background: var(--accent); color: #fff; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn--ghost { background: #eef2f8; color: var(--ink); }
.btn--danger { background: #fee4e2; color: var(--danger); }
.btn--ok { background: #e7f8ef; color: #0e9f52; }
.btn--wa { background: #22b85c; color: #fff; }
.btn--block { width: 100%; }
.btn--sm { padding: 8px 12px; font-size: 13.5px; border-radius: 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.ops-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ops-grid .btn { width: 100%; }

/* ---------- фильтры-чипы ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; }
.chip-btn {
  flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 13.5px;
}
.chip-btn.is-active { background: var(--dark); color: #fff; border-color: var(--dark); }

/* ---------- модалки/тосты ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(13,20,32,.6); z-index: 100; display: grid; place-items: end center; }
@media (min-width: 640px) { .modal-back { place-items: center; } }
.modal {
  background: #fff; width: 100%; max-width: 480px; border-radius: 20px 20px 0 0; padding: 20px;
  max-height: 90vh; overflow: auto;
}
@media (min-width: 640px) { .modal { border-radius: 20px; } }
.modal h3 { margin: 0 0 14px; }
.modal .btn-row { margin-top: 14px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px); bottom: 90px; z-index: 200;
  background: var(--dark); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); text-align: center;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%); }
.toast.is-error { background: var(--danger); }

/* ---------- прочее ---------- */
.section-title { font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 700; text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.photos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-cell { position: relative; border-radius: 12px; overflow: hidden; background: #eef2f8; aspect-ratio: 1; }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-cell .main-flag { position: absolute; top: 6px; left: 6px; background: rgba(13,20,32,.75); color: #ffd479; font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 999px; }
.photo-cell .photo-actions { position: absolute; bottom: 0; left: 0; right: 0; display: flex; background: rgba(13,20,32,.72); }
.photo-cell .photo-actions button { flex: 1; background: transparent; border: 0; color: #fff; padding: 6px 0; font-size: 13px; }
.add-photo {
  aspect-ratio: 1; border: 2px dashed #b8c5d6; border-radius: 12px; display: grid; place-items: center;
  color: var(--muted); font-weight: 700; background: #fbfcfe; font-size: 26px;
}
.mv { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; align-items: baseline; }
.mv:last-child { border-bottom: 0; }
.mv .t { flex: none; width: 86px; color: var(--muted); font-size: 12px; }
.mv .d { flex: 1; min-width: 0; }
.mv .q { font-weight: 800; flex: none; }
.mv--receipt .q { color: #0e9f52; } .mv--sale .q { color: var(--accent); }
.mv--reserve .q { color: var(--warn); } .mv--unreserve .q, .mv--writeoff .q { color: var(--danger); } .mv--return .q { color: #0e9f52; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(600px 300px at 50% 0%, rgba(31,107,255,.25), transparent 60%), var(--dark); padding: 20px; }
.login-card { background: #fff; border-radius: 20px; padding: 28px 24px; width: 100%; max-width: 380px; box-shadow: 0 24px 48px -12px rgba(0,0,0,.4); }
.login-card .logo-big { width: 64px; height: 64px; border-radius: 50%; background: #fff; margin: 0 auto 12px; box-shadow: 0 6px 16px -6px rgba(0,0,0,.5); }
.login-card h1 { font-size: 20px; text-align: center; margin: 0 0 4px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.summary-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.sum-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.sum-card .n { font-size: 22px; font-weight: 800; }
.sum-card .l { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.fab {
  position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 60;
  width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #fff; border: 0;
  font-size: 26px; box-shadow: 0 10px 22px -6px rgba(31,107,255,.6); display: grid; place-items: center;
}
@media (min-width: 900px) { .fab { bottom: 24px; } }

/* ---------- онлайн-чат ---------- */
.tab-badge {
  position: absolute; transform: translate(14px, -6px);
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 10px; font-weight: 800; min-width: 17px; height: 17px;
  display: inline-grid; place-items: center; padding: 0 4px; border: 2px solid var(--dark);
}
.tabbar button .ic { position: relative; }
.chat-wrap { display: block; }
.chat-wrap .chat-list-pane { display: block; }
.chat-wrap.is-open .chat-list-pane { display: none; }
.chat-empty-hint { color: var(--muted); text-align: center; padding: 48px 12px; font-size: 14px; }
.chat-item { align-items: flex-start; }
.chat-ava {
  flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft, #e8f0ff);
  color: var(--accent-dark); font-weight: 800; display: grid; place-items: center; font-size: 16px;
}
.chat-item .chat-preview {
  color: var(--muted); font-size: 13px; margin-top: 3px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.chat-item.is-unread { background: #f5f9ff; }
.chat-item.is-unread .chat-preview { color: var(--ink); font-weight: 600; }
.chat-unread-n {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 800; margin-top: 4px;
}
.chat-new-n {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--danger); color: #fff; border-radius: 999px; font-size: 10.5px; font-weight: 800;
}
.chat-dialog-pane { display: flex; flex-direction: column; min-height: 60vh; }
.chat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.chat-head .chat-who { flex: 1; min-width: 0; }
.chat-edit { background: transparent; border: 0; font-size: 13px; cursor: pointer; padding: 2px 4px; }
.chat-meta .hint { margin-top: 6px; }
.chat-msgs {
  flex: 1; overflow-y: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; min-height: 240px; max-height: 46vh;
  display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow);
}
.chat-msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 82%; }
.chat-msg.is-mine { align-items: flex-end; }
.chat-bubble {
  padding: 9px 12px; border-radius: 14px 14px 14px 4px; background: #eef2f8; font-size: 14.5px;
  white-space: pre-wrap; word-break: break-word; line-height: 1.4;
}
.chat-msg.is-mine .chat-bubble { background: var(--accent); color: #fff; border-radius: 14px 14px 4px 14px; }
.chat-time { color: var(--muted); font-size: 10.5px; margin-top: 3px; }
.chat-sys { text-align: center; color: var(--muted); font-size: 12.5px; background: #f6f8fb; border-radius: 999px; padding: 4px 12px; align-self: center; }
.chat-send { display: flex; gap: 8px; margin-top: 10px; }
.chat-send textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  font-size: 14.5px; max-height: 120px; background: var(--surface);
}
.chat-send .btn { flex: none; width: 52px; font-size: 18px; }
@media (min-width: 900px) {
  .chat-wrap { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
  .chat-wrap .chat-list-pane, .chat-wrap.is-open .chat-list-pane { display: block; }
  .chat-wrap.is-open .chat-dialog-pane { display: flex; }
  .chat-dialog-pane { min-height: 70vh; }
  .chat-msgs { max-height: 52vh; }
  .chat-back { display: none; }
}
.price-mode--hide { border-color: #f0c36d; background: #fffaf0; }
.card .hint code, .chat-wrap code { background: #f2f4f7; border-radius: 6px; padding: 1px 6px; font-size: 12.5px; }

/* Всплывающее уведомление о новом сообщении */
#msg-popup { position: fixed; inset: 0; z-index: 300; background: rgba(13,20,32,.45); display: grid; place-items: start center; padding-top: 10vh; }
.msg-popup-card {
  background: var(--surface); border-radius: 18px; padding: 18px 20px; width: min(430px, 92vw);
  box-shadow: 0 24px 60px -12px rgba(0,0,0,.5); border-top: 4px solid var(--accent);
  animation: msgpop .25s ease;
}
.msg-popup-title { font-weight: 800; font-size: 17px; margin-bottom: 8px; }
.msg-popup-text { color: var(--ink-2); margin-bottom: 14px; white-space: pre-wrap; font-size: 15px; }
@keyframes msgpop { from { transform: translateY(-14px); opacity: 0 } }
