/* ════════════════════════════════════════════════════════════════════════
   BOOM SENDER WEB — дизайн-система
   Тема переключается атрибутом <html data-theme="...">: каждая тема
   переопределяет CSS-переменные. Все компоненты (карточки, кнопки,
   таблицы, чат) используют только переменные.
   ════════════════════════════════════════════════════════════════════════ */

/* ── Темы ──────────────────────────────────────────────────────────────── */

:root, [data-theme="midnight"] {
  --bg: #0b0e14;
  --bg2: #12161f;
  --panel: #161c28;
  --panel2: #1d2433;
  --border: #27303f;
  --border2: #323d50;
  --text: #e8edf5;
  --muted: #8b98ab;
  --accent: #4f8cff;
  --accent2: #6ea8ff;
  --accent-dim: rgba(79, 140, 255, .14);
  --green: #34c77b;
  --red: #f2566d;
  --yellow: #f5b942;
  --own-bubble: linear-gradient(135deg, #3f7bff, #5f9bff);
  --shadow: 0 10px 34px rgba(0, 0, 0, .38);
  --radius: 14px;
  --nav-active-bg: linear-gradient(90deg, rgba(79, 140, 255, .22), rgba(79, 140, 255, .05));
  --head-grad: radial-gradient(1100px 500px at 12% -12%, rgba(79, 140, 255, .16), transparent 60%);
}

[data-theme="graphite"] {
  --bg: #0d0e10;
  --bg2: #131417;
  --panel: #181a1e;
  --panel2: #1f2227;
  --border: #272a30;
  --border2: #34383f;
  --text: #e7e9ec;
  --muted: #9198a3;
  --accent: #b8c2d0;
  --accent2: #d3dae5;
  --accent-dim: rgba(184, 194, 208, .14);
  --green: #5ecf8f;
  --red: #ef6b7f;
  --yellow: #e8c063;
  --own-bubble: linear-gradient(135deg, #54596b, #6d7387);
  --nav-active-bg: linear-gradient(90deg, rgba(200, 210, 224, .16), rgba(200, 210, 224, .04));
  --head-grad: radial-gradient(1100px 500px at 12% -12%, rgba(200, 210, 224, .10), transparent 60%);
}

[data-theme="nord"] {
  --bg: #22272e;
  --bg2: #272c34;
  --panel: #2e3440;
  --panel2: #353c4a;
  --border: #3b4252;
  --border2: #434c5e;
  --text: #eceff4;
  --muted: #97a1b1;
  --accent: #88c0d0;
  --accent2: #8fbcbb;
  --accent-dim: rgba(136, 192, 208, .16);
  --green: #a3be8c;
  --red: #bf616a;
  --yellow: #ebcb8b;
  --own-bubble: linear-gradient(135deg, #4c6a80, #5d7d95);
  --shadow: 0 10px 34px rgba(0, 0, 0, .30);
  --nav-active-bg: linear-gradient(90deg, rgba(136, 192, 208, .20), rgba(136, 192, 208, .04));
  --head-grad: radial-gradient(1100px 500px at 12% -12%, rgba(136, 192, 208, .13), transparent 60%);
}

[data-theme="dracula"] {
  --bg: #1a1b23;
  --bg2: #1e1f29;
  --panel: #282a36;
  --panel2: #343748;
  --border: #3b3d51;
  --border2: #4a4d66;
  --text: #f2f2f7;
  --muted: #9ba3c0;
  --accent: #bd93f9;
  --accent2: #d0a9ff;
  --accent-dim: rgba(189, 147, 249, .15);
  --green: #50fa7b;
  --red: #ff6b85;
  --yellow: #f1fa8c;
  --own-bubble: linear-gradient(135deg, #7c5bd1, #9a6ee6);
  --nav-active-bg: linear-gradient(90deg, rgba(189, 147, 249, .22), rgba(189, 147, 249, .05));
  --head-grad: radial-gradient(1100px 500px at 12% -12%, rgba(189, 147, 249, .15), transparent 60%);
}

[data-theme="forest"] {
  --bg: #10140f;
  --bg2: #141a13;
  --panel: #18201a;
  --panel2: #1f2a21;
  --border: #26332a;
  --border2: #31412f;
  --text: #e9f0e8;
  --muted: #8aa08c;
  --accent: #7bc96f;
  --accent2: #96dc8a;
  --accent-dim: rgba(123, 201, 111, .13);
  --green: #7bc96f;
  --red: #e5735f;
  --yellow: #dbb648;
  --own-bubble: linear-gradient(135deg, #4e8f47, #66a95c);
  --nav-active-bg: linear-gradient(90deg, rgba(123, 201, 111, .18), rgba(123, 201, 111, .04));
  --head-grad: radial-gradient(1100px 500px at 12% -12%, rgba(123, 201, 111, .12), transparent 60%);
}

[data-theme="ocean"] {
  --bg: #07161b;
  --bg2: #0a1c22;
  --panel: #0d232b;
  --panel2: #123039;
  --border: #17404c;
  --border2: #1e5260;
  --text: #e4f2f2;
  --muted: #7fa3a8;
  --accent: #2dd4bf;
  --accent2: #5eead4;
  --accent-dim: rgba(45, 212, 191, .14);
  --green: #34d399;
  --red: #fb7185;
  --yellow: #fbbf24;
  --own-bubble: linear-gradient(135deg, #0f9488, #14b8a6);
  --nav-active-bg: linear-gradient(90deg, rgba(45, 212, 191, .18), rgba(45, 212, 191, .04));
  --head-grad: radial-gradient(1100px 500px at 12% -12%, rgba(45, 212, 191, .13), transparent 60%);
}

[data-theme="sunset"] {
  --bg: #171012;
  --bg2: #1d1417;
  --panel: #241719;
  --panel2: #2d1c20;
  --border: #3a252b;
  --border2: #4a2d33;
  --text: #f5ecec;
  --muted: #ab8f94;
  --accent: #fb923c;
  --accent2: #fdba74;
  --accent-dim: rgba(251, 146, 60, .15);
  --green: #4ade80;
  --red: #f87171;
  --yellow: #facc15;
  --own-bubble: linear-gradient(135deg, #d97706, #f59e0b);
  --nav-active-bg: linear-gradient(90deg, rgba(251, 146, 60, .20), rgba(251, 146, 60, .05));
  --head-grad: radial-gradient(1100px 500px at 12% -12%, rgba(251, 146, 60, .13), transparent 60%);
}

[data-theme="light"] {
  --bg: #eef1f6;
  --bg2: #e4e9f1;
  --panel: #ffffff;
  --panel2: #f0f3f9;
  --border: #d5dbe8;
  --border2: #c2cad9;
  --text: #1d2733;
  --muted: #5d6b80;
  --accent: #2563eb;
  --accent2: #3b82f6;
  --accent-dim: rgba(37, 99, 235, .10);
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #d97706;
  --own-bubble: linear-gradient(135deg, #2563eb, #3b82f6);
  --shadow: 0 10px 30px rgba(30, 45, 75, .12);
  --nav-active-bg: linear-gradient(90deg, rgba(37, 99, 235, .12), rgba(37, 99, 235, .03));
  --head-grad: radial-gradient(1100px 500px at 12% -12%, rgba(37, 99, 235, .08), transparent 60%);
}

/* ── База ──────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Каркас ────────────────────────────────────────────────────────────── */

.layout { display: flex; min-height: 100vh; }
.side {
  width: 244px; flex: 0 0 244px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 16px 12px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side .brand {
  font-size: 16px; font-weight: 800; letter-spacing: .2px;
  padding: 6px 10px 4px; display: flex; align-items: center; gap: 8px;
  min-width: 0;
}
.brand .logo {
  width: 22px; height: 22px; border-radius: 7px; flex: 0 0 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff; box-shadow: 0 4px 14px var(--accent-dim);
}
.brand .brand-name { white-space: nowrap; min-width: 0; }
.brand .brand-name b { color: var(--accent2); font-weight: inherit; }
.side .platbox { padding: 6px 8px 10px; }

/* ── Кастомный дропдаун выбора площадки (флаги стран как PNG) ── */
.platdd { position: relative; }
.platdd-btn {
  width: 100%; min-width: 0; display: flex; align-items: center; gap: 8px;
  background: var(--bg2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; font-size: 12.5px; font-weight: 600;
  cursor: pointer; text-align: left; transition: border-color .15s;
}
.platdd-btn:hover { border-color: var(--border2); }
.platdd-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.platdd-chev { flex: 0 0 auto; color: var(--muted); font-size: 11px; transition: transform .15s; }
.platdd.open .platdd-chev { transform: rotate(180deg); }
.platdd-menu {
  display: none; position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  z-index: 80; max-height: 62vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 6px; box-shadow: 0 14px 34px rgba(0, 0, 0, .38);
}
.platdd.open .platdd-menu { display: block; }
/* заголовок страны: заметный «разделитель» — флаг + жирная подпись + линия,
   площадки под ним с отступом (видно иерархию) */
.platdd-cc {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 4px 4px; padding: 5px 8px;
  font-size: 12px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  position: sticky; top: 0; z-index: 2;
  backdrop-filter: blur(4px);
}
.platdd-cc .flag { width: 22px; height: 16px; flex: 0 0 22px; }
.platdd-menu .platdd-item { margin: 1px 4px 1px 14px; }
.platdd-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 9px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--text); cursor: pointer;
  transition: background .12s;
}
.platdd-item:hover { background: var(--panel); }
.platdd-item.active { background: var(--nav-active-bg); }
.flag {
  width: 20px; height: 15px; flex: 0 0 20px; border-radius: 2.5px; object-fit: cover;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .28); display: inline-block;
}
.flag-globe {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1; background: var(--panel);
}
.platdd-btn .flag-globe { font-size: 14px; background: none; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 4px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 600; font-size: 14px;
  position: relative; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.active {
  background: var(--nav-active-bg);
  color: var(--text);
}
.nav a.active::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px;
  width: 3px; border-radius: 3px; background: linear-gradient(180deg, var(--accent), var(--accent2));
}
.nav a .ico { width: 24px; text-align: center; flex: 0 0 24px; }
.nav-badge {
  margin-left: auto; min-width: 20px; text-align: center;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 10px; padding: 1px 6px;
  box-shadow: 0 2px 8px rgba(242, 86, 109, .4);
}

.side .userbox {
  margin-top: auto; padding: 12px; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; color: var(--muted); line-height: 1.6;
}
.side .userbox b { color: var(--text); display: block; margin-bottom: 2px; }
.side .userbox .logout { display: inline-block; margin-top: 6px; font-size: 13px; }

/* кнопка звука уведомлений в сайдбаре */
.sndbtn { margin: 8px 12px 0; width: calc(100% - 24px); }
.sndbtn.off { opacity: .6; }

/* точки тем в сайдбаре */
.theme-dots { display: flex; gap: 6px; padding: 10px 12px 8px; flex-wrap: wrap; }
.theme-dots .tdot {
  width: 18px; height: 18px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: transform .12s, border-color .12s;
  position: relative;
}
.theme-dots .tdot:hover { transform: scale(1.18); }
.theme-dots .tdot.active { border-color: var(--text); }

.main { flex: 1; padding: 26px 30px 40px; max-width: 1280px; min-width: 0; }
.pagehead {
  display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap;
}
.pagehead h1 { font-size: 23px; margin: 0; font-weight: 750; letter-spacing: .2px; }
.pagehead .sub { color: var(--muted); font-size: 13.5px; }
.spacer { flex: 1; }

/* ── Сетка и карточки ──────────────────────────────────────────────────── */

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1020px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  transition: border-color .18s, box-shadow .18s;
}
.card:hover { border-color: var(--border2); }
.card h3 {
  margin: 0 0 12px; font-size: 14.5px; font-weight: 700;
  display: flex; align-items: center; gap: 8px; letter-spacing: .2px;
}
.card h3 .muted { font-weight: 500; }
.card .muted { color: var(--muted); font-size: 13px; }
.stat { display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.stat::after {
  content: ""; position: absolute; right: -20px; top: -20px;
  width: 90px; height: 90px; border-radius: 50%;
  background: var(--accent-dim);
}
.stat .num { font-size: 27px; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: 13px; }
.stat .num.green { color: var(--green); }
.stat .num.red { color: var(--red); }
.stat .num.blue { color: var(--accent2); }
.stat .num.yellow { color: var(--yellow); }

/* ── Формы ─────────────────────────────────────────────────────────────── */

label.f { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; font-weight: 600; }
input[type=text], input[type=number], input[type=password], input[type=email],
input[type=file], textarea, select {
  width: 100%; background: var(--bg2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; font: inherit; font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input[type=checkbox] { width: auto; transform: scale(1.15); accent-color: var(--accent); }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 130px; }
.checkline { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; cursor: pointer; }
.checkline input { margin: 0; }

.autosave-chip {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 12.5px; font-weight: 600;
  opacity: 0; transition: opacity .25s;
}
.autosave-chip.show { opacity: 1; }
.autosave-chip.ok { color: var(--green); }
.autosave-chip.err { color: var(--red); }

/* ── Кнопки ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; padding: 9px 18px; border-radius: 10px;
  font: inherit; font-size: 14px; font-weight: 650;
  box-shadow: 0 4px 14px var(--accent-dim);
  /* «пружинная» кривая как в iOS: лёгкий overshoot при наведении */
  transition: transform .26s cubic-bezier(.34, 1.56, .64, 1),
              box-shadow .22s ease, filter .2s ease, background-color .18s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.07); }
.btn:active { transform: translateY(0) scale(.97); }
.btn.small { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.gray { background: var(--panel2); color: var(--text); box-shadow: none; border: 1px solid var(--border2); }
.btn.gray:hover { background: var(--border); }
.btn.red { background: linear-gradient(135deg, #e0465c, #f2566d); box-shadow: 0 4px 14px rgba(242, 86, 109, .25); }
.btn.green { background: linear-gradient(135deg, #2ba868, #3fda86); box-shadow: 0 4px 14px rgba(52, 199, 123, .25); }
.btn.yellow { background: linear-gradient(135deg, #e0a123, #f7c65d); color: #241a02; box-shadow: 0 4px 14px rgba(245, 185, 66, .22); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btnrow { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; align-items: center; }

/* ── Таблицы ───────────────────────────────────────────────────────────── */

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; color: var(--muted); font-weight: 650;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--panel); z-index: 1;
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px;
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--accent-dim); }
.tbl .mono { font-family: Consolas, monospace; font-size: 12.5px; }

/* ── Бейджи ────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 650;
}
.badge.green { background: rgba(52, 199, 123, .16); color: var(--green); }
.badge.red { background: rgba(242, 86, 109, .16); color: var(--red); }
.badge.yellow { background: rgba(245, 185, 66, .16); color: var(--yellow); }
.badge.gray { background: rgba(139, 152, 171, .16); color: var(--muted); }
.badge.blue { background: var(--accent-dim); color: var(--accent2); }

/* ── Прогресс / LED ────────────────────────────────────────────────────── */

.progress { height: 12px; background: var(--bg2); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.progress .bar {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 8px; transition: width .6s ease;
}
.led { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; background: var(--muted); }
.led.alive { background: var(--green); box-shadow: 0 0 8px var(--green); }
.led.paused { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }

/* ── Тосты ─────────────────────────────────────────────────────────────── */

#toasts { position: fixed; right: 22px; bottom: 22px; z-index: 99; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--border2); border-left: 4px solid var(--accent);
  padding: 11px 16px; border-radius: 11px; max-width: 380px;
  box-shadow: var(--shadow); animation: slidein .3s cubic-bezier(.3, 1.4, .5, 1);
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes slidein { from { transform: translateX(26px) scale(.95); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Прочее ────────────────────────────────────────────────────────────── */

.codebox {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; font-family: Consolas, monospace;
  font-size: 12.5px; white-space: pre-wrap; word-break: break-all;
}
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.pill-row { display: flex; flex-wrap: wrap; gap: 7px; }
.pill {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px; font-size: 12.5px; cursor: pointer;
  color: var(--muted); transition: border-color .15s, color .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.pill:hover { color: var(--text); border-color: var(--border2); }
.pill.on, .pill:hover.on { border-color: var(--accent); color: var(--accent2); background: var(--accent-dim); }
.pill .pill-x { color: var(--muted); font-weight: 700; padding: 0 1px; }
.pill .pill-x:hover { color: var(--red); }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { color: var(--muted); text-align: center; padding: 28px 10px; font-size: 14px; }
.mono { font-family: Consolas, monospace; }

/* ── Логин ─────────────────────────────────────────────────────────────── */

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--head-grad), var(--bg);
}
.login-card {
  width: 390px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 18px; padding: 32px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 6px; font-size: 23px; display: flex; align-items: center; gap: 10px; }
.login-card h1::before {
  content: "🚀"; width: 34px; height: 34px; border-radius: 10px; font-size: 17px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: inline-flex; align-items: center; justify-content: center;
}
.login-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }
.login-card .err { background: rgba(242, 86, 109, .12); color: var(--red); border-radius: 9px; padding: 10px 13px; font-size: 13.5px; margin-bottom: 14px; }

/* ── Панель задачи ─────────────────────────────────────────────────────── */

.runpanel {
  background: linear-gradient(180deg, var(--panel2) 0%, var(--panel) 100%);
  border: 1px solid var(--border2); padding: 18px;
}
.runpanel .big { font-size: 26px; font-weight: 800; }

/* ── Дропзона импорта аккаунтов ────────────────────────────────────────── */

.dropzone {
  border: 2px dashed var(--border2); border-radius: var(--radius);
  padding: 22px 18px; text-align: center; cursor: pointer;
  background: var(--bg2); transition: border-color .18s, background .18s, transform .12s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.dragover {
  border-color: var(--accent); background: var(--accent-dim);
  transform: scale(1.005);
}
.dropzone .dz-icon { font-size: 30px; margin-bottom: 6px; }
.dropzone b { font-size: 14.5px; }
.dropzone .muted { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.dz-files { margin-top: 10px; text-align: left; font-size: 13px; }

/* ── Страница тем оформления ───────────────────────────────────────────── */

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.theme-card {
  border: 2px solid var(--border); border-radius: var(--radius);
  padding: 14px; cursor: pointer; background: var(--bg2);
  transition: border-color .15s, transform .12s;
  position: relative;
}
.theme-card:hover { transform: translateY(-2px); border-color: var(--border2); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.theme-card.active .tc-check {
  position: absolute; top: 10px; right: 10px; color: var(--green); font-weight: 800;
}
.theme-prev {
  border-radius: 10px; overflow: hidden; border: 1px solid rgba(0, 0, 0, .25);
  height: 116px; display: flex; flex-direction: column; font-size: 0;
}
.theme-prev .tp-top { display: flex; height: 68px; }
.theme-prev .tp-side {
  width: 56px; padding: 6px; display: flex; flex-direction: column; gap: 4px;
}
.theme-prev .tp-side i { height: 7px; border-radius: 4px; display: block; }
.theme-prev .tp-main { flex: 1; padding: 7px; display: flex; flex-direction: column; gap: 5px; }
.theme-prev .tp-main i { height: 13px; border-radius: 6px; display: block; }
.theme-prev .tp-btn {
  margin-top: auto; align-self: flex-start; height: 13px; width: 52px;
  border-radius: 6px; display: block;
}
.theme-prev .tp-bubble { display: flex; height: 48px; }
.theme-prev .tp-bubble .b1 { width: 60%; border-radius: 12px 12px 12px 3px; margin: 5px 8px; }
.theme-prev .tp-bubble .b2 { width: 46%; border-radius: 12px 12px 3px 12px; margin: 5px 8px 5px auto; }
.theme-card .tc-name { font-weight: 700; margin-top: 10px; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.theme-card .tc-desc { color: var(--muted); font-size: 12.5px; }

/* ── Сообщения: выбор аккаунта ─────────────────────────────────────────── */

.accpick { position: relative; max-width: 430px; }
.accpick .ap-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 13px; cursor: pointer;
  color: var(--text); font: inherit; font-size: 14px;
  transition: border-color .15s;
}
.accpick .ap-btn:hover, .accpick.open .ap-btn { border-color: var(--accent); }
.accpick .ap-ava {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}
.accpick .ap-name { text-align: left; }
.accpick .ap-name b { display: block; font-size: 14px; }
.accpick .ap-name .muted { font-size: 12px; }
.accpick .ap-caret { margin-left: auto; color: var(--muted); transition: transform .18s; }
.accpick.open .ap-caret { transform: rotate(180deg); }
.accpick .ap-unread {
  background: var(--red); color: #fff; font-size: 11.5px; font-weight: 700;
  border-radius: 10px; padding: 2px 8px;
}
.accpick .ap-panel {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  max-height: 380px; overflow-y: auto; z-index: 40;
  background: var(--panel); border: 1px solid var(--border2);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px;
}
.accpick.open .ap-panel { display: block; }
.ap-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 9px; cursor: pointer;
}
.ap-item:hover { background: var(--bg2); }
.ap-item.sel { background: var(--accent-dim); }
.ap-item .ap-name { flex: 1; min-width: 0; }
.ap-item .ap-name b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-item .ap-name .muted { font-size: 11.5px; }
.ap-group {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); font-weight: 700; padding: 8px 10px 3px;
}

/* ── Сообщения: раскладка «Telegram» ───────────────────────────────────── */

.msg-layout {
  display: grid; grid-template-columns: 340px 1fr; gap: 14px;
  height: calc(100vh - 190px); min-height: 420px;
}
@media (max-width: 900px) { .msg-layout { grid-template-columns: 1fr; height: auto; } .dlg-pane { height: 60vh; } }

.dlg-pane, .chat-pane {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
}
.dlg-head {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px;
  background: var(--panel2);
}
.dlg-list { flex: 1; overflow-y: auto; padding: 6px; }
.dlg-item {
  display: flex; gap: 10px; padding: 8px 9px; border-radius: 11px;
  cursor: pointer; align-items: center;
  transition: background .15s ease, transform .2s cubic-bezier(.3, 1.4, .6, 1);
}
.dlg-item:hover { background: var(--bg2); }
.dlg-item:active { transform: scale(.98); }
.dlg-item.sel { background: var(--accent-dim); }
.dlg-ava {
  width: 40px; height: 40px; border-radius: 50%; flex: 0 0 40px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1);
}
.dlg-item:hover .dlg-ava { transform: scale(1.05); }
.dlg-ava.alt { background: linear-gradient(135deg, #8e6ee6, #bd93f9); }
.dlg-body { flex: 1; min-width: 0; }
.dlg-top { display: flex; align-items: baseline; gap: 8px; }
.dlg-name {
  font-weight: 650; font-size: 14px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.dlg-time { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.dlg-bottom { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.dlg-last {
  color: var(--muted); font-size: 12.5px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.dlg-last.has-unread { color: var(--text); font-weight: 600; }
.dlg-unread {
  background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700;
  border-radius: 11px; padding: 2px 8px; flex: 0 0 auto;
  box-shadow: 0 3px 10px var(--accent-dim);
}


.chat-head {
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; background: var(--panel2);
}
.chat-head .ch-name b { display: block; font-size: 14.5px; }
.chat-head .ch-name .muted { font-size: 12.5px; }
.chat-head .ch-act { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 12px 14px 6px; display: flex; flex-direction: column; gap: 2px; }
.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); flex-direction: column; gap: 10px; }
.chat-empty .ce-icon { font-size: 44px; opacity: .5; }

.day-sep { text-align: center; margin: 10px 0 6px; }
.day-sep span {
  background: var(--bg2); border: 1px solid var(--border); color: var(--muted);
  font-size: 11px; border-radius: 14px; padding: 2px 11px;
}
.msg-row { display: flex; }
.msg-row.own { justify-content: flex-end; }
/* пузыри в стиле Telegram/iMessage: без тяжёлых рамок,
   однострочный пузырь ≈ 35px высотой (17px текста + вертикальные отступы) */
.bubble {
  width: fit-content; max-width: min(72%, 480px); padding: 8.5px 10px; margin: 1.5px 0;
  border-radius: 13px; font-size: 13px; line-height: 1.36; min-height: 35px;
  word-break: break-word; overflow: hidden;
  background: var(--panel2); border: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
  border-bottom-left-radius: 5px;
}
/* pre-wrap только на тексте сообщения: сам пузырь обычный white-space,
   иначе переносы строк в разметке рисуют пустые строки и раздувают высоту */
.bubble .b-text { white-space: pre-wrap; }
.msg-row.own .bubble {
  background: var(--own-bubble); color: #fff;
  box-shadow: 0 2px 8px var(--accent-dim);
  border-bottom-left-radius: 13px; border-bottom-right-radius: 5px;
}
/* флаг языка оригинала — инлайном перед текстом входящего (когда переводчик вкл) */
.bubble .b-cc {
  width: 13px; height: 9.75px; vertical-align: -1px;
  margin-right: 4px; border-radius: 2px;
}
/* время — инлайном в последней строке текста: высота пузыря = строки текста */
.bubble .b-time {
  display: inline-block; float: right; line-height: 1;
  font-size: 10px; opacity: .6; margin: 6px -3px -3px 7px;
  user-select: none;
}
/* ✓ отправлено / ✓✓ прочитано — рядом со временем своих сообщений */
.bubble .b-ticks {
  float: right; line-height: 1; font-size: 10px; font-weight: 800;
  margin: 6px 4px -3px 8px; opacity: .55; user-select: none; letter-spacing: -1px;
}
.bubble .b-ticks.read { opacity: .95; color: var(--accent2); }
.msg-row.own .bubble .b-ticks.read { color: #fff; }
/* перевод — своей строкой под оригиналом: [🇷🇺] текст, спокойный серый */
.bubble .b-ru {
  display: flex; align-items: flex-start; gap: 6px; clear: both;
  margin-top: 3px; padding-top: 3px;
  font-size: 12.5px; line-height: 1.36; color: var(--muted); white-space: pre-wrap;
}
.bubble .b-ru .flag { width: 13px; height: 9.75px; flex: 0 0 13px; margin-top: 2.5px; border-radius: 2px; }
.bubble .b-att { display: block; margin-top: 4px; }
/* картинка-вложение: превью прямо в пузыре */
.bubble .b-att-img {
  display: block; margin-top: 4px; border-radius: 9px; overflow: hidden;
  border: 1px solid rgba(128, 140, 160, .25);
}
.bubble .b-att-img img {
  display: block; max-width: min(140px, 100%); max-height: 140px;
  object-fit: contain; border-radius: 9px;
}
.bubble .b-sender { display: block; font-size: 11px; font-weight: 700; color: var(--accent2); margin-bottom: 1px; }

/* онлайн-статус собеседника */
.on-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 7px var(--green); flex: 0 0 auto;
}
.dlg-ava { position: relative; }
.dlg-ava .on-dot {
  position: absolute; right: -2px; bottom: -2px;
  width: 12px; height: 12px; border: 2px solid var(--panel); box-shadow: none;
}
.chat-head .ch-name .ch-sub { display: flex; align-items: center; gap: 10px; font-size: 12.5px; min-height: 17px; }
.ch-pres { color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.ch-pres.on { color: var(--green); font-weight: 650; }

.composer {
  border-top: 1px solid var(--border); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px; background: var(--panel);
}
.comp-atts { display: flex; flex-wrap: wrap; gap: 8px; }
.comp-atts:empty { display: none; }
.att-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel2); border: 1px solid var(--border2);
  border-radius: 10px; padding: 3px 9px 3px 3px; font-size: 12.5px;
  animation: slidein .22s cubic-bezier(.3, 1.4, .5, 1); max-width: 100%;
  transition: border-color .18s ease, transform .24s cubic-bezier(.34, 1.56, .64, 1),
              box-shadow .22s ease;
}
.att-chip:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 5px 14px rgba(0, 0, 0, .16); }
.att-chip img { width: 32px; height: 32px; object-fit: cover; border-radius: 7px; display: block; }
.att-chip .att-file { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.att-chip .att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.att-chip .att-x { cursor: pointer; color: var(--muted); font-weight: 700; padding: 0 2px; }
.att-chip .att-x:hover { color: var(--red); }
.comp-row { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea {
  flex: 1; min-height: 42px; max-height: 130px; resize: none;
  border-radius: 12px; padding: 10px 14px;
}
.composer .icon-btn {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel2); border: 1px solid var(--border2);
  color: var(--accent2); cursor: pointer;
  transition: transform .32s cubic-bezier(.34, 1.56, .64, 1), background .22s ease,
              border-color .22s ease, box-shadow .3s ease, color .22s ease;
}
.composer .icon-btn svg {
  width: 19px; height: 19px; display: block;
  transition: transform .36s cubic-bezier(.34, 1.56, .64, 1);
}
.composer .icon-btn:hover {
  background: var(--accent-dim); border-color: var(--accent);
  box-shadow: 0 4px 14px var(--accent-dim);
  transform: scale(1.08);
}
.composer .icon-btn:hover svg { transform: rotate(-24deg); }
.composer .icon-btn:active { transform: scale(.88); }
.composer .icon-btn:active svg { transform: rotate(-10deg) scale(.92); }
.composer .icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-dim); }
.composer .send-btn {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; padding: 0;
  font-size: 16px;
  transition: transform .32s cubic-bezier(.34, 1.56, .64, 1), box-shadow .25s ease, filter .2s ease;
}
.composer .send-btn:hover { transform: scale(1.07); filter: brightness(1.08); box-shadow: 0 6px 18px var(--accent-dim); }
.composer .send-btn:active { transform: scale(.9); }
.composer .send-btn:disabled { opacity: .4; }
.chat-pane.dragover { outline: 2px dashed var(--accent); outline-offset: -6px; }

/* ── Вкладки-инструменты (страница «Аккаунты») ───────────────────────────── */

.tabbar {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px;
  border-bottom: 1px solid var(--border); padding-bottom: 0;
}
.tabbar .tab {
  appearance: none; background: none; border: none; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 650;
  padding: 9px 14px; border-radius: 10px 10px 0 0;
  border-bottom: 2px solid transparent; transition: color .14s, background .14s;
}
.tabbar .tab:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.tabbar .tab.active {
  color: var(--accent2); border-bottom-color: var(--accent); background: var(--accent-dim);
}
.tabpane { display: none; }
.tabpane.active { display: block; }

.sms-panel {
  background: var(--bg2); border: 1px dashed var(--border2);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: 13.5px;
}
.sms-panel b { color: var(--text); }
.sms-panel .phone {
  font-size: 16px; font-weight: 800; color: var(--accent2); letter-spacing: .3px;
}

/* ── Свёртываемые секции (рассылка → Сообщения / Интервалы / Прочее) ─────
   Задача: ЗАМЕТНО, что секции раскрываются — поэтому у каждой свёрнутой
   секции: акцентная кнопка-шеврон с пульсацией, светлая полоса-заголовок,
   сводка содержимого и бейдж «развернуть ▾». */

.card.collapsible-group { padding: 0; overflow: hidden; }
.card.collapsible-group > h3 { padding: 16px 16px 10px; }
.collapsible { border-top: 1px solid var(--border); }
.collapsible:first-of-type { border-top: none; }

.coll-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; border-left: 3px solid transparent;
  cursor: pointer; text-align: left; position: relative;
  color: var(--text); font: inherit; font-size: 14.5px; font-weight: 750;
  padding: 12px 14px 12px 13px; letter-spacing: .2px;
  transition: background .15s, border-color .15s;
}
.coll-head:hover { background: var(--accent-dim); border-left-color: var(--accent); }
.collapsible.open .coll-head {
  background: linear-gradient(90deg, var(--accent-dim), transparent 65%);
  border-left-color: var(--accent2);
}
.coll-head .chev-wrap {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 900;
  transition: transform .22s cubic-bezier(.34, 1.56, .64, 1), background .15s;
}
.collapsible:not(.open) .chev-wrap { animation: chevPulse 2.4s ease-in-out infinite; }
.collapsible.open .chev-wrap { transform: rotate(90deg); background: var(--accent2); }
@keyframes chevPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-dim); }
  50% { box-shadow: 0 0 0 7px rgba(0, 0, 0, 0); }
}
.coll-head .coll-ico { flex: 0 0 auto; font-size: 17px; }
.coll-head .coll-title { flex: 0 0 auto; }
.coll-head .coll-summary {
  flex: 1; min-width: 0; text-align: right; font-weight: 600; font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.coll-head .coll-hint {
  flex: 0 0 auto; font-size: 11.5px; font-weight: 800; color: var(--accent2);
  background: var(--accent-dim); border: 1px solid var(--accent);
  border-radius: 20px; padding: 3px 10px; white-space: nowrap;
  animation: hintPulse 2s ease-in-out infinite;
}
.collapsible.open .coll-hint { display: none; }
@keyframes hintPulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

.coll-body { display: none; padding: 4px 16px 14px; }
.collapsible.open .coll-body { display: block; animation: collFade .25s ease; }
@keyframes collFade { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }

.coll-foot { border-top: 1px solid var(--border); margin-top: 2px; padding-top: 14px; }
.coll-foot .btnrow { margin-top: 0; }

/* ── Дроп-зона файла со ссылками (поле таргетов на странице «Рассылка») ── */

.dropzone { position: relative; }
.dropzone .drop-overlay {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center; text-align: center;
  background: var(--accent-dim); border-radius: 10px;
  font-weight: 800; font-size: 14px; color: var(--accent2);
  z-index: 5; pointer-events: none; padding: 10px;
}
.dropzone.dragover .drop-overlay { display: flex; }
.dropzone.dragover textarea { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

/* фото под каждым сообщением рассылки */
.photo-row {
  display: flex; align-items: center; gap: 9px; margin: 6px 0 2px;
  min-height: 32px; flex-wrap: wrap;
}
.photo-row .photo-lbl { font-size: 12.5px; }
.photo-row .photo-lbl .mono { font-size: 12px; }
.photo-thumb {
  width: 30px; height: 30px; border-radius: 7px; object-fit: cover;
  border: 1px solid var(--border2); display: block;
}

/* ── Список аккаунтов: массовое выделение ─────────────────────────────── */

.listhead {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.listhead h3 { margin: 0; }
.listhead .btnrow { margin-top: 0; margin-left: auto; }
.tbl input[type=checkbox] { transform: scale(1.12); accent-color: var(--accent); }
.tbl tr.row-sel td { background: var(--accent-dim); }
.tbl tr.row-sel:hover td { background: var(--accent-dim); }
textarea.dragover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

/* ── Мобильная адаптация ───────────────────────────────────────────────── */

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side .brand { width: auto; padding: 6px 8px; }
  .side .platbox { width: 190px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav a { padding: 7px 10px; }
  .nav a.active::before { display: none; }
  .side .userbox { display: none; }
  .theme-dots { padding: 6px 8px; }
  .main { padding: 16px 12px 30px; }
}
