:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-cyan: #06b6d4;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: rgba(148, 163, 184, 0.35);
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.9);
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --panel-bg: linear-gradient(135deg, #eef2ff 0%, #f0f9ff 40%, #f8fafc 100%);
  --sidebar-w: 18rem;
  --sidebar-collapsed: 72px;
  --header-h: 56px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --body-bg: #e2e8f0;
  --chip-bg: rgba(255, 255, 255, 0.85);
  --input-bg: #ffffff;
  --elevated: rgba(255, 255, 255, 0.92);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--body-bg);
  min-height: 100vh;
}

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

/* —— Sidebar —— */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  width: var(--sidebar-w);
  height: 100vh;
  flex-shrink: 0;
}

.sidebar-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
}

.sidebar-border-gradient {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--primary-light), var(--primary-cyan));
  opacity: 0.85;
  pointer-events: none;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 16px 12px;
  position: relative;
  z-index: 1;
  min-height: 0;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  margin-right: -4px;
}

.custom-scrollbar::-webkit-scrollbar { width: 4px; }
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.45);
  border-radius: 4px;
}

.menu-group { margin-bottom: 4px; }

.menu-groups { display: flex; flex-direction: column; gap: 4px; }

.menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.group-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 8px 10px 4px;
  font-weight: 700;
  opacity: 1;
}

html.theme-dark .group-title {
  color: #cbd5e1;
  opacity: 1;
}

html:not(.theme-dark) .group-title {
  color: #475569;
  opacity: 1;
}

.group-title-icon { font-size: 12px; }

.submenu-container {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
}

.submenu-container.open { max-height: 280px; }

.menu-item-toggle.open + .submenu-container { max-height: 280px; }

.submenu-list {
  list-style: none;
  margin: 0 0 6px;
  padding: 2px 0 4px 10px;
}

.submenu-item { margin: 0; }

.submenu-link {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.submenu-link-text { line-height: 1.3; }

.submenu-link:hover {
  background: rgba(59, 130, 246, 0.08);
  color: var(--primary);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 12px 10px 18px 14px;
  margin-left: 2px;
  border-left: 0;
  border-image: none;
}

.logo-mark {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  text-decoration: none;
  flex-shrink: 0;
  overflow: hidden;
  padding: 0;
  box-shadow: none;
  outline: none;
  border: none;
}

.logo-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
}

/* mark-icon почти чёрный — в dark делаем светлым, без смены ассета */
html.theme-dark .logo-mark img {
  filter: brightness(0) invert(1);
  opacity: 1;
}

html:not(.theme-dark) .logo-mark img {
  filter: none;
  opacity: 1;
}

.sidebar-logo .logo-text {
  display: block;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
}

.logo-text {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--text);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s;
}

.menu-item:hover:not(.disabled) {
  background: rgba(59, 130, 246, 0.06);
  color: var(--text);
}

.menu-item.active {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
  border-color: rgba(59, 130, 246, 0.15);
}

.menu-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.1);
  font-size: 14px;
  color: var(--text-muted);
}

.menu-item.active .menu-icon,
.menu-icon-active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary-light);
}

.menu-item-toggle {
  cursor: pointer;
  background: none;
  font-family: inherit;
  text-align: left;
}

.submenu-chevron {
  margin-left: auto;
  font-size: 10px;
  opacity: 0.45;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.menu-item-toggle.open .submenu-chevron { transform: rotate(180deg); }

.menu-item.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.footer-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

.footer-btn:hover { background: rgba(59, 130, 246, 0.08); }

.footer-btn.active {
  background: rgba(59, 130, 246, 0.12);
  font-weight: 600;
}

.header-actions .icon-btn.active {
  color: var(--primary);
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.08);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 150;
}

/* —— Main —— */
.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.panel-background { background: var(--panel-bg); }

