/* ================================================================
   SUPERBOT DASHBOARD — Operations Command Center
   ================================================================ */

/* ===== Variables — Dark Theme (Default) ===== */
:root {
  --bg-primary: #0c0c12;
  --bg-secondary: #13131c;
  --bg-card: #1a1a26;
  --bg-hover: #222232;
  --bg-input: #15151f;
  --border: #2a2a3c;
  --border-light: #35354a;
  --text-primary: #e8e8f2;
  --text-secondary: #8a8aa8;
  --text-muted: #555570;
  --accent: #7c6af6;
  --accent-hover: #8e7eff;
  --accent-glow: rgba(124, 106, 246, 0.25);
  --accent-subtle: rgba(124, 106, 246, 0.08);
  --success: #00d68f;
  --success-glow: rgba(0, 214, 143, 0.3);
  --warning: #ffc145;
  --danger: #ff6b6b;
  --info: #4fc3f7;
  --terminal-bg: #08080e;
  --sidebar-width: 230px;
  --topbar-height: 54px;
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.2s ease;
  --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.4);
  --shadow-accent: 0 4px 24px rgba(124, 106, 246, 0.15);
}

/* ===== Light Theme ===== */
html.light-theme {
  --bg-primary: #f2f2f8;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #eaeaf2;
  --bg-input: #f0f0f6;
  --border: #dddde6;
  --border-light: #ccccda;
  --text-primary: #1a1a30;
  --text-secondary: #5c5c78;
  --text-muted: #8888a0;
  --accent: #6c5ce7;
  --accent-hover: #5b4ad6;
  --accent-glow: rgba(108, 92, 231, 0.15);
  --accent-subtle: rgba(108, 92, 231, 0.06);
  --success: #00a87a;
  --success-glow: rgba(0, 168, 122, 0.2);
  --warning: #c89b10;
  --danger: #d44040;
  --info: #1a7fd4;
  --terminal-bg: #0c0c14;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.08);
  --shadow-accent: 0 4px 20px rgba(108, 92, 231, 0.08);
}

/* ===== Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { font-size: 14px; }

body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ===== Theme Transitions ===== */
body, .sidebar, .topbar, .footer, .card, .section,
.setup-screen, .setup-card, .modal, .side-panel,
.nav-item, input, select, textarea,
.conv-item, .conv-detail-header, .chat-bubble.lead,
.content, .main-wrapper, .dashboard {
  transition: background-color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease, color 0.25s ease;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ===== Keyframe Animations ===== */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 var(--success-glow); }
  50% { box-shadow: 0 0 0 5px transparent; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===== Setup Screen ===== */
.setup-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  background-image: radial-gradient(ellipse at 50% 20%, var(--accent-glow) 0%, transparent 55%);
  z-index: 1000;
}

.setup-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: fadeSlideUp 0.5s ease forwards;
}

html.light-theme .setup-card {
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border);
}

.setup-logo {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 6px;
  text-align: center;
  color: var(--accent);
  margin-bottom: 6px;
  text-shadow: 0 0 40px var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.setup-logo-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 50%;
  box-shadow: 0 0 20px var(--accent-glow);
}

.setup-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 0.9rem;
}

.setup-error {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.85rem;
  text-align: center;
}

/* ===== Dashboard Layout ===== */
.dashboard {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ===== Sidebar ===== */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--accent);
  text-shadow: 0 0 24px var(--accent-glow);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent-glow);
}

.sidebar-toggle { display: none; }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 22px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  position: relative;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-subtle);
  border-left-color: var(--accent);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 12px var(--accent-glow), 0 0 4px var(--accent);
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { opacity: 1; }

.nav-label { white-space: nowrap; }

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

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 99;
}

/* ===== Main Wrapper ===== */
.main-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ===== Topbar ===== */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.sidebar-open { display: none; }

.view-title {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.3px;
}

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

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-subtle);
  transform: rotate(20deg);
}

.theme-toggle svg {
  transition: transform 0.3s ease;
}

html:not(.light-theme) .icon-moon { display: none; }
html.light-theme .icon-sun { display: none; }

