:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e3e8ef;
  --text: #1f2a37;
  --muted: #6b7280;
  --accent: #2563eb;
  --green: #16a34a;
  --yellow: #d97706;
  --red: #dc2626;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

.header {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  padding: 32px 0 28px;
  margin-bottom: 24px;
}
.header h1 { font-size: 22px; font-weight: 700; letter-spacing: 0.3px; margin-bottom: 8px; }
.header .meta { opacity: 0.9; font-size: 14px; margin-bottom: 10px; }
.header .updated { font-size: 13px; opacity: 0.85; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn-refresh {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}
.btn-refresh:hover { background: rgba(255,255,255,0.3); }
#refresh-status { font-size: 13px; }

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px; }
.kpi-value { font-size: 30px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.kpi-sub { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.card h2 { font-size: 18px; margin-bottom: 16px; }
.note { color: var(--muted); font-size: 13px; margin-bottom: 12px; }

/* Traffic */
.traffic-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.traffic-block { border-radius: 10px; padding: 16px; border: 1px solid var(--border); background: #fbfcfe; }
.traffic-label { font-weight: 600; margin-bottom: 6px; }
.traffic-count { font-size: 26px; font-weight: 800; margin-bottom: 10px; }
.traffic-green .traffic-count { color: var(--green); }
.traffic-yellow .traffic-count { color: var(--yellow); }
.traffic-red .traffic-count { color: var(--red); }
.bar { height: 8px; background: #eef1f6; border-radius: 6px; overflow: hidden; margin-bottom: 6px; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 6px; }
.traffic-green .bar-fill { background: var(--green); }
.traffic-yellow .bar-fill { background: var(--yellow); }
.traffic-red .bar-fill { background: var(--red); }
.traffic-pct { font-size: 13px; color: var(--muted); }

/* Tabs */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 10px 18px;
  border-radius: 24px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}
.tab:hover { border-color: var(--accent); color: var(--accent); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Table */
.table-wrap { overflow-x: auto; padding: 0; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table-wrap th {
  background: #f8fafc;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.table-wrap td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table-wrap tr:hover td { background: #f8fafc; }
.table-wrap .name { font-weight: 600; min-width: 260px; }
.analytics-cell { white-space: pre-line; }
.status-cell { white-space: pre-line; }

.footer { margin-top: 40px; padding: 24px 0; text-align: center; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); }

@media (max-width: 640px) {
  .header h1 { font-size: 18px; }
  .kpi-value { font-size: 24px; }
}
