/* ===== TGBot Admin — Premium Design System ===== */

:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --bg:              #eef1f6;
  --bg-elevated:     #ffffff;
  --bg-card:         #ffffff;
  --bg-sidebar:      #ffffff;
  --bg-input:        #f8fafc;
  --bg-muted:        #f1f5f9;
  --bg-inset:        #f8fafc;

  --border:          rgba(15, 23, 42, 0.08);
  --border-strong:   rgba(15, 23, 42, 0.14);

  --text:            #0f172a;
  --text-muted:      #64748b;
  --text-code:       #334155;

  --primary:         #2563eb;
  --primary-hover:   #1d4ed8;
  --primary-soft:    rgba(37, 99, 235, 0.1);
  --accent:          #6366f1;
  --accent-2:        #8b5cf6;

  --success:         #16a34a;
  --success-soft:    rgba(22, 163, 74, 0.12);
  --success-text:    #15803d;

  --danger:          #dc2626;
  --danger-soft:     rgba(220, 38, 38, 0.1);
  --danger-text:     #b91c1c;

  --warning:         #d97706;
  --warning-soft:    rgba(217, 119, 6, 0.12);
  --warning-text:    #b45309;

  --nav-hover:       rgba(15, 23, 42, 0.04);
  --nav-active:      rgba(37, 99, 235, 0.1);
  --nav-active-text: #2563eb;

  --gradient-brand:  linear-gradient(135deg, #2563eb 0%, #6366f1 55%, #8b5cf6 100%);
  --gradient-surface: linear-gradient(180deg, rgba(255,255,255,.95) 0%, rgba(255,255,255,.88) 100%);
  --gradient-mesh:     radial-gradient(ellipse 80% 60% at 10% -10%, rgba(37,99,235,.08), transparent 55%),
                       radial-gradient(ellipse 60% 50% at 100% 0%, rgba(99,102,241,.06), transparent 50%);

  --shadow-xs:   0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow:      0 4px 20px rgba(15, 23, 42, 0.06);
  --shadow-md:   0 12px 40px rgba(15, 23, 42, 0.1);
  --shadow-lg:   0 24px 60px rgba(15, 23, 42, 0.14);

  --radius:      16px;
  --radius-sm:   10px;
  --radius-xs:   8px;
  --radius-pill: 999px;

  --transition:  .2s cubic-bezier(.4, 0, .2, 1);
  --sidebar-w:   272px;

  --topbar-h:    72px;
  --log-bg:      #0f1419;
  --log-text:    #cbd5e1;
}

