/* Quatrain Manager — современная тёмная тема со стеклянными поверхностями */

:root {
  /* Базовые слои */
  --bg: #090b12;
  --bg-2: #0b0e17;
  --surface: rgba(19, 23, 34, 0.72);
  --surface-solid: #12151f;
  --surface-raised: rgba(28, 33, 48, 0.66);
  --bg-input: rgba(12, 15, 24, 0.7);

  /* Границы */
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --border-input: rgba(255, 255, 255, 0.1);

  /* Текст */
  --text: #eef0f8;
  --text-dim: #b6bcd0;
  --text-muted: #7b8199;

  /* Акцент */
  --accent: #8b7cf6;
  --accent-2: #6366f1;
  --accent-soft: rgba(139, 124, 246, 0.16);
  --accent-glow: rgba(139, 124, 246, 0.4);

  /* Статусы */
  --green: #4ade80;
  --green-bg: rgba(34, 197, 94, 0.14);
  --amber: #fbbf24;
  --amber-bg: rgba(251, 191, 36, 0.13);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.13);
  --red-border: rgba(248, 113, 113, 0.32);

  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Базовый тёмный слой под ведьмачьей сценой */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: var(--bg);
  pointer-events: none;
}

/* ───────── Ведьмачий фон приложения ───────── */
.app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.app-bg-svg {
  display: none;   /* старая рисованная сцена убрана — она мелькала до загрузки фото bg.jpg */
}
/* реальная картинка-фон (Ведьмак и т.п.) — перекрывает рисованную сцену, если файл есть */
.app-bg-photo {
  position: absolute;
  inset: 0;
  transition: transform 0.5s ease-out;   /* плавный параллакс от мыши */
}
.app-bg-photo-img {
  position: absolute;
  inset: -2%;                            /* небольшой запас под параллакс */
  background-size: cover;
  background-position: center 72%;       /* логотип чуть ниже, но целиком в кадре */
  background-repeat: no-repeat;
  transform-origin: center 80%;          /* зум наплывает от логотипа — он не «всплывает» */
  animation: kenburns 50s ease-in-out infinite alternate;   /* медленный наплыв */
}
@keyframes kenburns {
  from { transform: scale(1.03) translate(0, 0); }
  to   { transform: scale(1.10) translate(-1%, 0); }
}
/* слой эффектов (туман + споры) */
.app-bg-fx {
  position: absolute;
  inset: 0;
  transition: transform 0.5s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .app-bg-photo-img { animation: none; }
}
/* затемняющая вуаль + виньетка — чтобы панели и текст читались */
.app-bg-veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(140% 105% at 50% 8%, transparent 52%, rgba(6, 8, 15, 0.5) 100%),
    linear-gradient(180deg, rgba(9, 11, 18, 0.12), rgba(9, 11, 18, 0.30));
}
.ab-mist { animation: ab-mist-drift 32s linear infinite; }
.ab-mist2 { animation-duration: 46s; animation-direction: reverse; }
.ab-clouds { animation: ab-mist-drift 60s linear infinite; }
.ab-pulse { animation: ab-pulse 7s ease-in-out infinite; }
@keyframes ab-mist-drift { from { transform: translateX(-160px); } to { transform: translateX(160px); } }
@keyframes ab-pulse { 0%, 100% { opacity: .5; } 50% { opacity: .8; } }
@keyframes drift {
  from { transform: translate3d(-1.2%, -0.8%, 0) scale(1.02); }
  to   { transform: translate3d(1.2%, 1.2%, 0) scale(1.05); }
}
@media (prefers-reduced-motion: reduce) {
  .app-bg-svg, .ab-mist, .ab-clouds, .ab-pulse { animation: none; }
}

::selection { background: var(--accent-glow); color: #fff; }

/* Скроллбар */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.14) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); background-clip: padding-box; }

