:root {
  --blue: #1d6ff2;
  --blue-dark: #0b3c91;
  --blue-soft: #e8f1ff;
  --cyan: #51b7ff;
  --text: #14213d;
  --muted: #65758b;
  --border: #dbe7f8;
  --bg: #f7fbff;
  --card: rgba(255, 255, 255, 0.92);
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #16a34a;
  --shadow: 0 20px 60px rgba(20, 65, 130, 0.14);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(81, 183, 255, 0.18), transparent 34rem),
    linear-gradient(180deg, #f8fbff 0%, #edf6ff 100%);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
img { max-width: 100%; }

.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
  background: rgba(255,255,255,.78);
  border-bottom: 1px solid rgba(219,231,248,.7);
}
.nav-inner { height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 22px; color: var(--blue-dark); }
.logo-mark { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; color: white; background: linear-gradient(135deg, var(--blue), var(--cyan)); box-shadow: 0 12px 28px rgba(29,111,242,.28); }
.nav-links { display: flex; align-items: center; gap: 18px; color: var(--muted); font-weight: 600; }
.nav-links a.active, .nav-links a:hover { color: var(--blue); }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.burger { display: none; border: 0; background: transparent; font-size: 28px; color: var(--blue-dark); }
.health-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 999px; background: #fff; color: var(--muted); font-size: 13px; font-weight: 700; }
.health-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--warning); box-shadow: 0 0 0 5px rgba(245,158,11,.12); }
.health-pill.ok .health-dot { background: var(--success); box-shadow: 0 0 0 5px rgba(22,163,74,.12); }
.health-pill.bad .health-dot { background: var(--danger); box-shadow: 0 0 0 5px rgba(239,68,68,.14); }
.connection-banner { display: none; position: fixed; top: 86px; left: 50%; transform: translateX(-50%); z-index: 50; padding: 12px 18px; color: #7c2d12; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 14px; box-shadow: var(--shadow); font-weight: 700; }

.btn { border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 800; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: transform .2s, box-shadow .2s, background .2s; }
.btn:hover { transform: translateY(-2px); }
.btn-primary { color: white; background: linear-gradient(135deg, var(--blue), #2aa8ff); box-shadow: 0 18px 34px rgba(29,111,242,.28); }
.btn-ghost { color: var(--blue-dark); background: #fff; border: 1px solid var(--border); }
.btn-danger { color: white; background: var(--danger); }
.btn-small { padding: 9px 12px; border-radius: 10px; font-size: 13px; }

.hero { position: relative; overflow: hidden; padding: 76px 0 72px; }
.hero-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 46px; align-items: center; }
.eyebrow { display: inline-flex; gap: 8px; align-items: center; padding: 8px 12px; color: var(--blue-dark); background: #fff; border: 1px solid var(--border); border-radius: 999px; font-weight: 800; font-size: 13px; }
h1 { font-size: clamp(38px, 7vw, 76px); line-height: .98; letter-spacing: -0.06em; margin: 18px 0; }
.lead { color: var(--muted); font-size: 19px; line-height: 1.7; max-width: 660px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.hero-panel { position: relative; min-height: 470px; border-radius: 34px; padding: 22px; background: linear-gradient(145deg, rgba(255,255,255,.9), rgba(232,241,255,.85)); border: 1px solid rgba(219,231,248,.9); box-shadow: var(--shadow); overflow: hidden; }
.camera-preview { height: 240px; border-radius: 24px; background: linear-gradient(135deg, #0b3c91, #1d6ff2 55%, #51b7ff); position: relative; overflow: hidden; }
.camera-preview:before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, rgba(255,255,255,.08) 0 2px, transparent 2px 80px), repeating-linear-gradient(0deg, rgba(255,255,255,.05) 0 2px, transparent 2px 80px); animation: scan 5s linear infinite; }
.camera-preview:after { content: 'LIVE'; position: absolute; right: 18px; top: 18px; background: rgba(255,255,255,.9); color: var(--blue-dark); padding: 7px 11px; border-radius: 999px; font-weight: 900; font-size: 12px; }
@keyframes scan { from { transform: translateY(0); } to { transform: translateY(80px); } }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.mini-stat { padding: 16px; border-radius: 18px; background: #fff; border: 1px solid var(--border); }
.mini-stat strong { display: block; font-size: 24px; color: var(--blue-dark); }
.mini-stat span { color: var(--muted); font-size: 12px; font-weight: 700; }
.wave-bg { position: absolute; width: 420px; height: 420px; border-radius: 50%; right: -140px; bottom: -160px; background: radial-gradient(circle, rgba(81,183,255,.26), transparent 70%); }

.section { padding: 48px 0; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.section-title h2 { font-size: clamp(28px, 4vw, 44px); margin: 0; letter-spacing: -0.04em; }
.section-title p { color: var(--muted); max-width: 620px; line-height: 1.65; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 24px; padding: 22px; box-shadow: 0 12px 30px rgba(20,65,130,.08); }
.card h3 { margin-top: 0; color: var(--blue-dark); }
.card p { color: var(--muted); line-height: 1.65; }

.page-head { padding: 42px 0 20px; }
.page-head h1 { font-size: clamp(34px, 5vw, 56px); margin-bottom: 10px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 18px 0 24px; }
.dashboard-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.camera-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.camera-card { position: relative; overflow: hidden; }
.camera-card .meta { color: var(--muted); font-size: 14px; display: grid; gap: 6px; margin: 14px 0; }
.recording-dot { width: 12px; height: 12px; border-radius: 999px; display: inline-block; background: var(--warning); margin-right: 6px; vertical-align: -1px; }
.recording .recording-dot { background: var(--danger); animation: pulse 1.1s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); } 70% { box-shadow: 0 0 0 10px rgba(239,68,68,0); } 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); } }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 48px; border: 2px dashed var(--border); border-radius: 24px; color: var(--muted); background: rgba(255,255,255,.62); }

.modal { display: none; position: fixed; inset: 0; z-index: 80; background: rgba(7, 24, 48, .45); align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-box { width: min(560px, 100%); background: #fff; border-radius: 26px; padding: 24px; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { margin: 0; }
.close-modal { border: 0; background: #eef6ff; border-radius: 10px; width: 36px; height: 36px; cursor: pointer; }
.form-grid { display: grid; gap: 14px; }
.field label { display: block; font-weight: 800; margin-bottom: 7px; color: var(--blue-dark); }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--border); border-radius: 14px; padding: 13px 14px; outline: none; background: #fbfdff; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(29,111,242,.1); }
.form-message { min-height: 22px; color: var(--muted); font-weight: 700; }
.form-message.error { color: var(--danger); }
.form-message.ok { color: var(--success); }

.auth-shell { min-height: calc(100vh - 75px); display: grid; place-items: center; padding: 40px 0; }
.auth-card { width: min(520px, calc(100% - 32px)); }
.auth-card h1 { font-size: 38px; }

.video-shell { display: grid; grid-template-columns: 1.5fr .5fr; gap: 22px; align-items: start; }
.video-js { width: 100%; aspect-ratio: 16/9; border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); background: #071830; }
.stats-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 20px; }
.chart-card { min-height: 380px; }
.table { width: 100%; border-collapse: collapse; overflow: hidden; border-radius: 18px; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.table th { color: var(--blue-dark); background: var(--blue-soft); }
.geo-map { height: 250px; border-radius: 22px; position: relative; background: linear-gradient(135deg, #e8f1ff, #d6ebff); overflow: hidden; border: 1px solid var(--border); }
.geo-map span { position: absolute; width: 16px; height: 16px; border-radius: 999px; background: var(--blue); box-shadow: 0 0 0 9px rgba(29,111,242,.13); animation: pulseMap 2s infinite; }
@keyframes pulseMap { 50% { transform: scale(1.25); opacity: .75; } }
.footer { margin-top: 48px; padding: 30px 0; border-top: 1px solid var(--border); color: var(--muted); }

@media (max-width: 960px) {
  .hero-grid, .video-shell, .stats-grid { grid-template-columns: 1fr; }
  .grid-3, .camera-grid, .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
  .nav-links { display: none; position: absolute; top: 74px; left: 0; right: 0; background: #fff; padding: 18px; border-bottom: 1px solid var(--border); flex-direction: column; align-items: flex-start; }
  .nav-links.open { display: flex; }
  .burger { display: block; }
}

@media (max-width: 640px) {
  .container { width: min(100% - 22px, 1180px); }
  .hero { padding-top: 44px; }
  .grid-3, .camera-grid, .dashboard-stats, .stat-row { grid-template-columns: 1fr; }
  .nav-actions .btn-ghost:not(.keep-mobile) { display: none; }
  .section-title { align-items: flex-start; flex-direction: column; }
  .hero-panel { min-height: auto; }
}