.header-glass {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  height: var(--header-h);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title {
  font-size: 17px;
  font-weight: 700;
}

.text-gradient-primary {
  background: linear-gradient(135deg, var(--primary-light), var(--primary-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions { display: flex; gap: 8px; align-items: center; }

.content-wrapper {
  flex: 1;
  padding: 16px 20px 24px;
}

.content-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-height: calc(100vh - var(--header-h) - 48px);
}

.main-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* —— Stats —— */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.stat-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}

.stat-card:hover {
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.1);
  transform: translateY(-1px);
}

.stat-content { display: flex; flex-direction: column; gap: 4px; }

.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  margin-bottom: 4px;
}

.icon-active { background: #ecfdf5; color: #10b981; }
.icon-disabled { background: #f1f5f9; color: #64748b; }
.icon-total { background: #eff6ff; color: #3b82f6; }
.icon-limit { background: #f5f3ff; color: #8b5cf6; }
.icon-working { background: #eff6ff; color: #3b82f6; }
.icon-spam { background: #fffbeb; color: #f59e0b; }
.icon-banned { background: #fff1f2; color: #f43f5e; }

.stat-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.stat-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-hover-indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary-light), var(--primary-cyan));
  opacity: 0;
  transition: opacity 0.2s;
}

.stat-card:hover .stat-hover-indicator { opacity: 1; }

/* —— Action chips —— */
.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px dashed rgba(59, 130, 246, 0.45);
  background: rgba(255, 255, 255, 0.8);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.action-chip:hover {
  background: rgba(59, 130, 246, 0.08);
  border-style: solid;
}

.action-chip.proxy {
  border-color: rgba(16, 185, 129, 0.45);
  color: #059669;
}

.action-chip.proxy:hover { background: rgba(16, 185, 129, 0.08); }

.chip-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(59, 130, 246, 0.12);
  font-size: 12px;
}

.action-chip.proxy .chip-icon { background: rgba(16, 185, 129, 0.12); }

/* —— Table toolbar —— */
.filters-section { margin-bottom: 12px; }

.mobile-search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.search-box {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  position: relative;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.search-input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
  outline: none;
}

.search-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.p-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.p-btn:hover { background: var(--surface-hover); }

.p-btn-secondary {
  background: var(--surface);
  color: var(--text);
}

.p-btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-cyan));
  color: #fff;
  border: none;
}

.p-btn-primary:hover { filter: brightness(1.05); }

.p-btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.p-btn-danger:hover { background: rgba(239, 68, 68, 0.18); }

.p-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  vertical-align: middle;
}

.data-table tbody tr:hover td { background: rgba(59, 130, 246, 0.04); }

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

.avatar-cell {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dbeafe, #e0f2fe);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
}

.status-tag {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.status-tag.ok { background: #ecfdf5; color: #059669; }
.status-tag.off { background: #f1f5f9; color: #64748b; }

.btn-toggle-sm {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--text-muted);
}

.btn-toggle-sm.on {
  border-color: #10b981;
  color: #059669;
  background: #ecfdf5;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 40px;
  opacity: 0.35;
  margin-bottom: 12px;
  display: block;
}

.empty-hint { font-size: 12px; margin-top: 6px; opacity: 0.8; }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: #f8fafc;
}

.hint-banner {
  font-size: 12px;
  color: var(--text-muted);
  padding: 10px 14px;
  background: rgba(59, 130, 246, 0.06);
  border: 1px dashed rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-sm);
}

.loading-state {
  text-align: center;
  padding: 60px;
  color: var(--text-muted);
}

.loading-state i { margin-right: 8px; }

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.lg-hidden { display: none; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  transition: all 0.25s;
  z-index: 999;
  box-shadow: var(--shadow);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* —— Modules hub —— */
.modules-hub { display: flex; flex-direction: column; gap: 20px; }

.modules-intro {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 8px;
}

.category-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
}

.category-card:hover {
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.08);
  transform: translateY(-1px);
}

.category-card.active {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.04);
}

