/* 240FPS CRM — лаконичная тема. Светлая по умолчанию, тёмная по настройке системы. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e4e7ec;
  --text: #101828;
  --muted: #667085;
  --accent: #2f6bff;
  --accent-soft: #ecf1ff;
  --danger: #d92d20;
  --ok: #12a150;
  --warn: #dc8500;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #151a21;
    --surface-2: #1a202a;
    --border: #262d38;
    --text: #e7ebf2;
    --muted: #98a2b3;
    --accent: #5b8cff;
    --accent-soft: #1a2440;
    --danger: #f97066;
    --ok: #3ccb7f;
    --warn: #f5a524;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

/* --- Каркас --- */
.shell { display: grid; grid-template-columns: 208px 1fr; height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 4px;
}

.logo {
  font-weight: 700;
  letter-spacing: -.02em;
  font-size: 15px;
  padding: 4px 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo b { color: var(--accent); }

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; }
.who { padding: 6px 10px; font-size: 12px; color: var(--muted); }
.who strong { display: block; color: var(--text); font-size: 13px; }

.main { overflow: hidden; display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.page { flex: 1; min-height: 0; overflow: auto; padding: 20px 24px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 18px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.spacer { flex: 1; }

/* --- Элементы --- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; box-shadow: none; background: none; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.ghost.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }

input[type=text], input[type=password], input[type=number], input[type=search], input[type=date], textarea, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input[type=date] { color-scheme: light dark; }
label.field { display: block; margin-bottom: 10px; }
label.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 48px 16px; font-size: 13px; }

/* --- Диалоги --- */
/* minmax(0, 1fr) и min-height: 0 обязательны: без них строка сетки растягивается
   по высоте переписки, лишнее обрезается overflow: hidden и прокручивать нечего. */
.chat-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); flex: 1; min-height: 0; overflow: hidden; }
.chat-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--surface); min-height: 0; }
.chat-search { padding: 12px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }

