/* ===== CSS Variables ===== */
:root {
  --dark: #0a0a0a;
  --dark-surface: #141414;
  --dark-border: #222222;
  --dark-text: #e0e0e0;
  --dark-muted: #888888;
  --light: #fafafa;
  --light-surface: #ffffff;
  --light-border: #e5e5e5;
  --light-text: #1a1a1a;
  --light-muted: #6b7280;
  --accent: #22C55E;
  --accent-dim: rgba(34, 197, 94, 0.15);
  --accent-hover: #16a34a;
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --yellow: #eab308;
  --yellow-dim: rgba(234, 179, 8, 0.15);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.15);
  --orange: #f97316;
  --orange-dim: rgba(249, 115, 22, 0.15);
  --purple: #a855f7;
  --purple-dim: rgba(168, 85, 247, 0.15);
  --font: 'Instrument Sans', system-ui, sans-serif;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--light);
  color: var(--light-text);
  min-height: 100vh;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
table { border-collapse: collapse; width: 100%; }

/* ===== Top Navigation ===== */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 24px;
  background: var(--dark);
  border-bottom: 1px solid var(--dark-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topnav-left {
  display: flex;
  align-items: center;
  gap: 32px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.topnav-links {
  display: flex;
  gap: 4px;
}

.topnav-links a {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--dark-muted);
  transition: var(--transition);
}

.topnav-links a:hover {
  color: var(--dark-text);
  background: rgba(255,255,255,0.06);
}

.topnav-links a.active {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

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

.icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--dark-muted);
  transition: var(--transition);
}

.icon-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}

.notification-dot {
  position: absolute;
  top: 6px;
  right: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--dark);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

.user-info:hover {
  background: rgba(255,255,255,0.06);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--dark-text);
}

.user-info svg {
  color: var(--dark-muted);
}

/* ===== Main Split Layout ===== */
.main-split {
  display: flex;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* ===== Sidebar Panel (Dark, 30%) ===== */
.sidebar-panel {
  width: 30%;
  min-width: 260px;
  max-width: 320px;
  background: var(--dark);
  border-right: 1px solid var(--dark-border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  overflow-y: auto;
  animation: slideInLeft 0.5s ease-out;
}

@keyframes slideInLeft {
  from { transform: translateX(-30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

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

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--dark-muted);
  transition: var(--transition);
}

.sidebar-link:hover {
  color: var(--dark-text);
  background: rgba(255,255,255,0.05);
}

.sidebar-link.active {
  color: #fff;
  background: rgba(34, 197, 94, 0.12);
}

.sidebar-link.active svg {
  color: var(--accent);
}

.badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(255,255,255,0.1);
  color: var(--dark-text);
}

.badge.danger {
  background: var(--red-dim);
  color: var(--red);
}

.sidebar-divider {
  height: 1px;
  background: var(--dark-border);
  margin: 20px 0;
}

.plan-section {
  padding: 0 12px;
  margin-bottom: 20px;
}

.plan-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dark-muted);
  margin-bottom: 6px;
}

.plan-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
}

.plan-period {
  font-size: 0.78rem;
  color: var(--dark-muted);
  margin-top: 2px;
}

.usage-section {
  padding: 0 12px;
  margin-bottom: 20px;
}

.usage-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.usage-label {
  font-size: 0.78rem;
  color: var(--dark-muted);
}

.usage-value {
  font-size: 0.75rem;
  color: var(--dark-text);
  font-weight: 500;
}

.usage-bar {
  height: 5px;
  border-radius: 10px;
  background: var(--dark-border);
  overflow: hidden;
}

.usage-fill {
  height: 100%;
  border-radius: 10px;
  background: var(--accent);
  transition: width 1s ease-out;
}

.upgrade-btn {
  margin: auto 12px 0;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  transition: var(--transition);
}

.upgrade-btn:hover {
  background: var(--accent-hover);
}

/* ===== Content Panel (Light, 70%) ===== */
.content-panel {
  flex: 1;
  background: var(--light);
  overflow-y: auto;
  padding: 24px 28px;
  animation: slideInRight 0.5s ease-out;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  animation: fadeInUp 0.5s ease-out;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--light-text);
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--light-muted);
  margin-top: 2px;
}

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