/* ===== Connection Indicator ===== */
.connection-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  animation: pulse-dot 2.5s ease-in-out infinite;
}

.dot.offline {
  background: var(--danger);
  animation: none;
}

.clock {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ===== Content ===== */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.content > * {
  animation: fadeSlideUp 0.35s ease both;
}
.content > *:nth-child(2) { animation-delay: 0.04s; }
.content > *:nth-child(3) { animation-delay: 0.08s; }
.content > *:nth-child(4) { animation-delay: 0.12s; }

/* ===== Footer ===== */
.footer {
  padding: 10px 24px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ===== Cards ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 22px 20px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-smooth);
  animation: fadeSlideUp 0.4s ease both;
  opacity: 0;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 55%;
  background: linear-gradient(180deg, var(--accent-subtle) 0%, transparent 100%);
  pointer-events: none;
  transition: opacity var(--transition-smooth);
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow-accent);
}

.cards-grid .card:nth-child(1) { animation-delay: 0.05s; }
.cards-grid .card:nth-child(2) { animation-delay: 0.10s; }
.cards-grid .card:nth-child(3) { animation-delay: 0.15s; }
.cards-grid .card:nth-child(4) { animation-delay: 0.20s; }
.cards-grid .card:nth-child(5) { animation-delay: 0.25s; }

.card-value {
  font-family: 'Outfit', sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.1;
  position: relative;
}

.card-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

html.light-theme .card {
  box-shadow: var(--shadow-sm);
}

/* ===== Section ===== */
.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.section-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  letter-spacing: 0.2px;
}

.section-body { padding: 0; }
.section-body.padded { padding: 20px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--accent-subtle);
}

td {
  padding: 12px 16px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  transition: background-color 0.15s ease;
}

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

tr:hover td {
  background: var(--bg-hover);
}

td.clickable {
  cursor: pointer;
  color: var(--accent);
  font-weight: 500;
}

