:root {
  --bg: #0a0e1a;
  --bg-panel: #111a2e;
  --bg-panel-hover: #16213d;
  --border: #1f2c4d;
  --text: #e6ecfb;
  --text-dim: #8fa0c7;
  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --accent-glow: rgba(59, 130, 246, 0.25);
  --positive: #34d399;
  --negative: #f87171;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top left, #0d1730 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

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

header.topbar h1 {
  font-size: 22px;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.3px;
}

header.topbar h1 span {
  color: var(--accent-light);
}

#last-update {
  font-size: 12px;
  color: var(--text-dim);
}

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 24px;
}

.preset-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.preset-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.filters input[type="date"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.filters .divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
}

/* KPI cards */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-glow), transparent 60%);
  opacity: 0.5;
  pointer-events: none;
}

.kpi-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 6px;
}

.kpi-delta {
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.kpi-delta.positive {
  color: var(--positive);
}

.kpi-delta.negative {
  color: var(--negative);
}

.kpi-delta.neutral {
  color: var(--text-dim);
}

/* Charts */
.charts {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.panel h2 {
  font-size: 15px;
  margin: 0 0 14px;
  color: var(--text-dim);
  font-weight: 600;
}

/* Table */
.table-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 12px 16px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--bg-panel);
}

tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

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

.badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
}

.badge.won {
  background: rgba(52, 211, 153, 0.15);
  color: var(--positive);
}

.badge.default {
  background: rgba(143, 160, 199, 0.15);
  color: var(--text-dim);
}

.wa-link {
  color: var(--accent-light);
  text-decoration: none;
}

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

.table-scroll {
  max-height: 420px;
  overflow-y: auto;
}

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-dim);
}

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