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

:root {
  --bg: #0d0d12;
  --bg-card: #141420;
  --bg-sidebar: #0a0a10;
  --text: #e8e4d8;
  --text-dim: rgba(232,228,216,0.5);
  --text-label: rgba(232,228,216,0.35);
  --border: rgba(232,228,216,0.08);
  --positive: #4ade80;
  --negative: #f87171;
  --accent: #c8a96e;
  --sidebar-w: 240px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-weight: 400;
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 0 1.5rem 2rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
}

.sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.sidebar-nav li a:hover { color: var(--text); background: rgba(232,228,216,0.03); }
.sidebar-nav li a.active { color: var(--text); border-left-color: var(--accent); background: rgba(232,228,216,0.05); }

.sidebar-nav li a svg { width: 18px; height: 18px; opacity: 0.6; }
.sidebar-nav li a.active svg { opacity: 1; }

/* Main content */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2rem;
  min-height: 100vh;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.main-header h1 {
  font-size: 1.5rem;
  font-weight: 400;
}

.last-updated {
  font-size: 0.75rem;
  color: var(--text-label);
}

/* Status dot */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.5rem;
}
.status-dot.up { background: var(--positive); box-shadow: 0 0 6px var(--positive); }
.status-dot.down { background: var(--negative); box-shadow: 0 0 6px var(--negative); }

/* Sections */
.section { display: none; }
.section.active { display: block; }

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

.card-label {
  font-size: 0.7rem;
  color: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

.card-value {
  font-size: 1.8rem;
  font-weight: 300;
  line-height: 1.2;
}

.card-value.positive { color: var(--positive); }
.card-value.negative { color: var(--negative); }
.card-value.accent { color: var(--accent); }

.card-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

.card-change {
  font-size: 0.7rem;
  margin-top: 0.25rem;
  color: var(--text-dim);
}
.card-change.positive { color: var(--positive); }
.card-change.negative { color: var(--negative); }

.card-sparkline {
  margin-top: 0.5rem;
  height: 22px;
}
.card-sparkline svg { width: 100%; height: 100%; display: block; }

.status-text {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  margin-left: 0.25rem;
  vertical-align: middle;
}
.status-text.up { color: var(--positive); }
.status-text.down { color: var(--negative); }

.traffic-row {
  margin-bottom: 1rem;
}
.row-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
  padding-left: 0.25rem;
}
.kpi-grid-5 {
  grid-template-columns: repeat(5, 1fr);
}
@media (max-width: 900px) {
  .kpi-grid-5 { grid-template-columns: repeat(2, 1fr); }
}

/* Chart container */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.chart-card .card-label { margin-bottom: 1rem; }

.chart-card canvas {
  width: 100%;
  height: 200px;
  display: block;
}

/* Chart tooltip */
.chart-tooltip {
  position: absolute;
  background: #1a1a2e;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  font-size: 0.7rem;
  color: var(--text);
  pointer-events: none;
  display: none;
  z-index: 50;
}

/* List card */
.list-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.list-item:last-child { border-bottom: none; }
.list-item .label { color: var(--text-dim); }
.list-item .value { color: var(--text); }

/* Two-column layout */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, #1a1a28 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

.skeleton-text { height: 1.8rem; width: 60%; }
.skeleton-chart { height: 200px; width: 100%; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Error state */
.error-state {
  color: var(--text-label);
  font-size: 0.82rem;
  text-align: center;
  padding: 2rem;
}

.error-banner {
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.2);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: var(--negative);
  margin-bottom: 1.5rem;
  display: none;
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 60px;
    flex-direction: row;
    padding: 0;
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 100;
  }

  .sidebar-logo { display: none; }

  .sidebar-nav {
    flex-direction: row;
    width: 100%;
    justify-content: space-around;
    gap: 0;
  }

  .sidebar-nav li a {
    flex-direction: column;
    padding: 0.5rem;
    font-size: 0.6rem;
    gap: 0.25rem;
    border-left: none;
    border-top: 2px solid transparent;
    text-align: center;
  }

  .sidebar-nav li a.active {
    border-left: none;
    border-top-color: var(--accent);
    background: none;
  }

  .sidebar-nav li a svg { width: 20px; height: 20px; }

  .main {
    margin-left: 0;
    padding: 1rem 1rem 5rem;
  }

  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
