/* Кабинет: каркас, боковое меню, таблицы, воронка.
 *
 * Сборщика нет намеренно - файл раздаётся как есть, правку видно сразу на бою.
 * Шрифты только системные: ни одного внешнего запроса со страницы.
 * Цвета взяты с сайта компании: фон #121110, акцент #EA4E1B.
 */

:root {
  --bg: #121110;
  --bg-soft: #171514;
  --panel: #1c1a18;
  --panel-2: #221f1c;
  --line: #2c2724;
  --line-2: #3a3430;
  --text: #f4efeb;
  --text-2: #b8aea6;
  --muted: #857a72;
  --accent: #ea4e1b;
  --accent-2: #ff6a3c;
  --accent-soft: rgba(234, 78, 27, .14);
  --ok: #43a06c;
  --warn: #d59a2c;
  --bad: #d9503c;
  --radius: 12px;
  --side: 236px;
  --shadow: 0 18px 48px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }
/* Ссылка внутри карточки обязана быть видна как ссылка: иначе человек не знает,
 * что по имени клиента можно кликнуть. */
.kv a, .rows a, .card a, .tbl a { color: var(--accent-2); }
.kv a:hover, .rows a:hover, .card a:hover, .tbl a:hover, .feed a:hover { text-decoration: underline; }
.sep { color: var(--muted); padding: 0 5px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul { list-style: none; padding: 0; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------------ загрузка */

.boot {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
}

.spin {
  width: 26px;
  height: 26px;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ вход */

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 520px at 50% -10%, rgba(234, 78, 27, .16), transparent 70%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px 26px 26px;
  box-shadow: var(--shadow);
}

.mark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: .16em;
  font-size: 15px;
}

.mark i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  flex: 0 0 auto;
}

.login-sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13.5px;
}

.field { display: block; margin-top: 16px; }
.field > span { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }

.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg-soft);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus, .field select:focus, .field textarea:focus,
.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field textarea { resize: vertical; min-height: 74px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--panel-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}