[data-theme="dark"] {
  --bg:              #07080c;
  --bg-elevated:     #101218;
  --bg-card:         #12141c;
  --bg-sidebar:      #0d0e14;
  --bg-input:        #0a0b10;
  --bg-muted:        #171923;
  --bg-inset:        #0c0d12;

  --border:          rgba(255, 255, 255, 0.07);
  --border-strong:   rgba(255, 255, 255, 0.12);

  --text:            #eef2ff;
  --text-muted:      #94a3b8;
  --text-code:       #c4b5fd;

  --primary:         #60a5fa;
  --primary-hover:   #93c5fd;
  --primary-soft:    rgba(96, 165, 250, 0.14);
  --accent:          #818cf8;
  --accent-2:        #a78bfa;

  --success-soft:    rgba(74, 222, 128, 0.12);
  --success-text:    #86efac;

  --danger-soft:     rgba(248, 113, 113, 0.12);
  --danger-text:     #fca5a5;

  --warning-soft:    rgba(251, 191, 36, 0.12);
  --warning-text:    #fcd34d;

  --nav-hover:       rgba(255, 255, 255, 0.05);
  --nav-active:      rgba(96, 165, 250, 0.14);
  --nav-active-text: #93c5fd;

  --gradient-brand:  linear-gradient(135deg, #3b82f6 0%, #6366f1 50%, #a855f7 100%);
  --gradient-surface: linear-gradient(180deg, rgba(18,20,28,.98) 0%, rgba(18,20,28,.92) 100%);
  --gradient-mesh:     radial-gradient(ellipse 80% 60% at 10% -10%, rgba(59,130,246,.12), transparent 55%),
                       radial-gradient(ellipse 60% 50% at 100% 0%, rgba(139,92,246,.08), transparent 50%);

  --shadow-xs:   0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow:      0 8px 30px rgba(0, 0, 0, 0.35);
  --shadow-md:   0 16px 48px rgba(0, 0, 0, 0.45);
  --shadow-lg:   0 28px 70px rgba(0, 0, 0, 0.55);

  --log-bg:      #050608;
  --log-text:    #94a3b8;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  background-image: var(--gradient-mesh);
  color: var(--text);
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

.text-muted { color: var(--text-muted); }

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }

/* ===== APP SHELL ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 150;
  backdrop-filter: blur(3px);
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform var(--transition), background var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--gradient-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.sidebar-brand-name {
  display: block;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-brand-tag {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 8px 12px 6px;
  opacity: 0.85;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  transition: all var(--transition);
  text-decoration: none;
  margin-bottom: 2px;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--nav-hover);
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  background: var(--nav-active);
  color: var(--nav-active-text);
  border-color: rgba(37, 99, 235, 0.15);
  box-shadow: var(--shadow-xs);
}

[data-theme="dark"] .nav-item.active {
  border-color: rgba(96, 165, 250, 0.2);
}

.nav-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  transition: background var(--transition);
}

.nav-item.active .nav-icon {
  background: var(--primary-soft);
}

.nav-label { flex: 1; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.nav-logout { color: var(--danger-text) !important; }
.nav-logout:hover { background: var(--danger-soft) !important; color: var(--danger) !important; }

/* ===== MAIN ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  min-height: var(--topbar-h);
  background: var(--gradient-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.topbar-titles { min-width: 0; }

.page-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.25;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-card);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  transition: background var(--transition);
}

.sidebar-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: var(--transition);
}

.sidebar-toggle:hover { background: var(--nav-hover); }

.theme-toggle {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}

.theme-toggle:hover {
  background: var(--nav-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.content-body {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
}

/* ===== PAGE LAYOUTS ===== */
.page-grid {
  display: grid;
  gap: 24px;
}

.page-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.page-grid-split {
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  align-items: start;
}

.settings-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.settings-layout .card--wide { grid-column: 1 / -1; }

/* ===== SETTINGS TABS PAGE ===== */
.settings-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-tabs {
  position: relative;
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  scrollbar-width: none;
}

.settings-tabs::-webkit-scrollbar { display: none; }

.settings-tab {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.25s ease;
  white-space: nowrap;
}

.settings-tab:hover {
  color: var(--text);
}

.settings-tab.active {
  color: var(--primary);
}

.settings-tab-icon {
  font-size: 16px;
  line-height: 1;
}

.settings-tab-indicator {
  position: absolute;
  left: 6px;
  bottom: 6px;
  top: 6px;
  height: auto;
  background: var(--primary-soft);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: var(--radius-sm);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  z-index: 0;
}

[data-theme="dark"] .settings-tab-indicator {
  border-color: rgba(96, 165, 250, 0.25);
}

.settings-panels {
  position: relative;
  min-height: 320px;
}

.settings-panel {
  display: none;
  opacity: 0;
  transform: translateY(10px);
}

.settings-panel.active {
  display: block;
  animation: settingsPanelIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes settingsPanelIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.settings-panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.settings-panel-head {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-inset);
}

.settings-panel-head h3 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.settings-panel-head p {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.settings-form {
  padding: 22px 24px 24px;
}

/* Unified form controls inside settings */
.settings-form .field {
  padding: 0;
  margin-bottom: 16px;
}

.settings-form .field:first-of-type {
  margin-top: 0;
}

.settings-form .field label,
.settings-panel-card .field label {
  display: block;
  margin-bottom: 2px;
}

.settings-form input:not([type="hidden"]):not([type="checkbox"]):not([type="file"]):not([type="radio"]),
.settings-form textarea,
.settings-form select,
.settings-panel-card input:not([type="hidden"]):not([type="checkbox"]):not([type="file"]):not([type="radio"]),
.settings-panel-card textarea,
.settings-panel-card select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  font-family: inherit;
  width: 100%;
  line-height: 1.5;
  box-sizing: border-box;
}

.settings-form input:not([type="hidden"]):not([type="checkbox"]):not([type="file"]):not([type="radio"]):hover,
.settings-form textarea:hover,
.settings-form select:hover,
.settings-panel-card input:not([type="hidden"]):not([type="checkbox"]):not([type="file"]):not([type="radio"]):hover,
.settings-panel-card textarea:hover,
.settings-panel-card select:hover {
  border-color: var(--border-strong);
}

.settings-form input:not([type="hidden"]):not([type="checkbox"]):not([type="file"]):not([type="radio"]):focus,
.settings-form textarea:focus,
.settings-form select:focus,
.settings-panel-card input:not([type="hidden"]):not([type="checkbox"]):not([type="file"]):not([type="radio"]):focus,
.settings-panel-card textarea:focus,
.settings-panel-card select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  background: var(--bg-card);
}

.settings-form input[readonly],
.settings-panel-card input[readonly] {
  cursor: default;
  background: var(--bg-muted);
  color: var(--text-muted);
  border-style: dashed;
}

.settings-form select,
.settings-panel-card select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-input);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}

.settings-form textarea,
.settings-panel-card textarea {
  resize: vertical;
  min-height: 88px;
}

.settings-form textarea.welcome-text,
.settings-form .welcome-sec-text {
  min-height: 140px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.65;
}

.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.settings-form-footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.settings-info-box {
  padding: 14px 16px;
  background: var(--primary-soft);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 8px;
}

.settings-info-box code {
  font-size: 11px;
  word-break: break-all;
}

.settings-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.settings-filters-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.settings-panel-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

@media (max-width: 768px) {
  .settings-form-grid { grid-template-columns: 1fr; }
  .settings-tab-label { font-size: 12px; }
  .settings-tab { min-width: 100px; padding: 10px 12px; }
}

