/* ==========================================================================
   SignalSync - Monochrome Minimalist & Dot Matrix (Dotted UI) Design System
   ========================================================================== */

:root {
  /* LIGHT THEME (Monochrome Minimalist) */
  --bg-page: #f8f9fa;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-sidebar-active: #09090b;
  --text-sidebar-active: #ffffff;
  --bg-input: #ffffff;
  --bg-pill-neutral: #f1f3f5;
  --dot-pattern: rgba(0, 0, 0, 0.07);

  --border-subtle: #e4e4e7;
  --border-card: #e4e4e7;
  --border-input: #d4d4d8;
  --border-focus: #18181b;

  --text-main: #09090b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --text-dim: #a1a1aa;

  --primary: #18181b;
  --primary-hover: #27272a;
  --primary-subtle: #f4f4f5;

  --success: #10b981;
  --success-subtle: #ecfdf5;
  --success-text: #059669;

  --paused: #f59e0b;
  --paused-subtle: #fffbeb;
  --paused-text: #b45309;

  --danger: #ef4444;
  --danger-subtle: #fef2f2;
  --danger-text: #dc2626;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.06), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] {
  /* DARK THEME (Monochrome Obsidian & Titanium) */
  --bg-page: #09090b;
  --bg-surface: #121215;
  --bg-surface-elevated: #18181b;
  --bg-sidebar: #0e0e11;
  --bg-sidebar-active: #ffffff;
  --text-sidebar-active: #09090b;
  --bg-input: #18181b;
  --bg-pill-neutral: #1f1f23;
  --dot-pattern: rgba(255, 255, 255, 0.06);

  --border-subtle: #27272a;
  --border-card: #27272a;
  --border-input: #3f3f46;
  --border-focus: #ffffff;

  --text-main: #fafafa;
  --text-secondary: #d4d4d8;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;

  --primary: #ffffff;
  --primary-hover: #f4f4f5;
  --primary-subtle: #27272a;

  --success: #10b981;
  --success-subtle: rgba(16, 185, 129, 0.12);
  --success-text: #34d399;

  --paused: #f59e0b;
  --paused-subtle: rgba(245, 158, 11, 0.12);
  --paused-text: #fbbf24;

  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.12);
  --danger-text: #f87171;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.6);
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.7), 0 8px 10px -6px rgba(0, 0, 0, 0.6);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  /* DOT MATRIX SUBTLE BACKGROUND GRID */
  background-image: radial-gradient(var(--dot-pattern) 1.25px, transparent 1.25px);
  background-size: 20px 20px;
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  transition: background-color 0.2s ease, color 0.2s ease;
  overflow-x: hidden;
}

/* Toast System */
.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 10000;
}
.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slide-in 0.25s ease-out;
}
@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.hidden { display: none !important; }

/* APP LAYOUT */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100vw;
}

/* ==========================================================================
   SIDEBAR (Monochrome Minimalist)
   ========================================================================== */
.sidebar {
  width: 255px;
  min-width: 255px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.25rem 1rem;
  z-index: 200;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.sidebar-header {
  margin-bottom: 1.5rem;
  padding: 0 0.25rem;
}

.brand-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-badge-square {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--text-main);
  color: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.brand-info {
  display: flex;
  flex-direction: column;
}
.brand-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
}
.brand-role {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  overflow-y: auto;
}

.nav-group-title {
  font-size: 0.675rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  padding: 0.65rem 0.75rem 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

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

.nav-item.active {
  background-color: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
}

.nav-icon {
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-label {
  flex: 1;
}

.nav-badge {
  font-size: 0.675rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-pill-neutral);
  color: var(--text-muted);
}
.nav-item.active .nav-badge {
  background: rgba(125, 125, 125, 0.25);
  color: inherit;
}

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

.user-profile-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.65rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--text-main);
  color: var(--bg-surface);
  font-size: 0.7rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-details {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.user-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}
.user-sub {
  font-size: 0.675rem;
  color: var(--text-dim);
  font-weight: 500;
}

/* ==========================================================================
   TOPBAR
   ========================================================================== */
