:root {
  --bg: #0f1117;
  --surface: #181b24;
  --surface-2: #1f2430;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f4f4f5;
  --muted: #9ca3af;
  --accent: #f97316;
  --accent-soft: rgba(249, 115, 22, 0.15);
  --voice: #38bdf8;
  --voice-soft: rgba(56, 189, 248, 0.12);
  --wa: #4ade80;
  --wa-soft: rgba(74, 222, 128, 0.12);
  --orders: #c084fc;
  --orders-soft: rgba(192, 132, 252, 0.12);
  --danger-bg: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(239, 68, 68, 0.35);
  --danger-text: #fca5a5;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(249, 115, 22, 0.18), transparent 50%),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(56, 189, 248, 0.1), transparent 45%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #ea580c);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.35);
}

.sidebar-brand h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.25;
  font-weight: 700;
}

.sidebar-brand .subtitle {
  margin: 2px 0 0;
  font-size: 0.7rem;
  color: var(--muted);
}

.nav-label {
  padding: 18px 18px 8px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0 10px 20px;
  flex: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.sidebar-nav a.active {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

.sidebar-nav a.active .nav-dot { opacity: 1; }

.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0.5;
}

.nav-dot.dashboard { background: var(--accent); }
.nav-dot.wa { background: var(--wa); }
.nav-dot.voice { background: var(--voice); }
.nav-dot.orders { background: var(--orders); }

.sidebar-footer {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--muted);
}

.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), #ea580c);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(249, 115, 22, 0.45);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 28px 48px;
  max-width: 1100px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.page-header h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.range-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.range-pill strong { color: var(--text); font-weight: 600; }

.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="datetime-local"] {
  font-family: inherit;
  font-size: 0.9375rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  min-width: 200px;
}

input[type="datetime-local"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #ea580c);
  color: #fff;
  box-shadow: 0 4px 14px rgba(249, 115, 22, 0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(249, 115, 22, 0.45);
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.presets span {
  font-size: 0.75rem;
  color: var(--muted);
  align-self: center;
  margin-right: 4px;
}

.preset-link {
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.preset-link:hover {
  color: var(--text);
  border-color: rgba(249, 115, 22, 0.4);
  background: var(--accent-soft);
}

.error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.875rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}

.stat:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.14);
}

.stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.stat.voice::before { background: var(--voice); }
.stat.wa::before { background: var(--wa); }
.stat.orders::before { background: var(--orders); }
.stat.dashboard::before { background: var(--accent); }

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.stat.voice .stat-icon { background: var(--voice-soft); }
.stat.wa .stat-icon { background: var(--wa-soft); }
.stat.orders .stat-icon { background: var(--orders-soft); }
.stat.dashboard .stat-icon { background: var(--accent-soft); }

.stat-label {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.stat-value.mono {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

.summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 28px;
}

.summary-item { flex: 1; min-width: 120px; }

.summary-item .label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-item .num {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 2px;
}

.note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.note strong { color: var(--text); }

.note code {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--accent);
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.quick-link {
  display: block;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  transition: border-color 0.15s, transform 0.15s;
}

.quick-link:hover {
  border-color: rgba(249, 115, 22, 0.4);
  transform: translateY(-1px);
}

.quick-link span {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
  margin-top: 4px;
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 40;
  }
  .sidebar-backdrop.show { display: block; }
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .main { padding: 20px 16px 80px; }
}

@media (max-width: 600px) {
  input[type="datetime-local"] { min-width: 100%; width: 100%; }
  .filters-row { flex-direction: column; align-items: stretch; }
  .btn-primary { width: 100%; }
}