@media (max-width: 480px) {
  .settings-tab-label { display: none; }
  .settings-tab { min-width: 52px; }
}

/* ===== CARD ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
  background: var(--bg-inset);
}

.card-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.card-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.card-note {
  padding: 14px 22px;
  background: var(--primary-soft);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.65;
}

.card-body { padding: 22px; }

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.stat-card-premium {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card-premium::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--stat-accent, var(--gradient-brand));
  opacity: 0.9;
}

.stat-card-premium:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.stat-card-premium--blue  { --stat-accent: linear-gradient(90deg, #2563eb, #60a5fa); }
.stat-card-premium--green { --stat-accent: linear-gradient(90deg, #16a34a, #4ade80); }
.stat-card-premium--red   { --stat-accent: linear-gradient(90deg, #dc2626, #f87171); }
.stat-card-premium--violet { --stat-accent: linear-gradient(90deg, #6366f1, #a78bfa); }

.stat-card-premium-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-card-premium-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
}

.stat-card-premium-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 6px;
}

/* legacy stat */
.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
}
.stat-icon { font-size: 32px; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; font-weight: 600; }

/* ===== TABLE ===== */
.table-wrap {
  overflow-x: auto;
  border-radius: 0 0 var(--radius) var(--radius);
}

.tbl {
  width: 100%;
  border-collapse: collapse;
}

.tbl th, .tbl td {
  padding: 14px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

.tbl th {
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-inset);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.tbl tbody tr {
  transition: background var(--transition);
}

.tbl tbody tr:hover td { background: var(--nav-hover); }
.tbl tr:last-child td { border-bottom: none; }

.text-trunc { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nowrap { white-space: nowrap; }
.empty-row { text-align: center; color: var(--text-muted); padding: 48px 24px !important; font-weight: 500; }
.actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

code {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-code);
  font-family: ui-monospace, 'Cascadia Code', monospace;
}

.error-hint {
  color: var(--danger-text);
  font-size: 12px;
  margin-top: 4px;
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.badge-green  { background: var(--success-soft); color: var(--success-text); }
.badge-red    { background: var(--danger-soft);  color: var(--danger-text); }
.badge-gray   { background: var(--bg-muted); color: var(--text-muted); border: 1px solid var(--border); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--gradient-brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.4);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.25);
}

