/* ══ Токены: светлая тема по умолчанию ═════════════════════════════════════════ */
:root {
  --bg: #e9ecf0;
  --surface: #ffffff;
  --surface-2: #f4f6f8;
  --surface-3: #e3e7ec;
  --line: #d3d8df;
  --line-strong: #aeb6c1;
  --text: #0e141b;
  --text-2: #3a4450;
  --muted: #5b6672;
  --accent: #0b5cad;
  --accent-ink: #ffffff;
  --focus: #0b5cad;
  --hover: #eef3fa;
  --expanded: #f1f5fb;
  --selected: #dce8f8;
  --dock-h: 360px;

  /* Статусы: сплошная заливка, высокий контраст */
  --st-open: #1747a6;      --st-open-ink: #ffffff;
  --st-partial: #f2b01e;   --st-partial-ink: #1a1300;
  --st-replied: #157a3b;   --st-replied-ink: #ffffff;
  --st-unmatched: #c42020; --st-unmatched-ink: #ffffff;

  /* Источники: контурные теги */
  --src-batka_z: #0b5cad;
  --src-batka_rub: #b0123a;
  --src-batka_reaction: #a14a00;
  --src-daria_bridge: #0b6e66;
  --src-daria_easther: #6a2bc2;

  --warn: #a33c00;  --warn-bg: #ffe9d6;  --warn-line: #e88a45;
  --danger: #c42020;
  --old: #c42020;

  --group-bg: #26303c;  --group-ink: #ffffff;  --group-meta: #c4ccd6;

  --shadow: 0 1px 2px rgba(15, 23, 32, .08), 0 4px 16px rgba(15, 23, 32, .06);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d1116;
  --surface: #161b22;
  --surface-2: #1c232c;
  --surface-3: #252e39;
  --line: #2c3540;
  --line-strong: #46525f;
  --text: #f0f3f6;
  --text-2: #c9d1d9;
  --muted: #9aa5b1;
  --accent: #58a6ff;
  --accent-ink: #06121f;
  --focus: #58a6ff;
  --hover: #1d2836;
  --expanded: #1a2230;
  --selected: #1f3350;

  --st-open: #3b82f6;      --st-open-ink: #ffffff;
  --st-partial: #f5b82e;   --st-partial-ink: #1a1300;
  --st-replied: #2ea760;   --st-replied-ink: #04150a;
  --st-unmatched: #f05252; --st-unmatched-ink: #ffffff;

  --src-batka_z: #6cb6ff;
  --src-batka_rub: #ff7b93;
  --src-batka_reaction: #ffa657;
  --src-daria_bridge: #3fd1c1;
  --src-daria_easther: #c297ff;

  --warn: #ffb070;  --warn-bg: #3d2410;  --warn-line: #b8611e;
  --danger: #ff6b6b;
  --old: #ff7b72;

  --group-bg: #2e3946;  --group-ink: #ffffff;  --group-meta: #b9c4d0;

  --shadow: 0 1px 2px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #0d1116;
    --surface: #161b22;
    --surface-2: #1c232c;
    --surface-3: #252e39;
    --line: #2c3540;
    --line-strong: #46525f;
    --text: #f0f3f6;
    --text-2: #c9d1d9;
    --muted: #9aa5b1;
    --accent: #58a6ff;
    --accent-ink: #06121f;
    --focus: #58a6ff;
    --hover: #1d2836;
    --expanded: #1a2230;
  --selected: #1f3350;

    --st-open: #3b82f6;      --st-open-ink: #ffffff;
    --st-partial: #f5b82e;   --st-partial-ink: #1a1300;
    --st-replied: #2ea760;   --st-replied-ink: #04150a;
    --st-unmatched: #f05252; --st-unmatched-ink: #ffffff;

    --src-batka_z: #6cb6ff;
    --src-batka_rub: #ff7b93;
    --src-batka_reaction: #ffa657;
    --src-daria_bridge: #3fd1c1;
    --src-daria_easther: #c297ff;

    --warn: #ffb070;  --warn-bg: #3d2410;  --warn-line: #b8611e;
    --danger: #ff6b6b;
    --old: #ff7b72;

    --group-bg: #2e3946;  --group-ink: #ffffff;  --group-meta: #b9c4d0;

    --shadow: 0 1px 2px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

/* ══ База ══════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
/* Место под полосу прокрутки резервируется всегда: иначе при появлении/исчезновении
   прокрутки (мало строк после фильтра) вся страница сдвигается по горизонтали. */
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.4 var(--font); font-variant-numeric: tabular-nums;
}
h1, h2 { margin: 0; letter-spacing: -.01em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.mobile-only { display: none; }

.btn {
  appearance: none; font: inherit; font-weight: 600; cursor: pointer; line-height: 1.2;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 8px 14px;
}
.btn:hover { background: var(--hover); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-quiet { background: transparent; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); }
.btn-block { width: 100%; padding: 11px 14px; font-size: 15px; }
.btn-link {
  appearance: none; border: 0; background: none; padding: 0; font: inherit; color: var(--accent);
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}

input, select {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 5px 8px; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input::placeholder { color: var(--muted); }

.logo {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 16px;
}

/* ══ Вход ══════════════════════════════════════════════════════════════════════ */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 16px;
}
.login-head { display: flex; gap: 12px; align-items: center; }
.login-head .logo { width: 40px; height: 40px; font-size: 20px; border-radius: 10px; }
.login-head h1 { font-size: 22px; }
.login-head p { margin: 2px 0 0; }
.field { display: grid; gap: 6px; font-weight: 600; }
.field input { padding: 11px 12px; font-size: 16px; border-radius: 8px; }
.login-error {
  margin: 0; background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line);
  border-radius: 8px; padding: 9px 12px; font-weight: 600;
}
.login-foot { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }

