:root {
  --bg: #0a0814;
  --bg-2: #120c24;
  --card: rgba(20, 18, 38, 0.78);
  --card-solid: #151228;
  --border: rgba(139, 92, 246, 0.16);
  --border-strong: rgba(139, 92, 246, 0.32);
  --text: #f8f7ff;
  --muted: #8b85a7;
  --accent: #a78bfa;
  --accent-2: #7c3aed;
  --success: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  overflow-x: hidden;
}

.bg-stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 20%, rgba(124, 58, 237, 0.22) 0%, transparent 35%),
    radial-gradient(circle at 80% 10%, rgba(167, 139, 250, 0.14) 0%, transparent 30%),
    radial-gradient(circle at 50% 90%, rgba(124, 58, 237, 0.18) 0%, transparent 40%),
    var(--bg);
}

.bg-stars::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.12) 1px, transparent 1px),
    radial-gradient(circle, rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 40px 40px, 80px 80px;
  background-position: 0 0, 20px 60px;
  opacity: 0.5;
}

/* LOGIN */
.login {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-box {
  width: 100%;
  max-width: 420px;
  padding: 48px 36px;
  text-align: center;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--card);
  backdrop-filter: blur(20px);
  box-shadow:
    0 25px 80px rgba(0,0,0,0.5),
    0 0 60px rgba(124, 58, 237, 0.15);
  position: relative;
  overflow: hidden;
}

.login-box::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 180deg, transparent, rgba(167,139,250,0.10), transparent 30%);
  animation: rotate 8s linear infinite;
  pointer-events: none;
  z-index: -1;
}

.login-box::after {
  content: '';
  position: absolute;
  inset: 1px;
  border-radius: 23px;
  background: var(--card-solid);
  z-index: -1;
}

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

.logo {
  margin-bottom: 20px;
  filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.5));
}

.login h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: 34px;
  letter-spacing: 4px;
  margin: 0;
  background: linear-gradient(90deg, #fff, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  letter-spacing: 6px;
  color: var(--accent);
  margin-top: 6px;
  margin-bottom: 12px;
}

.login-desc {
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 28px;
}

.input-wrap {
  position: relative;
  margin-bottom: 18px;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

input[type="password"], input[type="text"], select {
  width: 100%;
  padding: 14px 16px 14px 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: all 0.2s;
}

select {
  padding-left: 14px;
  cursor: pointer;
}

input[type="password"]:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
}

.btn-primary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: #fff;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(124, 58, 237, 0.45);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  font-size: 13px;
}

.btn-ghost:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--border-strong);
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

.footer {
  margin-top: 32px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* APP */
.app {
  display: none;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 250px;
  border-right: 1px solid var(--border);
  background: rgba(10, 8, 20, 0.85);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  padding-left: 8px;
}

.brand-text { line-height: 1.2; }
.brand-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 16px;
  letter-spacing: 2px;
  font-weight: 700;
}
.brand-sub {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--accent);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  position: relative;
  transition: all 0.2s;
  overflow: hidden;
}

.nav-item:hover {
  background: rgba(139, 92, 246, 0.08);
  color: var(--text);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(124, 58, 237, 0.2), transparent);
  color: var(--text);
  border: 1px solid var(--border);
}

.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  padding: 0 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 20px;
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.2);
  font-size: 12px;
  color: var(--success);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.main {
  margin-left: 250px;
  padding: 28px 32px 100px;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: 28px;
  margin: 6px 0 0;
  letter-spacing: 1px;
}

.page-tag {
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.global-filters {
  display: flex;
  gap: 8px;
}

.global-filters select {
  padding: 10px 14px;
  font-size: 13px;
}

/* SECTIONS */
.section {
  display: none;
}

.section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header {
  margin-bottom: 24px;
}

.section-header h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 22px;
  margin: 0 0 6px;
  letter-spacing: 1px;
}

.section-header p {
  color: var(--muted);
  margin: 0;
  font-size: 14px;
}

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi {
  position: relative;
  padding: 20px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card);
  backdrop-filter: blur(10px);
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 14px;
}

.kpi-glow {
  position: absolute;
  top: -30px;
  right: -30px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  filter: blur(30px);
  opacity: 0.35;
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.kpi-icon.sent { background: rgba(52, 211, 153, 0.15); color: var(--success); }
.kpi-icon.reply { background: rgba(96, 165, 250, 0.15); color: var(--info); }
.kpi-icon.pending { background: rgba(251, 191, 36, 0.15); color: var(--warn); }
.kpi-icon.failed { background: rgba(248, 113, 113, 0.15); color: var(--danger); }
.kpi-icon.campaign { background: rgba(167, 139, 250, 0.15); color: var(--accent); }

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
}

/* CARDS */
.cards-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.card {
  position: relative;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--card);
  backdrop-filter: blur(10px);
  padding: 22px;
  overflow: hidden;
}

.card-glow {
  position: absolute;
  top: -40px;
  left: -40px;
  width: 100px;
  height: 100px;
  background: rgba(139, 92, 246, 0.2);
  filter: blur(40px);
  border-radius: 50%;
}