td.clickable:hover { text-decoration: underline; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.badge-success { background: rgba(0, 214, 143, 0.12); color: var(--success); }
.badge-danger { background: rgba(255, 107, 107, 0.12); color: var(--danger); }
.badge-warning { background: rgba(255, 193, 69, 0.12); color: var(--warning); }
.badge-info { background: rgba(79, 195, 247, 0.12); color: var(--info); }
.badge-accent { background: rgba(124, 106, 246, 0.12); color: var(--accent); }
.badge-muted { background: rgba(136, 136, 168, 0.1); color: var(--text-secondary); }

html.light-theme .badge-success { background: rgba(0, 168, 122, 0.10); }
html.light-theme .badge-danger { background: rgba(212, 64, 64, 0.10); }
html.light-theme .badge-warning { background: rgba(200, 155, 16, 0.10); }
html.light-theme .badge-info { background: rgba(26, 127, 212, 0.10); }
html.light-theme .badge-accent { background: rgba(108, 92, 231, 0.10); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  border-color: var(--text-muted);
  background: var(--bg-hover);
}

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(255, 107, 107, 0.1);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 12px;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-block { width: 100%; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="search"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea { resize: vertical; min-height: 80px; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238a8aa8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 22px;
  transition: background var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

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

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

.form-row-label {
  font-size: 0.85rem;
}

.form-inline {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-inline .form-group { margin-bottom: 0; }

/* ===== Filters Bar ===== */
.filters-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filters-bar .form-group {
  margin-bottom: 0;
  min-width: 140px;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
}

.pagination .btn { min-width: 36px; }

.page-info {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0 8px;
}

/* ===== Activity Feed ===== */
.activity-list { list-style: none; }

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  align-items: flex-start;
  transition: background-color 0.15s ease;
}

.activity-item:hover { background: var(--bg-hover); }
.activity-item:last-child { border-bottom: none; }

.activity-time {
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  white-space: nowrap;
  min-width: 60px;
  padding-top: 2px;
}

.activity-account {
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.activity-text { color: var(--text-secondary); }

/* ===== Conversations ===== */
.conversations-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  height: calc(100vh - var(--topbar-height) - 80px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.conv-list {
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.conv-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.conv-item:hover, .conv-item.active {
  background: var(--bg-hover);
}

.conv-item.active {
  border-left: 3px solid var(--accent);
}

.conv-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.conv-username {
  font-weight: 600;
  font-size: 0.9rem;
}

.conv-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.conv-preview {
  font-size: 0.8rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-detail {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.conv-detail-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.conv-detail-name { font-weight: 600; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-bubble {
  max-width: 70%;
  padding: 11px 16px;
  border-radius: 16px;
  font-size: 0.85rem;
  line-height: 1.45;
  word-break: break-word;
}

.chat-bubble.bot {
  background: var(--accent);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.chat-bubble.lead {
  background: var(--bg-hover);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-meta {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
}

.chat-meta.right { text-align: right; }

.conv-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ===== Terminal / Monitor Section ===== */
#monitor-terminal {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace !important;
  background: var(--terminal-bg) !important;
  border-radius: 0 0 var(--radius) var(--radius) !important;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.4) !important;
  position: relative;
}

.section:has(#monitor-terminal) .section-header {
  background: #10101a;
  color: var(--text-secondary);
  border-bottom: 1px solid #1e1e2e;
  position: relative;
  padding-left: 65px;
}

.section:has(#monitor-terminal) .section-header::before {
  content: '';
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff5f57;
  box-shadow: 16px 0 0 #febc2e, 32px 0 0 #28c840;
}

html.light-theme .section:has(#monitor-terminal) .section-header {
  background: #10101a;
  color: #8a8aa8;
  border-bottom-color: #1e1e2e;
}

.section:has(#monitor-terminal) {
  border-color: #1e1e2e;
}

html.light-theme .section:has(#monitor-terminal) {
  border-color: #1e1e2e;
  box-shadow: var(--shadow-md);
}

html.light-theme #monitor-terminal {
  background: var(--terminal-bg) !important;
}

/* ===== Side Panel (Accounts) ===== */
.side-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(3px);
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  z-index: 201;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.3);
}

html.light-theme .side-panel {
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.1);
}

.side-panel-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1rem;
}

.side-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
}

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

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: modalScaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
}

.detail-row {
  display: flex;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

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

.detail-label {
  width: 120px;
  color: var(--text-secondary);
  flex-shrink: 0;
  font-weight: 500;
}

.detail-value { flex: 1; word-break: break-word; }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 14px 22px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  color: #fff;
  animation: toastSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  border-left: 4px solid;
}

.toast-success {
  background: rgba(0, 214, 143, 0.92);
  border-left-color: #00a870;
  backdrop-filter: blur(8px);
}

.toast-error {
  background: rgba(255, 107, 107, 0.92);
  border-left-color: #d44;
  backdrop-filter: blur(8px);
}

.toast-info {
  background: rgba(79, 195, 247, 0.92);
  color: #0c0c12;
  border-left-color: #1a7fd4;
  backdrop-filter: blur(8px);
}

/* ===== Checkbox ===== */
.checkbox-cell { width: 40px; text-align: center; }

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ===== Bulk Actions Bar ===== */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--accent-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.bulk-bar .count { color: var(--accent); font-weight: 700; }

/* ===== Loading ===== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state-text { font-size: 0.9rem; }

/* ===== Code (Light mode override for inline styles in JS) ===== */
html.light-theme code {
  background: var(--bg-hover) !important;
  color: var(--text-primary) !important;
}

code {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
}

/* ===== Monitor Account Items (JS-generated, enhance with CSS) ===== */
.monitor-account-item {
  transition: background-color 0.15s ease !important;
}

.monitor-account-item:hover {
  background: var(--bg-hover) !important;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: -260px;
    width: 260px;
    transition: left var(--transition);
  }

  .sidebar.open { left: 0; }
  .sidebar-overlay.open { display: block; }

  .sidebar-open {
    display: block;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
  }

  .conversations-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .conv-list {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 300px;
  }

  .chat-messages { min-height: 300px; }

  .side-panel { width: 100%; }

  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

  .filters-bar { flex-direction: column; align-items: stretch; }

  .topbar-right { gap: 10px; }
  .clock { display: none; }
}
