/* ============================================================
   Egaxo — Кабинет (app shell)
   ============================================================ */

.app-body {
  background: var(--bg);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 18px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  font-size: 22px;
  padding: 4px 8px 22px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-weight: 500;
  font-size: 15px;
  transition: background 0.18s ease, color 0.18s ease;
}

.sidebar-nav a:hover {
  background: var(--glass);
  color: var(--text);
}

.sidebar-nav a.active {
  background: rgba(255, 45, 45, 0.12);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--red);
}

.nav-ico {
  width: 20px;
  text-align: center;
  color: var(--red);
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 16px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 0 6px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--grad-red);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.su-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.su-plan {
  font-size: 12px;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-logout {
  justify-content: flex-start;
  padding-left: 14px;
  border: 1px solid var(--border);
}

.sidebar-logout:hover {
  border-color: var(--border-red);
  color: var(--red);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 40;
}

.sidebar-overlay.show {
  display: block;
}

/* ---------- Main ---------- */
.app-main {
  flex: 1;
  margin-left: 260px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
}

/* Свёрнутый нав-сайдбар (десктоп): панель уезжает, контент на всю ширину */
.app-shell.nav-collapsed .app-sidebar { transform: translateX(-100%); }
.app-shell.nav-collapsed .app-main { margin-left: 0; }

.app-topbar {
  height: 64px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 26px;
  gap: 16px;
  position: sticky;
  top: 0;
  background: rgba(10, 10, 11, 0.8);
  backdrop-filter: blur(12px);
  z-index: 30;
}

.topbar-spacer {
  flex: 1;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-plan {
  font-size: 12px;
  font-weight: 600;
  color: var(--red);
  background: rgba(255, 45, 45, 0.1);
  padding: 5px 12px;
  border-radius: 999px;
  letter-spacing: 0.05em;
}

/* Кнопка «Улучшить тариф» в топбаре */
.topbar-upgrade {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--grad-red);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-red);
  transition: transform 0.16s ease, box-shadow 0.2s ease;
}

.topbar-upgrade:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px var(--red), var(--glow-red);
}

/* Сетка тарифов (billing) */
.billing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  align-items: stretch;
}

.billing-grid .price-card {
  display: flex;
  flex-direction: column;
  padding: 30px 26px;
}

@media (max-width: 900px) {
  .billing-grid {
    grid-template-columns: 1fr;
    max-width: 440px;
  }
}

/* Тарифные карточки (для страницы billing в кабинете) */
.price-card { position: relative; }
.price-card.featured {
  border-color: var(--red);
  background: linear-gradient(180deg, rgba(255, 31, 61, 0.08), var(--bg-card));
  box-shadow: 0 30px 70px -30px var(--red-glow);
}
.price-ribbon {
  position: absolute; top: 16px; right: 16px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: #fff; background: var(--grad-red);
  padding: 5px 12px; border-radius: 4px;
}
.price-head h3 { font-size: 1.4rem; margin-bottom: 6px; }
.price-value { margin: 16px 0 6px; display: flex; align-items: baseline; gap: 6px; }
.price-num { font-size: 2rem; font-weight: 900; }
.price-period { color: var(--text-mut); font-size: 0.95rem; }
.price-limit {
  display: inline-block; font-size: 0.82rem; font-weight: 600; color: var(--red);
  background: rgba(255, 31, 61, 0.1); padding: 5px 12px; border-radius: 4px; margin-bottom: 20px; width: fit-content;
}
.price-features { display: flex; flex-direction: column; gap: 11px; margin-bottom: 24px; flex: 1; }
.price-features li { display: flex; align-items: flex-start; gap: 10px; font-size: 0.93rem; color: var(--text-soft); }
.price-features .check { color: var(--red); font-weight: 800; }