/* Переключатель аккаунтов над списком диалогов */
.segmented { display: flex; gap: 2px; padding: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.seg {
  flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 5px 6px; border: none; border-radius: 6px; background: none; color: var(--muted);
  cursor: pointer; font-size: 12px;
}
.seg:hover { color: var(--text); }
.seg.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.seg-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.segmented.fit .seg { flex: none; padding: 5px 10px; }
.chat-items { overflow: auto; flex: 1; min-height: 0; }

.chat-item { padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; display: grid; gap: 3px; }
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--accent-soft); }
.chat-item .row { display: flex; align-items: center; gap: 8px; }
.chat-item .name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .time { font-size: 11px; color: var(--muted); flex: none; }
.chat-item .preview { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .item-title { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  background: var(--accent); color: #fff; border-radius: 20px;
  font-size: 11px; padding: 1px 6px; min-width: 18px; text-align: center; flex: none;
}

.chat-pane { display: flex; flex-direction: column; overflow: hidden; background: var(--bg); min-height: 0; }
.chat-head {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface); display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.chat-head .title { font-weight: 650; }

.messages { flex: 1; min-height: 0; overflow: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.messages > * { flex-shrink: 0; }
.msg { max-width: 62%; display: flex; flex-direction: column; gap: 3px; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.bubble {
  padding: 8px 12px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border); white-space: pre-wrap; word-break: break-word;
}
.msg.out .bubble { background: var(--accent); border-color: var(--accent); color: #fff; }
.bubble img { display: block; max-width: 280px; border-radius: 8px; }
.msg .meta { font-size: 11px; color: var(--muted); }
.day-sep { text-align: center; font-size: 11px; color: var(--muted); margin: 6px 0; }

.composer { border-top: 1px solid var(--border); background: var(--surface); padding: 10px 14px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { resize: none; min-height: 40px; max-height: 160px; }

/* --- Воронка --- */
.board { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 12px; height: 100%; }
.column { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: 258px; flex: none; display: flex; flex-direction: column; max-height: 100%; }
.column-head { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.column-head .count { color: var(--muted); font-weight: 500; }
/* Карточка фиксированной высоты, колонка вмещает ровно 8 — дальше прокрутка внутри колонки. */
.board { --deal-h: 84px; --deal-gap: 6px; }
.column-body {
  padding: 6px; display: flex; flex-direction: column; gap: var(--deal-gap); overflow: auto; min-height: 80px;
  max-height: calc(8 * var(--deal-h) + 7 * var(--deal-gap) + 12px);
}
.column.drag-over .column-body { background: var(--accent-soft); border-radius: 8px; }

.deal {
  flex: none; height: var(--deal-h); overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 9px; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
}
.deal:hover { border-color: var(--accent); }
.deal.stale { border-left: 3px solid var(--warn); }
.deal .top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.deal .top .avatar { width: 18px; height: 18px; font-size: 9px; }
.deal .who { color: var(--text); font-weight: 600; font-size: 13px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0; }
.deal .when { font-size: 11px; color: var(--muted); flex: none; }
.deal .sub { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal .last {
  font-size: 12px; line-height: 1.3; color: var(--muted); overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; word-break: break-word;
}
.avatar {
  width: 20px; height: 20px; border-radius: 50%; color: #fff; font-size: 10px;
  display: inline-flex; align-items: center; justify-content: center; flex: none; font-weight: 600;
}

/* --- Таблицы --- */
table.grid { width: 100%; border-collapse: collapse; background: var(--surface); }
table.grid th, table.grid td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
table.grid th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
table.grid tr:hover td { background: var(--surface-2); }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Статистика --- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { padding: 14px; }
.tile .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.tile .value { font-size: 22px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.section { margin-bottom: 24px; }
.section h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 10px; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 60px; align-items: center; gap: 10px; padding: 4px 0; font-size: 13px; }
.bar { height: 8px; border-radius: 6px; background: var(--accent); min-width: 2px; }
.bar-track { background: var(--surface-2); border-radius: 6px; }

/* --- Модальные окна --- */
.overlay {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50;
}
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; border: 1px solid var(--border); }
.modal.wide { max-width: 760px; }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal-head h2 { margin: 0; font-size: 15px; }
.modal-body { padding: 18px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.perm { display: flex; gap: 8px; align-items: flex-start; padding: 7px 0; }
.perm input { margin-top: 3px; }
.perm .t { font-weight: 600; font-size: 13px; }
.perm .h { font-size: 12px; color: var(--muted); }

.toast {
  position: fixed; right: 20px; bottom: 20px; background: var(--text); color: var(--bg);
  padding: 10px 14px; border-radius: 8px; z-index: 100; font-size: 13px; max-width: 360px;
}

/* --- Вход --- */
.login-wrap { height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { width: 340px; padding: 26px; }
.login-box h1 { font-size: 18px; margin: 0 0 4px; }
.login-box p { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }

[hidden] { display: none !important; }

/* --- Склад --- */
.stock-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.stock-warning { padding: 12px 14px; margin-bottom: 14px; border-color: var(--warn); }
.stock-warning-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 8px; font-size: 13px; }
.stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 12px; align-items: start; }
.stock-card { overflow: hidden; }
.stock-card-head { display: flex; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; }
.stock-row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.stock-row:hover { background: var(--surface-2); }
.stock-row.open { background: var(--accent-soft); }
.stock-row.warn .stock-label > div:first-child { color: var(--warn); font-weight: 600; }
.stock-label { flex: 1; min-width: 0; }
.stock-qty { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stock-items { background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 4px 0; }
.stock-item { display: flex; align-items: center; gap: 8px; padding: 3px 8px 3px 26px; font-size: 12px; }
.stock-item-name { flex: 1; min-width: 0; color: var(--muted); }
.stock-item-qty { font-variant-numeric: tabular-nums; white-space: nowrap; }
.stock-edit { padding: 2px 6px; font-size: 12px; }

/* --- Собранные ПК --- */
.pc-lines { display: grid; gap: 6px; }
.pc-line { display: grid; grid-template-columns: 170px minmax(0, 1fr) 70px auto; gap: 6px; align-items: center; }
.pc-line select, .pc-line input { min-width: 0; }
.pc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); gap: 12px; align-items: start; }
.pc-card { padding: 14px; display: grid; gap: 10px; }
.pc-card.sold { opacity: .85; }
.pc-card-head { display: flex; align-items: flex-start; gap: 10px; }
.pc-title { font-weight: 650; font-size: 15px; }
.pc-price { text-align: right; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pc-parts { display: grid; gap: 3px; font-size: 13px; }
.pc-part { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px; }
.pc-meta { display: grid; gap: 2px; }
.pc-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tag-ok { color: var(--ok); border-color: var(--ok); }
@media (max-width: 700px) {
  .pc-line { grid-template-columns: 1fr 64px auto; }
  .pc-line .pc-cat { grid-column: 1 / -1; }
  .pc-part { grid-template-columns: 1fr; gap: 0; }
}

/* --- Калькулятор --- */
.modal.calc-modal { max-width: 1120px; }
.calc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.calc-platforms { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.calc-platform-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }
.calc-platform { text-align: left; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; }
.calc-platform:hover { border-color: var(--accent); }
.calc-platform.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
.calc-platform-title { font-weight: 650; }
.calc-parts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.calc-field { margin-bottom: 8px; }
.calc-thumbs { display: flex; gap: 4px; margin-top: 6px; }
.calc-thumbs img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: zoom-in; }
.calc-right { position: sticky; top: 0; }
.calc-summary { background: #0b1628; color: #e7ebf2; border-radius: 12px; padding: 16px; display: grid; gap: 6px; }
.calc-summary .muted { color: #8b97ab; }
.calc-summary-title { color: #22d3ee; font-weight: 650; margin-bottom: 4px; }
.calc-line { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 8px; font-size: 12px; align-items: baseline; }
.calc-line.calc-sub { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 6px; }
.calc-price { white-space: nowrap; font-variant-numeric: tabular-nums; }
.calc-total { display: flex; justify-content: space-between; border-top: 1px solid rgba(255, 255, 255, .12); padding-top: 10px; margin-top: 4px; font-size: 18px; font-weight: 650; }
.calc-total span:last-child { color: #22d3ee; }
.calc-preview { width: 100%; border-radius: 8px; border: 1px solid var(--border); margin-top: 8px; }
.calc-actions { display: grid; gap: 6px; margin-top: 10px; }
.calc-actions .btn { text-align: center; }
.calc-lightbox { text-align: center; }
.calc-lightbox-img { max-width: 100%; max-height: 60vh; border-radius: 10px; }
@media (max-width: 900px) {
  .calc-layout { grid-template-columns: 1fr; }
  .calc-right { position: static; }
  .calc-platforms, .calc-parts { grid-template-columns: 1fr; }
}

/* --- Заказы на сборку --- */
.order-city { margin-bottom: 26px; }
.order-city-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.order-city-title { display: flex; align-items: center; gap: 8px; background: none; border: none; cursor: pointer; font-size: 17px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; padding: 0; }
.order-list { display: grid; gap: 8px; }
.order-card { overflow: hidden; }
.order-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: none; border: none; cursor: pointer; text-align: left; }
.order-head:hover { background: var(--surface-2); }
.order-number { font-weight: 650; white-space: nowrap; }
.order-head .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.order-total { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.order-body { padding: 4px 14px 14px; border-top: 1px solid var(--border); }
.order-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 12px; margin-top: 10px; }
.order-wide { grid-column: 1 / -1; }
.order-table-wrap { overflow-x: auto; }
.order-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.order-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px; }
.order-table td { padding: 4px 6px; vertical-align: bottom; }
.order-table td.center { text-align: center; vertical-align: middle; }
.order-table input, .order-table select { padding: 5px 7px; font-size: 12px; }
.order-item-name { min-width: 220px; }
.order-num { width: 100px; }
.order-item.received { background: rgba(124, 58, 237, .16); }
.order-item.av-wb { background: rgba(203, 17, 171, .12); }
.order-item.av-ozon { background: rgba(37, 99, 235, .16); }
.order-item.av-avito { background: rgba(34, 211, 238, .16); }
.order-item.av-dns { background: rgba(249, 115, 22, .16); }
.order-item.av-citilink { background: rgba(139, 94, 52, .22); }
.order-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; }
.order-issued-row { cursor: pointer; }
.order-issued-details td { background: var(--surface-2); }

/* --- Сборка ПК со склада в стиле калькулятора --- */
.pcb-select-row { display: flex; gap: 6px; }
.pcb-select-row select { flex: 1; min-width: 0; }
.pcb-select-row .pc-qty { width: 64px; flex: none; }
.pcb-hint { margin-top: 3px; }
.pcb-extras-title { font-weight: 650; margin: 16px 0 4px; }
.pcb-fields { margin-top: 12px; }
.pc-qty { width: 70px; }

/* === Меню с иконками (компьютер) === */
.nav-item { justify-content: flex-start; gap: 10px; }
.nav-icon { display: inline-flex; flex: none; opacity: .85; }
.nav-label { flex: 1; min-width: 0; }
.nav-more { display: none; }
.chat-back { display: none; }
.login-box { max-width: calc(100vw - 32px); }

/* Лист «Ещё» */
.more-sheet { display: grid; }
.more-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%;
  padding: 13px 4px; border: none; border-bottom: 1px solid var(--border); background: none;
  text-align: left; font-size: 15px; cursor: pointer; color: var(--text);
}
.more-item:last-child { border-bottom: none; }
.more-sep { height: 10px; }

/* === Телефон === */
@media (max-width: 760px) {
  html, body { overflow: hidden; overscroll-behavior: none; }
  /* 16px в полях ввода — иначе iPhone приближает страницу при каждом нажатии на поле. */
  input[type=text], input[type=password], input[type=number], input[type=search], input[type=date], textarea, select { font-size: 16px; }

  .shell { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; height: 100vh; height: 100dvh; }
  .main { order: 1; padding-top: env(safe-area-inset-top); }

  /* Боковое меню превращается в нижнюю панель. */
  .sidebar {
    order: 2; flex-direction: row; gap: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    border-right: none; border-top: 1px solid var(--border);
  }
  .sidebar .logo, .sidebar-foot { display: none; }
  #nav { display: flex; width: 100%; }
  .nav-item {
    position: relative; flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center;
    gap: 2px; padding: 6px 2px; font-size: 10.5px; border-radius: 10px;
  }
  .nav-item .nav-icon { opacity: 1; }
  .nav-item .nav-label { flex: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
  .nav-item .badge { position: absolute; top: 1px; left: 50%; margin-left: 4px; font-size: 10px; padding: 0 5px; }
  .nav-item.active { background: none; }
  .nav-item.active .nav-icon { background: var(--accent-soft); border-radius: 12px; padding: 1px 12px; }
  .nav-secondary { display: none; }
  .nav-more { display: flex; }

  .page { padding: 12px; }
  .page-head { margin-bottom: 10px; }
  .page-head h1 { font-size: 17px; }

  /* Диалоги: список и переписка — два экрана. */
  .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .chat-pane { display: none; }
  .chat-open .chat-list { display: none; }
  .chat-open .chat-pane { display: flex; }
  .chat-list { border-right: none; }
  .chat-back { display: inline-flex; font-size: 20px; padding: 2px 8px; }
  .chat-head { padding: 6px 8px; gap: 6px; flex-wrap: wrap; }
  .chat-head .avatar, .chat-head .tag { display: none; }
  .chat-head select { width: auto; max-width: 46vw; padding: 5px 8px; font-size: 14px; }
  .chat-head .btn { padding: 6px 9px; font-size: 13px; }
  .messages { padding: 12px 10px; }
  .msg { max-width: 86%; }
  .bubble img { max-width: 62vw; }
  .composer { padding: 6px 8px; gap: 6px; }
  .composer select { max-width: 30vw; }

  /* Воронка: колонка на экран, листается вбок. */
  .board { scroll-snap-type: x mandatory; gap: 10px; }
  .column { width: 84vw; scroll-snap-align: start; }

  /* Окна — на весь экран, «Ещё» — снизу листом. */
  .overlay { padding: 0; align-items: stretch; }
  .modal, .modal.wide, .modal.calc-modal { max-width: none; max-height: none; height: 100%; border-radius: 0; border: none; }
  .modal-head { padding-top: calc(12px + env(safe-area-inset-top)); position: sticky; top: 0; background: var(--surface); z-index: 2; }
  .modal-foot { position: sticky; bottom: 0; background: var(--surface); padding-bottom: calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .sheet-overlay { align-items: flex-end; }
  .sheet-overlay .modal { height: auto; max-height: 85vh; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .sheet-overlay .modal-head { padding-top: 14px; }
  .grid-2 { grid-template-columns: 1fr; }

  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile { padding: 10px; }
  .tile .value { font-size: 18px; }
  .card { overflow-x: auto; }
  table.grid th, table.grid td { padding: 8px; white-space: nowrap; }
  .bar-row { grid-template-columns: 110px 1fr 44px; }

  .order-head { flex-wrap: wrap; row-gap: 4px; }
  .order-foot .btn { flex: 1 1 auto; }
  .stock-toolbar { gap: 8px; }
  .pc-part { grid-template-columns: 1fr; gap: 0; }

  .toast { left: 12px; right: 12px; max-width: none; bottom: calc(72px + env(safe-area-inset-bottom)); }
}

/* --- Цены калькулятора --- */
input.price-input { width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