.btn-danger:hover { color: #fff; }

.btn-ghost {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.btn-ghost:hover {
  background: var(--nav-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-full { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: var(--radius-xs); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; padding: 18px 22px; }

.btn-run {
  background: var(--primary-soft);
  border: 1px solid rgba(37, 99, 235, 0.25);
  color: var(--primary);
  font-weight: 700;
}

[data-theme="dark"] .btn-run {
  border-color: rgba(96, 165, 250, 0.3);
  color: var(--primary);
}

.btn-run:hover { background: rgba(37, 99, 235, 0.18); color: var(--primary); }

/* ===== FORMS ===== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 22px;
  margin-bottom: 18px;
}

.field:first-of-type { margin-top: 20px; }

label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input[type=text],
input[type=password],
input[type=number],
input[type=email],
input[type=url],
input[type=search],
input[type=tel],
textarea,
select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  font-family: inherit;
  width: 100%;
  line-height: 1.5;
  box-sizing: border-box;
}

input:hover, textarea:hover, select:hover {
  border-color: var(--border-strong);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  background: var(--bg-card);
}

input[readonly] {
  cursor: default;
  background: var(--bg-muted);
  color: var(--text-muted);
  border-style: dashed;
}

select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}

textarea { resize: vertical; min-height: 88px; }

small {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
  font-weight: 500;
}

.input-copy-wrap {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-copy-wrap input { flex: 1; }
.btn-copy { flex-shrink: 0; }

.form-inline { display: flex; flex-direction: column; }
.form-inline .btn { margin: 0 22px 22px; align-self: flex-start; }

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 18px 22px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
  background: var(--bg-inset);
}

.form-row-inline {
  display: flex;
  gap: 12px;
  padding: 18px 22px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.form-row-inline .field {
  flex: 1;
  min-width: 220px;
  margin: 0;
  padding: 0;
}

/* ===== ALERTS ===== */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  line-height: 1.5;
}

.alert-success {
  background: var(--success-soft);
  border-color: rgba(22, 163, 74, 0.25);
  color: var(--success-text);
}

.alert-error {
  background: var(--danger-soft);
  border-color: rgba(220, 38, 38, 0.25);
  color: var(--danger-text);
}

.alert-warning {
  background: var(--warning-soft);
  border-color: rgba(217, 119, 6, 0.25);
  color: var(--warning-text);
}

/* ===== TABS & PAGINATION ===== */
.filter-tabs { display: flex; gap: 8px; flex-wrap: wrap; }

.tab {
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all var(--transition);
  text-decoration: none;
}

.tab:hover {
  background: var(--nav-hover);
  color: var(--text);
  text-decoration: none;
}

.tab.active {
  background: var(--gradient-brand);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.pagination {
  display: flex;
  gap: 6px;
  padding: 18px;
  justify-content: center;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  background: var(--bg-inset);
}

.page-btn {
  min-width: 36px;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: all var(--transition);
}

.page-btn:hover {
  background: var(--nav-hover);
  text-decoration: none;
  color: var(--text);
}

.page-btn.active {
  background: var(--gradient-brand);
  color: #fff;
  border-color: transparent;
}

/* ===== LOGIN ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
  background-image: var(--gradient-mesh);
  position: relative;
}

.login-theme {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10;
}

.login-wrap {
  width: 100%;
  max-width: 420px;
}

.login-card {
  padding: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  padding: 40px 28px 28px;
  background: var(--gradient-brand);
  color: #fff;
}

.login-logo .login-brand-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: rgba(255,255,255,.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  backdrop-filter: blur(8px);
}

.login-logo h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.login-logo p {
  color: rgba(255,255,255,.82);
  margin-top: 6px;
  font-size: 14px;
  font-weight: 500;
}

.login-form { padding: 28px; }
.login-form .field { padding: 0; margin-bottom: 16px; }
.login-form .field:first-of-type { margin-top: 0; }
.login-form .btn { margin-top: 8px; }
.login-card .alert { margin: 0 28px 0; }

/* ===== CHANNELS / SOURCES ===== */
.sources-page { display: flex; flex-direction: column; gap: 24px; }

.sources-page-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.sources-page-count {
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  box-shadow: var(--shadow);
}

.sources-page-count span:first-child {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  letter-spacing: -0.03em;
}

.sources-add-inner {
  display: flex;
  gap: 20px;
  padding: 22px;
}

.sources-add-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  color: #fff;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3);
}

.sources-add-body { flex: 1; min-width: 0; }

.sources-add-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.sources-add-hint {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
  font-weight: 500;
}

.sources-add-field { margin-top: 0 !important; padding: 0 !important; }
.sources-add-extra { margin-top: 16px; }

.sources-add-note {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
}

.input-with-btn {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-with-btn input { flex: 1; }

.channel-check-result { margin: 14px 0 0; }

.check-card {
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.65;
  background: var(--bg-inset);
}

.check-ok    { background: var(--success-soft); border-color: rgba(22,163,74,.25); }
.check-warn  { background: var(--warning-soft); border-color: rgba(217,119,6,.25); }
.check-error { background: var(--danger-soft);  border-color: rgba(220,38,38,.25); }
.check-loading { background: var(--bg-muted); color: var(--text-muted); }

.check-title { font-weight: 700; margin-bottom: 8px; color: var(--text); }
.check-meta  { color: var(--text-muted); margin-bottom: 4px; font-size: 12px; }
.check-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.check-preview-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.check-preview-avatar { width: 44px; height: 44px; flex-shrink: 0; }
.check-preview-text { flex: 1; min-width: 0; }

.channel-toast {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 3000;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  max-width: 380px;
  animation: toastIn .25s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.channel-toast-success {
  background: var(--gradient-brand);
  color: #fff;
}

.channel-toast-error {
  background: var(--danger);
  color: #fff;
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.source-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: all var(--transition);
}

.source-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: var(--border-strong);
}

.source-card--inactive { opacity: .72; }
.source-card--inactive .source-card-title { color: var(--text-muted); }

.source-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.source-avatar {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--gradient-brand);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.source-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.source-avatar.has-img img { display: block; }
.source-avatar.has-img .source-avatar-fallback { display: none; }

.source-avatar-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: #fff;
  user-select: none;
}

.source-card-head { flex: 1; min-width: 0; padding-top: 2px; }

.source-card-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.source-card-handle {
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.source-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
}

.source-switch input { opacity: 0; width: 0; height: 0; }

.source-switch-slider {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: 26px;
  transition: background var(--transition);
}

.source-switch-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: var(--shadow-xs);
}

.source-switch input:checked + .source-switch-slider {
  background: var(--success);
}

.source-switch input:checked + .source-switch-slider::before {
  transform: translateX(18px);
}

.source-card-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.source-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
  background: var(--bg-inset);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.source-stat-label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  margin-bottom: 3px;
}

.source-stat-value { font-size: 13px; font-weight: 700; }

.source-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.source-card-actions .btn-run { flex: 1; min-width: 100px; }

.sources-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 28px;
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}

.sources-empty-icon { font-size: 44px; margin-bottom: 14px; opacity: .65; }
.sources-empty h3 { font-size: 17px; color: var(--text); margin-bottom: 8px; font-weight: 800; }
.sources-empty p { font-size: 13px; max-width: 340px; font-weight: 500; }

.source-card-add {
  opacity: 0.55;
  border: 2px dashed var(--border-strong);
  background: var(--bg-inset);
  box-shadow: none;
  cursor: pointer;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  font-family: inherit;
  text-align: center;
  transition: opacity var(--transition), border-color var(--transition), background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.source-card-add:hover {
  opacity: 0.92;
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.source-card-add-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.source-card-add-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 300;
  line-height: 1;
  color: var(--primary);
  background: var(--bg-card);
  transition: inherit;
}

.source-card-add:hover .source-card-add-icon {
  border-color: var(--primary);
  transform: scale(1.05);
}

.source-card-add-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.source-card-add:hover .source-card-add-label {
  color: var(--primary);
}

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(8px);
}