/* ══ Верхняя панель ════════════════════════════════════════════════════════════ */
.appbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 var(--line);
}
.appbar-brand { display: flex; align-items: center; gap: 10px; }
.appbar-brand h1 { font-size: 19px; font-weight: 750; }
.badge-demo {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  color: var(--warn); background: var(--warn-bg); border: 1px solid var(--warn-line);
  padding: 2px 7px; border-radius: 5px;
}
.health { display: flex; gap: 6px; flex-wrap: wrap; }
.health-item {
  display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px 3px 8px;
}
.health-item b { font-weight: 650; color: var(--text); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.ok { background: var(--st-replied); }
.dot.idle { background: var(--st-partial); }
.dot.down { background: var(--danger); }
.appbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.appbar-actions form { margin: 0; }
.session { font-size: 13px; color: var(--muted); margin-right: 6px; }

/* ══ Страница ══════════════════════════════════════════════════════════════════ */
.page { padding: 20px 24px calc(var(--dock-h) + 32px); max-width: 1680px; margin: 0 auto; }

/* Быстрые фильтры по источнику */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  appearance: none; font: inherit; cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 8px 14px 8px 12px; min-height: 48px;
  box-shadow: inset 4px 0 0 var(--src, var(--line-strong));
}
.tab:hover { background: var(--hover); }
.tab-name { font-weight: 650; font-size: 14px; }
.tab-bot { display: block; font-size: 12px; color: var(--muted); }
.tab-num {
  font-size: 18px; font-weight: 800; min-width: 64px; text-align: center; white-space: nowrap;
  padding: 2px 8px; border-radius: 7px; background: var(--surface-3);
}
.tab-num small { font-size: 12px; font-weight: 600; color: var(--muted); }
.tab[aria-pressed="true"] {
  background: var(--text); color: var(--surface); border-color: var(--text);
  box-shadow: inset 4px 0 0 var(--src, var(--text));
}
.tab[aria-pressed="true"] .tab-bot { color: var(--surface-3); }
.tab[aria-pressed="true"] .tab-num { background: var(--surface); color: var(--text); }
.tab[aria-pressed="true"] .tab-num small { color: var(--muted); }
.tabs-hint { margin: 8px 2px 16px; font-size: 12px; color: var(--muted); }

