/* ============================================================
   Интерсити Тур — панель. Дизайн-система v4 (2026)
   Современный SaaS + мобильное приложение (нижняя навигация)
   ============================================================ */

:root {
    --brand:        #5b50e0;
    --brand-600:    #4d42cf;
    --brand-700:    #3f35b0;
    --brand-50:     #eeedfc;
    --brand-100:    #e0ddf9;

    --ink:          #181826;
    --muted:        #6a6a82;
    --faint:        #9a9ab0;
    --line:         #e8e8f0;
    --line-soft:    #f0f0f6;

    --bg:           #f5f6fb;
    --surface:      #ffffff;
    --surface-2:    #f7f7fc;

    --ok:    #15843b;  --ok-bg:   #e4f7ea;
    --warn:  #9a6310;  --warn-bg: #fdf2dc;
    --err:   #c0271f;  --err-bg:  #fdeceb;
    --info:  #1f6fd6;  --info-bg: #e7f1fd;

    --r-sm: 9px;
    --r:    13px;
    --r-lg: 18px;
    --r-xl: 24px;

    --sh-1: 0 1px 2px rgba(24,24,38,.06), 0 1px 3px rgba(24,24,38,.05);
    --sh-2: 0 2px 6px rgba(24,24,38,.06), 0 10px 30px rgba(24,24,38,.06);
    --sh-pop: 0 8px 30px rgba(24,24,38,.14);

    --sbw: 248px;          /* ширина сайдбара */
    --safe-b: env(safe-area-inset-bottom, 0px);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    min-height: 100vh;
    color: var(--ink);
    background: var(--bg);
    font: 15px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: none; }
img { max-width: 100%; }
/* иконки: страховка от «гигантских» SVG + корректный инлайн-размер в заголовках */
svg { max-width: 44px; max-height: 44px; }
h1 svg, h2 svg, h3 svg { width: 19px; height: 19px; vertical-align: -3px; margin-right: 3px; flex: none; }
::selection { background: var(--brand-100); }