.modal-overlay.active { display: flex; }

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  animation: modalIn .22s cubic-bezier(.4,0,.2,1);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-card-wide { max-width: 540px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-16px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-inset);
  position: sticky;
  top: 0;
  z-index: 1;
}

.modal-header h3 { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; }

.modal-close {
  width: 34px;
  height: 34px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 16px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover { background: var(--nav-hover); color: var(--text); }

.modal-body { padding: 22px; }

.modal-channel-name {
  font-weight: 800;
  font-size: 15px;
  color: var(--primary);
  margin-bottom: 14px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg-inset);
  position: sticky;
  bottom: 0;
}

.edit-modal-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  margin-bottom: 18px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.edit-modal-preview .source-avatar { width: 56px; height: 56px; }
.edit-modal-subtitle { font-weight: 800; font-size: 15px; margin-bottom: 2px; }
.edit-modal-meta { font-size: 12px; color: var(--text-muted); font-weight: 600; }

.edit-reset-block {
  margin-top: 8px;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
}

.edit-reset-block p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 12px;
}

.edit-reset-btn {
  border-color: var(--danger) !important;
  color: var(--danger-text) !important;
}

.run-result {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.7;
  margin-top: 12px;
  border: 1px solid var(--border);
}

.run-loading { background: var(--bg-muted); color: var(--text-muted); }
.run-success { background: var(--success-soft); border-color: rgba(22,163,74,.25); }
.run-error   { background: var(--danger-soft); border-color: rgba(220,38,38,.25); color: var(--danger-text); }

.run-log {
  margin-top: 10px;
  background: var(--log-bg);
  color: var(--log-text);
  font-size: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  white-space: pre-wrap;
  max-height: 140px;
  overflow-y: auto;
  font-family: ui-monospace, monospace;
}