.date-range {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--light-border);
  font-size: 0.85rem;
  color: var(--light-muted);
  background: var(--light-surface);
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  transition: var(--transition);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  background: var(--light-surface);
  border: 1px solid var(--light-border);
  border-radius: var(--radius);
  animation: fadeInUp 0.5s ease-out;
  animation-fill-mode: backwards;
  transition: var(--transition);
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

.stat-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.messages { background: var(--accent-dim); color: var(--accent); }
.stat-icon.spam { background: var(--red-dim); color: var(--red); }
.stat-icon.false-pos { background: var(--yellow-dim); color: var(--yellow); }
.stat-icon.detection { background: var(--blue-dim); color: var(--blue); }

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

.stat-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--light-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--light-text);
  letter-spacing: -0.03em;
}

.stat-change {
  font-size: 0.75rem;
  font-weight: 500;
}

.stat-change.positive { color: var(--accent); }
.stat-change.negative { color: var(--red); }

/* ===== Content Split Sections ===== */
.content-split {
  display: flex;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
  border: 1px solid var(--light-border);
  animation: fadeInUp 0.6s ease-out;
  animation-fill-mode: backwards;
  animation-delay: 0.3s;
}

.split-divider {
  width: 1px;
  background: var(--light-border);
  flex-shrink: 0;
}

.split-left, .split-right {
  padding: 20px;
  overflow: hidden;
}

.split-left {
  flex: 1;
}

.split-right {
  flex: 1;
}

.split-left.wide {
  flex: 1.4;
}

.split-right.narrow {
  flex: 0.6;
}

.dark-panel {
  background: var(--dark);
  color: var(--dark-text);
}

.dark-panel .split-divider + & {
  border-left: none;
}

.light-panel {
  background: var(--light-surface);
}

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

.panel-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--light-text);
}

.panel-title.light {
  color: #fff;
}

.view-all {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  transition: var(--transition);
}

.view-all:hover {
  text-decoration: underline;
}

.panel-tabs {
  display: flex;
  gap: 4px;
}

.tab-btn {
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--dark-muted);
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--dark-text);
}

.tab-btn.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

/* ===== Chart ===== */
.chart-container {
  height: 200px;
  position: relative;
  margin-bottom: 12px;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--dark-muted);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot.green { background: var(--accent); }
.legend-dot.red { background: var(--red); }
.legend-dot.yellow { background: var(--yellow); }

/* ===== Categories ===== */
.categories-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.category-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.category-icon.phishing { background: var(--red-dim); color: var(--red); }
.category-icon.promo { background: var(--blue-dim); color: var(--blue); }
.category-icon.scam { background: var(--orange-dim); color: var(--orange); }
.category-icon.malware { background: var(--purple-dim); color: var(--purple); }
.category-icon.other { background: rgba(107,114,128,0.15); color: var(--light-muted); }

.category-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--light-text);
  display: block;
}

.category-count {
  font-size: 0.75rem;
  color: var(--light-muted);
}

.category-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-bar {
  flex: 1;
  height: 6px;
  border-radius: 10px;
  background: var(--light-border);
  overflow: hidden;
}

.category-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 1s ease-out;
}

.category-fill.phishing { background: var(--red); }
.category-fill.promo { background: var(--blue); }
.category-fill.scam { background: var(--orange); }
.category-fill.malware { background: var(--purple); }
.category-fill.other { background: var(--light-muted); }

.category-pct {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--light-text);
  min-width: 32px;
  text-align: right;
}

/* ===== Threats Table ===== */
.threats-table-wrap {
  overflow-x: auto;
}

.threats-table th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--light-muted);
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--light-border);
  white-space: nowrap;
}

.threats-table td {
  font-size: 0.82rem;
  padding: 10px;
  border-bottom: 1px solid var(--light-border);
  color: var(--light-text);
  white-space: nowrap;
}

.threats-table tbody tr {
  transition: var(--transition);
}

.threats-table tbody tr:hover {
  background: rgba(34, 197, 94, 0.04);
}

.threat-type {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}