.app-burger {
  display: inline-flex;                 /* видна и на десктопе — сворачивает нав-сайдбар */
  flex-direction: column;
  gap: 5px;
  width: 40px; height: 40px; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--glass); border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  cursor: pointer; transition: border-color .15s ease;
  margin-right: 4px;
}
.app-burger:hover { border-color: var(--red); }

.app-burger span {
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.app-content {
  padding: 32px 34px 60px;
  width: 100%;
}

/* ---------- Page head ---------- */
.page-head {
  margin-bottom: 24px;
}

.page-head h1 {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.page-sub {
  color: var(--text-soft);
}

/* ---------- Usage bar ---------- */
.usage-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
}

.usage-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.usage-label {
  font-size: 13px;
  color: var(--text-mut);
}

.usage-count {
  font-size: 15px;
  font-weight: 600;
}

.usage-track {
  flex: 1;
  min-width: 140px;
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}

.usage-fill {
  height: 100%;
  background: var(--grad-red);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ---------- Generator ---------- */
.gen-input-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
}

.gen-textarea {
  width: 100%;
  min-height: 130px;
  resize: vertical;
  background: transparent;
  border: none;
  padding: 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.5;
}

.gen-textarea:focus {
  outline: none;
}

.gen-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 10px;
  gap: 12px;
}

.gen-hint {
  font-size: 13px;
  color: var(--text-mut);
}

/* ---------- Result ---------- */
.gen-result {
  margin-top: 24px;
  border: 1px solid var(--border-red);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 0 40px -20px var(--red-glow);
}

.gen-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.gen-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gen-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s ease;
}

.gen-tab:hover { color: var(--text); }
.gen-tab.active {
  color: var(--text);
  background: rgba(255, 31, 61, 0.1);
  border-color: var(--border-red);
}