/* ───────── Шапка ───────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 13px 22px;
  background: rgba(9, 11, 18, 0.6);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2px;
  background: linear-gradient(90deg, #fff, #cfc8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand::before {
  content: "◈ ";
  -webkit-text-fill-color: var(--accent);
  color: var(--accent);
}

.tabs { display: flex; gap: 4px; }
.tab {
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
a.tab { text-decoration: none; cursor: pointer; }
a.tab:hover { color: var(--text-dim); background: rgba(255, 255, 255, 0.05); }
.tab.active {
  background: var(--accent-soft);
  color: #d7d1ff;
  box-shadow: inset 0 0 0 1px rgba(139, 124, 246, 0.3);
}
.tab.disabled { cursor: default; opacity: 0.55; }

.main-nav { gap: 2px; }

/* Вторичный ряд площадок — сегментированный контрол (iOS-стиль) */
.platform-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.platform-tabs .tab {
  padding: 6px 16px;
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}

/* ───────── Заголовки и раскладка разделов ───────── */

.page-title { margin: 0; font-size: 18px; font-weight: 600; }
.toolbar .page-title { align-self: center; }
.content-narrow { max-width: 760px; }

.col-time { width: 140px; }
.col-user { width: 140px; }
.cell-detail { color: var(--text-dim); }

/* ───────── Настройки ───────── */