.category-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.category-card-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.category-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-card-count {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

.module-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.module-card {
  display: inline-flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px dashed rgba(59, 130, 246, 0.4);
  background: rgba(255, 255, 255, 0.9);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.module-card:hover {
  border-style: solid;
  background: rgba(59, 130, 246, 0.08);
}

.module-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* —— Module settings frame —— */
.module-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.module-toolbar-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.module-frame-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 520px;
}

.module-frame {
  width: 100%;
  min-height: 520px;
  height: calc(100vh - var(--header-h) - 140px);
  border: none;
  display: block;
  background: #f8fafc;
}

/* —— Bot placeholder —— */
.bot-placeholder {
  text-align: center;
  padding: 48px 24px;
  max-width: 420px;
  margin: 0 auto;
}

.bot-placeholder-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: rgba(59, 130, 246, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--primary);
}

.bot-placeholder p { color: var(--text-muted); font-size: 14px; margin-top: 8px; line-height: 1.5; }

.submenu-link.active,
.menu-item.active-module .menu-icon {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary);
}

.submenu-link.active {
  color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
}

.tag-premium {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #b45309;
  background: #fffbeb;
  padding: 1px 6px;
  border-radius: 4px;
}

.cell-muted { color: var(--text-muted); font-size: 12px; }

/* —— Panel settings forms —— */
.settings-page { display: flex; flex-direction: column; gap: 16px; max-width: 760px; }

.module-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.settings-templates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.settings-templates-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settings-input-inline { flex: 1; min-width: 120px; max-width: 200px; }

.settings-form-panel { display: flex; flex-direction: column; gap: 16px; }

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.settings-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.settings-fields { display: flex; flex-direction: column; gap: 14px; }

.settings-field { display: flex; flex-direction: column; gap: 6px; }

.settings-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.settings-input,
.settings-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.settings-input:focus,
.settings-textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.settings-textarea { min-height: 96px; resize: vertical; line-height: 1.45; }

.settings-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  cursor: pointer;
  font-size: 13px;
}

.settings-check input { width: 16px; height: 16px; accent-color: var(--primary); }

.field-hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.settings-actions { padding-top: 4px; }

.save-chip {
  border-color: rgba(16, 185, 129, 0.45);
  color: #059669;
}

.save-chip .chip-icon { background: rgba(16, 185, 129, 0.12); }

.save-chip:hover { background: rgba(16, 185, 129, 0.08); }