.gen-status {
  font-family: var(--mono);
  font-size: 12px;
  margin-left: 8px;
}
.gen-status.active { color: var(--red); animation: pulse 1.4s infinite; }
.gen-status.done { color: #4fd463; }

.gen-result-actions { display: flex; gap: 8px; }

.gen-panels { position: relative; }

.gen-preview {
  width: 100%;
  height: 500px;
  border: none;
  background: #fff;
  display: block;
}

.gen-code {
  margin: 0;
  max-height: 500px;
  overflow: auto;
  background: #0c0c10;
  padding: 18px 20px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: #c8c8d2;
  white-space: pre-wrap;
  word-break: break-word;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.soon-note {
  margin-top: 24px;
  padding: 14px 18px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-mut);
  font-size: 14px;
}

/* ---------- Общие карточки ---------- */
.card {
  background: var(--glass-panel);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 24px;
}

.card-sub {
  color: var(--text-soft);
  font-size: 0.92rem;
  margin: -6px 0 18px;
}

.side-title {
  font-size: 1rem;
  margin-bottom: 16px;
}

.muted {
  color: var(--text-mut);
}

.mono {
  font-family: 'SFMono-Regular', Menlo, monospace;
  font-size: 0.85em;
}

/* ---------- Алерт success ---------- */
.alert-success {
  background: rgba(39, 201, 63, 0.1);
  border: 1px solid rgba(39, 201, 63, 0.3);
  color: #7ee08a;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

/* ---------- Balance page ---------- */
.balance-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.balance-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 22px;
  align-items: start;
}

.balance-form-card h2 {
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.current-balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 18px 0 22px;
}

.current-balance span {
  color: var(--text-soft);
}

.current-balance strong {
  font-size: 1.6rem;
}

.block-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  margin: 18px 0 10px;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.preset,
.method {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.preset:hover,
.method:hover {
  border-color: var(--border-red);
}

.preset.active,
.method.active {
  border-color: var(--red);
  background: rgba(255, 45, 45, 0.08);
}

.custom-amount,
.email-field {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  margin-top: 12px;
}

.custom-amount:focus,
.email-field:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(255, 45, 45, 0.12);
}

.method-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.method {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.field-hint {
  font-size: 12px;
  color: var(--text-mut);
  margin-top: 7px;
}

.agree {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 20px 0;
  font-size: 13px;
  color: var(--text-soft);
}

.agree input {
  margin-top: 2px;
  accent-color: var(--red);
}

.agree a {
  color: var(--red);
}

.total-row {
  font-size: 1.05rem;
  margin-bottom: 16px;
}

.total-row strong {
  font-size: 1.5rem;
  margin-left: 6px;
}

.balance-side {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.info-row:last-child {
  border-bottom: none;
}

.info-row span {
  color: var(--text-soft);
}

.info-row b.ok {
  color: #27c93f;
}

.benefit {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  font-size: 0.9rem;
  color: var(--text-soft);
  border-bottom: 1px solid var(--border);
}

.benefit:last-child {
  border-bottom: none;
}

.benefit-ico {
  color: var(--red);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}

.tab {
  padding: 12px 18px;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 15px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--red);
}

.tab-count {
  font-size: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 1px 8px;
  border-radius: 999px;
  margin-left: 4px;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 560px;
}

.data-table th {
  text-align: left;
  padding: 14px 16px;
  color: var(--text-mut);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-soft);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.data-table .strong,
.data-table td.strong {
  color: var(--text);
  font-weight: 600;
}

.data-table .right,
th.right,
td.right {
  text-align: right;
}

.link {
  color: var(--red);
  font-weight: 600;
}

.amount-plus {
  color: #27c93f;
  font-weight: 600;
}

.amount-minus {
  color: #ff6b6b;
  font-weight: 600;
}

/* ---------- Badges / chips ---------- */
.badge-status {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

.badge-status.ok {
  background: rgba(39, 201, 63, 0.12);
  color: #4fd463;
}

.badge-status.pending {
  background: rgba(255, 189, 46, 0.12);
  color: #ffbd2e;
}

.badge-status.fail {
  background: rgba(255, 45, 45, 0.12);
  color: #ff6b6b;
}

.chip {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
}

.chip-red {
  background: rgba(255, 45, 45, 0.12);
  border-color: var(--border-red);
  color: var(--red);
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-ico {
  font-size: 40px;
  color: var(--red);
  margin-bottom: 14px;
}

.empty-state h3 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-soft);
  margin-bottom: 18px;
}

/* ---------- History list ---------- */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.hi-prompt {
  color: var(--text);
  margin-bottom: 8px;
}

.hi-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-mut);
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: 82vw;
    max-width: 300px;
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
  .app-burger {
    display: flex;
  }
  .balance-grid {
    grid-template-columns: 1fr;
  }
  .preset-row {
    grid-template-columns: repeat(3, 1fr);
  }
  .app-content { padding: 26px 20px 52px; }
  .app-topbar { padding: 0 16px; gap: 10px; }
  .method-row { grid-template-columns: 1fr; }
}

/* Телефоны — кабинет и админка */
@media (max-width: 560px) {
  .app-content { padding: 20px 14px 48px; }
  .page-head h1 { font-size: 1.5rem; }
  /* Заголовки-строки с кнопкой справа складываем в столбик */
  .page-head, .project-bar { flex-wrap: wrap; }
  /* Топбар: прячем второстепенное, оставляем бургер + тариф */
  .topbar-upgrade, .user-plan { font-size: 12px; padding: 6px 10px; }
  .su-name { max-width: 150px; }
  .preset-row { grid-template-columns: repeat(2, 1fr); }
  .scope-banner { flex-direction: column; align-items: flex-start; gap: 10px; }
  /* Табличные ячейки компактнее, чтобы влезали (обёртка и так скроллит) */
  .data-table th, .data-table td { padding: 10px 12px; font-size: 0.88rem; }
  .mini-stats { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 380px) {
  .preset-row { grid-template-columns: 1fr 1fr; }
  .app-content { padding: 18px 12px 44px; }
}

/* ============================================================
   Полировка таблиц админки + hover на деталях транзакций
   ============================================================ */

/* Таблицы: мягче, с анимацией строк */
.data-table { border-spacing: 0; }
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}
.data-table tbody tr {
  transition: background 0.16s ease, box-shadow 0.16s ease;
}
.data-table tbody tr:hover td {
  background: rgba(255, 31, 61, 0.06);
}
.data-table tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--red);
}
.data-table .btn { transition: all 0.18s ease; }