.settings-card {
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.settings-card h2 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.settings-card .hint { margin-bottom: 14px; }
.settings-row { display: flex; gap: 10px; }
.settings-row .input { flex: 1; }
.settings-soon { opacity: 0.7; }
.settings-msg { margin-top: 10px; font-size: 13px; }
.settings-msg.ok { color: #86efac; }
.settings-msg.err { color: #fca5a5; }

/* Токены площадок */
.tokens-list { display: flex; flex-direction: column; gap: 10px; }
.token-row {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
}
.token-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.token-name { font-weight: 600; }
.token-meta { font-size: 12px; color: var(--text-muted); }
.token-import { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.token-import textarea { width: 100%; }
.token-import .btn-accent { align-self: flex-start; }
.token-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.token-field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-dim); }
.token-msg { margin-top: 8px; font-size: 12px; }
.token-msg.ok { color: #86efac; }
.token-msg.err { color: #fca5a5; }
.token-info-hint { margin-top: 8px; font-size: 12px; color: var(--text-muted); }

/* ───────── Уведомления о сообщениях ───────── */

#notif-stack {
  position: fixed; right: 22px; bottom: 22px; z-index: 200;
  display: flex; flex-direction: column; gap: 12px; width: 380px; max-width: calc(100vw - 44px);
}
.notif {
  background: var(--surface-solid, #1b1b24); border: 1px solid var(--border);
  border-left: 5px solid var(--accent); border-radius: 14px; padding: 15px 18px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5); cursor: pointer;
  opacity: 0; transform: translateY(14px); transition: opacity 0.25s, transform 0.25s;
}
.notif.show { opacity: 1; transform: translateY(0); }
.notif-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.notif-who { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-plat { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.notif-text { font-size: 15px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.notif-img { max-width: 190px; max-height: 130px; border-radius: 10px; display: block;
  margin-top: 4px; object-fit: cover; }
.notif-text + .notif-img, .notif-img + .notif-text { margin-top: 8px; }
/* уведомление о новом заказе — зелёный акцент (деньги пришли) */
.notif-order { border-left-color: #4ade80; background: linear-gradient(180deg, rgba(74, 222, 128, 0.16), transparent 70%), var(--surface-solid, #12151f); }
.notif-order .notif-plat { color: #4ade80; }
.notif-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-amount { font-weight: 700; color: var(--text); }
/* градиент-подсветка ПОВЕРХ опакового фона — без просвечивания */
.notif-u7buy { border-left-color: #ff8a3d; background: linear-gradient(180deg, rgba(255, 138, 61, 0.16), transparent 70%), var(--surface-solid, #12151f); }
.notif-u7buy .notif-plat { color: #ff8a3d; }
.notif-g2g { border-left-color: #f0503a; background: linear-gradient(180deg, rgba(240, 80, 58, 0.16), transparent 70%), var(--surface-solid, #12151f); }
.notif-g2g .notif-plat { color: #f0503a; }
.notif-pa { border-left-color: #34d17a; background: linear-gradient(180deg, rgba(52, 209, 122, 0.16), transparent 70%), var(--surface-solid, #12151f); }
.notif-pa .notif-plat { color: #34d17a; }
.notif-eldorado { border-left-color: #f59e0b; background: linear-gradient(180deg, rgba(245, 158, 11, 0.16), transparent 70%), var(--surface-solid, #12151f); }
.notif-eldorado .notif-plat { color: #f59e0b; }
.notif-funpay { border-left-color: #3b82f6; background: linear-gradient(180deg, rgba(59, 130, 246, 0.16), transparent 70%), var(--surface-solid, #12151f); }
.notif-funpay .notif-plat { color: #3b82f6; }

/* ───────── Чаты ───────── */

.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  height: calc(100vh - 150px);
}
.chat-list {
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.chat-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.chat-item.unread {
  background: rgba(255, 255, 255, 0.045);
  box-shadow: inset 3px 0 0 var(--accent);
}
.chat-item.unread .chat-buyer { color: var(--text); }
.chat-item.unread .chat-item-last { color: var(--text); font-weight: 600; }
.chat-item:hover { background: rgba(255, 255, 255, 0.07); }
.chat-item.active { background: var(--accent-soft); }
.chat-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-buyer { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-unread {
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 600;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
}
.chat-item-plat { font-size: 11px; color: var(--text-muted); margin: 2px 0; }
.chat-item-last { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-thread {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
}
.chat-empty { margin: auto; color: var(--text-muted); }
.chat-thread { position: relative; }
.chat-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}
.chat-header-buyer { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-plat { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.chat-thread.drag-over::after {
  content: "Отпусти, чтобы отправить фото";
  position: absolute; inset: 8px; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--accent); border-radius: var(--radius-lg);
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
  pointer-events: none;
}
.chat-messages { flex: 1; overflow-y: auto; overflow-anchor: none; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 72%; padding: 8px 12px; border-radius: 12px; font-size: 13px; }
.msg-other { align-self: flex-start; background: rgba(255, 255, 255, 0.06); border-bottom-left-radius: 4px; }
.msg-self { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-bottom-right-radius: 4px; }
.msg-sender { font-size: 11px; color: var(--accent); font-weight: 600; margin-bottom: 3px; }
.msg-text { white-space: pre-wrap; word-break: break-word; }
.msg-time { font-size: 12px; opacity: 0.7; margin-top: 3px; text-align: right; }
.photo-confirm {
  display: flex; gap: 12px; align-items: center; padding: 12px;
  border-top: 1px solid var(--border); background: var(--accent-soft);
}
.photo-confirm img { max-width: 120px; max-height: 120px; border-radius: 8px; object-fit: cover; cursor: zoom-in; }

.lightbox {
  position: fixed; inset: 0; z-index: 100; padding: 24px;
  background: rgba(0, 0, 0, 0.85); display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.lightbox img { max-width: 95vw; max-height: 95vh; border-radius: 8px; box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6); }
.photo-confirm-side { display: flex; flex-direction: column; gap: 6px; }
.photo-confirm-name { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.photo-confirm-q { font-weight: 600; }
.photo-caption { width: 100%; min-width: 220px; font-size: 14px; padding: 7px 10px; }
.photo-confirm-btns { display: flex; gap: 8px; margin-top: 2px; }

.chat-reply { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-reply textarea { flex: 1; resize: none; max-height: 120px; }
.chat-attach {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  font-size: 18px; cursor: pointer; padding: 6px 10px; line-height: 1;
}
.chat-attach:hover { background: var(--accent-soft); }
.chat-attach:disabled { opacity: 0.5; cursor: default; }
.msg-img { max-width: 260px; max-height: 320px; border-radius: 8px; display: block; cursor: pointer; }
.msg-file { color: var(--accent); text-decoration: none; font-size: 13px; }

/* сообщение с действиями */
.msg-row { display: flex; align-items: center; gap: 6px; }
.msg-row.row-self { flex-direction: row-reverse; }
.msg-row .msg { max-width: 72%; }
.msg-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.12s; }
.msg-row:hover .msg-actions { opacity: 1; }
.msg-actions button {
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border);
  border-radius: 6px; width: 26px; height: 26px; cursor: pointer; font-size: 13px;
  color: var(--text-dim); padding: 0;
}
.msg-actions button:hover { background: var(--accent-soft); color: var(--text); }

.msg-img { max-width: 240px; max-height: 240px; border-radius: 8px; display: block; margin: 2px 0; cursor: pointer; }
/* Пока фото не загрузилось — резервируем место и показываем «скелетон»,
   чтобы вёрстка не прыгала (подпись не оказывалась одна, а скролл не съезжал). */
.msg-img:not([data-loaded="1"]) {
  min-width: 180px; min-height: 180px;
  background: linear-gradient(100deg, rgba(255,255,255,0.04) 30%, rgba(255,255,255,0.09) 50%, rgba(255,255,255,0.04) 70%);
  background-size: 200% 100%; animation: skel 1.2s ease-in-out infinite;
}
@keyframes skel { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.msg-file { color: inherit; text-decoration: underline; font-size: 13px; }
/* цитата — как в Telegram: имя автора + текст, блок над ответом */
.msg-quote {
  border-left: 3px solid var(--accent); border-radius: 4px;
  background: rgba(255, 255, 255, 0.06); padding: 3px 8px; margin-bottom: 5px;
  font-size: 12px; line-height: 1.3; overflow: hidden;
  display: flex; flex-direction: column; max-width: 260px;
}
.msg-quote-who { color: var(--accent); font-weight: 600; font-size: 11px; }
.msg-quote { white-space: nowrap; text-overflow: ellipsis; }
.msg-self .msg-quote { border-left-color: rgba(255, 255, 255, 0.7); background: rgba(255, 255, 255, 0.14); }
.msg-self .msg-quote-who { color: #fff; }

.msg-emoji-big { font-size: 40px; line-height: 1.1; }

.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.reaction-chip {
  background: rgba(255, 255, 255, 0.1); border: 1px solid var(--border);
  border-radius: 12px; padding: 2px 9px; font-size: 15px; cursor: pointer; color: var(--text);
  line-height: 1.2;
}
.reaction-chip:hover { background: var(--accent-soft); }
.reaction-chip.mine { background: var(--accent-soft); border-color: var(--accent); }

.emoji-picker {
  position: absolute; z-index: 50; display: flex; gap: 3px; padding: 6px;
  background: var(--surface-solid, #1b1b24); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}
.emoji-picker button { background: none; border: none; font-size: 24px; cursor: pointer; padding: 4px; border-radius: 8px; }
.emoji-picker button:hover { background: var(--accent-soft); }

.msg-menu {
  position: absolute; z-index: 55; display: flex; flex-direction: column; padding: 4px;
  background: var(--surface-solid, #1b1b24); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4); min-width: 150px;
}
.msg-menu button {
  background: none; border: none; color: var(--text); text-align: left;
  padding: 8px 12px; border-radius: 7px; cursor: pointer; font-size: 14px;
}
.msg-menu button:hover { background: var(--accent-soft); }

.chat-composer { border-top: 1px solid var(--border); }
.chat-composer .chat-reply { border-top: none; }
.reply-preview {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 12px 0; font-size: 12px;
}
.reply-preview-body { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.reply-preview-label { color: var(--accent); font-weight: 600; margin-right: 6px; }
.reply-preview-cancel { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; }

/* ───────── Баланс ───────── */

.balance-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 22px 26px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(139, 124, 246, 0.18), rgba(99, 102, 241, 0.08));
  border: 1px solid rgba(139, 124, 246, 0.3);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.balance-total .balance-amount { font-size: 34px; }

.balance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.balance-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.balance-card.is-soon { opacity: 0.6; }
.balance-card.has-error { border-color: var(--red-border); }
.balance-platform { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.balance-amount { font-size: 26px; font-weight: 700; font-family: ui-monospace, "SF Mono", Consolas, monospace; }
.balance-breakdown { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); }
.balance-err { font-size: 12px; color: #fca5a5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user { color: var(--text-muted); font-size: 13px; }

/* ───────── Контент и тулбар ───────── */

.content { padding: 20px; max-width: 1760px; margin: 0 auto; }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.search { flex: 1; min-width: 220px; }

.input {
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: rgba(12, 15, 24, 0.9);
}
.input::placeholder { color: var(--text-muted); }
select.input { cursor: pointer; }
textarea.input { resize: vertical; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 13px; }

/* ───────── Кнопки ───────── */

.btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 15px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.btn:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.09);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: wait; transform: none; }

.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px -8px var(--accent-glow);
}
.btn-accent:hover {
  background: linear-gradient(135deg, #9a8cf8, #7376f4);
  box-shadow: 0 12px 26px -8px var(--accent-glow);
}

.btn-danger { background: var(--red-bg); border-color: var(--red-border); color: #fca5a5; }
.btn-danger:hover { border-color: var(--red); background: rgba(248, 113, 113, 0.2); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); border-color: transparent; }

.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 5px 9px; font-size: 13px; }

/* ───────── Таблица ───────── */

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 12px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
}
td { padding: 11px 10px; border-top: 1px solid var(--border); }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: rgba(255, 255, 255, 0.035); }
tbody tr.selected { background: var(--accent-soft); }

th:first-child, td:first-child { padding-left: 16px; width: 44px; }
th:last-child, td:last-child { padding-right: 16px; }

.col-price { width: 110px; }
.price-input {
  width: 92px;
  padding: 5px 9px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 13px;
}
.price-input:disabled { opacity: 0.5; }
.col-profit { width: 92px; }
.cell-profit { font-family: ui-monospace, "SF Mono", Consolas, monospace; white-space: nowrap; font-weight: 600; }
.profit-pos { color: var(--green); }
.profit-neg { color: var(--red); }
.muted { color: var(--text-muted); }
.col-actions { width: 120px; }
.cell-game { color: var(--text-dim); white-space: nowrap; }
.cell-price { font-family: ui-monospace, "SF Mono", Consolas, monospace; }
.cell-id { color: var(--text-muted); font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12px; }
.cell-actions { text-align: right; white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-active { background: var(--green-bg); color: #86efac; border-color: rgba(74, 222, 128, 0.25); }
.badge-disabled { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); border-color: var(--border); }
.badge-error { background: rgba(248, 113, 113, 0.12); color: #f87171; border-color: rgba(248, 113, 113, 0.3); cursor: help; }
.badge-draft { background: var(--amber-bg); color: #fcd34d; border-color: rgba(251, 191, 36, 0.25); }
.badge-keys { background: var(--green-bg); color: #86efac; border-color: rgba(74, 222, 128, 0.25); }
.badge-manual { color: var(--text-muted); }

.note-icon { color: var(--amber); cursor: help; margin-left: 6px; }

/* ───────── Группы и drag-and-drop ───────── */

.cell-check { white-space: nowrap; }
.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  padding: 0 4px;
  user-select: none;
  transition: color 0.12s;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle:hover { color: var(--accent); }

.group-row {
  background: linear-gradient(90deg, var(--accent-soft), rgba(139, 124, 246, 0.02));
}
.group-row:hover { background: linear-gradient(90deg, rgba(139, 124, 246, 0.22), rgba(139, 124, 246, 0.04)); }
.group-cell {
  padding: 9px 16px !important;
  box-shadow: inset 3px 0 0 0 var(--accent);
}
.group-toggle {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font: inherit;
  padding: 0 6px;
  transition: color 0.12s;
}
.group-toggle:hover { color: var(--text); }
.group-name { font-weight: 700; margin: 0 8px; }
.group-stats { color: var(--text-muted); font-size: 12px; }
.group-actions { margin-left: 12px; display: inline-flex; gap: 6px; }
.group-cell .cell-game {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

tr.group-hidden { display: none; }
tr.dragging { opacity: 0.35; }
tr.drop-before td { box-shadow: inset 0 2px 0 0 var(--accent); }
tr.drop-after td { box-shadow: inset 0 -2px 0 0 var(--accent); }

/* ───────── Панель «Показанные» и подсказка о переносе ───────── */

.scope-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.scope-count { color: var(--text-dim); font-size: 13px; }
.dnd-hint {
  margin: -4px 0 12px;
  padding: 8px 14px;
  color: var(--text-muted);
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border-strong);
}

.empty { text-align: center; padding: 70px 20px; color: var(--text-muted); }
.empty p { font-size: 15px; margin-bottom: 16px; }
.hidden { display: none !important; }

/* ───────── Панель массовых действий ───────── */

.bulkbar {
  position: sticky;
  bottom: 14px;
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(20, 24, 36, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
#bulk-count { color: var(--text-dim); font-size: 13px; margin-right: 6px; font-weight: 500; }

/* ───────── Модалки ───────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 12, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 44px 16px;
  overflow-y: auto;
  z-index: 40;
  animation: fade 0.16s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: linear-gradient(180deg, rgba(24, 28, 42, 0.96), rgba(16, 19, 30, 0.96));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 720px;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
  animation: pop 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }
.modal-sm { width: 440px; }
.modal-lg { width: 980px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; }

.modal-body { padding: 20px 22px; }
.modal-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
}
.spacer { flex: 1; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}
.span2 { grid-column: span 2; }
.hint { font-size: 12px; color: var(--text-muted); line-height: 1.45; }
.hint code {
  background: rgba(255, 255, 255, 0.07);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, Consolas, monospace;
}

/* ───────── Шаблоны офферов ───────── */

.template-row {
  display: flex;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.template-row select { flex: 1; }

/* ───────── Массовое создание ───────── */

.bc-rows { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.bc-row {
  display: grid;
  grid-template-columns: 2fr 82px 82px 92px 1.2fr auto;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
}
.bc-row .bc-keys { grid-column: 1 / -1; resize: vertical; }
.bc-row .bc-remove { align-self: center; }
.bc-profit {
  align-self: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* Массовое создание для площадок (G2G/PA) — без фото/аккаунтов */
.pb-rows { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.pb-row {
  display: grid;
  grid-template-columns: 2fr 100px 100px 110px auto;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
}
.pb-row .bc-remove { align-self: center; }

/* ───────── Ячейки аккаунтов (автовыдача) ───────── */

.keys-wrap { display: flex; flex-direction: column; gap: 10px; font-size: 13px; color: var(--text-dim); }
.keys-label { display: flex; align-items: baseline; gap: 8px; font-weight: 500; }
.keys-sub { font-size: 12px; color: var(--text-muted); }
.keys-list { display: flex; flex-direction: column; gap: 8px; }
.keys-list:empty { display: none; }
.key-cell { display: flex; gap: 8px; align-items: flex-start; }
.key-cell textarea { flex: 1; }
.key-cell.removed textarea { opacity: 0.45; text-decoration: line-through; }
.cell-category { color: var(--text-muted); white-space: nowrap; }

.modal-error {
  margin-top: 14px;
  padding: 11px 14px;
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 13px;
  white-space: pre-wrap;
}

/* ───────── Склад аккаунтов G2G ───────── */

.ga-subhead { font-size: 13px; color: var(--text-dim); margin: 18px 0 10px; font-weight: 600; }
.ga-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.ga-count { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.ga-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 11px; background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px;
}
.ga-item-right { display: flex; align-items: center; gap: 6px; }
.ga-item.ga-pending { opacity: 0.6; }
.ga-email { color: var(--text-muted); }
.ga-bulk { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.ga-bulk summary { cursor: pointer; font-size: 13px; color: var(--text-dim); font-weight: 600; }
.ga-bulk textarea { margin-top: 8px; width: 100%; }
.ga-bulk-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; }

/* ───────── Журнал действий оффера ───────── */
.glog-list { display: flex; flex-direction: column; max-height: 340px; overflow-y: auto; margin-top: 10px; }
.glog-item { display: flex; gap: 12px; font-size: 12px; padding: 6px 2px; border-bottom: 1px solid var(--border); }
.glog-time { color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.glog-detail { color: var(--text-dim); }

/* ───────── Индикатор активной площадки (цвет платформы) ───────── */
.content[data-platform="u7buy"] {          /* осенний оранжевый (лист) */
  --pf: #ea580c; --pf-soft: rgba(234, 88, 12, 0.07); --pf-line: rgba(234, 88, 12, 0.5);
}
.content[data-platform="eldorado"] {       /* янтарный (бывш. U7Buy) */
  --pf: #f59e0b; --pf-soft: rgba(245, 158, 11, 0.07); --pf-line: rgba(245, 158, 11, 0.5);
}
.content[data-platform="g2g"] {            /* красный */
  --pf: #ef4444; --pf-soft: rgba(239, 68, 68, 0.07); --pf-line: rgba(239, 68, 68, 0.5);
}
.content[data-platform="pa"] {             /* зелёный */
  --pf: #22c55e; --pf-soft: rgba(34, 197, 94, 0.07); --pf-line: rgba(34, 197, 94, 0.5);
}
.content[data-platform="funpay"] {         /* синий */
  --pf: #3b82f6; --pf-soft: rgba(59, 130, 246, 0.07); --pf-line: rgba(59, 130, 246, 0.5);
}

/* Funpay-модалка: строка «Активен» — чекбокс в строку, без верхнего лейбла */
#fc-backdrop .fc-active-row {
  flex-direction: row; align-items: center; gap: 8px; cursor: pointer;
}
#fc-backdrop .fc-active-row input { width: auto; margin: 0; }
#fc-selects:empty { display: none; }

/* Активная площадка — залитая «пилюля» в её цвете с мягким свечением */
.platform-tabs .tab.active {
  background: var(--pf, var(--accent));
  color: #fff;
  box-shadow: 0 4px 14px -5px var(--pf, var(--accent)),
              inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.platform-tabs .tab.active:hover { color: #fff; }

/* Сама таблица офферов «окрашивается» под площадку — явно, но аккуратно */
.content[data-platform] .table-wrap { border-left: 3px solid var(--pf); }
.content[data-platform] thead th {
  background: var(--pf-soft);
  border-bottom: 2px solid var(--pf-line);
}
.content[data-platform] tbody tr:hover { background: var(--pf-soft); }

/* ───────── Под-статусы токенов (напр. G2G: access_token + G2GSESID_V4) ───────── */
.token-details { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 7px; padding-left: 2px; }
.token-detail { font-size: 12px; color: var(--text-dim); display: inline-flex; align-items: center; gap: 6px; }
.token-detail .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.token-detail .dot-ok { background: var(--green); box-shadow: 0 0 6px -1px var(--green); }
.token-detail .dot-off { background: var(--text-muted); }

/* ───────── Логин ───────── */

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 360px;
  padding: 34px 30px;
  background: linear-gradient(180deg, rgba(24, 28, 42, 0.82), rgba(14, 17, 27, 0.82));
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-card h1 {
  margin: 0;
  font-size: 20px;
  text-align: center;
  background: linear-gradient(90deg, #fff, #cfc8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-sub { margin: -8px 0 6px; text-align: center; color: var(--text-muted); font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
.login-card input {
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-error { padding: 10px 12px; background: var(--red-bg); border: 1px solid var(--red-border); border-radius: var(--radius-sm); color: #fca5a5; font-size: 13px; }

/* ───────── Тост ───────── */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 24, 36, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 500;
  z-index: 50;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  animation: pop 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast.error { border-color: var(--red-border); color: #fca5a5; }
.toast.success { border-color: rgba(74, 222, 128, 0.4); color: #86efac; }

@media (max-width: 760px) {
  .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: span 1; }
  .toolbar { flex-wrap: wrap; }
}