.run-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== LOGS ===== */
.log-terminal {
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

.log-error { color: #f87171; }
.log-warn  { color: #fbbf24; }
.log-ok    { color: #4ade80; }
.log-head  { color: #60a5fa; font-weight: 700; }

.cron-log {
  background: var(--log-bg);
  color: var(--log-text);
  font-family: ui-monospace, 'Cascadia Code', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.65;
  padding: 20px 22px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 520px;
  overflow-y: auto;
  margin: 0;
  border-top: 1px solid var(--border);
}

.log-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.log-toolbar select {
  width: auto;
  min-width: 130px;
  padding: 8px 32px 8px 12px;
  font-size: 13px;
}

/* ===== SETTINGS ===== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0 24px;
}

.settings-grid-checks { grid-template-columns: 1fr; }

.webhook-info { padding: 0; }
.webhook-info .field { margin-top: 18px; }
.webhook-info .alert { margin: 0 22px 12px; }

/* ===== HTML TOOLBAR ===== */
.html-toolbar {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.html-btn {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-card);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.html-btn:hover { background: var(--nav-hover); border-color: var(--border-strong); }

.html-preview-wrap {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.html-preview-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 3px;
  white-space: nowrap;
  color: var(--text-muted);
}

.html-preview {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  flex: 1;
  min-height: 32px;
  word-break: break-word;
  white-space: pre-wrap;
}

/* ===== REPLACEMENTS PAGE ===== */
.rules-page {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.rules-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.rules-page-count {
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  box-shadow: var(--shadow);
}

.rules-page-count span:first-child {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  letter-spacing: -0.03em;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.rule-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: all var(--transition);
}

.rule-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.rule-card--inactive {
  opacity: 0.68;
}

.rule-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.rule-priority {
  min-width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gradient-brand);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.rule-card-head {
  flex: 1;
  min-width: 0;
}

.rule-card-type {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.rule-type-icon { font-size: 14px; }

.rule-card-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rule-toggle-form { flex-shrink: 0; margin: 0; }

.rule-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: stretch;
  padding: 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.rule-flow-block {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rule-flow-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.rule-flow-code {
  display: block;
  font-size: 11px;
  word-break: break-all;
  white-space: pre-wrap;
  line-height: 1.45;
  max-height: 64px;
  overflow: hidden;
}

.rule-flow-delete {
  font-size: 12px;
  font-weight: 700;
  color: var(--danger-text);
}

.rule-flow-arrow {
  display: flex;
  align-items: center;
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
  padding-top: 16px;
}

.rule-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.rule-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.rule-card-actions form { margin: 0; display: inline; }

.rule-card-add {
  opacity: 0.55;
  border: 2px dashed var(--border-strong);
  background: var(--bg-inset);
  box-shadow: none;
  cursor: pointer;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  text-align: center;
  padding: 18px;
  transition: opacity var(--transition), border-color var(--transition), background var(--transition), transform var(--transition);
}

.rule-card-add:hover {
  opacity: 0.92;
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-2px);
}

.rule-card-add-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.rule-card-add-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 300;
  color: var(--primary);
  background: var(--bg-card);
}

.rule-card-add-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.rule-card-add:hover .rule-card-add-label { color: var(--primary); }

.rules-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 56px 28px;
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  margin-top: 16px;
}

.rules-empty-icon { font-size: 42px; margin-bottom: 12px; opacity: 0.65; }
.rules-empty h3 { font-size: 17px; color: var(--text); margin-bottom: 8px; font-weight: 800; }
.rules-empty p { font-size: 13px; max-width: 360px; margin-bottom: 16px; font-weight: 500; }

.rule-form-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.type-hint {
  color: var(--primary);
  margin-top: 6px;
  font-weight: 600;
  display: block;
}

.type-example {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 4px;
  display: block;
}

.rule-row {
  display: flex;
  gap: 16px;
  padding: 0 22px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.type-examples { display: none; }

.priority-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  font-weight: 800;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-muted);
  border: 1px solid var(--border);
}

.row-disabled td { opacity: 0.45; }

@media (max-width: 768px) {
  .rules-grid { grid-template-columns: 1fr; }
  .rule-flow { grid-template-columns: 1fr; }
  .rule-flow-arrow {
    padding: 0;
    justify-content: center;
    transform: rotate(90deg);
  }
}

/* legacy replacements */

/* ===== TEST PARSE ===== */
.test-post {
  border-bottom: 1px solid var(--border);
  padding: 20px 22px;
  transition: background var(--transition);
}

.test-post:hover { background: var(--nav-hover); }
.test-post:last-child { border-bottom: none; }

.test-post-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.test-post-media { margin-bottom: 12px; }
.test-post-gallery { display: flex; gap: 10px; flex-wrap: wrap; }

.test-post-gallery img {
  max-width: 160px;
  max-height: 120px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border);
}

.test-post-cols {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: start;
}

.test-post-arrow {
  font-size: 22px;
  color: var(--primary);
  padding-top: 28px;
  font-weight: 800;
}

.test-post-col-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.test-pre {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  font-family: ui-monospace, monospace;
  margin: 0;
  max-height: 220px;
  overflow-y: auto;
}

.test-pre-final {
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--primary-soft);
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
}

.toggle-label input[type=checkbox] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

.text-danger { color: var(--danger-text); }

/* ===== DASHBOARD ===== */
.dash {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.dash-hero {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.dash-hero-glow {
  position: absolute;
  inset: 0;
  background: var(--gradient-brand);
  opacity: 0.07;
  pointer-events: none;
}

.dash-hero-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 30px;
  flex-wrap: wrap;
}

.dash-eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 8px;
}

.dash-hero-title {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 8px;
}

.dash-hero-desc {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.6;
  max-width: 620px;
}

.dash-hero-desc code {
  font-size: 12px;
}

.dash-hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.dash-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.dash-metric {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dash-metric--accent {
  border-color: rgba(37, 99, 235, 0.25);
  background: linear-gradient(180deg, var(--primary-soft), var(--bg-card));
}

.dash-metric-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.dash-metric-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--text);
}

.dash-metric-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: start;
}

.dash-feed-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.dash-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-inset);
}

.dash-section-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.dash-section-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

.dash-feed {
  display: flex;
  flex-direction: column;
}

.dash-post-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.dash-post-card:last-child { border-bottom: none; }
.dash-post-card:hover { background: var(--nav-hover); }

.dash-post-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.dash-post-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.dash-post-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.dash-post-source {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}

.dash-post-dot { color: var(--text-muted); }
.dash-post-time { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.dash-post-excerpt {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  font-weight: 500;
}

.dash-post-excerpt--muted { font-style: italic; opacity: 0.85; }

.dash-post-error {
  margin-top: 6px;
  font-size: 12px;
  color: var(--danger-text);
  line-height: 1.4;
}

.dash-post-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  min-width: 96px;
}

.btn-preview {
  background: var(--primary-soft);
  border: 1px solid rgba(37, 99, 235, 0.25);
  color: var(--primary);
  font-weight: 700;
}

[data-theme="dark"] .btn-preview {
  border-color: rgba(96, 165, 250, 0.3);
}

.btn-preview:hover {
  background: rgba(37, 99, 235, 0.18);
  color: var(--primary);
}

.dash-feed-empty {
  text-align: center;
  padding: 56px 28px;
  color: var(--text-muted);
}

.dash-feed-empty-icon { font-size: 42px; margin-bottom: 12px; opacity: 0.7; }
.dash-feed-empty h4 { color: var(--text); font-size: 17px; margin-bottom: 8px; font-weight: 800; }
.dash-feed-empty p { margin-bottom: 16px; font-size: 13px; }

.dash-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dash-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.dash-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.dash-panel-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}

.dash-panel-head .dash-panel-title { margin-bottom: 0; }

.dash-panel-empty {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.dash-panel-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}

.dash-quick-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dash-quick-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-inset);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition);
}