/* Детали транзакции: статичны по умолчанию, «оживают» при наведении */
.detail-grid .card {
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.detail-grid .card:hover {
  border-color: var(--border-red);
  box-shadow: 0 18px 50px -28px var(--red-glow);
}

.info-row {
  border-radius: var(--radius-sm);
  padding: 10px 10px;
  margin: 0 -10px;
  border-bottom: 1px solid var(--border);
  transition: background 0.18s ease, box-shadow 0.18s ease, padding-left 0.18s ease;
}
.info-row:hover {
  background: rgba(255, 31, 61, 0.06);
  box-shadow: inset 3px 0 0 var(--red);
  padding-left: 16px;
}
.info-row:hover span { color: var(--text); }

/* ============================================================
   Тип генерации, проекты, анимация генерации
   ============================================================ */

/* Баннер типа генерации */
.scope-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 16px; background: var(--bg-card);
  position: relative; overflow: hidden;
}
.scope-banner::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--grad-red);
}
.scope-banner.scope-full::before { background: linear-gradient(180deg,#ffd15a,#ff8a3d); }
.sb-main { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--text-soft); }
.sb-main b { color: var(--text); }
.sb-ico { font-size: 24px; }
.scope-full { background: linear-gradient(120deg, rgba(255,190,60,0.06), var(--bg-card)); border-color: rgba(255,190,60,0.25); }

/* Проекты */
.usage-projects { font-size: 13px; color: var(--text-mut); }
.usage-projects strong { color: var(--text); }
.project-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.pb-label { font-size: 13px; color: var(--text-mut); }
.pb-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.pb-empty { font-size: 13px; color: var(--text-mut); font-style: italic; }
.pb-chip {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 15px; color: var(--text-soft); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all 0.18s ease; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pb-chip:hover { color: var(--text); border-color: var(--border-red); }
.pb-chip.active { border-color: var(--red); color: var(--text); background: rgba(255,31,61,0.1); }
.pb-new {
  background: transparent; border: 1px dashed var(--border-red); border-radius: 999px;
  padding: 7px 15px; color: var(--red); font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.18s ease;
}
.pb-new:hover:not(:disabled) { background: rgba(255,31,61,0.08); }
.pb-new:disabled { opacity: 0.4; cursor: not-allowed; }
.pb-rename {
  background: transparent; border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 15px; color: var(--text-soft); font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.18s ease;
}
.pb-rename:hover { border-color: var(--border-red); color: var(--red); }
.pb-new.active { background: rgba(255,31,61,0.12); border-style: solid; }

/* Анимация генерации */
.gen-loading {
  position: absolute; inset: 0; z-index: 5;
  background: radial-gradient(circle at 50% 40%, #14141c, #0a0a0e);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  overflow: hidden;
}
/* Атрибут hidden должен реально скрывать оверлей (класс .gen-loading задаёт display:flex) */
.gen-loading[hidden] { display: none; }
.gl-orb { position: relative; width: 110px; height: 110px; display: flex; align-items: center; justify-content: center; }
.gl-mark {
  width: 54px; height: 54px; background: url('/favicon.svg') center/contain no-repeat;
  filter: drop-shadow(0 0 14px var(--red-glow)); animation: glpulse 1.6s ease-in-out infinite;
}
.gl-ring { position: absolute; border-radius: 50%; border: 2px solid var(--red); opacity: 0.5; }
.gl-ring { width: 80px; height: 80px; animation: glring 1.8s ease-out infinite; }
.gl-ring.r2 { width: 80px; height: 80px; animation-delay: 0.9s; }
@keyframes glring { 0% { transform: scale(0.5); opacity: 0.7; } 100% { transform: scale(1.6); opacity: 0; } }
@keyframes glpulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.gl-scan {
  position: absolute; left: 0; right: 0; height: 2px; top: 0;
  background: linear-gradient(90deg, transparent, var(--red), transparent);
  box-shadow: 0 0 16px var(--red); animation: glscan 2.2s linear infinite;
}
@keyframes glscan { 0% { top: 6%; } 50% { top: 94%; } 100% { top: 6%; } }
.gl-text { color: var(--text-soft); font-family: var(--mono); font-size: 14px; }
.gl-dots i { animation: blink 1.2s infinite; }
.gl-dots i:nth-child(2) { animation-delay: 0.2s; } .gl-dots i:nth-child(3) { animation-delay: 0.4s; }
.gl-bar { width: 220px; height: 4px; background: var(--bg-elev); border-radius: 999px; overflow: hidden; }
.gl-bar span { display: block; height: 100%; width: 40%; background: var(--grad-red); border-radius: 999px; animation: glbar 1.4s ease-in-out infinite; }
@keyframes glbar { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

.gen-preview { transition: opacity 0.3s ease; }

/* Красивый empty-state (glow + плавание иконки) */
.empty-state {
  position: relative;
  background:
    radial-gradient(circle at 50% 0%, rgba(255,31,61,0.06), transparent 60%),
    var(--bg-card);
  border: 1px solid var(--border);
}
.empty-ico { animation: floaty 3.5s ease-in-out infinite; filter: drop-shadow(0 0 16px var(--red-glow)); }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ---------- Статус тарифа (страница billing) ---------- */
.plan-status {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
}
.plan-status-badge {
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: #fff;
  background: var(--grad-red);
  padding: 4px 12px;
  border-radius: 999px;
}
.plan-status-text { color: var(--text-soft); font-size: 0.95rem; }
.plan-status-text strong { color: var(--text); }

/* ---------- Предупреждение о точности запроса ---------- */
.gen-warn {
  margin-top: 12px;
  font-size: 13px;
  color: #ffbd8a;
  background: rgba(255, 145, 46, 0.08);
  border: 1px solid rgba(255, 145, 46, 0.28);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  line-height: 1.55;
}

/* ---------- Окно правки результата ---------- */
.gen-edit {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.gen-edit[hidden] { display: none; }
.gen-edit-ico { color: var(--red); font-size: 16px; }
.gen-edit-input {
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
}
.gen-edit-input:focus { outline: none; border-color: var(--red); }

/* ---------- Пакеты генераций ---------- */
.packs-section { margin-top: 40px; }
.packs-head { margin-bottom: 18px; }
.packs-title { font-size: 1.5rem; margin-bottom: 4px; }
.pack-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.pack-card { text-align: center; padding: 26px 22px; display: flex; flex-direction: column; align-items: center; }
.pack-count { font-size: 2.6rem; font-weight: 900; line-height: 1; }
.pack-unit { color: var(--text-mut); font-size: 0.9rem; margin: 4px 0 14px; }
.pack-price {
  font-size: 1.3rem; font-weight: 800; color: var(--red); margin-bottom: 18px;
}
.pack-card .btn { width: 100%; }
@media (max-width: 720px) { .pack-grid { grid-template-columns: 1fr; } }

/* ---------- Плавающее окно: лимит генераций ---------- */
.limit-modal {
  position: fixed; inset: 0; z-index: 210;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.limit-modal[hidden] { display: none; }
.limit-overlay {
  position: absolute; inset: 0;
  background: rgba(5, 5, 8, 0.8); backdrop-filter: blur(6px);
}
.limit-dialog {
  position: relative; width: 100%; max-width: 420px;
  padding: 34px 30px 26px; text-align: center;
  border: 1px solid var(--border-red, rgba(255, 31, 61, 0.4));
  box-shadow: 0 40px 120px -30px var(--red-glow, rgba(255, 31, 61, 0.6));
  animation: limitIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes limitIn { from { opacity: 0; transform: translateY(22px) scale(0.96); } to { opacity: 1; transform: none; } }
.limit-close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--text-soft); cursor: pointer; font-size: 14px;
}
.limit-close:hover { border-color: var(--red); color: var(--red); }
.limit-emoji { font-size: 46px; margin-bottom: 10px; animation: floaty 3s ease-in-out infinite; }
.limit-title { font-size: 1.5rem; margin-bottom: 10px; }
.limit-text { color: var(--text-soft); font-size: 0.95rem; line-height: 1.6; margin-bottom: 22px; }
.limit-actions { display: flex; flex-direction: column; gap: 10px; }
.limit-later {
  margin-top: 14px; background: none; border: none; cursor: pointer;
  color: var(--text-mut); font-size: 0.85rem; text-decoration: underline;
}
.limit-later:hover { color: var(--text-soft); }

/* ---------- Модальное окно оплаты (Opera GX) ---------- */
.pay-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.pay-modal[hidden] { display: none; }
.pay-overlay {
  position: absolute; inset: 0;
  background: rgba(5, 5, 8, 0.78);
  backdrop-filter: blur(6px);
}
.pay-dialog {
  position: relative;
  width: 100%; max-width: 440px;
  padding: 30px 28px 26px;
  border: 1px solid var(--border-red, rgba(255, 31, 61, 0.4));
  box-shadow: 0 40px 120px -30px var(--red-glow, rgba(255, 31, 61, 0.6));
  animation: payIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes payIn { from { opacity: 0; transform: translateY(18px) scale(0.98); } to { opacity: 1; transform: none; } }
.pay-close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--text-soft); cursor: pointer; font-size: 14px;
}
.pay-close:hover { border-color: var(--red); color: var(--red); }
.pay-title { font-size: 1.4rem; margin: 6px 0 18px; }
.pay-amount-row {
  display: flex; align-items: baseline; justify-content: space-between;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px;
}
.pay-amount-row span { color: var(--text-mut); font-size: 0.9rem; }
.pay-amount-row b { font-size: 1.8rem; font-weight: 900; }
.pay-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.pay-method {
  padding: 12px; border-radius: var(--radius-sm);
  background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--text-soft); cursor: pointer; font-size: 13.5px; font-weight: 600;
  transition: border-color 0.18s ease, color 0.18s ease;
}
.pay-method.active { border-color: var(--red); color: #fff; box-shadow: inset 0 0 0 1px var(--red); }
.pay-field { display: block; margin-bottom: 18px; }
.pay-field span { display: block; font-size: 12.5px; color: var(--text-mut); margin-bottom: 6px; }
.pay-field input {
  width: 100%; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; color: var(--text); font-size: 14px;
}
.pay-field input:focus { outline: none; border-color: var(--red); }
.pay-submit { font-size: 15px; padding: 14px; }
.pay-secure { margin-top: 14px; font-size: 12px; color: var(--text-mut); text-align: center; line-height: 1.5; }

/* Блок платёжного провайдера (Lava) */
.pay-provider {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 16px;
}
.pay-provider-badge {
  flex-shrink: 0; font-weight: 800; font-size: 13px; letter-spacing: 0.02em;
  color: #fff; background: var(--grad-red); padding: 6px 12px; border-radius: 6px;
  box-shadow: var(--glow-red);
}
.pay-provider-text { font-size: 12.5px; color: var(--text-soft); line-height: 1.45; }

/* ---------- Действия в истории + модалка предпросмотра ---------- */
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.hi-actions { flex-shrink: 0; }

.preview-modal .preview-dialog {
  position: relative;
  width: 100%; max-width: 1100px; height: 84vh;
  display: flex; flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-red, rgba(255, 31, 61, 0.4));
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 40px 120px -30px var(--red-glow, rgba(255, 31, 61, 0.6));
  animation: payIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.preview-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.preview-title {
  font-weight: 600; font-size: 14px; color: var(--text-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.preview-head-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
/* Кнопка закрытия в предпросмотре — в потоке, а не absolute (иначе налазит на «Открыть») */
.preview-head-actions .pay-close { position: static; top: auto; right: auto; flex-shrink: 0; }
.preview-frame { flex: 1; width: 100%; border: none; background: #fff; }

/* ---------- Стеклянные панели кабинета (glassmorphism, весь сайт) ---------- */
.usage-bar,
.gen-input-wrap,
.project-bar,
.stat-card,
.gen-result {
  background: var(--glass-panel) !important;
  border: 1px solid var(--glass-border) !important;
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
}
.app-topbar {
  background: rgba(10, 10, 13, 0.55);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.app-sidebar {
  background: rgba(11, 12, 17, 0.5);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.usage-extra { color: var(--red); font-weight: 600; }

/* Баланс токенов в хедере кабинета */
.topbar-tokens {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--text);
  background: var(--glass); border: 1px solid var(--glass-border);
  padding: 6px 12px; border-radius: 999px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.topbar-tokens b { color: var(--red); }
.topbar-tokens:hover { border-color: var(--red); box-shadow: var(--glow-red); }

/* Цена генерации на кнопке */
.gen-btn-cost { opacity: 0.85; font-weight: 600; }

/* «Своя сумма» токенов */
.custom-topup { padding: 22px 24px; margin-top: 16px; }
.custom-topup .ct-head h3 { font-size: 1.15rem; margin-bottom: 4px; }
.ct-row { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-top: 14px; }
.ct-field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 180px; }
.ct-field span { font-size: 12.5px; color: var(--text-mut); }
.ct-field input {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; color: var(--text); font-size: 16px; font-family: inherit;
}
.ct-field input:focus { outline: none; border-color: var(--red); }
.ct-price { display: flex; flex-direction: column; gap: 4px; }
.ct-price span { font-size: 12.5px; color: var(--text-mut); }
.ct-price b { font-size: 1.5rem; font-weight: 900; }
.custom-topup #ctBuy { padding: 13px 26px; }
@media (max-width: 560px) { .ct-row { flex-direction: column; align-items: stretch; } .custom-topup #ctBuy { width: 100%; } }

/* ============================================================
   Подписки (наброски) — сегмент-переключатель + карточки
   ============================================================ */
.subs { margin-bottom: 28px; }
.subs-toggle {
  display: inline-flex; gap: 4px; padding: 5px;
  background: var(--glass-panel, rgba(255,255,255,.04));
  border: 1px solid var(--glass-border, var(--border));
  backdrop-filter: blur(var(--blur, 14px));
  border-radius: 999px; margin: 0 auto 10px; 
}
.subs { text-align: center; }
.subs-tab {
  appearance: none; border: 0; cursor: pointer;
  padding: 9px 26px; border-radius: 999px;
  font: 600 15px var(--font, inherit); color: var(--text-mut);
  background: transparent; transition: color .2s ease, background .25s ease, box-shadow .25s ease;
}
.subs-tab.active {
  color: #fff; background: var(--grad-red, linear-gradient(135deg,#ff2740,#ff5a70));
  box-shadow: 0 8px 24px -8px var(--red-glow, rgba(255,39,64,.6));
}
.subs-hint { color: var(--text-mut); font-size: .95rem; margin: 0 0 22px; }

.subs-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; text-align: left;
}
.subs-grid[hidden] { display: none; }
@media (max-width: 1100px) { .subs-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px) { .subs-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .subs-grid { grid-template-columns: 1fr; } }

.sub-card { position: relative; display: flex; flex-direction: column; padding: 24px 22px; }
.sub-card.featured {
  border-color: var(--border-red, rgba(255,39,64,.45));
  box-shadow: 0 24px 70px -30px var(--red-glow, rgba(255,39,64,.55));
}
.sub-badge {
  position: absolute; top: 16px; right: 16px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  padding: 4px 10px; border-radius: 999px;
  color: var(--text-soft); background: var(--bg-elev); border: 1px solid var(--border);
}
.sub-badge.hot { color: #fff; background: linear-gradient(135deg,#ff9d2e,#ff5a2e); border: 0; }
.sub-badge.save { color: #2ee06a; background: rgba(46,224,106,.12); border-color: rgba(46,224,106,.35); }
.sub-name { font: 800 1.5rem var(--font-head, inherit); margin-bottom: 12px; }
.sub-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.sub-old { color: var(--text-mut); text-decoration: line-through; font-size: 1rem; }
.sub-num { font-size: 1.7rem; font-weight: 900; }
.sub-per { color: var(--text-mut); font-size: .9rem; }
.sub-access { color: var(--text-soft); font-size: .9rem; margin-bottom: 16px; min-height: 2.4em; }
.sub-features { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 10px; }
.sub-features li { display: flex; gap: 8px; align-items: flex-start; font-size: .9rem; color: var(--text-soft); line-height: 1.4; }
.sub-features .check { color: var(--red); font-weight: 800; flex-shrink: 0; }
.sub-card .btn { margin-top: auto; }

/* ============================================================
   Гостевой режим чата (как в ChatGPT): без кабинет-сайдбара,
   минимальный топбар с логотипом и кнопками Войти/Регистрация
   ============================================================ */
.app-shell.guest .app-main { margin-left: 0; }
.topbar-logo {
  display: inline-flex; align-items: center; gap: 2px;
  font: 800 20px var(--font-head); text-decoration: none; letter-spacing: -.01em;
}
.topbar-logo .logo-mark { color: var(--red); }
.topbar-logo .topbar-ai {
  margin-left: 6px; font: 800 12px var(--mono); letter-spacing: .1em;
  color: var(--red); background: rgba(255,39,64,.12); border: 1px solid var(--border-red);
  padding: 2px 7px; border-radius: 999px;
}
.topbar-login { white-space: nowrap; }
.topbar-reg { white-space: nowrap; }

/* Счётчик бесплатных запросов под строкой ввода */
.free-hint { color: var(--text-soft); }
.free-hint b { color: var(--red); }

/* ---------- Стена регистрации ---------- */
.reg-wall {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(6,6,10,.72);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: rwFade .25s ease both;
}
@keyframes rwFade { from { opacity: 0; } to { opacity: 1; } }
.reg-wall-card {
  width: 100%; max-width: 420px; text-align: center; padding: 34px 28px;
  background: var(--glass-panel); border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(var(--blur)) var(--glass-sat); backdrop-filter: blur(var(--blur)) var(--glass-sat);
  border-radius: 24px; box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-hi);
  animation: rwUp .3s cubic-bezier(.22,1,.36,1) both;
}
@keyframes rwUp { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.reg-wall-logo { font: 900 1.7rem var(--font-head); margin-bottom: 16px; }
.reg-wall-logo .ce-ai { color: var(--red); }
.reg-wall-title { font: 800 1.4rem var(--font-head); letter-spacing: -.02em; margin-bottom: 8px; }
.reg-wall-sub { color: var(--text-mut); margin-bottom: 22px; line-height: 1.5; }
.reg-wall-actions { display: flex; flex-direction: column; gap: 10px; }

@media (max-width: 560px) {
  .topbar-reg { display: none; } /* на узких — оставляем «Войти», регистрация есть в стене */
}
