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

:root {
  --bg: #0b1220;
  --bg2: #111827;
  --card: rgba(255,255,255,.06);
  --card-border: rgba(255,255,255,.1);
  --ink: #f8fafc;
  --muted: #94a3b8;
  --brand: #3b82f6;
  --brand2: #6366f1;
  --green: #22c55e;
  --orange: #f59e0b;
  --red: #ef4444;
  --line: rgba(255,255,255,.08);
  --shadow: 0 8px 32px rgba(0,0,0,.35);
  --radius: 16px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #1e3a5f 0%, transparent 50%),
              radial-gradient(900px 500px at 90% 0%, #312e81 0%, transparent 45%),
              var(--bg);
  color: var(--ink);
  min-height: 100vh;
}
.muted { color: var(--muted); }
.error { color: var(--red); font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

/* ── Topbar ── */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px;
  background: rgba(15,23,42,.85);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 100;
}
.brand {
  font-weight: 700; font-size: 18px;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.top-right { display: flex; align-items: center; gap: 14px; }
.badge-live {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 5px 10px;
  border-radius: 999px; background: rgba(34,197,94,.15); color: var(--green);
  border: 1px solid rgba(34,197,94,.3);
}
.badge-live.off { background: rgba(239,68,68,.12); color: var(--red); border-color: rgba(239,68,68,.25); }
.badge-live .dot {
  width: 8px; height: 8px; border-radius: 50%; background: currentColor;
  animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

.container {
  max-width: 1200px; margin: 24px auto; padding: 0 20px 40px;
  display: flex; flex-direction: column; gap: 20px;
}

/* ── Controls ── */
.controls { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.controls .spacer { flex: 1; }
.exports { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
input[type=date], input[type=text], input[type=password] {
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; background: rgba(0,0,0,.25); color: var(--ink);
}
input:focus { outline: 2px solid rgba(59,130,246,.5); border-color: var(--brand); }

button {
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  color: #fff; border: 0; border-radius: 10px;
  padding: 11px 18px; font-size: 15px; font-weight: 600; cursor: pointer;
}
button:hover { filter: brightness(1.08); }
.ghost, a.ghost {
  background: rgba(255,255,255,.05); color: #dbeafe; border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; text-decoration: none;
  font-size: 13px; font-weight: 500;
}
.ghost:hover { background: rgba(255,255,255,.1); }

/* ── Live camera ── */
.live-camera h2, .section-title {
  margin: 0 0 14px; font-size: 17px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.live-wrap {
  position: relative; background: #000; border-radius: 14px;
  overflow: hidden; aspect-ratio: 16/9; max-height: 480px;
  border: 1px solid var(--line);
}
.live-wrap img { width: 100%; height: 100%; object-fit: contain; display: none; }
.live-placeholder {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 15px; text-align: center; padding: 20px;
  background: linear-gradient(180deg, #0f172a, #020617);
}
.live-placeholder .icon { font-size: 42px; margin-bottom: 8px; opacity: .5; }

/* ── KPIs ── */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi {
  text-align: left; position: relative; overflow: hidden;
}
.kpi::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand2));
}
.kpi.in::before { background: linear-gradient(90deg, #22c55e, #16a34a); }
.kpi.out::before { background: linear-gradient(90deg, #f59e0b, #ea580c); }
.kpi.inside::before { background: linear-gradient(90deg, #3b82f6, #6366f1); }
.kpi.peak::before { background: linear-gradient(90deg, #a855f7, #ec4899); }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi-val { font-size: 36px; font-weight: 800; margin-top: 8px; line-height: 1; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.days { display: flex; flex-wrap: wrap; gap: 10px; }
.day-chip {
  background: rgba(255,255,255,.04); color: var(--ink); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 14px; cursor: pointer; font-size: 13px;
  display: flex; gap: 10px; align-items: center; transition: .15s;
}
.day-chip span { color: var(--muted); }
.day-chip:hover, .day-chip.active { border-color: var(--brand); background: rgba(59,130,246,.12); }
.summary {
  padding: 14px 18px; border-radius: 12px;
  background: rgba(59,130,246,.08); border: 1px solid rgba(59,130,246,.2);
  font-size: 14px; line-height: 1.5;
}

/* ── Login ── */
.login-page {
  display: grid; place-items: center; min-height: 100vh; padding: 20px;
}
.login-card {
  width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px;
}
.login-card h1 {
  margin: 0; font-size: 28px; font-weight: 800;
  background: linear-gradient(135deg, #60a5fa, #c084fc);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-logo { font-size: 48px; text-align: center; margin-bottom: -8px; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