.main-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 2rem;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.825rem;
}
.bc-root { color: var(--text-dim); font-weight: 500; }
.bc-sep { color: var(--text-dim); }
.bc-current { color: var(--text-main); font-weight: 700; }

.topbar-center {
  flex: 1;
  max-width: 420px;
  margin: 0 1.5rem;
}

.global-search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.85rem;
  transition: border-color 0.2s;
}
.global-search-box:focus-within {
  border-color: var(--border-focus);
}
.global-search-box input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 0.825rem;
  color: var(--text-main);
  width: 100%;
}
.search-icon { font-size: 0.85rem; color: var(--text-dim); }
.search-shortcut {
  font-size: 0.675rem;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--border-subtle);
  padding: 2px 5px;
  border-radius: 4px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.btn-topbar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-topbar:hover {
  border-color: var(--border-input);
  color: var(--text-main);
}
.btn-topbar .topbar-btn-text { font-size: 0.775rem; }

.live-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-main);
}
.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}
.live-dot.pulse {
  animation: live-pulse 2s infinite;
}
@keyframes live-pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 5px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ==========================================================================
   PAGE CONTENT & CARDS
   ========================================================================== */
.page-content {
  padding: 1.75rem 2rem 3rem;
  flex: 1;
}

.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fade-in 0.2s ease-out; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.content-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}
.page-subtitle {
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-chip {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
}

/* Cards */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

/* METRICS GRID */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 1200px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .metrics-grid { grid-template-columns: 1fr; }
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.metric-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.metric-trend {
  font-size: 0.675rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}
.metric-trend.green { background: var(--bg-pill-neutral); color: var(--text-secondary); }
.metric-trend.blue { background: var(--bg-pill-neutral); color: var(--text-secondary); }

.metric-body {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}
.metric-number {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

/* DOT MATRIX MICRO SPARKLINES */
.mini-sparkline {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 24px;
}
.mini-sparkline .bar {
  width: 5px;
  background: var(--text-main);
  border-radius: 1px;
  opacity: 0.9;
}
.bar.b1 { height: 35%; opacity: 0.3; }
.bar.b2 { height: 60%; opacity: 0.5; }
.bar.b3 { height: 45%; opacity: 0.4; }
.bar.b4 { height: 85%; opacity: 0.8; }
.bar.b5 { height: 100%; opacity: 1; }

.metric-footer {
  font-size: 0.725rem;
  color: var(--text-dim);
}

/* DASHBOARD CHARTS ROW (Dot Matrix Style) */
.dashboard-charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 1024px) {
  .dashboard-charts-grid { grid-template-columns: 1fr; }
}

.chart-card-pixel {
  padding: 1.25rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
}

.chart-header-pixel {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.chart-title-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.chart-title-line {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.chart-title-text {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.info-badge {
  font-size: 0.7rem;
  color: var(--text-dim);
  cursor: help;
}

.chart-meta-legend {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.775rem;
  color: var(--text-muted);
}
.chart-meta-legend strong {
  color: var(--text-main);
  font-size: 0.95rem;
}

.legend-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.725rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.pixel-dot {
  width: 8px;
  height: 8px;
  border-radius: 1.5px;
  display: inline-block;
}
.pixel-dot-primary { background: var(--text-main); }
.pixel-dot-secondary { background: #94a3b8; }
.pixel-dot-green { background: #10b981; }
.pixel-dot-red { background: #ef4444; }

/* Segmented Timeframe Switcher */
.timeframe-segmented {
  display: flex;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.tf-btn {
  background: transparent;
  border: none;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.3rem 0.65rem;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  transition: all 0.15s ease;
}
.tf-btn:hover { color: var(--text-main); }
.tf-btn.active {
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Canvas Wrappers */
.pixel-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 220px;
}
.pixel-canvas-wrapper.ring-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}
.pixel-canvas-wrapper canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Pixel Tooltip (Matching Image 2) */
.pixel-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.65rem 0.85rem;
  font-size: 0.75rem;
  color: var(--text-main);
  z-index: 100;
  transform: translate(-50%, -100%);
  margin-top: -10px;
  white-space: nowrap;
}
.pixel-tooltip .tt-date {
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.3rem;
  font-size: 0.775rem;
}
.pixel-tooltip .tt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  color: var(--text-secondary);
  font-size: 0.725rem;
  margin-top: 0.15rem;
}
.pixel-tooltip .tt-row strong {
  font-family: var(--font-mono);
  color: var(--text-main);
}

/* ==========================================================================
   DATA TABLE (Minimalist Monochrome)
   ========================================================================== */
.table-card {
  padding: 0;
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  gap: 1rem;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.badge-count {
  font-size: 0.725rem;
  font-weight: 700;
  background: var(--bg-pill-neutral);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 999px;
}

.toolbar-right .filter-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-select-sm {
  background-color: var(--bg-page);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  outline: none;
}
.form-select-sm:focus { border-color: var(--border-focus); }

.table-responsive { width: 100%; overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.825rem;
}

.data-table th {
  background-color: var(--bg-page);
  color: var(--text-dim);
  font-size: 0.675rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tr:hover td {
  background-color: rgba(0, 0, 0, 0.015);
}
[data-theme="dark"] .data-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

.data-table tr.row-paused td {
  background-color: rgba(245, 158, 11, 0.03);
}

/* Status Pill Badges with Colored Dots */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.725rem;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.pill-success {
  background: var(--success-subtle);
  color: var(--success-text);
  border-color: rgba(16, 185, 129, 0.2);
}
.pill-success .dot { background: var(--success); }

.pill-paused {
  background: var(--paused-subtle);
  color: var(--paused-text);
  border-color: rgba(245, 158, 11, 0.2);
}
.pill-paused .dot { background: var(--paused); }

.pill-danger {
  background: var(--danger-subtle);
  color: var(--danger-text);
  border-color: rgba(239, 68, 68, 0.2);
}
.pill-danger .dot { background: var(--danger); }

.pill-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
}
.pill-warning .dot { background: #d97706; }

.pill-neutral {
  background: var(--bg-pill-neutral);
  color: var(--text-secondary);
}

.code-font {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* Table Pagination Footer */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}
.pagination-info { font-size: 0.775rem; color: var(--text-muted); }
.pagination-buttons { display: flex; gap: 0.4rem; }

/* ==========================================================================
   BUTTONS & FORMS (Minimalist Monochrome)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.775rem; }

.btn-primary {
  background-color: var(--primary);
  color: var(--bg-surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}
[data-theme="dark"] .btn-primary {
  color: #09090b;
}

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

.btn-outline {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}
.btn-outline:hover {
  border-color: var(--border-input);
  color: var(--text-main);
}

.btn-outline-danger {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.25);
  color: var(--danger);
}
.btn-outline-danger:hover {
  background: var(--danger-subtle);
  border-color: var(--danger);
}

.btn-block { width: 100%; }

.btn-icon-ghost {
  background: transparent;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
}
.btn-icon-ghost:hover {
  background: var(--border-subtle);
  color: var(--text-main);
}

.btn-icon-soft {
  background: var(--bg-pill-neutral);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-main);
  transition: transform 0.15s;
}
.btn-icon-soft:hover { transform: scale(1.08); }

/* Form Elements */
.form-group { margin-bottom: 1.15rem; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  font-size: 0.85rem;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s;
}
.form-control:focus {
  border-color: var(--border-focus);
}

.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-secondary { color: var(--text-secondary); }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.py-5 { padding-top: 2.5rem; padding-bottom: 2.5rem; }
.text-center { text-align: center; }

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--border-input);
  transition: 0.25s;
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.25s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
input:checked + .slider {
  background-color: var(--text-main);
}
input:checked + .slider:before {
  transform: translateX(20px);
}
[data-theme="dark"] input:checked + .slider {
  background-color: #ffffff;
}
[data-theme="dark"] input:checked + .slider:before {
  background-color: #09090b;
}

.switch.switch-sm { width: 36px; height: 20px; }
.switch.switch-sm .slider:before { height: 14px; width: 14px; left: 3px; bottom: 3px; }
.switch.switch-sm input:checked + .slider:before { transform: translateX(16px); }

/* ==========================================================================
   LOGIN SCREEN
   ========================================================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-page);
  background-image: radial-gradient(var(--dot-pattern) 1.5px, transparent 1.5px);
  background-size: 24px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 390px;
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.login-theme-bar {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}
.login-brand .brand-badge-square {
  margin: 0 auto 1rem;
  width: 48px;
  height: 48px;
  font-size: 1.6rem;
}
.login-brand h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
}
.login-brand p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}
.input-with-icon .input-icon {
  position: absolute;
  left: 0.85rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.input-with-icon input {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem 0.65rem 2.4rem;
  font-size: 0.875rem;
  color: var(--text-main);
  outline: none;
}
.input-with-icon input:focus {
  border-color: var(--border-focus);
}

.error-msg {
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 1rem;
  background: var(--danger-subtle);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.login-footer {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 1.75rem;
}

/* ==========================================================================
   CHANNELS & BOTS GRID
   ========================================================================== */
.channels-grid, .bots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.channel-card, .bot-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s, border-color 0.15s;
}
.channel-card:hover, .bot-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-2px);
}
.channel-card.card-paused, .bot-card.card-paused {
  opacity: 0.7;
  background: var(--bg-page);
  border-style: dashed;
}

.channel-header, .bot-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.channel-title, .bot-title { font-size: 0.95rem; font-weight: 700; color: var(--text-main); }
.channel-slug, .bot-username { font-size: 0.75rem; color: var(--text-dim); font-family: var(--font-mono); }

.channel-meta-box, .bot-token {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.775rem;
  margin-bottom: 1rem;
}
.channel-chatid { font-family: var(--font-mono); color: var(--text-main); font-weight: 700; }

.channel-url-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  margin-bottom: 1rem;
}

.channel-footer, .bot-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   SIMULATOR & SETTINGS PANELS
   ========================================================================== */
.sim-card, .settings-card { padding: 1.75rem; }
.sim-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 900px) { .sim-grid { grid-template-columns: 1fr; } }
.sim-submit-row { display: flex; justify-content: flex-end; }
.sim-result-box {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}
.sim-result-box h4 { font-size: 0.85rem; font-weight: 700; margin-bottom: 0.5rem; }

.form-group-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}
.switch-title { font-size: 0.9rem; font-weight: 700; color: var(--text-main); }
.switch-desc { font-size: 0.775rem; color: var(--text-muted); margin-top: 2px; }