.chart-card { min-height: 340px; display: flex; flex-direction: column; }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.card-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.chart-legend {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.legend-dot.sent { background: var(--success); }
.legend-dot.failed { background: var(--danger); }
.legend-dot.reply { background: var(--info); }

.chart-wrap {
  flex: 1;
  position: relative;
  min-height: 250px;
}

.summary-card .mission-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.summary-card .mission-item:last-child { border-bottom: none; }

.mission-label {
  color: var(--muted);
  font-size: 13px;
}

.mission-value {
  text-align: right;
}

/* TABLES */
.table-card { overflow: hidden; }
.responsive {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.responsive th {
  text-align: left;
  padding: 14px 16px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.responsive td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.responsive tbody tr:last-child td { border-bottom: none; }
.responsive tbody tr:hover { background: rgba(139, 92, 246, 0.05); }

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-warm { background: rgba(251, 191, 36, 0.12); color: var(--warn); }
.badge-active { background: rgba(52, 211, 153, 0.12); color: var(--success); }
.badge-draft { background: rgba(139, 92, 246, 0.12); color: var(--accent); }
.badge-pending { background: rgba(96, 165, 250, 0.12); color: var(--info); }
.badge-sending { background: rgba(167, 139, 250, 0.2); color: #c4b5fd; }
.badge-failed { background: rgba(248, 113, 113, 0.12); color: var(--danger); }

/* PROGRESS */
.progress {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* AGENT CARDS */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.agent-card {
  position: relative;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--card);
  backdrop-filter: blur(10px);
  padding: 20px;
  overflow: hidden;
}

.agent-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.agent-email {
  font-weight: 600;
  font-size: 14px;
  word-break: break-all;
}

.agent-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.meta-item {
  text-align: center;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
}

.meta-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.meta-value {
  font-size: 18px;
  font-weight: 700;
}

/* REPLIES */
.replies-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.reply-card {
  position: relative;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card);
  backdrop-filter: blur(10px);
  padding: 20px;
  overflow: hidden;
}

.reply-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.reply-from {
  font-weight: 700;
  font-size: 15px;
}

.reply-campaign {
  font-size: 12px;
  color: var(--accent);
  margin-top: 2px;
}

.reply-subject {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.reply-body {
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  border-left: 2px solid var(--accent);
  max-height: 160px;
  overflow-y: auto;
}

.reply-meta {
  display: flex;
  gap: 14px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

/* EVENTS */
.filters-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.filters-bar select {
  padding: 10px 14px;
  font-size: 13px;
  min-width: 130px;
}

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

.event-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  backdrop-filter: blur(10px);
  transition: background 0.2s;
}

.event-item:hover { background: rgba(139, 92, 246, 0.08); }

.event-time {
  font-size: 12px;
  color: var(--muted);
  min-width: 100px;
  flex-shrink: 0;
  padding-top: 4px;
}

.event-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 5px 10px;
  border-radius: 20px;
  flex-shrink: 0;
}

.event-main {
  flex: 1;
  min-width: 0;
}

.event-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.event-detail {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.event-payload {
  font-size: 12px;
  color: var(--muted);
  background: rgba(0,0,0,0.22);
  padding: 8px 12px;
  border-radius: 8px;
  margin-top: 8px;
  word-break: break-word;
  max-height: 80px;
  overflow-y: auto;
  line-height: 1.5;
  border: 1px solid rgba(255,255,255,0.04);
}

.event-payload strong {
  color: var(--text);
  font-weight: 600;
}

/* EMPTY */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

/* BOTTOM NAV MOBILE */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(10, 8, 20, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  justify-content: space-around;
  align-items: center;
  z-index: 20;
  padding: 0 8px;
}

.bottom-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 10px;
  padding: 8px 4px;
  flex: 1;
  transition: color 0.2s;
}

.bottom-item.active {
  color: var(--accent);
}

.bottom-item svg {
  stroke: currentColor;
}

/* TOOLTIP */
.tooltip {
  position: relative;
  cursor: help;
}

.tooltip:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-solid);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text);
  white-space: pre;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  min-width: 200px;
}

/* CSV BUTTON */
.csv-btn {
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: var(--success);
}

.csv-btn:hover {
  background: rgba(52, 211, 153, 0.2);
}

/* ETA BAR */
.eta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 28px;
  padding: 14px 18px;
  margin: 12px 16px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 12px;
  font-size: 13px;
  color: var(--muted);
}

.eta-bar strong {
  color: var(--text);
  font-weight: 700;
}

/* VARIANT CARD */
.variant-card .table-card {
  margin: 0;
  box-shadow: none;
  border: 1px solid var(--border);
}

/* RESPONSIVE */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 20px 16px 90px; }
  .bottom-nav { display: flex; }
  .cards-row { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .agent-meta { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .cards-grid { grid-template-columns: 1fr; }
  .responsive thead { display: none; }
  .responsive tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
  }
  .responsive td {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
  }
  .responsive td::before {
    content: attr(data-label);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    font-weight: 600;
  }
  .responsive td:last-child { border-bottom: none; }
  .event-item { flex-direction: column; gap: 6px; }
  .event-time { min-width: auto; }
}

@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: 1fr; }
}
