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

:root {
  --bg: #0a0e14;
  --bg-card: #111820;
  --bg-card-hover: #161f2b;
  --border: #1e2a3a;
  --text: #e8eef5;
  --text-muted: #7a8ba0;
  --text-faint: #4a5568;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.15);
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.1);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.1);
  --chart-views: rgba(59, 130, 246, 0.35);
  --chart-visitors: #3b82f6;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 14px;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Login */
.login-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh; gap: 20px; padding: 24px;
}
.login-screen h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.login-screen input {
  width: 100%; max-width: 340px; padding: 14px 18px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  font-size: 16px; font-family: var(--font); outline: none;
  transition: border-color 0.3s;
}
.login-screen input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.login-screen button {
  padding: 14px 40px; border-radius: 12px; border: none;
  background: var(--accent); color: #fff; font-size: 15px;
  font-weight: 600; cursor: pointer; font-family: var(--font);
  transition: transform 0.2s, box-shadow 0.2s;
}
.login-screen button:hover { transform: translateY(-1px); box-shadow: 0 8px 24px var(--accent-glow); }
.login-error { color: var(--red); font-size: 14px; }

/* Header */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: rgba(10, 14, 20, 0.85);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); z-index: 10;
}
.header h1 { font-size: 18px; font-weight: 800; letter-spacing: -0.03em; }
.header-right { display: flex; align-items: center; gap: 10px; }

/* Range Selector */
.range-selector { display: flex; gap: 2px; background: var(--bg-card); border-radius: 10px; padding: 3px; }
.range-btn {
  padding: 7px 14px; border-radius: 8px; border: none;
  background: transparent; color: var(--text-muted); font-size: 13px;
  font-weight: 600; cursor: pointer; font-family: var(--font);
  transition: all 0.25s;
}
.range-btn.active { background: var(--accent); color: #fff; }
.range-btn:hover:not(.active) { color: var(--text); }

.refresh-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-muted); font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.3s;
}
.refresh-btn:hover { border-color: var(--accent); color: var(--accent); }
.refresh-btn.spinning { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.last-updated { font-size: 11px; color: var(--text-faint); }

/* Dashboard */
.dashboard {
  max-width: 960px; margin: 0 auto; padding: 20px;
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 14px;
}

/* Cards */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  transition: border-color 0.3s, transform 0.3s;
  animation: cardIn 0.4s ease-out both;
}
.card:hover { border-color: rgba(59, 130, 246, 0.3); }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-2 { grid-column: span 2; }
.card-full { grid-column: 1 / -1; }

.card h2 {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-faint); margin-bottom: 14px;
}

/* Stat Cards */
.stat-value {
  font-size: 36px; font-weight: 800; line-height: 1;
  letter-spacing: -0.03em; margin-bottom: 4px;
}
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

.stat-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 8px; border-radius: 6px; font-size: 12px;
  font-weight: 700; margin-top: 8px;
}
.stat-badge.up { background: var(--green-bg); color: var(--green); }
.stat-badge.down { background: var(--red-bg); color: var(--red); }
.stat-badge.neutral { background: rgba(255,255,255,0.05); color: var(--text-muted); }

/* Live Pulse */
.live-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--green); margin-right: 6px; position: relative;
}
.live-dot::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  background: var(--green); opacity: 0; animation: pulse 2s ease-out infinite;
}
@keyframes pulse { 0% { opacity: 0.5; transform: scale(1); } 100% { opacity: 0; transform: scale(2); } }

.live-value {
  font-size: 52px; font-weight: 800; line-height: 1;
  letter-spacing: -0.04em; color: var(--green);
}

/* Chart */
.chart-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.chart-header h2 { margin-bottom: 0; }
.time-nav { display: flex; align-items: center; gap: 8px; }
.nav-arrow {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-muted); font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; font-family: var(--font);
}
.nav-arrow:hover:not(.disabled) { border-color: var(--accent); color: var(--accent); }
.nav-arrow.disabled { opacity: 0.3; cursor: default; }
.period-label { font-size: 12px; color: var(--text-muted); font-weight: 600; min-width: 100px; text-align: center; }