/* Панель с таблицей */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.panel-bar {
  display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.search { flex: 1 1 360px; display: flex; max-width: 560px; }
.search input { width: 100%; padding: 8px 12px; font-size: 14px; border-radius: 8px; }
.bar-field { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.bar-field select { font-size: 13px; padding: 6px 8px; }
.count { margin-left: auto; font-size: 13px; color: var(--text-2); font-weight: 600; }

/* ══ Таблица ═══════════════════════════════════════════════════════════════════ */
.table-scroll { overflow-x: auto; }
.grid { width: 100%; min-width: 1380px; border-collapse: collapse; table-layout: fixed; }
.w-state { width: 124px; }
.w-age { width: 92px; }
.w-bot { width: 78px; }
.w-chat { width: auto; }
.w-amount { width: 220px; }
.w-pay { width: 180px; }
.w-tags { width: 360px; }

.grid thead .head th {
  text-align: left; padding: 0; background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.grid th.num, .grid td.num { text-align: right; }
.sort {
  appearance: none; border: 0; background: none; font: inherit; cursor: pointer; width: 100%;
  text-align: inherit; padding: 10px 10px; color: var(--text-2);
  font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .05em;
  display: flex; align-items: center; gap: 6px;
}
.num .sort { justify-content: flex-end; }
.sort:hover { color: var(--text); background: var(--hover); }
.sort::after { content: "↕"; opacity: .35; font-size: 12px; }
.sort[aria-sort="ascending"], .sort[aria-sort="descending"] { color: var(--accent); }
.sort[aria-sort="ascending"]::after { content: "↑"; opacity: 1; }
.sort[aria-sort="descending"]::after { content: "↓"; opacity: 1; }

.grid thead .filters td {
  padding: 6px 6px 8px; background: var(--surface-2); border-bottom: 2px solid var(--line-strong);
  vertical-align: middle;
}
.filters select, .filters input { width: 100%; }
.amount-filter { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 4px; }
.filters .is-active { border-color: var(--accent); background: var(--hover); font-weight: 650; }

/* Строки */
.grid tbody td {
  padding: 0 10px; height: 44px; border-bottom: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}
.grid tbody tr.row { cursor: pointer; }
.grid tbody tr.row:hover td { background: var(--hover); }

.grid tbody tr.row td:first-child { box-shadow: inset 4px 0 0 var(--row-state, transparent); padding-left: 14px; }
.grid thead .head th:first-child .sort { padding-left: 14px; }
.grid thead .filters td:first-child { padding-left: 10px; }
.grid tbody tr.row.selected td { background: var(--selected); }
.grid tbody tr.row.selected td:first-child { box-shadow: inset 6px 0 0 var(--accent); }
.row[data-state="open"] { --row-state: var(--st-open); }
.row[data-state="partial"] { --row-state: var(--st-partial); }
.row[data-state="replied"] { --row-state: var(--st-replied); }
.row[data-state="unmatched"] { --row-state: var(--st-unmatched); }
.row.is-replied td:not(:first-child) { color: var(--text-2); }

.c-chev { text-align: center; padding: 0 !important; }
.chev {
  display: inline-block; width: 18px; color: var(--muted); font-size: 16px; font-weight: 700;
  transition: transform .12s;
}
.row.open .chev { transform: rotate(90deg); color: var(--accent); }

.state {
  display: inline-block; font-size: 12px; font-weight: 750; letter-spacing: .01em;
  padding: 4px 9px; border-radius: 6px; line-height: 1.1;
}
.state-open { background: var(--st-open); color: var(--st-open-ink); }
.state-partial { background: var(--st-partial); color: var(--st-partial-ink); }
.state-replied { background: var(--st-replied); color: var(--st-replied-ink); }
.state-unmatched { background: var(--st-unmatched); color: var(--st-unmatched-ink); }

.age { font-weight: 600; }
.age.old { color: var(--old); font-weight: 800; }

.chat { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chat-title { overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.chat-title.unknown { color: var(--muted); font-style: italic; font-weight: 500; }
.chat-none { color: var(--muted); }
.tg-link {
  flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px;
  color: var(--accent); text-decoration: none; font-weight: 700; border: 1px solid transparent;
}
.tg-link:hover { border-color: var(--accent); background: var(--surface); }

.amount { font-weight: 750; font-size: 15px; }
.amount .cur { margin-left: 6px; }
.amount.unknown { color: var(--warn); font-weight: 700; font-size: 13px; }

.pay { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.bar { flex: none; width: 56px; height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--st-partial); }
.pay-left { overflow: hidden; text-overflow: ellipsis; }
.pay-left b { font-weight: 750; }
.pay-reply { color: var(--st-replied); font-weight: 700; }
.pay-none { color: var(--muted); }
.pay-action { color: var(--st-unmatched); font-weight: 700; }

.tags { display: flex; gap: 5px; align-items: center; overflow: hidden; }
.tag {
  flex: none; font-size: 12px; font-weight: 650; line-height: 1; padding: 4px 7px; border-radius: 5px;
  border: 1px solid var(--line-strong); color: var(--text-2); background: var(--surface);
}
.tag-src { color: var(--src); border-color: var(--src); font-weight: 750; }
.tag-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); font-weight: 750; }
[data-src="batka_z"] { --src: var(--src-batka_z); }
[data-src="batka_rub"] { --src: var(--src-batka_rub); }
[data-src="batka_reaction"] { --src: var(--src-batka_reaction); }
[data-src="daria_bridge"] { --src: var(--src-daria_bridge); }
[data-src="daria_easther"] { --src: var(--src-daria_easther); }

/* Группы */
.group-row td {
  background: var(--group-bg); color: var(--group-ink); padding: 0 12px; height: 40px;
  cursor: pointer; user-select: none; border-bottom: 1px solid var(--group-bg);
}
.group-row:hover td { filter: brightness(1.12); }
.group-in { display: flex; align-items: center; gap: 12px; }
.group-title { font-weight: 750; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.group-count {
  flex: none; background: var(--group-ink); color: var(--group-bg); font-weight: 800; font-size: 12px;
  border-radius: 99px; padding: 2px 8px;
}
.group-sum { margin-left: auto; color: var(--group-meta); font-size: 13px; font-weight: 600; white-space: nowrap; }
.group-sum b { color: var(--group-ink); }
.group-chev { display: inline-block; transition: transform .12s; font-weight: 800; }
.group-row.collapsed .group-chev { transform: rotate(-90deg); }

/* Раскрытие */
.detail-row td {
  background: var(--expanded); padding: 4px 16px 18px 48px; border-bottom: 2px solid var(--line-strong);
  white-space: normal;
}
.detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px;
}
.card h3 {
  margin: 0 0 10px; font-size: 12px; font-weight: 750; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-2);
}
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; font-weight: 550; }
.req-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.req-val { font-family: var(--mono); font-size: 13.5px; font-weight: 600; }
.req-val.plain { font-family: inherit; }
.req-val.revealed { background: var(--warn-bg); outline: 1px solid var(--warn-line); padding: 1px 5px; border-radius: 4px; }
.reveal {
  appearance: none; font: inherit; font-size: 12px; font-weight: 650; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  border-radius: 5px; padding: 2px 8px;
}
.reveal:hover { border-color: var(--accent); color: var(--accent); }
.links { display: grid; gap: 8px; }
.link-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  text-decoration: none; color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 9px 12px; background: var(--surface-2);
}
.link-btn:hover { border-color: var(--accent); background: var(--hover); }
.link-btn .lb-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn .lb-sub { display: block; font-size: 12px; color: var(--muted); }
.link-btn .lb-go { color: var(--accent); font-weight: 750; white-space: nowrap; font-size: 13px; }
.link-btn.disabled { color: var(--muted); border-style: dashed; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13.5px; }
.timeline li { display: flex; gap: 12px; }
.timeline .t { color: var(--muted); min-width: 96px; }
.timeline b { font-weight: 750; }
.detail-actions { margin-top: 12px; display: flex; gap: 8px; }
.warn-box {
  background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn);
  border-radius: 8px; padding: 8px 12px; font-weight: 650; font-size: 13px;
}