/* ── скроллбары ── */
* { scrollbar-width: thin; scrollbar-color: #cfcfe0 transparent; }
*::-webkit-scrollbar { height: 8px; width: 8px; }
*::-webkit-scrollbar-thumb { background: #d4d4e4; border-radius: 8px; }

/* ============================================================
   ЛЕЙАУТ: сайдбар (десктоп) / нижняя панель (мобайл)
   ============================================================ */

.sidebar {
    position: fixed; top: 0; left: 0; z-index: 40;
    display: flex; flex-direction: column;
    width: var(--sbw); height: 100vh;
    padding: 18px 14px;
    background: var(--surface);
    border-right: 1px solid var(--line);
}
.brand {
    display: flex; align-items: center; gap: 11px;
    padding: 6px 8px 22px; color: var(--ink); font-weight: 700; font-size: 16.5px; letter-spacing: -.2px;
}
.brand:hover { text-decoration: none; }
.logo {
    display: grid; place-items: center; flex: none;
    width: 38px; height: 38px; border-radius: 11px;
    color: #fff; font-size: 14px; font-weight: 800; letter-spacing: .5px;
    background: linear-gradient(135deg, var(--brand), #7a6ef0);
    box-shadow: 0 4px 12px rgba(91,80,224,.35);
}
.nav { display: grid; gap: 3px; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: var(--r-sm);
    color: var(--muted); font-weight: 600; font-size: 14.5px;
    transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--brand-50); color: var(--brand-700); }
.nav-ic { display: grid; place-items: center; }
.nav-ic svg { width: 19px; height: 19px; stroke-width: 1.9; }
.nav-item.active .nav-ic svg { stroke-width: 2.2; }

.sidebar-foot { margin-top: auto; padding-top: 12px; }
.user-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--r);
    background: var(--surface-2);
}
.user-ava {
    display: grid; place-items: center; flex: none;
    width: 32px; height: 32px; border-radius: 50%;
    color: #fff; font-weight: 700; font-size: 13px;
    background: linear-gradient(135deg, var(--brand), #8a7ef2);
}
.user-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-out { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: var(--muted); }
.user-out:hover { background: var(--err-bg); color: var(--err); }
.user-out svg { width: 17px; height: 17px; }

/* топ-бар (только мобайл) */
.topbar {
    display: none;
    position: sticky; top: 0; z-index: 30;
    align-items: center; gap: 12px;
    height: 56px; padding: 0 14px;
    background: rgba(255,255,255,.86); backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}
.topbar-brand .logo { width: 32px; height: 32px; font-size: 12px; }
.topbar-title { flex: 1; font-weight: 700; font-size: 17px; letter-spacing: -.2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-act { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: var(--muted); }
.topbar-act svg { width: 21px; height: 21px; }

/* нижняя панель (только мобайл) */
.bottombar { display: none; }
.more-sheet, .sheet-backdrop { display: none; }

/* основная область */
.main {
    margin-left: var(--sbw);
    padding: 26px 30px 60px;
    max-width: 1240px;
}
/* Отчётность — широкие финансовые таблицы (пассажиры, свод за месяц): 1240px им мало,
   правые колонки обрезались. Отдаём всю ширину экрана, остальные разделы не трогаем. */
body[data-page="reporting"] .main { max-width: none; }
.flash-top { margin-bottom: 18px; }

/* ============================================================
   ТИПОГРАФИКА И ШАПКА СТРАНИЦЫ
   ============================================================ */
h1 { margin: 0; font-size: 25px; font-weight: 750; letter-spacing: -.5px; }
h2 { margin: 0 0 14px; font-size: 18px; font-weight: 700; letter-spacing: -.2px; }
h3 { margin: 0 0 6px; font-size: 15.5px; font-weight: 700; }
.eyebrow { color: var(--brand); font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 16px; }
.compact { margin: 12px 0 0; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.page-head {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
    margin-bottom: 22px;
}
.page-head .sub { margin-top: 4px; color: var(--muted); font-size: 13.5px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   КАРТОЧКИ
   ============================================================ */
.card {
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-1);
}
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-3, .grid-4 { display: grid; gap: 16px; }
.grid-3 > .card + .card, .grid-4 > .card + .card { margin-top: 0; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ============================================================
   КНОПКИ
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 17px; min-height: 42px;
    border: 0; border-radius: var(--r);
    color: #fff; background: var(--brand);
    font: inherit; font-weight: 650; font-size: 14.5px; line-height: 1;
    cursor: pointer; white-space: nowrap;
    box-shadow: 0 2px 8px rgba(91,80,224,.28);
    transition: background .12s, transform .06s, box-shadow .12s;
}
.btn:hover { background: var(--brand-600); text-decoration: none; }
.btn:active, .chat-send-btn:active, .bn-item:active, .sheet-item:active { transform: scale(.98); }
.btn[aria-busy="true"] { pointer-events: none; opacity: .72; }
.btn[aria-busy="true"]::after { content: '…'; margin-left: 4px; }
.btn svg { width: 17px; height: 17px; }
.btn.ghost { color: var(--brand-700); background: var(--brand-50); box-shadow: none; }
.btn.ghost:hover { background: var(--brand-100); }
.btn.secondary { color: var(--ink); background: var(--surface-2); box-shadow: none; border: 1px solid var(--line); }
.btn.secondary:hover { background: var(--line-soft); }
.btn.danger { color: var(--err); background: var(--err-bg); box-shadow: none; }
.btn.sm { padding: 8px 13px; min-height: 36px; font-size: 13.5px; border-radius: var(--r-sm); }
.btn[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn-small { padding: 7px 12px; min-height: 32px; font-size: 13px; border-radius: var(--r-sm); display: inline-flex; align-items: center; gap: 6px; color: #fff; background: var(--brand); border: 0; cursor: pointer; }
.btn-link { display: inline-flex; align-items: center; gap: 8px; padding: 11px 17px; border-radius: var(--r); color: #fff; background: var(--brand); font-weight: 650; box-shadow: 0 2px 8px rgba(91,80,224,.28); }
.btn-link:hover { background: var(--brand-600); text-decoration: none; }
.btn-link.secondary { color: var(--brand-700); background: var(--brand-50); box-shadow: none; }
.icon-btn {
    display: inline-grid; place-items: center; width: 34px; height: 34px;
    border: 0; border-radius: var(--r-sm); background: transparent; color: var(--faint); cursor: pointer;
    transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--err-bg); color: var(--err); }
.icon-btn svg { width: 16px; height: 16px; }

/* ============================================================
   ФОРМЫ
   ============================================================ */
input[type=text], input[type=password], input[type=date], input[type=datetime-local], input[type=number],
input[type=url], input[type=email], input[type=file], select, textarea {
    width: 100%; padding: 11px 13px; min-height: 42px;
    border: 1.5px solid var(--line); border-radius: var(--r);
    background: var(--surface); color: var(--ink);
    font: inherit; font-size: 14.5px;
    transition: border-color .12s, box-shadow .12s;
    -webkit-appearance: none; appearance: none;
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%236a6a82' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 34px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
textarea { min-height: 90px; line-height: 1.5; resize: vertical; }
label.f, .field-label { display: block; margin-bottom: 14px; color: var(--muted); font-size: 12.5px; font-weight: 650; }
label.f > input, label.f > select, label.f > textarea, .field-label > input, .field-label > textarea { margin-top: 6px; font-weight: 400; }
.text-input, .template-box { width: 100%; margin-top: 6px; }
.template-box { font: 14px/1.55 var(--font); }

/* ============================================================
   ТАБЛИЦЫ
   ============================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
table.t { width: 100%; border-collapse: collapse; }
.t th {
    padding: 10px 12px; border-bottom: 1.5px solid var(--line);
    color: var(--muted); font-size: 11.5px; font-weight: 700; text-align: left;
    text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
}
.t td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr { transition: background .1s; }
.t tbody tr:hover td { background: var(--surface-2); }
.row-actions, td.actions { white-space: nowrap; text-align: right; }
.row-actions a { color: var(--brand); }
.phone { white-space: nowrap; font-variant-numeric: tabular-nums; }
.invalid { color: var(--err); font-weight: 600; }

/* инлайн-редактируемые ячейки */
.cell {
    width: 100%; padding: 8px 10px; min-height: 36px;
    border: 1.5px solid transparent; border-radius: var(--r-sm);
    background: transparent; font: inherit; font-size: 14px;
}
.cell:hover { background: var(--surface-2); }
.cell:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-50); }
table.cat input.cell, table.cat select.cell { font-size: 13.5px; }
.phone-bad { border-color: var(--err) !important; background: var(--err-bg); }

/* ============================================================
   БЕЙДЖИ И СТАТУСЫ
   ============================================================ */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 650; white-space: nowrap;
}
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.info { color: var(--info); background: var(--info-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.err { color: var(--err); background: var(--err-bg); }
.badge.muted { color: var(--muted); background: var(--line-soft); }
/* Бейджи наличия каналов — фирменные цвета (WhatsApp зелёный, MAX фиолетовый, Telegram голубой) */
.ch-badge { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 600; line-height: 1.55; white-space: nowrap; }
.ch-badge.on-wa  { color: #0e7a44; background: #e3f7ec; }
.ch-badge.on-max { color: #5b2bd6; background: #ece6ff; }
.ch-badge.on-tg  { color: #1683b8; background: #e2f3fc; }
.ch-badge.off    { color: #9aa0a6; background: transparent; border: 1px solid var(--line-soft); }
.ch-badge.unk    { color: #9aa0a6; background: var(--line-soft); }
.status { display: inline-flex; align-items: center; padding: 5px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.status-ok { color: var(--ok); background: var(--ok-bg); }
.status-warn { color: var(--warn); background: var(--warn-bg); }
.status-neutral { color: var(--muted); background: var(--line-soft); }
.statement-check { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; }
.statement-match { color: var(--ok); background: var(--ok-bg); }
.statement-mismatch { color: var(--err); background: var(--err-bg); }

.alert { margin-bottom: 16px; padding: 13px 16px; border-radius: var(--r); font-weight: 550; font-size: 14px; }
.alert.ok { color: var(--ok); background: var(--ok-bg); }
.alert.err { color: var(--err); background: var(--err-bg); }
.alert.warn { color: var(--warn); background: var(--warn-bg); }
.alert a { color: inherit; font-weight: 700; }
.alert ul { margin: 7px 0 0; padding-left: 20px; }
.sales-source-status { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.sales-source-status span { font-weight: 500; text-align: right; }

.empty-state { padding: 34px; border: 1.5px dashed var(--line); border-radius: var(--r-lg); color: var(--muted); text-align: center; }

/* ============================================================
   ДАШБОРД
   ============================================================ */
.stat {
    padding: 18px 20px; border-radius: var(--r-lg);
    background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-1);
}
.stat .num { font-size: 30px; font-weight: 780; letter-spacing: -1px; line-height: 1.1; }
.stat .lbl { margin-top: 4px; color: var(--muted); font-size: 13px; }
.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.service {
    position: relative; display: flex; flex-direction: column; gap: 12px;
    padding: 16px; border-radius: var(--r-lg);
    background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-1);
    color: var(--ink); font-weight: 650; transition: transform .1s, box-shadow .12s;
}
.service:hover { transform: translateY(-2px); box-shadow: var(--sh-2); text-decoration: none; }
.service .ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; }
.service .ic svg { width: 20px; height: 20px; }
.service .del { position: absolute; top: 8px; right: 8px; display: none; border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 15px; }
.service:hover .del { display: block; }
.ic.violet { color: var(--brand-700); background: var(--brand-50); }
.ic.blue { color: var(--info); background: var(--info-bg); }
.ic.green { color: var(--ok); background: var(--ok-bg); }
.ic.orange { color: var(--warn); background: var(--warn-bg); }
.ic.red { color: var(--err); background: var(--err-bg); }

.sales-chart { display: flex; gap: 4px; align-items: flex-end; height: 160px; padding-top: 10px; overflow-x: auto; }
.sales-bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 26px; height: 100%; }
.sales-bar .bar { width: 18px; min-height: 3px; border-radius: 5px 5px 0 0; background: linear-gradient(180deg, var(--brand), #8a7ef2); }
.sales-bar span { margin-top: 5px; color: var(--muted); font-size: 10px; white-space: nowrap; }

/* ============================================================
   ЗАГРУЗКА ФАЙЛА
   ============================================================ */
.drop {
    display: grid; place-items: center; gap: 8px; padding: 32px;
    border: 2px dashed var(--brand-100); border-radius: var(--r-lg);
    background: var(--surface-2); color: var(--muted); text-align: center; cursor: pointer;
    transition: border-color .12s, background .12s;
}
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-50); }
.drop svg { width: 32px; height: 32px; color: var(--brand); }
/* Подтягивание ведомости по номеру рейса из системы автовокзала */
.pull-row { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.pull-input { flex: 0 0 150px; font-size: 16px; font-weight: 650; text-align: center; letter-spacing: 1px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.pull-input:focus { border-color: var(--brand); outline: none; }
.pull-preview { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); padding: 14px 16px; }
.pull-preview-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.pull-ic { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--ok-bg, #e4f6ec); color: var(--ok, #1a9a54); font-weight: 700; }
.pull-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.pull-metrics > div { background: var(--surface); border-radius: 8px; padding: 9px 11px; }
.pull-metrics b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; }
.pull-metrics span { font-size: 11.5px; color: var(--muted); }
.drop input { display: none; }
.drop b { color: var(--ink); }

/* ============================================================
   ЭКРАН-МАСТЕР (шаги)
   ============================================================ */
.step-card { padding: 18px 20px; }
.step-row { display: flex; gap: 14px; align-items: flex-start; }
.step-num { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 13px; font-weight: 750; }
.step-num.done { background: var(--ok); }
.step-title { font-size: 16px; font-weight: 700; }
.step-title-sub { margin-top: 2px; }
.send-bar { position: static; border: 1.5px solid var(--brand); box-shadow: var(--sh-2); }
.manifest-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.facts > div { padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); }
.facts span { display: block; color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 4px; }
.facts b { font-size: 14.5px; }
.facts .cell { font-size: 14px; }

/* ============================================================
   ГРУППЫ ПОСАДКИ (аккордеон)
   ============================================================ */
.gcard { border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 0 var(--r) var(--r) 0; margin-bottom: 8px; overflow: hidden; background: var(--surface); }
.gcard-problem { border-left-color: var(--err); }
.gcard-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.gcard-head:hover { background: var(--surface-2); }
.gtitle { font-weight: 700; font-size: 14.5px; }
.g-tpl-badge { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 20px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.g-tpl-badge.custom { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.group-template { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); }
.origin-template { padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.origin-template .ot-select { font-size: 12px; max-width: 170px; }
.origin-template textarea { font-size: 13px; }
/* Счётчик живёт внутри flex-контейнера с галочками каналов — без этого он встаёт
   ещё одной «фишкой» в общий ряд и теряется. Отдельная строка на всю ширину. */
.daily-counts { flex: 0 0 100%; margin-top: 8px; color: var(--muted); font-size: 12px; }
.daily-counts .daily-near { color: var(--warn); font-weight: 600; }
.daily-counts .daily-over { color: var(--err); font-weight: 700; }
.gmeta { margin-top: 4px; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.gchev { color: var(--faint); transition: transform .15s; }
.gcard.open .gchev { transform: rotate(180deg); }
.gcard-body { display: none; padding: 2px 14px 14px; }
.gcard.open .gcard-body { display: block; }
.gcard-controls { gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.notif-readiness { padding: 18px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.notif-ready-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.notif-ready-head { display: flex; align-items: center; gap: 12px; }
.notif-ready-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--ok-bg); color: var(--ok); font-size: 20px; font-weight: 800; }
.notif-ready-icon.warn { background: var(--err-bg); color: var(--err); }
.notif-ready-title { color: var(--ink); font-size: 17px; font-weight: 750; }
.notif-metrics, .notif-delivery-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-top: 16px; }
.notif-metrics > div, .notif-delivery-metrics > div { padding: 11px 13px; border-radius: 11px; background: var(--surface-2); }
.notif-metrics > div.warn, .notif-delivery-metrics > div.warn { background: var(--warn-bg); color: var(--warn); }
.notif-metrics b, .notif-delivery-metrics b { display: block; font-size: 22px; line-height: 1.15; }
.notif-metrics span, .notif-delivery-metrics span { display: block; margin-top: 3px; color: var(--muted); font-size: 11.5px; }
.notif-auto-check { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.notif-issues, .notif-attention { margin-top: 12px; overflow: hidden; border: 1px solid #f0d6a8; border-radius: var(--r); background: #fffaf1; }
.notif-issues-head { display: flex; justify-content: space-between; gap: 12px; padding: 11px 14px; border-bottom: 1px solid #f0dfc2; }
.notif-issue { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 11px; padding: 10px 14px; border-bottom: 1px solid #f3e6d0; }
.notif-issue:last-child { border-bottom: 0; }
.notif-origin { margin-top: 12px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.notif-origin-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 13px 15px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.notif-origin-title { margin-bottom: 3px; color: var(--ink); font-size: 15.5px; font-weight: 750; }
/* Метка «что ушло по блоку» — берётся с сервера, видна при открытии ведомости. */
.origin-sent { margin-top: 5px; font-weight: 650; display: flex; align-items: center; gap: 5px; }
.origin-sent-ok { color: var(--ok, #1a9a54); }
.origin-sent-warn { color: var(--warn, #b8760a); }
.notif-origin-routes .gcard { margin: 0; border-width: 0 0 1px 4px; border-radius: 0; box-shadow: none; }
.notif-origin-routes .gcard:last-child { border-bottom: 0; }
.notif-origin-routes .gcard-head { padding: 11px 14px; }
.notif-origin-routes .gmeta { margin-top: 3px; }
.notif-overview-empty { padding: 20px; border-radius: var(--r); background: var(--surface-2); text-align: center; }
.notif-delivery-line { height: 8px; margin: 14px 0 9px; overflow: hidden; border-radius: 99px; background: var(--line-soft); }
.notif-delivery-line span { display: block; height: 100%; border-radius: inherit; background: var(--ok); transition: width .2s; }
.notif-attention { background: var(--surface); }
.send-channel-panel { display: grid; grid-template-columns:minmax(210px,1fr) auto; align-items:center; gap:10px 18px; padding:14px; border:1px solid var(--line); border-radius:var(--r); background:var(--surface-2); }
.send-channel-choices { display:flex; flex-wrap:wrap; gap:7px; }
.send-channel-choice { display:inline-flex; align-items:center; gap:7px; min-height:38px; padding:7px 10px; border:1px solid var(--line); border-radius:10px; background:var(--surface); color:var(--ink); font-weight:650; cursor:pointer; }
.send-channel-choice input { width:17px; height:17px; margin:0; accent-color:var(--brand); }
.send-channel-choice.disabled { opacity:.5; cursor:not-allowed; }
.send-channel-choice small { color:var(--faint); font-size:10px; font-weight:500; }
.send-channel-choice small.chan-off { color:var(--err); }
#sendChannelEstimate { grid-column:1 / -1; }
.send-channel-warning { padding:9px 11px; border-radius:9px; background:var(--warn-bg); color:var(--warn); font-weight:650; }
.channel-attempts { display:inline-flex; flex-wrap:wrap; gap:4px; }
.g-preview, .msg-preview { max-width: 460px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; padding: 12px 14px; border-radius: 14px 14px 14px 4px; background: #e7f8ef; font-size: 13.5px; color: #14503a; }
.feed-item { overflow-wrap: anywhere; word-break: break-word; }
.preview-cell { min-width: 280px; max-width: 420px; color: #333; font-size: 13px; }
.row-disabled td { opacity: .55; }
.muted-inline { color: var(--muted); }
details summary::-webkit-details-marker { color: var(--muted); }
.channel-switch { display: flex; gap: 6px; }
.channel-switch a { padding: 9px 16px; border: 1.5px solid var(--line); border-radius: 999px; color: var(--brand-700); font-weight: 650; font-size: 14px; }
.channel-switch a.active { color: #fff; background: var(--brand); border-color: var(--brand); }

/* ============================================================
   ВКЛАДКИ
   ============================================================ */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1.5px solid var(--line); overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 11px 16px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: inherit; font-weight: 650; cursor: pointer; white-space: nowrap; }
.tab svg { width: 17px; height: 17px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand-700); border-bottom-color: var(--brand); }
.tab .badge { font-weight: 600; }

/* ============================================================
   КАНАЛЫ / WhatsApp / шаблоны
   ============================================================ */
.wa-card { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; margin-top: 10px; padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.wa-card.wa-active { border-color: var(--brand-100); background: var(--brand-50); }
.wa-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--line); flex: none; }
.wa-info { flex: 1 1 180px; min-width: 0; }
.wa-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14.5px; }
.wa-star { color: var(--brand); font-size: 15px; }
.wa-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.tpl { padding: 14px 0; border-top: 1px solid var(--line); }
.tpl:first-child { border-top: 0; }
.bus-photo { white-space: nowrap; }
.bus-photo img { width: 56px; height: 38px; object-fit: cover; border-radius: 6px; vertical-align: middle; }
.photo-up { display: inline-grid; place-items: center; width: 32px; height: 32px; margin-left: 6px; border-radius: 8px; background: var(--brand-50); cursor: pointer; }
.photo-up input { display: none; }

/* ── меню документов ── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 25; min-width: 250px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-pop); }
.dropdown-menu a { display: block; padding: 9px 11px; border-radius: var(--r-sm); color: var(--ink); }
.dropdown-menu a:hover { background: var(--brand-50); }
.dd-section { margin: 8px 4px 4px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.dd-select { width: 100%; margin-bottom: 6px; }
.dd-check { display: flex; align-items: center; gap: 8px; padding: 7px 4px; font-size: 13.5px; color: var(--muted); }

/* ── QR ── */
.qr-box { display: grid; place-items: center; gap: 12px; padding: 20px; }
.qr-box img { width: 240px; height: 240px; border-radius: var(--r); border: 1px solid var(--line); background: #fff; padding: 10px; }

/* ── лента ── */
.split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.feed { display: grid; }
.feed-item { display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line-soft); }
.feed-item:last-child { border-bottom: 0; }
.feed-item .when { min-width: 86px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* ============================================================
   ЛОГИН
   ============================================================ */
.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: radial-gradient(120% 120% at 50% 0%, #efeefc 0%, var(--bg) 55%); }
.login-card { width: min(400px, 100%); padding: 34px 30px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--sh-2); }
.login-card h1 { margin: 16px 0 24px; font-size: 22px; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 48px; }
.password-toggle { position: absolute; top: 50%; right: 6px; display: grid; place-items: center; width: 38px; height: 38px; transform: translateY(-50%); border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; }
.password-toggle:hover { color: var(--brand); background: var(--brand-50); }
.login-layout { max-width: 460px; }

/* десктоп: мобильная навигация всегда скрыта */
@media (min-width: 861px) {
    .topbar, .bottombar, .more-sheet, .sheet-backdrop { display: none !important; }
    .sidebar { display: flex !important; }
}

/* ============================================================
   АДАПТИВ — планшет
   ============================================================ */
@media (max-width: 1100px) {
    .split { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   АДАПТИВ — МОБАЙЛ (нижняя навигация)
   ============================================================ */
@media (max-width: 860px) {
    .sidebar { display: none; }
    .topbar { display: flex; }
    body { overflow-x: hidden; }

    .main {
        margin-left: 0;
        padding: 16px 14px calc(86px + var(--safe-b));
        max-width: 100%;
    }
    .g-preview, .msg-preview, .preview-cell { max-width: 100%; }
    .split { gap: 12px; }
    .split > div + div { margin-top: 0; }
    /* данные-таблицы: не крушим колонки, а скроллим горизонтально */
    #contactsTable { min-width: 900px; }
    #ptable { min-width: 880px; }
    table.cat { min-width: 720px; }
    #usersTable { min-width: 640px; }
    .table-wrap { margin: 0 -16px; padding: 0 16px; }
    /* подсказка о прокрутке */
    .table-wrap { position: relative; }

    h1 { font-size: 21px; }
    .page-head { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 16px; }
    .page-head .head-actions { gap: 8px; }
    .page-head .head-actions .btn, .page-head .head-actions .btn-link, .page-head .head-actions .dropdown { flex: 1; }
    .page-head .head-actions .btn, .page-head .head-actions .btn-link { justify-content: center; }

    .card { padding: 16px; border-radius: var(--r); }
    .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat .num { font-size: 24px; }
    .stat .lbl { font-size: 12px; }
    .facts { grid-template-columns: 1fr; }
    /* Главная команда остаётся рядом с итогом проверки, но не закрывает нижнюю навигацию. */
    .send-bar { position: sticky; bottom: calc(70px + var(--safe-b)); z-index: 20; box-shadow: 0 8px 28px rgba(28,25,64,.14); background: rgba(255,255,255,.94); backdrop-filter: saturate(180%) blur(14px); }
    .notif-metrics, .notif-delivery-metrics { grid-template-columns: 1fr 1fr; }
    .notif-ready-top { display: block; }
    .notif-ready-top > .btn { width: 100%; margin-top: 12px; justify-content: center; }
    .notif-issue { grid-template-columns: auto minmax(0,1fr); }
    .notif-issue .btn { grid-column: 1 / -1; }
    .notif-origin-head { display: block; }
    .notif-origin-head > .badge { margin-top: 8px; }
    .send-channel-panel { grid-template-columns:1fr; }
    #sendChannelEstimate { grid-column:auto; }
    .send-channel-choice { flex:1 1 46%; justify-content:center; }

    /* крупные тач-цели */
    .btn, .btn-link { min-height: 46px; }
    input, select, textarea, .cell { font-size: 16px; min-height: 46px; }  /* 16px = без зума iOS */
    .cell { min-height: 40px; }
    .sales-source-status { display: block; line-height: 1.45; }
    .sales-source-status span { display: block; margin-top: 4px; text-align: left; }

    .dropdown-menu { position: fixed; left: 12px; right: 12px; top: auto; bottom: calc(86px + var(--safe-b)); min-width: 0; }

    /* нижняя таб-навигация */
    .bottombar {
        display: flex;
        position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
        padding: 6px 4px calc(6px + var(--safe-b));
        background: rgba(255,255,255,.92); backdrop-filter: saturate(180%) blur(14px);
        border-top: 1px solid var(--line);
    }
    .bn-item {
        flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
        padding: 6px 2px; border: 0; background: none; color: var(--faint);
        font: inherit; font-size: 10.5px; font-weight: 600; cursor: pointer;
    }
    .bn-ic { display: grid; place-items: center; }
    .bn-ic svg { width: 23px; height: 23px; stroke-width: 1.9; }
    .bn-item.active { color: var(--brand); }
    .bn-item.active .bn-ic svg { stroke-width: 2.3; }

    /* шторка «Ещё» */
    .sheet-backdrop { display: block; position: fixed; inset: 0; z-index: 49; background: rgba(20,20,40,.4); opacity: 0; pointer-events: none; transition: opacity .2s; }
    .more-sheet {
        display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
        padding: 8px 16px calc(20px + var(--safe-b));
        background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
        box-shadow: 0 -8px 40px rgba(20,20,40,.18);
        transform: translateY(calc(100% + var(--sheet-drag, 0px))); transition: transform .24s cubic-bezier(.32,.72,0,1);
        touch-action: none;
    }
    .sheet-grab { width: 40px; height: 4px; margin: 8px auto 12px; border-radius: 99px; background: var(--line); }
    .sheet-item { display: flex; align-items: center; gap: 14px; padding: 14px 8px; border-radius: var(--r); color: var(--ink); font-weight: 600; font-size: 16px; }
    .sheet-item svg { width: 22px; height: 22px; color: var(--muted); }
    .sheet-item.active { color: var(--brand-700); background: var(--brand-50); }
    .sheet-item.active svg { color: var(--brand); }
    .sheet-user { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; padding: 14px 8px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
    .sheet-out { display: inline-flex; align-items: center; gap: 8px; color: var(--err); font-weight: 650; }
    .sheet-out svg { width: 19px; height: 19px; }

    body.sheet-open .sheet-backdrop { opacity: 1; pointer-events: auto; }
    body.sheet-open .more-sheet { transform: translateY(var(--sheet-drag, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
    .btn:active, .chat-send-btn:active, .bn-item:active, .sheet-item:active { transform: none; }
}

@media (max-width: 420px) {
    .grid-3 { grid-template-columns: 1fr; }
    .bn-label { font-size: 10px; }
}

/* ============================================================
   ЧАТЫ
   ============================================================ */
body[data-page="chats"] { overflow: hidden; }
body[data-page="chats"] .main { padding: 22px 26px; height: 100vh; max-width: 1400px; }

.chat-wrap {
    display: grid; grid-template-columns: 210px 330px 1fr;
    height: calc(100vh - 44px);
    background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--r-lg);
    overflow: hidden; box-shadow: var(--sh-2);
}

/* — очереди shared inbox — */
.chat-queues { min-width: 0; padding: 14px 10px; border-right: 1px solid var(--line); background: var(--surface-2); overflow-y: auto; }
.queue-monitor { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:16px; }
.queue-monitor h2 { margin:0 0 4px; }
.queue-monitor .queue-ok { color:var(--success,#16803c); }
.queue-monitor .queue-warn { color:var(--warning,#9a6700); }
@media (max-width: 700px) { .queue-monitor { align-items:flex-start; flex-direction:column; } }
.chat-queues-title { padding: 4px 10px 8px; color: var(--ink); font-size: 15px; font-weight: 800; }
.chat-queues-title.channels { margin-top: 15px; color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.cq { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.cq:hover { background: var(--surface); color: var(--ink); }
.cq.active { background: var(--brand-100); color: var(--brand-700); font-weight: 700; }
.cq b { min-width: 19px; padding: 1px 5px; border-radius: 99px; background: var(--line); font-size: 10.5px; text-align: center; }
.cq.active b { background: var(--brand); color: #fff; }
.cq.channel span { display: flex; align-items: center; gap: 7px; }
.cq.channel i { width: 8px; height: 8px; border-radius: 50%; background: var(--chc,var(--muted)); }
.cq.channel.active { color: var(--chc,var(--brand)); background: var(--surface); }
.cq.channel.active b { background: var(--chc,var(--brand)); }

/* — список диалогов — */
.chat-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.chat-list-head { padding: 12px 12px 10px; border-bottom: 1px solid var(--line-soft); }
.chat-search { width: 100%; min-height: 40px; padding: 9px 14px; border: 1.5px solid var(--line); border-radius: 99px; background: var(--surface-2); font-size: 14px; }
/* фильтр-вкладки каналов в списке диалогов */
.chat-ch-tabs { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 9px; }
.chtab { padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--chc, var(--muted)); cursor: pointer; }
.chtab.active { background: var(--chc, var(--brand)); border-color: var(--chc, var(--brand)); color: #fff; }
.ct-ch { flex: none; font-size: 10px; font-weight: 700; color: #fff; padding: 1px 6px; border-radius: 5px; }
.chat-threads { flex: 1; overflow-y: auto; padding: 6px; }
.chat-hint { padding: 28px 16px; text-align: center; color: var(--faint); font-size: 13px; line-height: 1.5; }

.chat-thread { display: flex; align-items: center; gap: 11px; padding: 10px 11px; border-radius: var(--r); cursor: pointer; transition: background .12s; }
.chat-thread:hover { background: var(--surface-2); }
.chat-thread.active { background: var(--brand-50); }
.ct-ava { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), #8a7ef2); color: #fff; font-weight: 700; font-size: 16px; }
.ct-main { flex: 1; min-width: 0; }
.ct-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ct-name { font-weight: 650; font-size: 14.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-time { flex: none; font-size: 11.5px; color: var(--faint); }
.ct-bot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.ct-last { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-thread.unread .ct-last { color: var(--ink); font-weight: 600; }
.ct-badge { flex: none; min-width: 20px; height: 20px; padding: 0 6px; display: grid; place-items: center; border-radius: 99px; background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 700; }
.ct-owner { margin-top: 3px; color: var(--faint); font-size: 10.5px; }
.ct-priority { display: inline-grid; place-items: center; width: 15px; height: 15px; margin-right: 4px; border-radius: 50%; background: #fff1c2; color: #946300; font-size: 10px; }
.ct-priority.urgent { background: var(--err-bg); color: var(--err); }
.chat-more { width: calc(100% - 12px); margin: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--brand); cursor: pointer; }

/* — окно переписки — */
.chat-conv { display: flex; min-width: 0; min-height: 0; background: var(--bg); }
.chat-empty[hidden], .chat-pane[hidden] { display: none; }   /* перебиваем display:flex у класса */
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--faint); }
.chat-empty svg { width: 56px; height: 56px; opacity: .5; }
.chat-empty p { margin: 0; font-size: 14px; }

.chat-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
/* Имя и номер собеседника — главное в шапке, они не должны сжиматься до «П..»/«+...».
   При нехватке места контролы и ссылка на рейс переносятся на вторую строку (flex-wrap),
   а не давят идентификацию. */
.chat-head { display: flex; align-items: center; gap: 12px; padding: 11px 16px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; row-gap: 8px; }
.chat-back { display: none; place-items: center; width: 36px; height: 36px; margin-left: -6px; border: 0; background: none; border-radius: 10px; color: var(--ink); cursor: pointer; }
.chat-back svg { width: 24px; height: 24px; }
.chat-head-ava { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), #8a7ef2); color: #fff; font-weight: 700; }
.chat-head-info { flex: 1 1 200px; min-width: 180px; }
.chat-head-name { font-weight: 700; font-size: 15px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-phone { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-controls { display: flex; align-items: center; gap: 6px; flex: none; }
.chat-head-controls select, .chat-note-btn { max-width: 145px; min-height: 34px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink); font-size: 11.5px; }
.chat-note-btn { cursor: pointer; }
.chat-head-card { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: var(--muted); }
.chat-head-card:hover { background: var(--brand-50); color: var(--brand-700); }
.chat-trip-link { max-width: 220px; padding: 7px 9px; border-radius: 8px; background: var(--brand-50); color: var(--brand-700); font-size: 11px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-trip-link[hidden] { display: none; }

.chat-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 18px 16px; }
.chat-load-older { align-self: center; margin: 0 0 8px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); color: var(--brand); font-size: 12px; cursor: pointer; }
.cm { display: flex; }
.cm.out { justify-content: flex-end; }
.cm.in { justify-content: flex-start; }
.cm-bubble { max-width: 74%; padding: 8px 12px 6px; border-radius: 16px; box-shadow: var(--sh-1); }
.cm.in .cm-bubble { background: var(--surface); border-bottom-left-radius: 5px; }
.cm.out .cm-bubble { background: linear-gradient(135deg, var(--brand), #6a5fe6); color: #fff; border-bottom-right-radius: 5px; }
.cm-text { display: block; font-size: 14px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.cm-media { display: block; cursor: zoom-in; }
.cm-media img { display: block; max-width: 240px; max-height: 280px; width: auto; border-radius: 10px; object-fit: cover; }
.cm-media + .cm-text { margin-top: 6px; }
/* Лайтбокс картинки из чата (закрывается крестиком / фоном / Esc — важно для PWA) */
.img-lightbox { position: fixed; inset: 0; z-index: 9999; display: none; align-items: center; justify-content: center; padding: 24px; background: rgba(0,0,0,.86); }
.img-lightbox.open { display: flex; }
.img-lightbox img { max-width: 96vw; max-height: 90vh; border-radius: 8px; box-shadow: 0 10px 46px rgba(0,0,0,.6); }
.img-lightbox-close { position: absolute; top: 14px; right: 18px; width: 46px; height: 46px; border: none; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; font-size: 30px; line-height: 1; cursor: pointer; }
.img-lightbox-close:hover { background: rgba(255,255,255,.3); }
.cm-file { display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 10px; background: rgba(0,0,0,.05); color: inherit; font-size: 13.5px; font-weight: 600; }
.cm.out .cm-file { background: rgba(255,255,255,.18); }
.cm-file svg { width: 22px; height: 22px; flex: none; opacity: .85; }
.cm-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.cm-meta { display: block; margin-top: 3px; text-align: right; font-size: 10.5px; color: var(--faint); }
.cm.out .cm-meta { color: rgba(255,255,255,.78); }
.cm-channel { display: inline-block; margin-right: 6px; padding: 1px 5px; border: 1px solid currentColor; border-radius: 5px; color: var(--cm-channel,var(--muted)); font-size: 9.5px; font-weight: 800; line-height: 1.25; vertical-align: 1px; }
.cm.out .cm-channel { color: #fff; background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.55); text-shadow: 0 1px 1px rgba(0,0,0,.16); }
.cm.pending { opacity: .72; }
.cm.pending .cm-bubble { box-shadow: none; }
.cm-tick { margin-left: 4px; }
.cm-tick.read { color: #8be0ff; }
.cm-tick.fail { color: #ffd2cd; font-weight: 700; }

.chat-input { display: flex; align-items: flex-end; gap: 10px; padding: 12px 14px; background: var(--surface); border-top: 1px solid var(--line); }
.chat-text { flex: 1; min-height: 44px; max-height: 140px; padding: 11px 15px; border: 1.5px solid var(--line); border-radius: 22px; background: var(--surface-2); font-size: 14px; line-height: 1.4; resize: none; }
.chat-send-btn { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border: 0; border-radius: 50%; background: var(--brand); color: #fff; cursor: pointer; box-shadow: 0 2px 8px rgba(91,80,224,.3); transition: background .12s; }
.chat-send-btn:hover { background: var(--brand-600); }
.chat-send-btn:disabled { opacity: .5; cursor: default; }
.chat-send-btn svg { width: 20px; height: 20px; }
.chat-channel-note { padding: 0 16px 8px; color: var(--err); font-size: 12.5px; min-height: 0; }
.chat-channel-note:empty { display: none; }
.chat-notes-dialog { width: min(480px,calc(100% - 28px)); max-height: 80vh; padding: 0; border: 0; border-radius: 14px; color: var(--ink); background: var(--surface); box-shadow: 0 24px 80px rgba(28,25,64,.28); }
.chat-notes-dialog::backdrop { background: rgba(24,22,45,.48); }
.chat-notes-head { display: flex; justify-content: space-between; align-items: center; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.chat-notes-head button { border: 0; background: none; color: var(--muted); font-size: 24px; cursor: pointer; }
.chat-notes-list { max-height: 45vh; overflow-y: auto; padding: 12px 18px; }
.chat-note { margin-bottom: 9px; padding: 10px 12px; border-radius: 10px; background: #fff8d9; color: #584400; font-size: 13px; }
.chat-note small { display: block; margin-top: 5px; color: #8b7635; }
.chat-notes-dialog form { display: grid; gap: 9px; padding: 14px 18px 18px; border-top: 1px solid var(--line); }
.chat-notes-dialog textarea { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 9px; resize: vertical; }

@media (max-width: 1120px) and (min-width: 861px) {
    .chat-wrap { grid-template-columns: 180px 285px 1fr; }
    .chat-head-controls select { max-width: 105px; }
    .chat-note-btn { padding-left: 6px; padding-right: 6px; }
}

@media (max-width: 860px) {
    body[data-page="chats"] { overflow: hidden; }
    body[data-page="chats"] .main { padding: 0; height: auto; max-width: 100%; }
    .chat-wrap {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: calc(100dvh - 56px - 58px - var(--safe-b));
        border: 0; border-radius: 0; box-shadow: none;
    }
    .chat-queues { display: flex; gap: 5px; padding: 7px 8px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
    .chat-queues-title { display: none; }
    .chat-queue-channels { display: flex; gap: 5px; }
    .cq { flex: none; width: auto; white-space: nowrap; padding: 6px 9px; }
    .chat-list { border-right: 0; }
    .chat-wrap:not(.conv-open) .chat-conv { display: none; }
    .chat-wrap.conv-open .chat-list, .chat-wrap.conv-open .chat-queues { display: none; }
    .chat-wrap.conv-open { grid-template-rows: 1fr; }
    .chat-back { display: grid; }
    .chat-head { gap: 8px; padding-left: 8px; padding-right: 8px; flex-wrap: wrap; }
    .chat-head-controls { width: 100%; order: 3; overflow-x: auto; }
    .chat-trip-link { order: 4; width: 100%; max-width: none; }
    .chat-head-controls select { flex: 1; max-width: none; min-width: 105px; }
    .cm-bubble { max-width: 84%; }
    .chat-text { font-size: 16px; }   /* без зума iOS */
    .chat-search { font-size: 16px; }
    .chat-pane { touch-action: pan-y; }
    .chat-body { overscroll-behavior: contain; }
}

/* ============================================================
   ПРОДАЖИ
   ============================================================ */
.seg { display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 18px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; }
.seg-item { padding: 7px 14px; border-radius: 8px; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.seg-item:hover { color: var(--ink); text-decoration: none; }
.seg-item.active { background: var(--surface); color: var(--brand-700); box-shadow: var(--sh-1); }

.ch-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.sales-split > .card { min-width: 0; }
.sales-page-head { align-items: center; }
.sales-settings-grid { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(280px,.8fr); gap: 18px; align-items: start; }
.sales-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.sales-card-head h2, .sales-card-head p { margin-top: 0; }
.sales-card-head p { margin-bottom: 0; }
.sales-address-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 14px; }
.sales-discovered { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.sales-discovered > span { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); }
.sales-discovered code { overflow-wrap: anywhere; }
.sales-rules-table { min-width: 980px; }
.sales-rules-table th:nth-child(1) { width: 16%; }
.sales-rules-table th:nth-child(2) { width: 19%; }
.sales-rules-table th:nth-child(3) { width: 17%; }
.sales-rules-table th:nth-child(4) { width: 22%; }
.sales-rules-table th:nth-child(5) { width: 90px; }
.sales-rules-table td.actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.sales-filters { display: grid; grid-template-columns: repeat(3,minmax(150px,1fr)); gap: 12px; margin-bottom: 12px; }
.sales-filters label { color: var(--muted); font-size: 12px; font-weight: 650; }
.sales-filters input, .sales-filters select { margin-top: 5px; }
.sales-filter-actions { display: flex; align-items: end; gap: 8px; }
.sales-owner-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.sales-event-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }

.topdates { display: flex; flex-direction: column; gap: 9px; }
.td-row { display: grid; grid-template-columns: 78px 1fr 28px; align-items: center; gap: 10px; }
.td-date { font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }
.td-bar { height: 8px; background: var(--line-soft); border-radius: 99px; overflow: hidden; }
.td-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #8a7ef2); border-radius: 99px; }
.td-cnt { text-align: right; font-weight: 700; font-size: 13.5px; }

.sfeed { display: flex; flex-direction: column; }
.sf-row { display: grid; grid-template-columns: 84px 110px 92px 1fr auto; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.sf-row:last-child { border-bottom: 0; }
.sf-time { color: var(--faint); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.sf-ch { color: #fff; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 7px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sf-kind { justify-self: start; }
.sf-route { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-amount { font-weight: 700; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
    .split { grid-template-columns: 1fr !important; }
    .sf-row { grid-template-columns: 64px 84px 1fr auto; }
    .sf-kind { display: none; }
    .sales-settings-grid, .sales-filters { grid-template-columns: 1fr; }
    .sales-address-list { grid-template-columns: 1fr; }
    .sales-card-head { align-items: stretch; flex-direction: column; }
    .sales-card-head .btn { width: 100%; justify-content: center; }
    .sales-filter-actions .btn { flex: 1; justify-content: center; }
    .sales-rules-table { min-width: 0; }
    .sales-rules-table thead { display: none; }
    .sales-rules-table, .sales-rules-table tbody, .sales-rules-table tr, .sales-rules-table td { display: block; width: 100%; }
    .sales-rules-table tr { margin-bottom: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
    .sales-rules-table td { padding: 5px 0; border: 0; }
    .sales-rules-table td::before { content: attr(data-label); display: block; margin: 0 0 3px; color: var(--muted); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
    .sales-rules-table td.actions { display: flex; margin-top: 6px; }
    .sales-rules-table td.actions::before { display: none; }
    .sales-rules-table td.actions .btn { flex: 1; justify-content: center; }
}

/* Логи */
.seg-n { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 3px; border-radius: 99px; background: var(--line); color: var(--muted); font-size: 11px; font-weight: 700; }
.seg-item.active .seg-n { background: var(--brand-100); color: var(--brand-700); }
.logfeed { display: flex; flex-direction: column; }
.lg-row { padding: 11px 4px; border-bottom: 1px solid var(--line-soft); }
.lg-row:last-child { border-bottom: 0; }
.lg-fail { background: rgba(192,39,31,.04); border-radius: 8px; }
.lg-top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; }
.lg-time { color: var(--faint); font-variant-numeric: tabular-nums; }
.lg-ch { color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 7px; white-space: nowrap; }
.lg-to { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.lg-body { color: var(--muted); font-size: 13px; margin-top: 4px; overflow-wrap: anywhere; }
.lg-err { margin-top: 5px; padding: 6px 10px; border-radius: 8px; background: var(--err-bg); color: var(--err); font-size: 12.5px; font-weight: 600; overflow-wrap: anywhere; }

/* плашка «отправка по WhatsApp» */
.wa-note { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; padding: 11px 15px; border-radius: var(--r); background: var(--ok-bg); color: var(--ok); border: 1px solid #bfe6cb; font-size: 13.5px; font-weight: 600; }
.wa-note svg { width: 20px; height: 20px; flex: none; }
.wa-note b { font-weight: 800; }

/* ============================================================
   ОТЧЁТНОСТЬ ПО РЕЙСАМ
   ============================================================ */
.report-upload { display: grid; grid-template-columns: minmax(280px,1fr) minmax(360px,1fr); gap: 28px; align-items: center; }
.report-upload h2, .report-card-head h2, .report-trip-card h2 { margin: 0 0 6px; }
.report-upload p { margin: 0; max-width: 700px; }
.report-upload-form { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.report-drop { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; border: 1px dashed var(--brand); border-radius: 10px; background: var(--brand-50); color: var(--brand-700); font-size: 13px; font-weight: 700; }
.report-drop input { max-width: 220px; }
.report-card-head { justify-content: space-between; align-items: center; margin-bottom: 14px; }
.report-passenger-actions { gap: 8px; flex-wrap: wrap; }
.report-scenario-label { gap: 6px; margin: 0; }
.report-scenario-select { width: 170px; }
.report-source-row { gap: 8px; }
.report-source-input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.report-station-add { gap: 8px; flex-wrap: wrap; align-items: center; }
.report-station-select { max-width: 230px; }
.report-station-amount { max-width: 150px; }
.report-context-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -4px 0 14px; padding: 10px 12px; border: 1px solid var(--brand-100); border-radius: var(--r); background: var(--brand-50); color: var(--brand-700); font-size: 13px; }
.report-list td { vertical-align: middle; }
.report-agents summary { cursor: pointer; }
.report-agent-form { display: grid; grid-template-columns: repeat(3,minmax(180px,1fr)); gap: 12px; align-items: end; }
.report-agent-form label, .report-facts label, .report-note { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.report-agent-form input, .report-agent-form select, .report-facts input, .report-facts select, .report-note textarea, .report-file-form input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: var(--surface); color: var(--ink); }
.report-agent-form input, .report-agent-form select, .report-facts input, .report-facts select, .report-note textarea, .report-file-form input,
.report-dialog input, .report-dialog select { font: inherit; font-size: 14px; }
.report-rate-field { width: 94px !important; min-width: 94px; }
.report-trip-head h1 { margin-top: 5px; }
.report-tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.report-tabs::-webkit-scrollbar { display: none; }
.report-tabs a { padding: 10px 14px; color: var(--muted); font-weight: 700; font-size: 13px; border-bottom: 2px solid transparent; white-space: nowrap; }
.report-tabs a.active { color: var(--brand); border-color: var(--brand); }
.report-tabs a:not(.active):hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
#reportPassengers, #reportCalculation, #reportControl { scroll-margin-top: 18px; }
.report-tabs a:focus-visible, .report-p-field:focus-visible, .report-context-bar .btn:focus-visible { outline: 3px solid var(--brand-100); outline-offset: 2px; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--brand-100); outline-offset: 2px; }
.report-facts { display: grid; grid-template-columns: repeat(3,minmax(180px,1fr)); gap: 12px; }
.report-facts.compact { grid-template-columns: 1fr; }
.report-facts input:disabled { color: var(--muted); background: var(--surface-2); }
.report-metrics { display: grid; grid-template-columns: repeat(5,minmax(150px,1fr)); gap: 10px; margin: 16px 0; }
.report-metrics > div { padding: 15px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); box-shadow: var(--sh-1); }
.report-metrics span { display: block; min-height: 32px; color: var(--muted); font-size: 12px; }
.report-metrics strong { display: block; font-size: 21px; font-variant-numeric: tabular-nums; }
.report-metrics .accent { color: #fff; background: linear-gradient(135deg,var(--brand),#7669e9); border-color: transparent; }
.report-metrics .accent span { color: rgba(255,255,255,.78); }
.report-summary-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; margin: 16px 0; }
.report-summary-card { margin: 0; }
.report-summary-card h2 { margin-bottom: 10px; }
.report-summary-lines > div { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.report-summary-lines > div:last-child { border-bottom: 0; }
.report-summary-lines span { color: var(--ink-2); }
.report-summary-lines strong { white-space: nowrap; font-variant-numeric: tabular-nums; }
.report-summary-lines .negative { color: var(--err); }
.report-summary-total { margin-top: 4px; padding-top: 12px !important; border-top: 2px solid var(--line); font-weight: 750; }
.report-summary-total strong { font-size: 18px; }
.report-summary-profit { border-color: var(--brand-100); }
.report-carrier-report-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.report-carrier-report-head h2 { margin: 4px 0 2px; font-size: 20px; text-transform: none; letter-spacing: -.2px; color: var(--ink); }
.report-carrier-report-head p { margin: 0; }
.report-carrier-kpis { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin: 16px 0; }
.report-carrier-kpis > div { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.report-carrier-kpis span { display: block; color: var(--muted); font-size: 12px; }
.report-carrier-kpis strong { display: block; margin-top: 4px; font-size: 21px; font-variant-numeric: tabular-nums; }
.report-carrier-columns { display: grid; grid-template-columns: minmax(0,1.15fr) minmax(280px,.85fr); gap: 16px; }
.report-carrier-columns .card { margin: 0; }
.report-carrier-version { margin-top: 20px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.report-passengers { padding-left: 0; padding-right: 0; }
.report-passengers > .report-card-head, .report-passengers > .report-save-state { margin-left: 18px; margin-right: 18px; }
/* Таблица пассажиров вмещается в экран: раньше стояло min-width:1600px при контенте
   в 1240px — правые колонки (цены, комментарий) уезжали за край и терялись. */
.report-passenger-table { min-width: 1120px; table-layout: fixed; }
.report-passenger-table td { vertical-align: middle; padding: 6px 5px; }
.report-passenger-table th { padding-left: 5px; padding-right: 5px; }
.report-passenger-table td .small { line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Подсветка строки пассажира: чья продажа и что с билетом — видно сразу.
   Левая цветная полоса — сторона расчёта, фон — проблемные состояния. */
.report-passenger-table tr { border-left: 3px solid transparent; }
.report-passenger-table tr.row-ours    { border-left-color: var(--ok, #1a9a54); }
.report-passenger-table tr.row-carrier { border-left-color: var(--warn, #b8760a); background: #fffaf2; }
.report-passenger-table tr.row-none    { border-left-color: var(--err, #d4443a); }
.report-passenger-table tr.row-noshow  { background: var(--warn-bg, #fff6e8); }
.report-passenger-table tr.row-refund  { background: var(--err-bg, #fdeeee); }
.report-passenger-table tr.row-refund td { opacity: .55; }
/* У полей в строке общий min-width:105px — он распирал узкие колонки (места и цены
   по 56–96px), из-за чего таблица вылезала за экран и правые колонки обрезались. */
.report-passenger-table .report-p-field { min-width: 0; }
/* Чекбокс — не текстовое поле: width:100% схлопывал его в точку, когда сняли min-width. */
.report-passenger-table input[type="checkbox"].report-p-field {
    width: 19px; height: 19px; min-width: 19px; flex: none; padding: 0; margin: 0;
    accent-color: var(--brand); cursor: pointer;
}
.report-passenger-table .money-input { min-width: 0; width: 100%; }
.seat-input { min-width: 0; max-width: 44px; text-align: center; padding-left: 4px; padding-right: 4px; }
.p-noshow { display: flex; gap: 8px; align-items: center; }
.p-noshow select { font-size: 12px; max-width: 118px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.report-p-field { width: 100%; min-width: 105px; border: 1px solid transparent; border-radius: 7px; padding: 7px 8px; background: transparent; color: var(--ink); font: inherit; }
.report-p-field:hover, .report-p-field:focus { border-color: var(--line); background: var(--surface); outline: none; }
.report-p-field.small-input { margin-top: 3px; color: var(--muted); font-size: 11.5px; }
select.report-p-field { border-color: var(--line); background: var(--surface); }
select.attendance-present { color: var(--ok); background: var(--ok-bg); }
select.attendance-absent { color: var(--err); background: var(--err-bg); }
select.attendance-unknown { color: var(--muted); }
.report-refund { display: flex; gap: 6px; align-items: center; padding: 7px 4px; font-size: 12px; white-space: nowrap; }
.money-input { text-align: right; font-variant-numeric: tabular-nums; }
.report-save-state { padding-top: 10px; }
.report-error { color: var(--err) !important; }
.report-bottom-grid, .report-file-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.report-breakdown > div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.report-breakdown strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Продажи автовокзалов: суммы столбиком справа, итоговая строка выделена */
.ta-r { text-align: right; }
.money-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.report-station-total td { border-top: 2px solid var(--line); background: var(--surface-2); }
.report-stations .table-wrap { margin-bottom: 4px; }
.report-warning { margin-bottom: 7px; padding: 8px 10px; border-radius: 8px; background: #fff7df; color: #815d00; font-size: 12.5px; }
.report-note { margin-top: 12px; }
.report-note textarea { min-height: 76px; resize: vertical; }
.report-cash { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.report-cash small { color: var(--muted); }
.report-file-form { display: grid; gap: 10px; }
.report-files { display: grid; grid-template-columns: repeat(2,minmax(280px,1fr)); gap: 10px; }
.report-file { display: grid; grid-template-columns: 40px 1fr 20px; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); }
.report-file:hover { border-color: var(--brand); text-decoration: none; }
.report-file svg { width: 20px; height: 20px; }
.report-file-ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; background: var(--brand-50); color: var(--brand); }
.report-file small { display: block; margin-top: 3px; color: var(--muted); }
.report-dialog { width: min(460px,calc(100% - 28px)); border: 0; border-radius: 16px; padding: 22px; color: var(--ink); background: var(--surface); box-shadow: 0 24px 80px rgba(28,25,64,.28); }
.report-dialog::backdrop { background: rgba(24,22,45,.48); backdrop-filter: blur(2px); }
.report-dialog form { display: grid; gap: 13px; }
.report-dialog label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.report-dialog input, .report-dialog select { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.report-dialog .head-actions { justify-content: flex-end; }

/* Инструкция по отчётности */
.report-guide-layout { display: grid; grid-template-columns: 220px minmax(0,900px); gap: 18px; align-items: start; }
.report-guide-nav { position: sticky; top: 18px; display: flex; flex-direction: column; gap: 3px; padding: 14px; }
.report-guide-nav strong { padding: 5px 9px 9px; }
.report-guide-nav a { padding: 7px 9px; border-radius: 8px; color: var(--muted); font-size: 12.5px; }
.report-guide-nav a:hover { background: var(--brand-50); color: var(--brand-700); text-decoration: none; }
.report-guide { line-height: 1.6; }
.report-guide section { padding-bottom: 22px; margin-bottom: 22px; border-bottom: 1px solid var(--line-soft); scroll-margin-top: 20px; }
.report-guide section:last-child { border-bottom: 0; }
.report-guide h2 { margin: 0 0 12px; font-size: 21px; }
.report-guide h3 { margin: 18px 0 7px; font-size: 16px; }
.report-guide p { margin: 8px 0; }
.report-guide li { margin: 5px 0; }
.guide-flow { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.guide-flow span { padding: 7px 11px; border-radius: 9px; background: var(--brand-50); color: var(--brand-700); font-size: 12px; font-weight: 700; }
.guide-flow i { color: var(--faint); font-style: normal; }
.guide-callout { margin: 14px 0; padding: 12px 14px; border-left: 3px solid var(--brand); border-radius: 8px; background: var(--brand-50); }
.guide-callout.warn { border-color: #d89b00; background: #fff7df; color: #715400; }
.guide-cases { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.guide-cases > div { padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.guide-cases p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.guide-math { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin: 12px 0; }
.guide-math span { padding: 12px; border-radius: 9px; background: var(--surface-2); font-weight: 800; font-variant-numeric: tabular-nums; }
.guide-math small { display: block; margin-top: 4px; color: var(--muted); font-weight: 500; line-height: 1.25; }
.guide-checklist { padding-left: 0; list-style: none; counter-reset: guide; }
.guide-checklist li { position: relative; padding: 8px 10px 8px 39px; border-bottom: 1px solid var(--line-soft); counter-increment: guide; }
.guide-checklist li::before { content: counter(guide); position: absolute; left: 6px; top: 7px; display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); font-size: 11px; font-weight: 800; }
.guide-schema { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; }
.guide-schema > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.guide-schema span { color: var(--muted); }

@media (max-width: 1100px) {
    .report-metrics { grid-template-columns: repeat(3,1fr); }
    .report-agent-form { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 700px) {
    .report-context-bar { align-items: stretch; flex-direction: column; }
    .report-context-bar .btn { width: 100%; justify-content: center; }
    .report-upload, .report-bottom-grid, .report-file-grid, .report-summary-grid, .report-carrier-columns { grid-template-columns: 1fr; }
    .report-carrier-kpis { grid-template-columns: 1fr; }
    .report-carrier-report-head { align-items: stretch; flex-direction: column; }
    .report-upload-form { align-items: stretch; flex-direction: column; }
    .report-drop { align-items: flex-start; flex-direction: column; }
    .report-facts { grid-template-columns: 1fr 1fr; }
    .report-metrics { display: flex; overflow-x: auto; padding-bottom: 4px; }
    .report-metrics > div { min-width: 170px; }
    .report-agent-form, .report-files { grid-template-columns: 1fr; }
    .report-trip-head .head-actions { width: 100%; }
    .report-trip-head .head-actions .btn { flex: 1; }
    .report-cash { flex-direction: column; gap: 4px; }
    .report-guide-layout { grid-template-columns: 1fr; }
    .report-guide-nav { display: none; }
    .report-guide { padding: 16px; }
    .guide-cases, .guide-schema { grid-template-columns: 1fr; }
    .guide-math { grid-template-columns: 1fr 1fr; }

    /* На телефоне строка пассажира становится карточкой, без горизонтального скролла. */
    .report-passenger-table { min-width: 0; display: block; }
    .report-passenger-table thead { display: none; }
    .report-passenger-table tbody, .report-passenger-table tr { display: block; }
    .report-passenger-table tr { display: grid; grid-template-columns: 34px minmax(0, 1fr) 34px; grid-template-areas:
        "seat passenger delete" "route route route" "agent agent agent" "manifest our our" "note note note" "noshow noshow noshow"; gap: 8px 10px; padding: 12px 10px; border-left-width: 4px; border-bottom: 1px solid var(--line); }
    .report-passenger-table tr:last-child { border-bottom: 0; }
    .report-passenger-table td { min-width: 0; padding: 0; border: 0; white-space: normal; }
    .report-passenger-table td:nth-child(1) { grid-area: seat; }
    .report-passenger-table td:nth-child(2) { grid-area: passenger; }
    .report-passenger-table td:nth-child(3) { grid-area: route; padding-top: 1px; }
    .report-passenger-table td:nth-child(4) { grid-area: agent; }
    .report-passenger-table td:nth-child(5) { grid-area: manifest; }
    .report-passenger-table td:nth-child(6) { grid-area: our; }
    .report-passenger-table td:nth-child(7) { grid-area: note; }
    .report-passenger-table td:nth-child(8) { grid-area: noshow; }
    .report-passenger-table td:nth-child(9) { grid-area: delete; justify-self: end; }
    .report-passenger-table td:nth-child(5)::before, .report-passenger-table td:nth-child(6)::before,
    .report-passenger-table td:nth-child(7)::before, .report-passenger-table td:nth-child(8)::before { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; font-weight: 650; }
    .report-passenger-table td:nth-child(5)::before { content: "Ведомость"; }
    .report-passenger-table td:nth-child(6)::before { content: "Наша стоимость"; }
    .report-passenger-table td:nth-child(7)::before { content: "Комментарий"; }
    .report-passenger-table td:nth-child(8)::before { content: "Посещаемость и возврат"; }
    .report-passenger-table .report-p-field { min-height: 40px; padding: 8px 9px; border-color: var(--line); background: var(--surface); }
    .report-passenger-table .seat-input { max-width: none; text-align: center; }
    .report-passenger-table .p-noshow { min-height: 40px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
    .report-passenger-table .p-noshow select { flex: 1; max-width: none; }
    .report-passenger-table td .small { white-space: normal; }
    .report-passenger-actions { width: 100%; }
    .report-passenger-actions .btn { flex: 1 1 180px; }
    .report-scenario-label { width: 100%; justify-content: space-between; }
    .report-scenario-select, .report-station-select, .report-station-amount { max-width: none; width: 100%; }
    .report-source-row { align-items: stretch; flex-direction: column; }
    .report-source-row .btn { width: 100%; justify-content: center; }
}

/* ============================================================
   ПЕЧАТЬ
   ============================================================ */
@media print {
    .sidebar, .topbar, .bottombar, .more-sheet, .sheet-backdrop, .page-head .head-actions, .no-print { display: none !important; }
    body { background: #fff; }
    .main { margin: 0; padding: 0; max-width: 100%; }
    .card { box-shadow: none; border: 0; padding: 0; }
}

/* Field persistence: text feedback accompanies the field outline. */
.save-feedback { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.save-feedback > div { flex:1 1 220px; overflow-wrap:anywhere; }
.save-feedback .save-error { color:var(--err); }
.save-feedback button { min-height:44px; white-space:normal; }
.save-feedback button[hidden] { display:none; }
input.cell[data-save-state="error"] { outline:2px solid var(--err); outline-offset:-2px; }
input.cell[data-save-state="changed"], input.cell[data-save-state="saving"] { box-shadow:inset 0 -2px var(--warn); }
.chat-draft-hint { padding:0 16px 8px; font-size:12px; line-height:1.5; color:var(--muted); }
.chat-channel-note { overflow-wrap:anywhere; }

.workspace-state { padding:0 0 8px; line-height:1.5; overflow-wrap:anywhere; }
.workspace-state:empty { display:none; }
/* Keep the composer above mobile navigation when workspace feedback wraps. */
body[data-page="chats"] .main { display:flex; flex-direction:column; }
body[data-page="chats"] .workspace-state { flex:none; }
body[data-page="chats"] .chat-wrap { flex:1; min-height:0; height:auto; }
@media (max-width:860px) {
    body[data-page="chats"] .main { height:calc(100dvh - var(--workspace-top,56px) - var(--workspace-bottom,70px)); }
    body[data-page="chats"] .workspace-state { padding:4px 12px 8px; }
}
