:root {
  --bg: #17212b;
  --bg-chat: #0e1621;
  --header: #17212b;
  --press: #232e3c;
  --accent: #3390ec;
  --out: #2b5278;
  --in: #213243;
  --search: #242f3d;
  --text: #ffffff;
  --muted: #7d8e9e;
  --divider: rgba(255, 255, 255, 0.06);
  --divider-strong: rgba(255, 255, 255, 0.16);
  --danger: #e0506a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Светлая тема ── */
html[data-theme="light"] {
  --bg: #ffffff;
  --bg-chat: #e8ebf0;
  --header: #ffffff;
  --press: #e6e9ef;
  --accent: #3390ec;
  --out: #3390ec;       /* исходящие пузыри / активные кнопки — синие, текст белый */
  --in: #eef1f5;        /* входящие пузыри / поля ввода — светло-серые */
  --search: #ebedf1;
  --text: #14171a;
  --muted: #6a7682;
  --divider: rgba(0, 0, 0, 0.10);
  --divider-strong: rgba(0, 0, 0, 0.18);
}
/* контрастные правки там, где цвета заданы жёстко */
html[data-theme="light"] .icon-btn { color: var(--muted); }
html[data-theme="light"] .msg .meta { color: rgba(0, 0, 0, .42); }
html[data-theme="light"] .msg.out .meta { color: #dbe9fb; }
html[data-theme="light"] .popup { background: #ffffff; box-shadow: 0 -8px 30px rgba(0, 0, 0, .18); }
html[data-theme="light"] .bar { background: #d6dde4; }
html[data-theme="light"] .order-status { background: #e7ecf1; color: #5a6b7b; }
html[data-theme="light"] .toast { background: #2a3540; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overscroll-behavior: none;
}
body { overflow: hidden; position: fixed; inset: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin-top: 10px; min-height: 18px; font-size: 14px; }

.screen {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; /* заполняет весь физический экран */
  transform: translateY(var(--vtop, 0px));
  display: flex; flex-direction: column;
}
/* при открытой клавиатуре ограничиваем высоту видимой областью (класс ставит JS) */
html.kbd .screen { height: var(--vh); bottom: auto; }
/* попапы (шторки снизу) тем же приёмом поднимаем над клавиатурой — иначе она накрывает поля ввода */
html.kbd .popup-overlay { height: var(--vh); bottom: auto; transform: translateY(var(--vtop, 0px)); }

/* ── Топбар ── */
.topbar {
  display: flex; align-items: center; gap: 6px;
  padding: calc(var(--safe-top) + 4px) 10px 4px;
  background: var(--header);
  flex: 0 0 auto;
  position: relative; z-index: 5;
}
.topbar .title { font-size: 18px; font-weight: 600; flex: 1; }
.icon-btn {
  background: none; border: none; color: #aebfce;
  font-size: 21px; padding: 6px 8px; cursor: pointer; border-radius: 50%;
}
.icon-btn:active { background: var(--press); }
/* переключатель темы (ползунок) */
.theme-toggle { background: none; border: none; padding: 4px 2px; cursor: pointer; flex: 0 0 auto; line-height: 0; }
.th-track { display: block; width: 46px; height: 26px; border-radius: 13px; background: var(--in); position: relative; transition: background .2s; }
.th-track::before { content: '🌙'; position: absolute; left: 5px; top: 0; line-height: 26px; font-size: 11px; }
.th-track::after { content: '☀️'; position: absolute; right: 5px; top: 0; line-height: 26px; font-size: 11px; }
.th-knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); transition: transform .2s; z-index: 1; }
.theme-toggle.light .th-track { background: var(--accent); }
.theme-toggle.light .th-knob { transform: translateX(20px); }
.chat-head { gap: 4px; }
.chat-head-info { flex: 1; min-width: 0; text-align: center; }
.chat-head .title { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subtitle { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .subtitle { display: flex; gap: 6px; justify-content: center; align-items: baseline; overflow: visible; }
.chat-head .chi-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chat-head .chi-link { color: var(--accent); text-decoration: none; }
.chat-head .chi-price { flex: 0 0 auto; color: var(--text); font-weight: 600; }
.back { display: flex; align-items: center; gap: 1px; font-size: 26px; }
.back-count { font-size: 15px; color: var(--accent); font-weight: 400; }

/* ── Поиск ── */
.search-wrap { background: var(--header); padding: 0 8px 6px; flex: 0 0 auto; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--search); border-radius: 16px; padding: 6px 12px;
}
.search-ic { opacity: .6; font-size: 14px; }
.search input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 15px;
}
.search input::placeholder { color: var(--muted); }

/* ── Логин ── */
.login { align-items: center; justify-content: center; background: var(--bg); }
.login-box { width: min(86%, 340px); text-align: center; }
.login-logo {
  width: 84px; height: 84px; margin: 0 auto; border-radius: 50%;
  background: linear-gradient(135deg, #72d5fd, #2a9ef1);
  display: flex; align-items: center; justify-content: center; font-size: 40px;
}
.login-box h1 { margin: 16px 0 4px; font-size: 22px; }
.login-box input {
  width: 100%; margin-top: 18px; padding: 14px;
  background: var(--search); border: none; border-radius: 12px;
  color: var(--text); font-size: 16px; outline: none; text-align: center;
}
.login-box button {
  width: 100%; margin-top: 12px; padding: 14px;
  background: var(--accent); border: none; border-radius: 12px;
  color: #fff; font-size: 16px; font-weight: 600; cursor: pointer;
}

/* ── Аватарки ── */
.avatar {
  width: 54px; height: 54px; border-radius: 50%; flex: 0 0 auto;
  background: var(--press) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; font-weight: 600; color: #fff; overflow: hidden;
}
.avatar.sm { width: 38px; height: 38px; font-size: 16px; }

/* ── Список чатов ── */
.chat-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; background: var(--bg); }
/* звонки */
.call-card { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--divider); }
.call-ic { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 19px; flex: 0 0 auto; background: var(--in); }
.call-ic.call-ok { background: rgba(62, 196, 109, .18); }
.call-ic.call-miss { background: rgba(224, 80, 106, .18); }
.call-info { flex: 1; min-width: 0; }
.call-phone { display: block; font-size: 16px; font-weight: 600; color: var(--text); text-decoration: none; }
.call-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.call-meta .call-ok { color: #3ec46d; }
.call-meta .call-miss { color: var(--danger); }
.call-play { margin-left: auto; flex: 0 0 auto; background: var(--accent); color: #fff; border: none; border-radius: 16px; padding: 7px 14px; font-size: 14px; cursor: pointer; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.rl-count { padding: 34px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.rl-count b { color: var(--accent); font-size: 18px; font-variant-numeric: tabular-nums; }
.chat-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; cursor: pointer; position: relative;
}
.chat-row:active { background: var(--press); }
.chat-row::after {
  content: ''; position: absolute; left: 78px; right: 0; bottom: 0;
  border-bottom: 1px solid var(--divider);
}
.chat-main { flex: 1; min-width: 0; }
.chat-top { display: flex; align-items: center; gap: 8px; }
.chat-name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.chat-time { color: var(--muted); font-size: 13px; flex: 0 0 auto; }
.chat-time .rd { color: #6fd0ff; }
.chat-row { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* вкладки Все/Контроль над поиском */
.chat-tabs { display: flex; justify-content: center; gap: 8px; background: var(--header); padding: 2px 8px 6px; flex: 0 0 auto; }
.chat-tab { background: var(--in); border: none; color: var(--muted); font-size: 14px; font-weight: 600; padding: 6px 18px; border-radius: 16px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chat-tab.active { background: var(--out); color: #fff; }
.ctab-count { background: var(--accent); color: #fff; font-size: 11px; min-width: 17px; height: 17px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }

/* тег-пилюля в строке чата */
.chat-tag { flex: 0 0 auto; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 9px; white-space: nowrap; }
.tag-call { background: #16314a; color: #58b0f0; }
.tag-remind { background: #3c3219; color: #e7be64; }
.tag-return { background: #3a1f24; color: #e07a8c; }

/* выбор тега (попап) */
.tag-opts { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 4px; }
.tag-opt { text-align: left; background: var(--in); border: none; color: var(--text); font-size: 16px; padding: 13px 14px; border-radius: 12px; cursor: pointer; }
.tag-opt:active { background: var(--press); }
.tag-opt.tag-del { color: var(--danger); background: var(--press); }
/* быстрые сообщения */
.quick-status { color: var(--muted); font-size: 13px; line-height: 1.4; margin: 6px 0; }
.quick-status.quick-error { color: var(--danger); }
.quick-retry { background: var(--press); color: var(--text); border: none; border-radius: 10px; padding: 9px 12px; margin-bottom: 8px; cursor: pointer; }
.quick-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 10px; max-height: 48vh; overflow-y: auto; }
.quick-item { display: flex; align-items: stretch; gap: 6px; }
.quick-text { flex: 1; text-align: left; background: var(--in); color: var(--text); font-size: 15px; line-height: 1.3; padding: 11px 13px; border-radius: 12px; cursor: pointer; }
.quick-text:active { background: var(--press); }
.quick-del { flex: 0 0 auto; width: 40px; background: var(--press); border: none; color: var(--muted); font-size: 14px; border-radius: 12px; cursor: pointer; }
.quick-add { display: flex; gap: 6px; margin-bottom: 4px; }
.quick-add input { flex: 1; min-width: 0; background: var(--search); border: none; color: var(--text); font-size: 15px; padding: 11px 13px; border-radius: 12px; outline: none; }
.quick-add input::placeholder { color: var(--muted); }
.quick-add button { flex: 0 0 auto; width: 44px; background: var(--accent); border: none; color: #fff; font-size: 22px; line-height: 1; border-radius: 12px; cursor: pointer; }

/* суммы в Заказах */
.order-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 4px 12px 10px; background: var(--bg); flex: 0 0 auto; }
.order-sum-card { background: var(--in); border-radius: 14px; padding: 12px 14px; }
.order-sum-card .lbl { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.order-sum-card .big { font-size: 20px; font-weight: 700; line-height: 1.1; }
.order-sum-card .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.chat-item-line { display: flex; align-items: baseline; gap: 5px; margin-top: 2px; }
.chat-item { color: var(--accent); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.chat-price { color: var(--accent); font-size: 13px; font-weight: 600; flex: 0 0 auto; white-space: nowrap; }
.chat-bottom { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.chat-last { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; flex: 1; min-width: 0; }
.wait-badge { background: #38301a; color: #e7be64; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 9px; flex: 0 0 auto; white-space: nowrap; }
.badge {
  background: var(--accent); color: #fff; border-radius: 12px;
  min-width: 22px; height: 22px; padding: 0 7px; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.badge.dot { min-width: 12px; width: 12px; height: 12px; padding: 0; }

/* ── Переписка ── */
.messages {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 10px 10px 14px; display: flex; flex-direction: column; gap: 2px;
  background-color: var(--bg-chat);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150' viewBox='0 0 150 150'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='0.035' stroke-width='2'%3E%3Ccircle cx='22' cy='24' r='9'/%3E%3Cpath d='M62 30 q11 -12 22 0'/%3E%3Ccircle cx='120' cy='52' r='6'/%3E%3Cpath d='M30 96 l11 11 l-11 11'/%3E%3Ccircle cx='96' cy='118' r='11'/%3E%3Cpath d='M126 104 h16 M134 96 v16'/%3E%3Cpath d='M14 130 q10 8 20 0'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 300px;
}
.date-sep { align-self: center; margin: 10px 0; }
.date-sep span {
  background: rgba(0, 0, 0, .35); color: #c9d6e3; font-size: 12px; font-weight: 600;
  padding: 4px 12px; border-radius: 14px;
}
.sys-msg {
  align-self: center; max-width: 88%; text-align: center; margin: 4px auto;
  background: var(--in); color: var(--muted); font-size: 13px; line-height: 1.35;
  padding: 7px 13px; border-radius: 13px;
}
.msg {
  max-width: 78%; padding: 6px 9px 6px 11px; border-radius: 14px;
  font-size: 15.5px; line-height: 1.35; word-wrap: break-word; white-space: pre-wrap;
  position: relative; margin-top: 2px;
}
.msg.in { align-self: flex-start; background: var(--in); border-bottom-left-radius: 5px; }
.msg.out { align-self: flex-end; background: var(--out); color: #fff; border-bottom-right-radius: 5px; }
/* «хвостик» как в Telegram */
.msg.in.tail { border-bottom-left-radius: 16px; }
.msg img { max-width: 100%; border-radius: 12px; display: block; margin: -2px -3px 3px -5px; }
.msg .meta { font-size: 11px; color: rgba(255, 255, 255, .45); text-align: right; margin-top: 1px; float: right; margin-left: 8px; position: relative; top: 6px; }
.msg.out .meta { color: #8bbce6; }
.msg.out .meta .read { color: #6fd0ff; }
.msg .sys { font-style: italic; opacity: .7; }
.voice-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 16px;
  padding: 7px 16px; font-size: 14px; cursor: pointer;
}
.voice-audio { max-width: 230px; height: 38px; display: block; }

/* ── Композер ── */
.composer {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 3px 6px calc(5px + var(--safe-bottom));
  background: var(--header); flex: 0 0 auto;
}
.attach { font-size: 22px; padding: 8px; cursor: pointer; color: #8696a7; }
.composer textarea {
  flex: 1; resize: none; max-height: 120px;
  background: var(--search); border: none; border-radius: 20px;
  color: var(--text); font-size: 16px; padding: 10px 16px; outline: none; font-family: inherit;
  line-height: 1.3;
}
.send {
  background: var(--accent); border: none; color: #fff;
  width: 42px; height: 42px; border-radius: 50%; font-size: 19px; cursor: pointer; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.send:disabled { opacity: .5; }
.mic {
  background: none; border: none; color: var(--accent);
  width: 42px; height: 42px; font-size: 22px; cursor: pointer; flex: 0 0 auto;
}

/* ── Тост ── */
.toast {
  position: fixed; left: 50%; bottom: calc(80px + var(--safe-bottom)); transform: translateX(-50%);
  background: #000b; color: #fff; padding: 10px 16px; border-radius: 20px;
  font-size: 14px; z-index: 100; max-width: 80%; text-align: center;
}
.spinner { text-align: center; color: var(--muted); padding: 20px; }

/* баннер «доступна новая версия» — страховка авто-обновления PWA */
.upd-banner {
  position: fixed; left: 50%; bottom: calc(80px + var(--safe-bottom)); transform: translateX(-50%);
  background: var(--accent); color: #fff; padding: 11px 18px; border-radius: 20px;
  font-size: 14px; font-weight: 600; z-index: 300; box-shadow: 0 4px 16px rgba(0, 0, 0, .35); cursor: pointer;
  max-width: 86%; text-align: center;
}

/* ── Таб-бар ── */
.tabbar {
  display: flex; flex: 0 0 auto;
  background: var(--header); border-top: 1px solid var(--divider);
  padding-bottom: 4px; /* в браузере (Opera GX и т.п.) — таб-бар у самого низа вьюпорта, без лишнего зазора */
}
/* только в установленном на «Домой» приложении даём клиренс под домашнюю полоску iPhone */
@media (display-mode: standalone) {
  .tabbar { padding-bottom: max(4px, calc(var(--safe-bottom) - 12px)); }
}
.tab {
  flex: 1; background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 5px 0 0; font-size: 22px; cursor: pointer; position: relative;
}
.tab span { font-size: 11px; }
.tab.active { color: var(--accent); }
.tab-dot { position: absolute; top: 3px; left: 50%; margin-left: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--header); }

/* ── под-табы статистики (Авито / Отчёт) ── */
.stats-tabs { display: flex; gap: 8px; padding: 6px 12px 8px; background: var(--header); flex: 0 0 auto; }
.stats-tab { flex: 1; background: var(--in); border: none; color: var(--muted); font-size: 15px; font-weight: 600; padding: 9px 0; border-radius: 12px; cursor: pointer; }
.stats-tab.active { background: var(--out); color: #fff; }
/* воронки отчёта */
.funnel { margin: 2px 0 22px; }
.funnel-title { font-size: 16px; font-weight: 700; margin: 4px 0 12px; }
.funnel-stage { margin: 0 auto; border-radius: 10px; padding: 9px 14px; display: flex; align-items: center; justify-content: center; gap: 8px; color: #fff; transition: min-width .25s ease; }
.funnel-stage.fz { opacity: .42; }
.funnel-stage .fs-label { font-size: 14px; font-weight: 600; white-space: nowrap; }
.funnel-stage .fs-val { font-size: 16px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.funnel-conv { text-align: center; font-size: 11.5px; color: var(--muted); padding: 3px 0; }
.fm { background: #3a78c2; }
.fm-cost { background: #b9602e; }
.fs { background: #2f8f6b; }
.fs-net { background: #1f7a55; }
.fs-neg { background: var(--danger); }
/* Прибыли и убытки (P&L) — компактные строки (используется в Отчёте) */
.pnl { margin-top: 4px; }
.pnl-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 2px; font-size: 15px; border-bottom: 1px solid var(--divider); }
.pnl-row .pnl-val { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.pnl-row.neg .pnl-val { color: var(--danger); }
.pnl-row.sub { padding: 5px 2px 5px 16px; font-size: 13px; color: var(--muted); border-bottom: none; }
.pnl-row.sub .pnl-val { font-weight: 500; color: var(--muted); }
.pnl-row.total { font-weight: 700; border-top: 2px solid var(--divider-strong); border-bottom: none; margin-top: 2px; padding-top: 10px; }
.pnl-row.total .pnl-val { color: var(--text); }
.pnl-row.grand { font-weight: 800; font-size: 18px; border-top: 2px solid var(--accent); border-bottom: none; margin-top: 6px; padding-top: 11px; color: var(--accent); }
.pnl-row.grand .pnl-val { color: var(--accent); }
/* ── Статистика ── */
.stats-content {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 12px 12px 20px;
}
.stat-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat-card {
  background: var(--in); border-radius: 16px; padding: 13px 15px; min-height: 82px;
  display: flex; flex-direction: column; justify-content: center;
}
.stat-card .lbl { font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.stat-card .big { font-size: 23px; font-weight: 700; line-height: 1.1; }
.stat-card .sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.stat-card .stars { color: #f5b50a; font-size: 16px; letter-spacing: 1px; }
.bar { height: 8px; border-radius: 4px; background: #2a3a4a; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: #3ec46d; border-radius: 4px; }

.period-seg { display: flex; background: var(--in); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.seg {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: 8px 0; border-radius: 9px; font-size: 14px; cursor: pointer;
}
.seg.active { background: var(--out); color: #fff; }

.stat-list { background: var(--in); border-radius: 16px; overflow: hidden; margin-bottom: 12px; }
.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--divider); font-size: 15px; gap: 10px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row .k { color: var(--text); }
.stat-row .v { font-weight: 600; flex: 0 0 auto; }
.stat-row .v.na { color: var(--muted); font-weight: 400; }
.stat-card.tappable { cursor: pointer; }
.stat-card .tap-hint { font-size: 11px; color: var(--accent); margin-top: 4px; }

/* ── Объявления в статистике ── */
.items-title { font-size: 14px; color: var(--muted); margin: 6px 2px 8px; }
.items-sort { display: flex; gap: 6px; margin-bottom: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sort-btn { background: var(--in); border: none; color: var(--muted); font-size: 12px; padding: 6px 12px; border-radius: 9px; white-space: nowrap; cursor: pointer; flex: 0 0 auto; }
.sort-btn.active { background: var(--out); color: #fff; }
.items-stat { display: flex; flex-direction: column; gap: 8px; }
.item-stat-card { background: var(--in); border-radius: 12px; padding: 9px 12px; display: flex; align-items: center; gap: 10px; }
.item-stat-info { flex: 1; min-width: 0; }
.item-stat-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 5px; }
.item-stat-metrics { display: flex; gap: 10px 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.item-stat-metrics span { white-space: nowrap; }
.item-stat-img { width: 46px; height: 46px; border-radius: 8px; background: var(--press) center/cover no-repeat; flex: 0 0 auto; }

/* кнопка обновления статистики */
.refresh-btn { font-size: 20px; line-height: 1; }
.refresh-btn.spinning { animation: spin 0.8s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

/* «Стоимость клика» + «Стоимость обращения» в одной карточке.
   Эта строка шире (клик/обращение), «Все расходы» — уже, чтобы суммы влезали в строку. */
.stat-cards.cards-cpc { grid-template-columns: 1.6fr 1fr; }
.cpc-split { display: flex; align-items: center; width: 100%; }
.cpc-half { flex: 1; min-width: 0; }
.cpc-half + .cpc-half { border-left: 1px solid var(--divider); padding-left: 10px; margin-left: 10px; }
.cpc-half .lbl { font-size: 12px; margin-bottom: 4px; }
.cpc-half .big { font-size: 17px; font-weight: 700; line-height: 1.1; white-space: nowrap; }
.cpc-half .cpc-hint { font-size: 11px; color: var(--accent); margin-top: 3px; }

/* навигация по месяцам */
.month-nav { display: flex; align-items: center; justify-content: center; gap: 16px; margin: -4px 0 12px; }
.month-arrow { background: var(--in); border: none; color: var(--text); font-size: 20px; width: 36px; height: 34px; border-radius: 9px; cursor: pointer; }
.month-arrow:active { background: var(--press); }
#monthLabel { font-size: 15px; font-weight: 600; min-width: 140px; text-align: center; }

/* метка версии (для проверки обновления приложения) */
.app-ver { text-align: center; color: var(--muted); font-size: 11px; opacity: .5; padding: 14px 0 4px; }

/* переключатель аккаунтов */
.acct-btn { background: var(--in); border: none; color: var(--text); font-size: 13px; padding: 6px 12px; border-radius: 14px; cursor: pointer; flex: 0 0 auto; }
.acct-row { padding: 14px 6px; border-bottom: 1px solid var(--divider); font-size: 16px; cursor: pointer; display: flex; justify-content: space-between; }
.acct-row:last-child { border-bottom: none; }
.acct-row.active { color: var(--accent); font-weight: 600; }

/* ── Заказы ── */
.orders-list {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 10px 12px; background: var(--bg);
}
.orders-filter { display: flex; gap: 7px; padding: 0 12px 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--bg); flex: 0 0 auto; }
.ofilter { background: var(--in); border: none; color: var(--muted); font-size: 13px; padding: 7px 14px; border-radius: 16px; white-space: nowrap; flex: 0 0 auto; cursor: pointer; }
.ofilter.active { background: var(--out); color: #fff; }
.order-card { background: var(--in); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; display: flex; gap: 11px; }
.order-img { width: 54px; height: 54px; border-radius: 9px; background: var(--press) center/cover no-repeat; flex: 0 0 auto; }
.order-body { flex: 1; min-width: 0; }
.order-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.order-title { font-weight: 600; font-size: 15px; flex: 1; }
.order-total { font-weight: 700; font-size: 15px; flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; }
.order-payout { font-size: 10px; font-weight: 500; color: var(--muted); }
.order-status { display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 10px; margin-top: 7px; background: #23303f; color: #9fb3c8; }
.order-status.ok { background: #163528; color: #5ed29a; }
.order-status.warn { background: #38301a; color: #e7be64; }
.order-status.bad { background: #381f24; color: #e07a8c; }
.order-meta { color: var(--muted); font-size: 13px; margin-top: 7px; line-height: 1.45; }
.order-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.order-actions button { font-size: 13px; padding: 7px 13px; border-radius: 9px; border: none; cursor: pointer; background: var(--press); color: var(--text); }
.order-actions button.primary { background: var(--accent); color: #fff; }
.order-actions button.danger { background: #3a1f24; color: #e07a8c; }
.order-actions button.share-btn { padding: 7px 10px; } /* компактная иконка-кнопка «Поделиться» */

/* ── Попап ── */
.popup-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .8); display: flex; align-items: flex-end; justify-content: center; z-index: 200; }
.popup { background: #1e2a38; width: 100%; max-width: 480px; border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + var(--safe-bottom)); box-shadow: 0 -8px 30px rgba(0, 0, 0, .5); -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.popup-title { font-size: 18px; font-weight: 600; margin-bottom: 10px; }
.popup-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--divider); font-size: 15px; }
.popup-row .v { font-weight: 600; }
.popup-row.total { font-weight: 700; border-bottom: none; border-top: 2px solid var(--divider); margin-top: 2px; }
.popup-close { width: 100%; margin-top: 14px; padding: 13px; background: var(--accent); border: none; border-radius: 12px; color: #fff; font-size: 16px; font-weight: 600; cursor: pointer; }
.popup-cancel { width: 100%; margin-top: 8px; padding: 12px; background: var(--in); border: none; border-radius: 12px; color: var(--muted); font-size: 15px; cursor: pointer; }
/* попап «Поделиться заказом» */
.share-item-title { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
#sharePartNum { width: 100%; box-sizing: border-box; background: var(--in); border: none; border-radius: 12px; padding: 13px 14px; color: var(--text); font-size: 16px; }