.settings-status { font-size: 13px; min-height: 20px; }
.settings-status.ok { color: #059669; }
.settings-status.err { color: #dc2626; }
.cell-name b { display: block; font-weight: 600; }

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s;
    width: min(320px, 85vw);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
  .main-wrap { margin-left: 0; }
  .lg-hidden { display: flex; }
}

@media (min-width: 1025px) {
  .sidebar .menu-label,
  .sidebar .group-title,
  .footer-btn span { display: block; }
}

@media (max-width: 1024px) {
  .sidebar .menu-label,
  .sidebar .group-title,
  .footer-btn span { display: inline; }
}

/* —— Modals (accounts manager) —— */
body.modal-open { overflow: hidden; }

.panel-modal {
  position: fixed;
  inset: 0;
  z-index: 10100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.panel-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}

.panel-modal-card {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: min(90vh, 720px);
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.panel-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.panel-modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.panel-modal-body {
  padding: 16px 18px;
  overflow: auto;
}

.panel-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
}

.modal-hint {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-status {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
  min-height: 20px;
}

.modal-status a { color: var(--primary); }

.modal-radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 6px;
}

.upload-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 140px;
  padding: 20px;
  border: 2px dashed rgba(59, 130, 246, 0.45);
  border-radius: var(--radius);
  background: rgba(59, 130, 246, 0.04);
  cursor: pointer;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.upload-drop i { font-size: 28px; color: var(--primary); }
.upload-drop.drag { border-color: var(--primary); background: rgba(59, 130, 246, 0.1); }

.account-picker {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.account-picker-all {
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.account-picker-row { display: flex; margin: 4px 0; }

.download-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.download-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}

.download-item:hover { border-color: var(--primary-light); transform: translateY(-1px); }
.download-item i { font-size: 22px; color: var(--primary); }
.download-item b { display: block; font-size: 14px; }
.download-item span { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.download-list button.download-item {
  width: 100%;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.cell-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-icon-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: #dc2626;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-sm:hover { background: rgba(239, 68, 68, 0.08); }

.data-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.check-results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

@media (min-width: 520px) {
  .check-results-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.check-result-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 96px;
  padding: 12px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.check-result-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.check-result-card i { font-size: 20px; }
.check-result-value { font-size: 22px; font-weight: 700; line-height: 1; }
.check-result-label { font-size: 12px; color: var(--text-muted); }

.check-tone-ok { border-color: rgba(16, 185, 129, 0.35); }
.check-tone-ok i, .check-tone-ok .check-result-value { color: #059669; }
.check-tone-warn { border-color: rgba(245, 158, 11, 0.4); }
.check-tone-warn i, .check-tone-warn .check-result-value { color: #d97706; }
.check-tone-bad { border-color: rgba(239, 68, 68, 0.35); }
.check-tone-bad i, .check-tone-bad .check-result-value { color: #dc2626; }
.check-tone-freeze { border-color: rgba(59, 130, 246, 0.35); }
.check-tone-freeze i, .check-tone-freeze .check-result-value { color: #2563eb; }

.check-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.check-summary-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 13px;
}

.ai-protection-bar .ai-prot-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.ai-protection-bar .ai-prot-toggle input {
  width: auto;
  margin: 0;
}

.check-group-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 360px;
  overflow: auto;
}

.check-group-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.check-group-item:last-child { border-bottom: none; }
.check-group-id { font-weight: 600; font-size: 13px; word-break: break-all; }
.check-group-status { font-size: 12px; color: var(--text-muted); }

.check-group-item.check-tone-warn .check-group-id { color: #d97706; }
.check-group-item.check-tone-bad .check-group-id { color: #dc2626; }
.check-group-item.check-tone-freeze .check-group-id { color: #2563eb; }
.check-group-item.check-tone-ok .check-group-id { color: #059669; }

/* —— Sidebar module search —— */
.sidebar-search-wrap { padding: 0 12px 10px; }
.sidebar-search {
  position: relative;
  display: flex;
  align-items: center;
}
.sidebar-search i {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  font-size: 13px;
}
.sidebar-search-input {
  width: 100%;
  padding: 8px 10px 8px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  outline: none;
}
.sidebar-search-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.search-hidden { display: none !important; }

/* —— Journal page —— */
.journal-page { display: flex; flex-direction: column; gap: 16px; }
.journal-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.journal-tab {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--elevated);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
}
.journal-tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-cyan));
  color: #fff;
  border-color: transparent;
}
.journal-section-title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
}
.journal-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.journal-row {
  display: grid;
  grid-template-columns: 10px 1fr auto auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--elevated);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  color: var(--text);
}
.journal-row:hover { border-color: var(--primary-light); transform: translateY(-1px); }
.journal-row-active { border-color: rgba(16, 185, 129, 0.45); background: rgba(16, 185, 129, 0.06); }
.journal-row-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}
.journal-status-running { background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2); }
.journal-status-done { background: #059669; }
.journal-status-error { background: #dc2626; }
.journal-status-cancelled { background: #94a3b8; }
.journal-row-main b { display: block; font-size: 14px; }
.journal-row-meta { font-size: 12px; color: var(--text-muted); }
.journal-row-stats { font-size: 13px; font-weight: 600; color: var(--primary); }
.journal-row-badge {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
}
.journal-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.journal-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.journal-detail-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

/* —— Module live log (Raptor-style) —— */
.module-live-log { margin-top: 16px; }
.module-live-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.module-live-log-title { margin: 0; font-size: 15px; font-weight: 700; }
.live-log-badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}
.live-log-badge.live {
  background: rgba(34, 197, 94, 0.15);
  color: #059669;
}
.live-log-progress {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.15);
  font-size: 12px;
  white-space: pre-wrap;
  font-family: inherit;
  max-height: 120px;
  overflow: auto;
}
.live-log-console {
  margin: 0;
  min-height: 160px;
  max-height: 280px;
  overflow: auto;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--log-console-bg, #f1f5f9);
  color: var(--log-console-fg, #334155);
  border: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
}

/* —— Тёмная тема (тёмно-синяя, акценты как GramGPT) —— */
html.theme-dark {
  --primary: #22d3ee;
  --primary-light: #67e8f9;
  --primary-cyan: #38bdf8;
  --text: #e8eef7;
  --text-muted: #94a3b8;
  --border: rgba(100, 130, 180, 0.32);
  --glass-bg: rgba(22, 36, 62, 0.88);
  --glass-border: rgba(71, 100, 150, 0.4);
  --surface: #1a2744;
  --surface-hover: #243656;
  --panel-bg: linear-gradient(160deg, #0c1528 0%, #152238 42%, #1e3a5f 100%);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45);
  --body-bg: #0a1220;
  --chip-bg: rgba(30, 58, 95, 0.65);
  --input-bg: #1e2d4a;
  --elevated: rgba(26, 42, 72, 0.92);
  color-scheme: dark;
}

html.theme-dark .custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(100, 130, 180, 0.45);
}

html.theme-dark .icon-active { background: rgba(16, 185, 129, 0.18); color: #34d399; }
html.theme-dark .icon-disabled { background: rgba(51, 65, 85, 0.5); color: #94a3b8; }
html.theme-dark .icon-total,
html.theme-dark .icon-working { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
html.theme-dark .icon-limit { background: rgba(139, 92, 246, 0.18); color: #c4b5fd; }
html.theme-dark .icon-spam { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
html.theme-dark .icon-banned { background: rgba(244, 63, 94, 0.15); color: #fb7185; }

html.theme-dark .action-chip,
html.theme-dark .module-card,
html.theme-dark .journal-tab,
html.theme-dark .journal-row,
html.theme-dark .check-result-card {
  background: var(--chip-bg);
}

html.theme-dark .data-table th,
html.theme-dark .table-footer {
  background: #152238;
}

html.theme-dark .settings-input,
html.theme-dark .settings-textarea,
html.theme-dark .sidebar-search-input {
  background: var(--input-bg);
  color: var(--text);
}

html.theme-dark .module-frame {
  background: #152238;
}

html.theme-dark .panel-modal-card {
  background: var(--elevated);
}

html.theme-dark .sidebar-backdrop {
  background: rgba(2, 6, 23, 0.65);
}

html.theme-dark .live-log-progress {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(96, 165, 250, 0.25);
}

html.theme-dark {
  --log-console-bg: #0f1a2e;
  --log-console-fg: #e2e8f0;
}

html.theme-dark .tag-premium {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.15);
}

html.theme-dark .hint-banner {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(96, 165, 250, 0.28);
}

html.theme-dark .toast {
  background: var(--elevated);
  border-color: var(--border);
  color: var(--text);
}

html.theme-dark .category-card,
html.theme-dark .search-input,
html.theme-dark .p-btn-secondary {
  background: var(--surface);
}

html.theme-dark .menu-item:hover {
  background: rgba(34, 211, 238, 0.08);
}

html.theme-dark .menu-item.active {
  background: rgba(34, 211, 238, 0.12);
  color: var(--primary-light);
  border-color: rgba(34, 211, 238, 0.2);
  box-shadow: inset 3px 0 0 var(--primary-cyan);
}

html.theme-dark .menu-item.active .menu-icon,
html.theme-dark .menu-icon-active {
  background: rgba(34, 211, 238, 0.18);
  color: var(--primary-cyan);
}

html.theme-dark .sidebar-border-gradient {
  background: linear-gradient(180deg, #22d3ee, #3b82f6);
  opacity: 1;
}

html.theme-dark .p-btn-primary,
html.theme-dark .journal-tab.active,
html.theme-dark .save-chip {
  background: linear-gradient(135deg, #22d3ee, #2563eb);
}

html.theme-dark .submenu-link.active {
  color: var(--primary-cyan);
  background: rgba(34, 211, 238, 0.1);
}