.btn:hover { background: #2a2521; border-color: #463f39; }
.btn:disabled { opacity: .55; cursor: default; }

.btn-main {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn-main:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-wide { width: 100%; margin-top: 18px; padding: 12px 16px; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn-bad { color: #ffb9ae; }
.btn-bad:hover { background: rgba(217, 80, 60, .18); border-color: rgba(217, 80, 60, .5); }

.note {
  margin-top: 12px;
  min-height: 20px;
  font-size: 13px;
  color: var(--text-2);
}

.note.bad { color: #ff9c8a; }
.note.ok { color: #8fd9ae; }

/* Чем можно войти. Список рисуется по ответу ядра, а не зашит в разметку:
   подключён бот или нет, куплены SMS или нет - знает только сервер. */
.ways { margin-top: 18px; }

.way {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-2);
}

.way:first-child { border-top: 0; }
.way b { color: var(--text); font-weight: 600; }
.way p { margin-top: 2px; }

/* Точка состояния: работает или нет. Цвет - единственное, что отличает,
   поэтому рядом всегда стоит текст «не подключены», а не только кружок. */
.way i {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #6ec48f;
}

.way.off i { background: #8a6a60; }
.way.off b { color: var(--text-2); }

.way-bot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.way-bot:hover { background: #2a2521; border-color: #463f39; }

/* Главный путь входа. Он же единственный, который работает без покупок,
   поэтому и выглядит главным, а «Прислать код» становится обычной кнопкой.
   Класс называется «hot», а не «main»: «main» уже занят колонкой каркаса
   (.main { flex-direction: column }), и кнопка от него разъезжалась в две строки. */
.way-bot.hot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.way-bot.hot:hover { background: var(--accent-2); border-color: var(--accent-2); }

/* Разделитель «или»: без него форма с телефоном читается как единственный путь. */
.or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 2px;
  font-size: 12px;
  color: var(--muted);
}

.or::before, .or::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

/* ------------------------------------------------------------------ каркас */

.app {
  display: grid;
  grid-template-columns: var(--side) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  z-index: 30;
}

.brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--line);
}

.brand small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: .04em;
}

.nav { padding: 10px 10px 16px; flex: 1 1 auto; }

.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  margin-bottom: 2px;
  border-radius: 9px;
  color: var(--text-2);
  font-size: 14px;
  transition: background .12s, color .12s;
}

.nav a:hover { background: var(--panel); color: var(--text); }

.nav a.on {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}

.nav svg { width: 17px; height: 17px; flex: 0 0 auto; opacity: .9; }
.nav a.on svg { color: var(--accent); opacity: 1; }

.nav .cnt {
  margin-left: auto;
  font-size: 11.5px;
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--panel-2);
  color: var(--text-2);
}

.nav .cnt.hot { background: rgba(217, 80, 60, .2); color: #ffb0a2; }

.side-foot {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}

.side-foot b { display: block; color: var(--text); font-size: 13.5px; font-weight: 600; }
.side-foot .btn { margin-top: 10px; width: 100%; }

.main { min-width: 0; display: flex; flex-direction: column; }

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  background: rgba(18, 17, 16, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.top h1 { font-size: 19px; font-weight: 650; letter-spacing: -.01em; }
.top .crumb { color: var(--muted); font-size: 13px; }
.top-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.burger {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  cursor: pointer;
}

.view { padding: 22px; flex: 1 1 auto; }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 25;
  display: none;
}

/* ------------------------------------------------------------------ плитки обзора */

/* Плиток ровно шесть. Автоподбор ширины раскладывал бы их как 5 плюс 1
 * с дырой во всю строку, поэтому колонки задаём явно: 2, 3 или 6. */
.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 700px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1560px) { .tiles { grid-template-columns: repeat(6, 1fr); } }

.tile {
  display: block;
  padding: 16px 17px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s, transform .15s;
}

.tile:hover { border-color: var(--line-2); transform: translateY(-1px); }
.tile .cap { font-size: 12.5px; color: var(--muted); }
.tile .val { margin-top: 7px; font-size: 27px; font-weight: 680; letter-spacing: -.02em; }
.tile .sub { margin-top: 4px; font-size: 12.5px; color: var(--text-2); }
.tile.hot { border-color: rgba(217, 80, 60, .45); }
.tile.hot .val { color: #ff8a76; }
.tile.acc .val { color: var(--accent-2); }

.h2 {
  margin: 26px 0 12px;
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  /* На телефоне заголовок и кнопки рядом не помещаются: без переноса заголовок
     сжимался в столбик по одному слову, а кнопки уезжали за край экрана. */
  flex-wrap: wrap;
}

.h2 span { font-weight: 400; font-size: 12.5px; color: var(--muted); }

/* ------------------------------------------------------------------ лента */

.feed { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }

.feed li { display: flex; gap: 12px; padding: 11px 16px; border-top: 1px solid var(--line); }
.feed li:first-child { border-top: 0; }
.feed li:hover { background: var(--panel-2); }
.feed .kind {
  flex: 0 0 auto;
  width: 84px;
  font-size: 11.5px;
  color: var(--muted);
  text-transform: lowercase;
  padding-top: 2px;
}
.feed .what { flex: 1 1 auto; min-width: 0; font-size: 13.5px; overflow-wrap: anywhere; }
.feed .when { flex: 0 0 auto; font-size: 12px; color: var(--muted); padding-top: 2px; }

/* ------------------------------------------------------------------ панель раздела */

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.search { position: relative; flex: 1 1 260px; max-width: 420px; }

.search input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  outline: none;
}

.search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.chips { display: flex; gap: 7px; flex-wrap: wrap; }

.chip {
  padding: 7px 13px;
  border: 1px solid var(--line-2);
  border-radius: 20px;
  background: var(--panel);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
}

.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }

select.pick {
  padding: 9px 12px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  outline: none;
}

/* ------------------------------------------------------------------ таблица */