.chart-wrapper { position: relative; overflow: hidden; }
.chart-wrapper canvas { width: 100%; max-width: 100%; cursor: crosshair; display: block; }
.chart-tooltip {
  position: absolute; background: rgba(22,31,43,0.95); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; font-size: 12px; color: var(--text);
  pointer-events: none; opacity: 0; transition: opacity 0.15s; z-index: 5;
  line-height: 1.5; white-space: nowrap; transform: translateX(-50%);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.chart-legend {
  display: flex; gap: 16px; justify-content: center; margin-top: 10px; font-size: 12px; color: var(--text-muted);
}
.chart-legend-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px;
}

/* Social */
.social-divider { border-top: 1px solid var(--border); margin: 8px 0; }
.recent-follows { margin-top: 8px; font-size: 11px; color: var(--text-faint); }
.delta {
  color: var(--green); font-size: 12px; font-weight: 700; margin-right: 6px;
  background: var(--green-bg); padding: 1px 5px; border-radius: 4px;
}

/* Social */
.social-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.social-platform { display: flex; flex-direction: column; gap: 8px; }
.platform-name {
  font-size: 14px; font-weight: 700; color: var(--accent);
  display: flex; align-items: center; gap: 6px;
}
.social-stat {
  display: flex; justify-content: space-between; padding: 4px 0;
  font-size: 14px; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.social-stat:last-child { border-bottom: none; }
.social-stat .label { color: var(--text-muted); }
.social-stat .value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Page List */
.page-list { list-style: none; }
.page-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 13px; animation: fadeIn 0.3s ease both;
}
.page-item:last-child { border-bottom: none; }
.page-url {
  color: var(--text-muted); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 75%; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px;
}
.page-count {
  font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,0.04); padding: 2px 8px; border-radius: 6px; font-size: 12px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Agent Runs */
.run-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 13px;
}
.run-item:last-child { border-bottom: none; }
.run-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.run-dot.success { background: var(--green); box-shadow: 0 0 8px rgba(34,197,94,0.4); }
.run-dot.failure { background: var(--red); box-shadow: 0 0 8px rgba(239,68,68,0.4); }
.run-name { flex: 1; font-weight: 500; }
.run-time { color: var(--text-faint); font-size: 12px; }

/* Commit Links */
.commit-link {
  color: var(--text-muted); text-decoration: none; transition: color 0.2s;
}
.commit-link:hover { color: var(--accent); }

/* Deploy Details */
.deploy-item { cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.04); }
.deploy-item:last-child { border-bottom: none; }
.deploy-item .run-item { border-bottom: none; }
.deploy-chevron {
  font-size: 10px; color: var(--text-faint); transition: transform 0.2s; margin-left: 8px;
}
.deploy-details {
  padding: 8px 0 12px 18px; font-size: 13px; animation: fadeIn 0.2s ease;
}
.deploy-status {
  color: var(--text-muted); font-size: 12px; margin-right: 12px;
}
.deploy-link {
  color: var(--accent); text-decoration: none; font-size: 12px;
}
.deploy-link:hover { text-decoration: underline; }

/* Loading */
.loading { display: flex; align-items: center; justify-content: center; min-height: 100vh; color: var(--text-muted); }
.error-msg { color: var(--red); font-size: 14px; padding: 20px; text-align: center; }

/* Responsive */
@media (max-width: 768px) {
  .dashboard { grid-template-columns: 1fr 1fr; padding: 12px; gap: 10px; }
  .card-full, .card-2 { grid-column: 1 / -1; }
  .stat-value { font-size: 28px; }
  .live-value { font-size: 40px; }
  .header { padding: 12px 16px; }
  .header h1 { font-size: 16px; }
  .range-btn { padding: 6px 10px; font-size: 12px; }
  .chart-wrapper canvas { height: 160px; }
  .time-nav { gap: 4px; }
  .period-label { font-size: 11px; min-width: 80px; }
  .nav-arrow { width: 24px; height: 24px; font-size: 12px; }
  .social-grid { grid-template-columns: 1fr; }
}

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