/* Analytics List */
.stats-rank-list { display: flex; flex-direction: column; gap: 0.75rem; }
.rank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  background: var(--bg-page);
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
}
.rank-item strong { color: var(--text-main); }

/* ==========================================================================
   GUIDE & LEGEND SECTION
   ========================================================================== */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1.25rem;
}
.guide-card { padding: 1.5rem; }
.guide-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}
.guide-card-header h3 { font-size: 1rem; font-weight: 700; color: var(--text-main); }
.guide-icon { font-size: 1.35rem; }

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}
.legend-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.legend-desc { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.45; }
.legend-desc strong { color: var(--text-main); }

.guide-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  font-size: 0.825rem;
  color: var(--text-secondary);
}
.guide-list strong { color: var(--text-main); }

.code-header {
  font-size: 0.775rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.code-snippet {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.775rem;
  color: var(--text-main);
  overflow-x: auto;
  line-height: 1.45;
}

.tip-item { margin-bottom: 0.85rem; }
.tip-item:last-child { margin-bottom: 0; }
.tip-title { font-size: 0.85rem; font-weight: 700; color: var(--paused-text); margin-bottom: 2px; }
.tip-desc { font-size: 0.775rem; color: var(--text-secondary); line-height: 1.45; }

.alert-box { padding: 0.75rem; border-radius: var(--radius-sm); font-size: 0.775rem; line-height: 1.45; }
.alert-info {
  background: var(--bg-pill-neutral);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

/* ==========================================================================
   MODAL WINDOWS
   ========================================================================== */
.modal {
  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: 999;
  padding: 1.5rem;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-pop 0.2s ease-out;
}
@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--text-main); }
.modal-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 1.5rem;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-page);
}

.json-viewer {
  max-height: 350px;
  font-size: 0.75rem;
}