.tbl-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.tbl th {
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover td { background: var(--panel-2); }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl .dim { color: var(--muted); }
/* Название позиции переносим по буквам: «высококачественная» и адреса прайсов
   не влезают в столбец на телефоне и распирают таблицу. */
.tbl .nm { font-weight: 600; overflow-wrap: anywhere; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  color: var(--text-2);
  white-space: nowrap;
}

.pill.ok { color: #8fd9ae; border-color: rgba(67, 160, 108, .45); background: rgba(67, 160, 108, .12); }
.pill.bad { color: #ffa898; border-color: rgba(217, 80, 60, .45); background: rgba(217, 80, 60, .12); }
.pill.acc { color: var(--accent-2); border-color: rgba(234, 78, 27, .45); background: var(--accent-soft); }
/* Жёлтая плашка - «не сделано, но и не сломано»: репетиция звонка, отменённый разбор. */
.pill.warn { color: #e5bd6a; border-color: rgba(213, 154, 44, .45); background: rgba(213, 154, 44, .12); }

.more { margin: 14px 0 0; display: flex; justify-content: center; }

/* ------------------------------------------------------------------ пусто и ошибка */

.empty {
  padding: 44px 24px;
  text-align: center;
  background: var(--panel);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
}

.empty b { display: block; font-size: 15px; font-weight: 600; }
.empty p { margin-top: 7px; color: var(--muted); font-size: 13.5px; }
.empty .btn { margin-top: 16px; }

.fail {
  padding: 16px 18px;
  background: rgba(217, 80, 60, .1);
  border: 1px solid rgba(217, 80, 60, .4);
  border-radius: var(--radius);
  color: #ffb0a2;
  font-size: 13.5px;
}

.load { padding: 34px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* ------------------------------------------------------------------ карточка */

.cols { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; align-items: start; }

/* Колонка карточки обязана уметь стать уже своего содержимого.
 * Без этого ячейка сетки берёт ширину по самому широкому потомку: широкая
 * таблица разбора файла растягивала колонку, а с ней и всю страницу, и на
 * телефоне экран уезжал вбок целиком вместо того, чтобы прокручиваться внутри
 * своей рамки (.tbl-wrap уже умеет overflow-x). */
.cols > * { min-width: 0; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card + .card { margin-top: 14px; }
.card h3 { font-size: 14px; font-weight: 650; margin-bottom: 12px; }
.card h3 span { font-weight: 400; color: var(--muted); font-size: 12.5px; }

.kv { display: grid; grid-template-columns: minmax(96px, 34%) 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.rows li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
}
.rows li:first-child { border-top: 0; }
.rows .grow { flex: 1 1 auto; min-width: 0; }
.rows .dim { color: var(--muted); font-size: 12.5px; }

.msgs li { padding: 9px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.msgs li:first-child { border-top: 0; }
.msgs .hd { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.msgs .body { overflow-wrap: anywhere; white-space: pre-wrap; }

/* ------------------------------------------------------------------ воронка */

.funnel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 10px;
  align-items: stretch;
}

.col {
  flex: 0 0 232px;
  min-height: 320px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 190px);
}

/* Название, счётчик и сумма. Без переноса сумма встаёт третьей колонкой
 * и растягивает шапку в поле ввода - поэтому перенос включён явно. */
.col-hd {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}

.col-hd b { font-size: 13px; font-weight: 650; }
.col-hd .n { margin-left: auto; font-size: 12px; color: var(--muted); }
.col-hd .col-sum { flex: 0 0 100%; font-size: 12px; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.col-body { padding: 10px; overflow-y: auto; flex: 1 1 auto; min-height: 60px; }
.col.is-target { border-color: var(--accent); background: var(--accent-soft); }
.col.is-locked { opacity: .45; }

.deal {
  display: block;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: grab;
}

.deal:hover { border-color: #4a423b; }
.deal.drag { opacity: .4; }
.deal .nm { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.deal .amt { margin-top: 5px; font-size: 13px; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.deal .who { margin-top: 4px; font-size: 11.5px; color: var(--muted); }

.col-empty { padding: 14px 6px; text-align: center; color: var(--muted); font-size: 12px; }

.stage-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ------------------------------------------------------------------ окно формы */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(8, 7, 6, .7);
}

.modal-card {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.modal-card h3 { font-size: 17px; font-weight: 650; }
.modal-foot { display: flex; gap: 9px; justify-content: flex-end; margin-top: 20px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

/* ------------------------------------------------------------------ сообщения */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: min(400px, calc(100vw - 36px));
}

.toast {
  padding: 12px 15px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  animation: rise .18s ease-out;
}

.toast.bad { border-left-color: var(--bad); color: #ffb0a2; }
.toast.ok { border-left-color: var(--ok); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.frame {
  width: 100%;
  height: calc(100vh - 130px);
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

/* ------------------------------------------------------------------ телефон */

@media (max-width: 980px) {
  .cols { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }

  .side {
    position: fixed;
    left: 0;
    top: 0;
    width: 258px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow);
  }

  .app.open .side { transform: none; }
  .app.open .scrim { display: block; }
  .burger { display: flex; }
  .top { padding: 12px 14px; }
  .top h1 { font-size: 17px; }
  .view { padding: 14px; }
  .tiles { gap: 10px; }
  .tile .val { font-size: 23px; }
  .col { max-height: none; flex-basis: 84vw; }
  .feed .kind { display: none; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .tbl th, .tbl td { padding: 10px 12px; }
  .toasts { left: 14px; right: 14px; bottom: 14px; max-width: none; }
}

@media (max-width: 520px) {
  .two { grid-template-columns: 1fr; }
  .hide-xs { display: none; }
  /* Кнопка в заголовке раздела занимает свою строку целиком: две штуки в ряд
     на 390 px не помещаются, а урезанная кнопка не нажимается. */
  .h2 > .btn { flex: 1 1 140px; }
}
