/* Фирменные цвета DEALERDV: чёрный, белый, красный. Меняются здесь. */
:root {
  --brand: #0E0E10;
  --accent: #E4242F;
  --accent-dark: #BF0A17;
  --bg: #F4F4F5;
  --card: #FFFFFF;
  --text: #111113;
  --muted: #6E6E76;
  --line: #E4E4E7;
  --soft: #EDEDEF;
  --bad-bg: #FDE8EA;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }

/* ───── Вход ───── */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; background: var(--brand); padding: 24px; }
.login-card { width: 380px; max-width: 100%; background: var(--card); border-radius: 16px; padding: 32px; display: grid; gap: 14px; border-top: 4px solid var(--accent); }
.login-logo { height: 52px; width: auto; justify-self: start; }
.login-card h1 { margin: 4px 0 0; font-size: 22px; }
.login-card p { margin: 0; }
label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
input, select, textarea { width: 100%; min-height: 38px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 14px; color: var(--text); }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.btn { height: 36px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--accent-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.big { height: 44px; font-size: 15px; }
.btn.small { height: 30px; padding: 0 12px; font-size: 13px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--soft); }
.top .btn.ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.top .btn.ghost:hover { background: rgba(255,255,255,.1); }
.btn.dark { background: var(--brand); }
.btn.dark:hover { background: #2A2A2E; }
.form-err { padding: 10px 14px; border-radius: 10px; background: var(--bad-bg); color: #8E1018; font-size: 13px; }

/* ───── Шапка ───── */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px; height: 62px; padding: 0 20px; background: var(--brand); color: #fff; border-bottom: 3px solid var(--accent); }
.brand { display: flex; align-items: center; gap: 10px; }
.mark { height: 32px; width: auto; display: block; }
.logo { font-weight: 800; font-size: 19px; letter-spacing: .04em; }
.logo b { color: var(--accent); margin-left: 2px; }
.sub { color: #9A9AA2; font-size: 13px; padding-left: 10px; border-left: 1px solid #3A3A40; }
.tabs { display: flex; gap: 4px; }
.tab { height: 34px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: #C9C9CE; font-weight: 600; cursor: pointer; position: relative; }
.tab:hover { background: rgba(255,255,255,.08); color: #fff; }
.tab.on { background: #fff; color: var(--text); }
.tab { padding-right: 20px; }
.tab .dot { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.search { flex: 1; max-width: 420px; }
.search input { height: 36px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.1); color: #fff; }
.search input::placeholder { color: rgba(255,255,255,.55); }
.search input:focus { background: rgba(255,255,255,.18); outline: none; border-color: rgba(255,255,255,.4); }
.actions { margin-left: auto; display: flex; gap: 10px; }

main { padding: 18px 20px 30px; }

/* ───── Панель фильтров ───── */
.bar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--soft); border-radius: 10px; padding: 3px; }
.seg button { height: 30px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.bar .count { margin-left: auto; color: var(--muted); font-size: 13px; }

/* ───── Воронка ───── */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: 256px; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; min-height: calc(100vh - 170px); }
.col { background: #EAEAEC; border-radius: var(--radius); padding: 10px; display: grid; gap: 8px; align-content: start; min-height: 140px; }
.col.over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.col-h { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 4px; font-weight: 700; }
.col-h span { color: var(--muted); font-weight: 600; font-size: 12px; background: #fff; border-radius: 9px; padding: 1px 8px; }
.col.stage-new .col-h { color: var(--accent); }
.card { background: var(--card); border-radius: 10px; padding: 11px 12px; cursor: pointer; box-shadow: 0 1px 2px rgba(20,20,30,.08); border-left: 3px solid transparent; display: grid; gap: 5px; }
.card:hover { box-shadow: 0 4px 14px rgba(20,20,30,.14); }
.card.unread { border-left-color: var(--accent); }
.card.dragging { opacity: .4; }
.card .t { font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.card .badge { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; line-height: 20px; text-align: center; font-weight: 700; }
.card .car { color: var(--text); }
.card .meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.card .prev { color: var(--muted); font-size: 12px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--soft); color: var(--text); }
.chip.free { background: var(--bad-bg); color: #8E1018; }
.chip.src { background: #111113; color: #fff; }
.col .empty { color: #9A9AA2; text-align: center; padding: 14px 0; font-size: 13px; }

/* ───── Список ───── */
.table-wrap { background: var(--card); border-radius: var(--radius); overflow: auto; box-shadow: 0 1px 2px rgba(20,20,30,.06); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #FAFAFA; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #F8F8F9; }
tbody tr:last-child td { border-bottom: 0; }
td.unread b { color: var(--accent); }
.empty-big { padding: 50px; text-align: center; color: var(--muted); }

/* ───── Карточка сделки ───── */
.scrim { position: fixed; inset: 0; background: rgba(15,15,20,.4); z-index: 30; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 560px; max-width: 100vw; z-index: 40; background: var(--card); box-shadow: -8px 0 32px rgba(0,0,0,.2); transform: translateX(100%); visibility: hidden; transition: transform .2s ease, visibility .2s; display: flex; flex-direction: column; }
.drawer.open { transform: none; visibility: visible; }
.d-head { padding: 18px 20px 12px; border-bottom: 1px solid var(--line); position: relative; }
.d-head h2 { margin: 0 40px 2px 0; font-size: 20px; }
.d-head .sub2 { color: var(--muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.d-head .sub2 a { color: inherit; }
.x { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border: 0; border-radius: 8px; background: var(--soft); font-size: 18px; cursor: pointer; }
.d-fields { padding: 14px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; border-bottom: 1px solid var(--line); max-height: 46vh; overflow-y: auto; }
.d-fields .full { grid-column: 1 / -1; }
.d-fields textarea { min-height: 56px; }
.d-actions { padding: 10px 20px; display: flex; gap: 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.chat { flex: 1; overflow-y: auto; padding: 14px 20px; display: flex; flex-direction: column; gap: 8px; background: #F7F7F8; }
.msg { max-width: 82%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.msg small { display: block; margin-top: 3px; font-size: 11px; opacity: .65; }
.msg.in { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.note { align-self: flex-end; background: #FFF6D6; color: #5C4A00; border: 1px dashed #E0C766; }
.msg.sys { align-self: center; background: transparent; color: var(--muted); font-size: 12px; padding: 2px 8px; max-width: 100%; text-align: center; }
.msg .ch { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; opacity: .6; display: block; margin-bottom: 2px; }
.composer { padding: 10px 20px 16px; border-top: 1px solid var(--line); display: grid; gap: 8px; background: #fff; }
.composer .row { display: flex; gap: 8px; align-items: center; }
.composer select { width: auto; min-width: 150px; }
.composer textarea { min-height: 60px; }
.composer .hint { color: var(--muted); font-size: 12px; margin-left: auto; }

/* ───── Модальные окна и настройки ───── */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(15,15,20,.5); padding: 20px; }
.modal-card { position: relative; width: 480px; max-width: 100%; max-height: 92vh; overflow-y: auto; background: #fff; border-radius: 16px; padding: 26px; display: grid; gap: 12px; }
.modal-card h2 { margin: 0 36px 4px 0; font-size: 20px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.settings { display: grid; gap: 16px; max-width: 860px; }
.panel { background: var(--card); border-radius: var(--radius); padding: 20px 22px; box-shadow: 0 1px 2px rgba(20,20,30,.06); display: grid; gap: 12px; }
.panel h3 { margin: 0; font-size: 16px; }
.panel p { margin: 0; color: var(--muted); line-height: 1.5; }
.panel ol { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.6; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.status i { width: 9px; height: 9px; border-radius: 50%; background: #9A9AA2; }
.status.on i { background: #1E8E5A; }
.status.err i { background: var(--accent); }
.urow { display: grid; grid-template-columns: 1fr 160px 130px 110px; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.urow:first-of-type { border-top: 0; }
.warn { padding: 10px 14px; border-radius: 10px; background: #FFF6D6; color: #5C4A00; font-size: 13px; line-height: 1.5; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); }
.check input { width: 18px; height: 18px; min-height: 0; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 60; padding: 11px 20px; border-radius: 10px; background: #000; color: #fff; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.3); }

@media (max-width: 900px) {
  .search { display: none; }
  .tabs .tab { padding: 0 9px; }
  .drawer { width: 100vw; }
  .urow { grid-template-columns: 1fr 1fr; }
}

/* ═════════ Логистика ═════════ */
/* Статусы оплат и документов: в порядке — нейтрально, требует действия — красным */
.chip.ok { color: #111113; background: #E9E9EB; }
.chip.bad { color: #fff; background: var(--accent); }
.chip.wait { color: #B3121C; background: var(--bad-bg); }
.chip.info { color: #fff; background: #111113; }
.chip.na { color: var(--muted); background: var(--soft); }
.chip.none { color: #B4B4BC; background: transparent; padding-left: 0; font-weight: 400; }
.lg .chip { font-size: 12px; padding: 3px 9px; white-space: nowrap; }

.stage { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; line-height: 1.25; }
.stage i { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #B4B4BC; }
.stage.bought i { background: #9A9AA2; }
.stage.yard i { background: #55555C; }
.stage.customs i { background: var(--accent); }
.stage.done i { background: #111113; }
.lg-warn { margin-left: 6px; color: var(--accent); font-weight: 800; }

.lg .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { text-align: left; padding: 14px 16px; border: 2px solid transparent; border-radius: var(--radius); background: var(--card); box-shadow: 0 1px 2px rgba(20,20,30,.06); cursor: pointer; }
.kpi:hover { box-shadow: 0 4px 14px rgba(20,20,30,.1); }
.kpi .n { display: block; font-size: 28px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .l { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }
.kpi.active { border-color: var(--accent); }
.kpi.alert .n { color: var(--accent); }

.lg .filters { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.lg .filters label { display: grid; gap: 4px; }
.lg .filters select { min-width: 180px; height: 34px; min-height: 0; padding: 0 10px; }
.lg .filters .count { margin-left: auto; color: var(--muted); font-size: 13px; align-self: center; }
.lg .filters .sync { color: var(--muted); font-size: 12px; align-self: center; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn.ghost.small { color: var(--text); }

.banner { margin-bottom: 14px; padding: 10px 14px; border-radius: 10px; font-size: 13px; line-height: 1.5; background: #ECECEE; }
.banner.err { background: var(--bad-bg); color: #8E1018; }
.banner button { margin-left: 8px; height: 28px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }

.lg td { padding: 10px 8px; }
.lg th { padding: 10px 8px; position: sticky; top: 0; }
.lg .date, .lg .mgr { color: var(--muted); white-space: nowrap; }
.lg .car b { display: block; font-weight: 600; }
.lg .car small, .lg .client small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.lg .client { max-width: 200px; }
.lg .client .deal-link { color: #1E8E5A; font-weight: 600; }
.lg td.st { min-width: 140px; }

/* быстрая смена статуса */
button.pick { font: inherit; border: 0; cursor: pointer; }
button.chip.pick:hover, button.stage.pick:hover { box-shadow: 0 0 0 2px var(--accent); }
button.chip.none.pick { background: transparent; border: 1px dashed #CFCFD4; color: #A8A8B0; padding: 2px 10px; }
button.stage.pick { background: transparent; padding: 3px 6px; margin: -3px -6px; border-radius: 8px; color: inherit; text-align: left; }
.menu { position: fixed; z-index: 70; min-width: 220px; padding: 6px; display: grid; gap: 2px; background: var(--card); border-radius: 12px; box-shadow: 0 12px 36px rgba(15,15,20,.28); border: 1px solid var(--line); }
.menu button { height: 38px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-weight: 500; cursor: pointer; }
.menu button:hover { background: var(--bg); }
.menu button.cur { background: #111113; color: #fff; font-weight: 700; }
.menu button.clear { color: var(--muted); font-weight: 400; }

/* карточка авто в боковой панели */
.lg-pane { position: relative; flex: 1; overflow-y: auto; padding: 22px 24px 32px; }
.lg-pane h2 { margin: 0 44px 4px 0; font-size: 20px; }
.lg-pane .vin { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.lg-pane .problems { margin-top: 14px; padding: 10px 14px; border-radius: 10px; background: var(--bad-bg); color: #8E1018; }
.lg-pane .banner { margin: 14px 0 0; }
.lg-pane .form { margin-top: 16px; display: grid; gap: 12px; }
.lg-pane fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 12px; min-width: 0; }
.lg-pane .form textarea { min-height: 84px; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }
.deal-open { margin-top: 14px; width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: baseline; text-align: left; padding: 10px 14px; border: 1px solid var(--line); border-left: 3px solid #1E8E5A; border-radius: 10px; background: #fff; cursor: pointer; }
.deal-open:hover { background: #F8F8F9; }
.deal-open span { color: var(--muted); font-size: 12px; }
.deal-open em { font-style: normal; color: var(--muted); font-size: 12px; }

/* блок логистики в карточке сделки */
.d-car { margin: 0; padding: 10px 20px 12px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; background: #FBFBFC; font-size: 13px; }
.d-car.muted { color: var(--muted); }
.d-car-h { display: flex; align-items: center; gap: 12px; }
.d-car-h b { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.d-car-h .btn { margin-left: auto; }
.d-car-c { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.d-car-c .ck { display: grid; gap: 2px; }
.d-car-c small { color: var(--muted); font-size: 11px; }
.d-car-p { color: #8E1018; }
.d-car-n { color: var(--muted); white-space: pre-wrap; }
.steps-box summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
.lg td.st { min-width: 170px; }

@media (max-width: 900px) {
  .top { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px 14px; }
  .top .sub { display: none; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .actions { margin-left: auto; }
  main { padding: 14px 16px 30px; }
  .lg .filters .count { margin-left: 0; width: 100%; }
}

/* ═════════ Калькулятор ═════════ */
:root { --c-car: #3d4f66; --c-ship: #1f8a8a; --c-duty: var(--accent); --c-ru: #c48a12; --c-fee: #8a7fa8; }
.calc { max-width: 1180px; display: grid; gap: 14px; }
.c-top { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.c-top .seg button { padding: 0 16px; }
.c-top .seg .sym { font-weight: 800; color: var(--accent); }
#c-deal-wrap { flex: 1; min-width: 280px; }
.c-deal { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px 8px 14px; background: var(--card); border: 1px solid var(--line); border-left: 3px solid #1E8E5A; border-radius: 10px; }
.c-deal.none { border-left-color: var(--line); color: var(--muted); font-size: 13px; }
.c-deal .c-deal-l { color: var(--muted); font-size: 12px; }
.c-deal .btn:first-of-type { margin-left: auto; }
.c-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.c-col { display: grid; gap: 12px; min-width: 0; }
.c-card { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(20,20,30,.06); }
.c-card > h2 { margin: 0; padding: 11px 16px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
.c-upd { text-transform: none; letter-spacing: 0; font-weight: 500; }
.c-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 18px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.c-row:last-child { border-bottom: 0; }
.c-lab { flex: 1 1 260px; min-width: 0; font-size: 14px; color: var(--text); display: block; }
.c-lab small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.c-lab a, .c-rate a { color: var(--accent); }
.c-ctl { flex: 0 0 auto; width: 220px; max-width: 100%; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.c-inp { width: 100%; display: flex; align-items: center; background: #F7F7F8; border: 1px solid var(--line); border-radius: 8px; }
.c-inp:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(228,36,47,.18); }
.c-inp.changed { background: #FFF6D6; border-color: #E0C766; }
.c-inp input { flex: 1; min-width: 0; min-height: 0; height: 38px; border: 0; background: transparent; text-align: right; padding: 0 4px 0 11px; font-variant-numeric: tabular-nums; }
.c-inp input:focus { outline: none; }
.c-inp .u { padding: 0 11px 0 6px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.conv { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.c-sub { background: #FAFAFA; font-weight: 700; border-radius: 0 0 var(--radius) var(--radius); }
.c-sub .v { font-variant-numeric: tabular-nums; white-space: nowrap; }
.c-rate { display: grid; grid-template-columns: 1fr 150px; gap: 10px 14px; padding: 12px 16px 14px; align-items: end; }
.c-rate label { color: var(--muted); font-size: 13px; }
.c-shared { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-radius: 10px; background: #FFF6D6; color: #5C4A00; font-size: 13px; }
.c-shared span { flex: 1 1 260px; }
.c-result { position: sticky; top: 80px; padding: 18px; display: grid; gap: 14px; }
.c-result .cap { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.c-total { font-size: 32px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.c-total .cur { color: var(--accent); font-size: 24px; }
.c-bar { display: flex; height: 12px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--soft); }
.c-bar span { display: block; height: 100%; min-width: 2px; transition: width .25s ease; }
.c-legend { list-style: none; margin: 0; padding: 0; }
.c-legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 36px; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); }
.c-legend li:last-child { border-bottom: 0; }
.c-legend .dot { width: 10px; height: 10px; border-radius: 2px; align-self: center; }
.c-legend .amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.c-legend .pct { color: var(--muted); font-size: 12px; text-align: right; }
.c-actions { display: grid; gap: 8px; }
.c-actions .btn:not(.small) { width: 100%; height: 40px; }
.c-actions-row { display: flex; flex-wrap: wrap; gap: 6px; }
.c-actions-row .btn { flex: 1 1 auto; }

/* выбор сделки */
.pick-list { display: grid; gap: 4px; max-height: 50vh; overflow-y: auto; }
.pick-deal { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; text-align: left; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; }
.pick-deal:hover { background: #F8F8F9; border-color: #D0D0D6; }
.pick-deal span { color: var(--muted); font-size: 13px; grid-column: 1; }
.pick-deal em { font-style: normal; color: var(--muted); font-size: 12px; grid-column: 2; grid-row: 1; }

/* окно с картинкой для клиента */
.modal-card.wide { width: 620px; }
.ci-prev { max-height: 58vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: #F7F7F8; }
.ci-prev img { display: block; width: 100%; height: auto; }
.ci-actions { display: grid; gap: 8px; }
.ci-actions > .btn { width: 100%; height: 42px; }

/* бланк для печати */
#print { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  body > *:not(#print) { display: none !important; }
  #print { display: block; color: #000; font-size: 12px; }
}
.p-sheet { max-width: 180mm; margin: 0 auto; }
.p-head { display: flex; gap: 16px; align-items: center; padding-bottom: 12px; border-bottom: 3px solid var(--accent); }
.p-head img { height: 54px; width: auto; }
.p-head div { display: grid; gap: 1px; }
.p-head b { font-size: 16px; }
.p-head span { color: #444; font-size: 11px; }
.p-sheet h1 { font-size: 16px; text-transform: uppercase; margin: 18px 0 8px; letter-spacing: .02em; }
.p-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 12px; color: #333; }
.p-sheet table { width: 100%; border-collapse: collapse; }
.p-sheet td, .p-sheet th { padding: 6px 6px; border-bottom: 1px solid #ddd; text-align: left; font-size: 12px; color: #000; text-transform: none; letter-spacing: 0; background: none; }
.p-sheet tr.h th { padding-top: 14px; font-weight: 800; text-transform: uppercase; border-bottom: 2px solid #000; }
.p-sheet td.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.p-sheet td.u { width: 18px; color: #555; }
.p-sheet tr.sum td { font-weight: 700; border-bottom: 0; }
.p-total { margin-top: 16px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: baseline; border: 2px solid #000; font-weight: 800; text-transform: uppercase; }
.p-total b { font-size: 20px; }
.p-note { color: #555; font-size: 10px; margin-top: 10px; }

@media (max-width: 1000px) {
  .c-grid { grid-template-columns: minmax(0, 1fr); }
  .c-result { position: static; }
}
@media (max-width: 560px) {
  .c-ctl { width: 100%; align-items: stretch; }
  .c-lab { flex-basis: 100%; }
  .c-rate { grid-template-columns: 1fr; }
  .c-total { font-size: 26px; }
}

/* просьба об отзыве */
.chip.rv-ok { background: #E6F4EC; color: #146C43; }
#rv-text { min-height: 200px; line-height: 1.45; }

/* мессенджеры клиента */
.chip.ch-tg { background: #E3F1FB; color: #1B6FA8; }
.chip.ch-max { background: #ECE7FF; color: #5B3FD1; }
.chip.ch-ig { background: #FCE7F1; color: #B0306A; }
.chip.ch-wa { background: #E7F8EC; color: #128C3E; }
.chip.ch-avito { background: #E6F7EE; color: #0A7A43; }

/* ═════════ iPhone: приложение на экране «Домой» ═════════ */
.top { padding-top: env(safe-area-inset-top); height: calc(62px + env(safe-area-inset-top)); padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
.drawer { padding-top: env(safe-area-inset-top); }
.composer { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.toast { bottom: calc(26px + env(safe-area-inset-bottom)); }
.login { padding-top: max(24px, env(safe-area-inset-top)); }
.install-hint { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 55; display: flex; gap: 10px; align-items: flex-start; padding: 14px 14px 14px 16px; border-radius: 14px; background: #111113; color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.35); font-size: 14px; line-height: 1.4; }
.install-hint div { display: grid; gap: 4px; flex: 1; }
.install-hint span { color: #CFCFD4; }
.install-hint button { width: 30px; height: 30px; flex: none; border: 0; border-radius: 8px; background: rgba(255,255,255,.12); color: #fff; font-size: 18px; cursor: pointer; }
.share-ic { display: inline-block; width: 14px; height: 16px; vertical-align: -2px; border: 2px solid #4DA3FF; border-top: 0; border-radius: 2px; position: relative; margin: 0 2px; }
.share-ic::before { content: ''; position: absolute; left: 50%; top: -7px; width: 2px; height: 11px; background: #4DA3FF; transform: translateX(-50%); }
@media (max-width: 900px) {
  .top { height: auto; padding-top: calc(10px + env(safe-area-inset-top)); }
  .actions .btn { height: 34px; padding: 0 12px; }
  .board { grid-auto-columns: 82vw; scroll-snap-type: x mandatory; min-height: calc(100vh - 220px); }
  .col { scroll-snap-align: start; }
  .d-fields { grid-template-columns: 1fr; max-height: 38vh; }
  .modal { padding: 12px; align-items: flex-end; }
  .modal-card { max-height: 88vh; border-radius: 16px; padding: 20px; }
  .row2 { grid-template-columns: 1fr; }
  input, select, textarea { font-size: 16px; }   /* iPhone не увеличивает страницу при вводе */
  .search { display: block; order: 4; flex-basis: 100%; max-width: none; }
  .tabs .tab { padding-right: 22px; }
  /* карточка сделки на телефоне прокручивается целиком, поле ответа прижато к низу */
  .drawer { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .d-fields { max-height: none; overflow: visible; }
  .chat { flex: none; min-height: 45vh; overflow: visible; }
  .composer { position: sticky; bottom: 0; z-index: 2; box-shadow: 0 -4px 12px rgba(0,0,0,.06); }
}

.btn.ghost.danger { color: #C8102E; border-color: rgba(200,16,46,.35); }
.btn.ghost.danger:hover { background: rgba(200,16,46,.08); }