.empty, .offline { text-align: center; color: var(--muted); padding: 40px 0; margin: 0; font-size: 15px; }
.offline { color: var(--warn); font-weight: 650; }

/* Диалог */
.confirm {
  border: 1px solid var(--line); border-radius: 12px; padding: 22px; width: min(440px, calc(100% - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 16px 48px rgba(0, 0, 0, .3);
}
.confirm::backdrop { background: rgba(5, 8, 12, .55); }
.confirm h2 { font-size: 18px; margin-bottom: 8px; }
.confirm p { color: var(--text-2); margin: 0; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ══ Средние экраны ════════════════════════════════════════════════════════════ */
@media (max-width: 1280px) {
  .tab-bot { display: none; }
}

/* ══ Узкие экраны и телефоны: карточки ═════════════════════════════════════════ */
@media (max-width: 1000px) {
  .appbar { padding: 10px 16px; gap: 8px 12px; }
  .health { order: 3; width: 100%; }
  .session { display: none; }
  .page { padding: 14px 12px 40px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; min-height: 44px; padding: 6px 12px 6px 10px; }
  .tabs-hint { display: none; }
  .tabs { margin-bottom: 12px; }
  .mobile-only { display: inline-block; }
  .search { flex-basis: 100%; max-width: none; }
  .count { margin-left: 0; width: 100%; }
  .panel { background: none; border: 0; box-shadow: none; overflow: visible; }
  .panel-bar {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    margin-bottom: 10px; padding: 10px;
  }

  .grid, .grid tbody, .grid thead { display: block; }
  .grid colgroup, .grid thead .head { display: none; }
  .grid thead .filters { display: none; }
  .grid thead .filters.open {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px; margin-bottom: 10px;
  }
  .grid thead .filters.open td {
    display: grid; gap: 4px; padding: 0; background: none; border: 0;
  }
  .grid thead .filters.open td::before {
    content: attr(data-label); font-size: 12px; font-weight: 700; color: var(--text-2);
  }
  .grid thead .filters.open td.c-chev { display: none; }
  .grid thead .filters.open td[data-label="Сумма"] { grid-column: 1 / -1; }
  .filters select, .filters input { font-size: 15px; padding: 8px; }

  .grid tbody tr.row {
    display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 6px 10px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 10px 12px 10px 14px; margin-bottom: 8px; position: relative; overflow: hidden;
    box-shadow: inset 4px 0 0 var(--row-state);
  }
  .grid tbody tr.row td { display: block; height: auto; padding: 0; border: 0; background: none !important; box-shadow: none !important; }
  .grid tbody tr.row.open { border-color: var(--accent); margin-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
  .grid td.c-chev { display: none !important; }
  .grid td.c-state { grid-column: 1; grid-row: 1; }
  .grid td.c-age { grid-column: 2; grid-row: 1; font-size: 13px; }
  .grid td.c-amount { grid-column: 3 / 5; grid-row: 1; text-align: right; }
  .grid td.c-origin { grid-column: 1 / -1; grid-row: 2; }
  .grid td.c-exec { grid-column: 1 / -1; grid-row: 3; }
  .grid td.c-pay { grid-column: 1 / -1; grid-row: 4; }
  .grid td.c-tags { grid-column: 1 / -1; grid-row: 5; }
  .grid td.c-origin::before { content: "Откуда"; }
  .grid td.c-exec::before { content: "Кому"; }
  .grid td.c-origin::before, .grid td.c-exec::before {
    float: left; width: 64px; font-size: 12px; font-weight: 700; color: var(--muted); line-height: 24px;
  }
  .tags { flex-wrap: wrap; }
  .group-row { display: block; margin: 14px 0 8px; }
  .group-row td { display: block; height: auto; padding: 10px 12px; border-radius: 8px; }
  .detail-row { display: block; margin-bottom: 10px; }
  .detail-row td {
    display: block; padding: 10px; border: 1px solid var(--accent); border-top: 0;
    border-radius: 0 0 var(--radius) var(--radius);
  }
  .detail { grid-template-columns: 1fr; gap: 10px; }
}
@media (max-width: 420px) {
  .amount-filter { grid-template-columns: 1fr 1fr 1fr; }
  .appbar-brand h1 { font-size: 17px; }
}
.chat-missing { color: var(--warn); font-weight: 700; }

/* ══ Бот ═══════════════════════════════════════════════════════════════════════ */
.bot {
  display: inline-block; font-size: 11.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 7px; border-radius: 5px; line-height: 1; color: #fff;
}
.bot-batka { background: #374151; }
.bot-daria { background: #9d174d; }
:root[data-theme="dark"] .bot-batka { background: #4b5563; }
:root[data-theme="dark"] .bot-daria { background: #be185d; }
.btn-icon { width: 34px; padding-left: 0; padding-right: 0; font-size: 16px; }
.grid tbody td.c-tags { overflow: hidden; text-overflow: clip; }

/* ══ Нижняя панель заявки (не блокирует страницу) ══════════════════════════════ */
/* Ширина панели совпадает с контейнером страницы (.page: max 1680px, поля 24px). */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: var(--dock-h);
  width: calc(min(1680px, 100%) - 48px); margin: 0 auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-bottom: 0;
  border-top: 3px solid var(--accent); border-radius: 12px 12px 0 0; overflow: hidden;
  box-shadow: 0 -8px 28px rgba(10, 15, 25, .18);
}
.dock-in { height: 100%; display: flex; flex-direction: column; }
.dock-head {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); flex: none; min-width: 0;
}
.dock-title { font-size: 16px; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-title .arrow { color: var(--muted); font-weight: 500; margin: 0 6px; }
.dock-amount { font-size: 18px; font-weight: 800; white-space: nowrap; }
.dock-amount .cur { margin-left: 8px; font-size: 12px; }
.dock-spacer { flex: 1; }
.dock-close {
  appearance: none; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  width: 32px; height: 32px; border-radius: 8px; font-size: 18px; line-height: 1; cursor: pointer; flex: none;
}
.dock-close:hover { border-color: var(--accent); color: var(--accent); }
.dock-body {
  flex: 1; overflow: auto; padding: 14px 16px 18px;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-content: start;
  background: var(--surface-2);
}
.dock-gone { grid-column: 1 / -1; }
.tag-list { display: grid; gap: 8px; }
.tag-row { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.tag-row .tag { flex: none; }
.tag-row span:last-child { color: var(--text-2); }
.kv dd.strong { font-weight: 800; }
.kv dd.good { color: var(--st-replied); font-weight: 750; }
@media (max-width: 1280px) { .dock-body { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card h3.sub { margin-top: 14px; }
.tag-more { background: var(--surface-3); border-color: transparent; color: var(--text); }

/* ══ Валюты: у каждой свой цвет ════════════════════════════════════════════════ */
.cur {
  display: inline-block; font-size: 11.5px; font-weight: 800; letter-spacing: .03em; line-height: 1;
  padding: 3px 6px; border-radius: 5px; vertical-align: 1px;
  color: var(--cur-ink, var(--text-2)); background: var(--cur-bg, var(--surface-3));
}
.cur[data-cur="USD"]  { --cur-ink: #0f6b33; --cur-bg: #d3f5df; }
.cur[data-cur="USDT"] { --cur-ink: #0b5f59; --cur-bg: #c8f1ec; }
.cur[data-cur="RUB"]  { --cur-ink: #a3121f; --cur-bg: #fde0e2; }
.cur[data-cur="CNY"]  { --cur-ink: #9a3a00; --cur-bg: #ffe6cc; }
.cur[data-cur="AED"]  { --cur-ink: #6b21a8; --cur-bg: #efe1fb; }
.cur[data-cur="EUR"]  { --cur-ink: #1846a8; --cur-bg: #dce7fb; }
:root[data-theme="dark"] .cur[data-cur="USD"]  { --cur-ink: #7ee2a1; --cur-bg: #12351f; }
:root[data-theme="dark"] .cur[data-cur="USDT"] { --cur-ink: #6fe0d2; --cur-bg: #0f3431; }
:root[data-theme="dark"] .cur[data-cur="RUB"]  { --cur-ink: #ff9aa4; --cur-bg: #3d161b; }
:root[data-theme="dark"] .cur[data-cur="CNY"]  { --cur-ink: #ffb877; --cur-bg: #3d2410; }
:root[data-theme="dark"] .cur[data-cur="AED"]  { --cur-ink: #d4a8ff; --cur-bg: #2e1a44; }
:root[data-theme="dark"] .cur[data-cur="EUR"]  { --cur-ink: #9cc0ff; --cur-bg: #172a4d; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .cur[data-cur="USD"]  { --cur-ink: #7ee2a1; --cur-bg: #12351f; }
  :root[data-theme="system"] .cur[data-cur="USDT"] { --cur-ink: #6fe0d2; --cur-bg: #0f3431; }
  :root[data-theme="system"] .cur[data-cur="RUB"]  { --cur-ink: #ff9aa4; --cur-bg: #3d161b; }
  :root[data-theme="system"] .cur[data-cur="CNY"]  { --cur-ink: #ffb877; --cur-bg: #3d2410; }
  :root[data-theme="system"] .cur[data-cur="AED"]  { --cur-ink: #d4a8ff; --cur-bg: #2e1a44; }
  :root[data-theme="system"] .cur[data-cur="EUR"]  { --cur-ink: #9cc0ff; --cur-bg: #172a4d; }
}

/* Копирование названия группы */
.chat .chat-title { min-width: 0; }
.copy-btn {
  appearance: none; flex: none; display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 6px; cursor: pointer; padding: 0;
  border: 1px solid transparent; background: none; color: var(--muted);
  font: inherit; font-size: 14px; line-height: 1; opacity: .35;
}
tr.row:hover .copy-btn, .copy-btn:focus-visible, .copy-btn.done { opacity: 1; }
.copy-btn:hover { border-color: var(--line-strong); background: var(--surface); color: var(--accent); }
.copy-btn.done { color: var(--st-replied); font-weight: 800; }
@media (hover: none) { .copy-btn { opacity: .8; } }
.chat-title.guessed { font-style: italic; font-weight: 500; color: var(--text-2); }
/* Кнопки копирования в карточке заявки */
.kv dd { display: flex; align-items: flex-start; gap: 6px; }
.kv dd .kv-val { flex: 1; min-width: 0; }
.kv dd .copy-btn { margin-top: -3px; }
.dock .kv dd:hover .copy-btn { opacity: 1; }
.link-btn.disabled .copy-btn { opacity: 1; }