.dash-quick-link:hover {
  background: var(--nav-hover);
  border-color: var(--border-strong);
  color: var(--text);
  text-decoration: none;
  transform: translateX(2px);
}

.dash-quick-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.dash-channel-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dash-channel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.dash-channel-item:last-child { border-bottom: none; padding-bottom: 0; }

.dash-channel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
}

.dash-channel-dot.is-active { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }

.dash-channel-info {
  flex: 1;
  min-width: 0;
}

.dash-channel-name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-channel-id {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-summary-rows { display: flex; flex-direction: column; gap: 10px; }

.dash-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}

.dash-summary-row:last-child { border-bottom: none; }
.dash-summary-row strong { color: var(--text); font-size: 15px; font-weight: 800; }

/* Post preview modal */
.modal-card-preview { max-width: 560px; }

.post-preview-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

.tg-preview-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0 16px;
}

.tg-preview-bubble {
  width: 100%;
  max-width: 100%;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  word-break: break-word;
  box-shadow: var(--shadow-xs);
}

.tg-preview-bubble a {
  color: var(--primary);
  text-decoration: underline;
}

.tg-preview-bubble b, .tg-preview-bubble strong { font-weight: 800; }
.tg-preview-bubble code {
  background: var(--bg-muted);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.tg-preview-bubble pre {
  background: var(--log-bg);
  color: var(--log-text);
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  overflow-x: auto;
  font-size: 12px;
  margin-top: 8px;
}

.tg-preview-bubble tg-spoiler,
.tg-preview-bubble .tg-spoiler {
  background: var(--border-strong);
  border-radius: 4px;
  padding: 0 4px;
}

.post-preview-plain {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.post-preview-plain-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.post-preview-plain p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.post-preview-error {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid rgba(220, 38, 38, 0.25);
  color: var(--danger-text);
  font-size: 13px;
  line-height: 1.5;
}

/* ===== POSTS HISTORY ===== */
.posts-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.posts-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.posts-page-count {
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  box-shadow: var(--shadow);
}

.posts-page-count span:first-child {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  letter-spacing: -0.03em;
}

.posts-feed-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.posts-feed {
  display: flex;
  flex-direction: column;
}

.post-history-card {
  display: grid;
  grid-template-columns: auto 44px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.post-history-card:last-child { border-bottom: none; }
.post-history-card:hover { background: var(--nav-hover); }

.post-history-id {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding-top: 14px;
  min-width: 36px;
}

.post-history-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.post-history-card--error .post-history-avatar {
  background: linear-gradient(135deg, #dc2626, #f87171);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.post-history-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.post-history-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.post-history-source {
  font-weight: 700;
  font-size: 13px;
}

.post-history-dot { color: var(--text-muted); }

.post-history-time {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.post-history-excerpt {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  font-weight: 500;
}

.post-history-excerpt--muted { font-style: italic; opacity: 0.85; }

.post-history-error {
  margin-top: 6px;
  font-size: 12px;
  color: var(--danger-text);
  line-height: 1.45;
}

.post-history-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 96px;
  padding-top: 4px;
}

.posts-empty {
  text-align: center;
  padding: 64px 28px;
  color: var(--text-muted);
}

.posts-empty-icon { font-size: 42px; margin-bottom: 12px; opacity: 0.65; }
.posts-empty h3 { font-size: 17px; color: var(--text); margin-bottom: 8px; font-weight: 800; }
.posts-empty p { font-size: 13px; max-width: 360px; margin: 0 auto; font-weight: 500; }

@media (max-width: 768px) {
  .post-history-card {
    grid-template-columns: 44px minmax(0, 1fr);
  }
  .post-history-id { display: none; }
  .post-history-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    min-width: 0;
  }
  .post-history-actions .btn { flex: 1; }
  .posts-page-header { flex-direction: column; align-items: stretch; }
  .filter-tabs { justify-content: center; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-layout { grid-template-columns: 1fr; }
  .page-grid-2 { grid-template-columns: 1fr; }
  .dash-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }

  .main-content { margin-left: 0; }
  .sidebar-toggle { display: flex; }

  .content-body { padding: 20px 16px; }
  .topbar { padding: 0 16px; min-height: 64px; }

  .page-grid-split { grid-template-columns: 1fr; }
  .test-post-cols { grid-template-columns: 1fr; }
  .test-post-arrow { display: none; }
}

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr; }
  .dash-metrics { grid-template-columns: 1fr; }
  .dash-post-card { grid-template-columns: 40px minmax(0, 1fr); }
  .dash-post-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    min-width: 0;
  }
  .dash-post-actions .btn { flex: 1; }
  .dash-hero-inner { padding: 22px 18px; }
  .dash-hero-actions { width: 100%; }
  .dash-hero-actions .btn { flex: 1; }
  .sources-add-inner { flex-direction: column; }
  .sources-grid { grid-template-columns: 1fr; }
  .sources-page-header { justify-content: stretch; }
  .sources-page-count { justify-content: center; width: 100%; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn { width: 100%; }
  .modal-footer { flex-direction: column; }
  .modal-footer .btn { width: 100%; }
}

/* ===== WELCOME SETTINGS ===== */
.welcome-enabled-toggle {
  margin-bottom: 20px;
  padding: 14px 16px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.welcome-form .settings-panel-card {
  padding-bottom: 4px;
}

.welcome-form .settings-panel-card > :not(.settings-panel-head) {
  padding-left: 24px;
  padding-right: 24px;
}

.welcome-form .settings-panel-card > :last-child {
  padding-bottom: 22px;
}

.welcome-form .settings-panel-head + .welcome-enabled-toggle {
  margin-top: 20px;
}

.welcome-form .settings-panel-card + .settings-panel-card {
  margin-top: 18px;
}

.welcome-form .settings-info-box {
  margin-top: 18px;
}

.welcome-form .field small {
  display: block;
  margin-top: 6px;
}

.welcome-lang-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.welcome-lang-tab {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.welcome-lang-tab:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.welcome-lang-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.welcome-lang-panels { position: relative; }

.welcome-lang-panel {
  display: none;
  animation: settingsPanelIn 0.25s ease;
}

.welcome-lang-panel.active { display: block; }

.welcome-media-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  align-items: start;
  margin-top: 8px;
}

@media (max-width: 640px) {
  .welcome-media-row { grid-template-columns: 1fr; }
}

.welcome-media-input-wrap {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.welcome-media-input-wrap input[type="url"],
.welcome-media-input-wrap input[type="text"] {
  flex: 1;
  min-width: 0;
}

.welcome-upload-btn {
  position: relative;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.welcome-upload-btn input { display: none; }

.welcome-buttons-card { margin-top: 18px; }

.welcome-buttons-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.welcome-btn-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  background: var(--bg-inset);
  transition: border-color var(--transition);
}

.welcome-btn-card .field {
  padding: 0;
  margin-bottom: 0;
  gap: 6px;
}

.welcome-btn-card input,
.welcome-btn-card select,
.welcome-btn-card textarea {
  background: var(--bg-card);
}

.welcome-btn-card textarea {
  min-height: 120px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

.welcome-btn-card:hover { border-color: var(--border-strong); }

.welcome-btn-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.welcome-btn-type-badge {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.welcome-btn-card-actions {
  display: flex;
  gap: 4px;
}

.welcome-btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
}

@media (max-width: 768px) {
  .welcome-btn-grid { grid-template-columns: 1fr; }
}

.welcome-section-body {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.welcome-section-lang-panel {
  display: none;
  margin-top: 12px;
}

.welcome-section-lang-panel.active { display: block; }

.welcome-buttons-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.welcome-form .settings-form-footer {
  margin-top: 18px;
}

/* ===== BOT STATS PAGE ===== */
.bot-stats-page {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.bot-stats-metrics {
  margin: 0;
}

.bot-stats-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bot-stats-search {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.bot-stats-search input[type="search"] {
  flex: 1;
  min-width: 200px;
  max-width: 420px;
}

.bot-stats-note {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
}

.bot-users-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bot-user-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px 16px;
  align-items: center;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.bot-user-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.bot-user-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.bot-user-avatar-wrap { flex-shrink: 0; }

.bot-user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.bot-user-avatar--letter {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-soft), var(--bg-inset));
  color: var(--primary);
  font-weight: 800;
  font-size: 18px;
  border: 1px solid var(--border);
}

.bot-user-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.bot-user-names {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.bot-user-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.bot-user-username {
  font-size: 13px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.bot-user-username:hover { text-decoration: underline; }

.bot-user-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.bot-user-meta code {
  font-size: 11px;
}

.bot-user-dot { opacity: 0.5; }

.bot-user-side {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.bot-user-events-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.bot-user-open-hint {
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

.modal-card-bot-user { max-width: 560px; }

.modal-card-bot-user .modal-header {
  align-items: flex-start;
  gap: 12px;
}

.bot-user-modal-head { flex: 1; min-width: 0; }

.bot-user-modal-head-inner {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.bot-user-modal-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.bot-user-modal-head-text { min-width: 0; }

.bot-user-modal-names {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
}

.bot-user-modal-name {
  font-weight: 800;
  font-size: 16px;
}

.bot-user-modal-username {
  color: var(--primary);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}

.bot-user-modal-username:hover { text-decoration: underline; }

.bot-user-modal-ids,
.bot-user-modal-times {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.bot-user-events {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 420px;
  overflow-y: auto;
}

.bot-event-row {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.bot-event-row:last-child { border-bottom: none; }

.bot-event-icon {
  font-size: 18px;
  line-height: 1;
  margin-top: 2px;
}

.bot-event-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.bot-event-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.bot-user-events-empty,
.bot-user-events-loading {
  text-align: center;
  color: var(--text-muted);
  padding: 24px;
  font-size: 14px;
}

@media (max-width: 640px) {
  .bot-user-card {
    grid-template-columns: auto 1fr;
  }
  .bot-user-side {
    grid-column: 2;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }
}