.threat-type.phishing { background: var(--red-dim); color: var(--red); }
.threat-type.promo { background: var(--blue-dim); color: var(--blue); }
.threat-type.scam { background: var(--orange-dim); color: var(--orange); }
.threat-type.malware { background: var(--purple-dim); color: var(--purple); }
.threat-type.other { background: rgba(107,114,128,0.12); color: var(--light-muted); }

.risk-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.risk-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.risk-dot.critical { background: var(--red); }
.risk-dot.high { background: var(--orange); }
.risk-dot.medium { background: var(--yellow); }
.risk-dot.low { background: var(--accent); }

.action-link {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  transition: var(--transition);
}

.action-link:hover {
  text-decoration: underline;
}

/* ===== Blocked Domains ===== */
.blocked-domains {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.domain-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.04);
  transition: var(--transition);
}

.domain-item:hover {
  background: rgba(255,255,255,0.08);
}

.domain-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.domain-rank {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  color: var(--dark-muted);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.domain-name {
  font-size: 0.85rem;
  color: var(--dark-text);
  font-weight: 500;
}

.domain-count {
  font-size: 0.78rem;
  color: var(--red);
  font-weight: 600;
}

.quick-actions-divider {
  height: 1px;
  background: var(--dark-border);
  margin: 20px 0;
}

/* ===== Quick Actions ===== */
.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--dark-text);
  transition: var(--transition);
}

.action-btn:hover {
  background: rgba(34, 197, 94, 0.1);
  color: var(--accent);
}

.action-btn svg {
  flex-shrink: 0;
}

/* ===== Live Feed ===== */
.live-feed-panel {
  background: var(--light-surface);
  border: 1px solid var(--light-border);
  border-radius: var(--radius);
  padding: 20px;
  animation: fadeInUp 0.6s ease-out;
  animation-fill-mode: backwards;
  animation-delay: 0.5s;
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  margin-right: 6px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.feed-controls {
  display: flex;
  gap: 4px;
}

.feed-btn {
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--light-muted);
  transition: var(--transition);
}

.feed-btn:hover {
  color: var(--light-text);
}

.feed-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.feed-list {
  display: flex;
  flex-direction: column;
  max-height: 200px;
  overflow-y: auto;
}

.feed-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--light-border);
  animation: feedSlide 0.4s ease-out;
}

.feed-item:last-child {
  border-bottom: none;
}

@keyframes feedSlide {
  from { transform: translateX(-20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.feed-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.feed-status.blocked { background: var(--red); }
.feed-status.allowed { background: var(--accent); }
.feed-status.flagged { background: var(--yellow); }

.feed-message {
  flex: 1;
  font-size: 0.82rem;
  color: var(--light-text);
}

.feed-message strong {
  font-weight: 600;
}

.feed-time {
  font-size: 0.75rem;
  color: var(--light-muted);
  white-space: nowrap;
}

/* ===== Scrollbar ===== */
.sidebar-panel::-webkit-scrollbar,
.content-panel::-webkit-scrollbar,
.feed-list::-webkit-scrollbar {
  width: 6px;
}

.sidebar-panel::-webkit-scrollbar-track,
.feed-list::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-panel::-webkit-scrollbar-thumb {
  background: var(--dark-border);
  border-radius: 10px;
}

.content-panel::-webkit-scrollbar-track {
  background: transparent;
}

.content-panel::-webkit-scrollbar-thumb,
.feed-list::-webkit-scrollbar-thumb {
  background: var(--light-border);
  border-radius: 10px;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .main-split {
    flex-direction: column;
    height: auto;
  }

  .sidebar-panel {
    width: 100%;
    max-width: none;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--dark-border);
    max-height: 300px;
  }

  .content-split {
    flex-direction: column;
  }

  .split-divider {
    width: 100%;
    height: 1px;
  }

  .split-left.wide,
  .split-right.narrow {
    flex: 1;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .topnav-links {
    display: none;
  }
}

@media (max-width: 640px) {
  .topnav {
    padding: 0 16px;
  }

  .content-panel {
    padding: 16px;
  }

  .content-header {
    flex-direction: column;
    gap: 12px;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  .user-name {
    display: none;
  }

  .threats-table th:nth-child(2),
  .threats-table td:nth-child(2) {
    display: none;
  }
}
