/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2233;
  --bg-card-hover: #1f2a3d;
  --bg-input: #0f1623;
  --border: #2a3548;
  --border-focus: #3b82f6;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .5px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--text-muted); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-danger  { background: var(--danger); color: #fff; }

.btn-full { width: 100%; padding: 12px; }

.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
.btn-spinner.hidden { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Main ─────────────────────────────────────────────────────────────────── */
.main {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Landing ──────────────────────────────────────────────────────────────── */
.landing-hero {
  text-align: center;
  padding: 48px 0 32px;
}

.landing-icon {
  width: 64px;
  height: 64px;
  color: var(--accent);
  margin-bottom: 16px;
}

.landing-hero h2 {
  font-size: 28px;
  margin-bottom: 8px;
}

.landing-hero p {
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto;
}

/* ── Camera Grid ──────────────────────────────────────────────────────────── */
.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 20px;
  margin-top: 8px;
}

.camera-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}

.camera-card:hover {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 1px var(--border-focus);
}

.camera-card.placeholder {
  opacity: .6;
}

.camera-feed {
  aspect-ratio: 16/9;
  background: #060a12;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.feed-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.feed-placeholder svg {
  width: 48px;
  height: 48px;
}

.feed-placeholder span {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.camera-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}

.camera-name {
  font-weight: 600;
  font-size: 14px;
}

.camera-status {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.camera-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.camera-status.online  { color: var(--success); }
.camera-status.online::before  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.camera-status.offline { color: var(--text-muted); }
.camera-status.offline::before { background: var(--text-muted); }

/* Feed timestamp overlay */
.feed-timestamp {
  position: absolute;
  bottom: 8px;
  right: 10px;
  background: rgba(0,0,0,.7);
  color: #ccc;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
}

.feed-label {
  position: absolute;
  top: 8px;
  left: 10px;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.feed-rec {
  position: absolute;
  top: 8px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0,0,0,.7);
  color: var(--danger);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
}

.feed-rec::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
  animation: blink 1s ease-in-out infinite;
}

@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ── Dashboard ────────────────────────────────────────────────────────────── */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.dashboard-header h2 {
  font-size: 22px;
}

.dashboard-user {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn .2s ease;
}

.modal-overlay.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: var(--shadow);
  animation: slideUp .25s ease;
}

@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } }

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.modal-close:hover { color: var(--text-primary); }

.modal-header {
  text-align: center;
  margin-bottom: 24px;
}

.modal-logo {
  width: 40px;
  height: 40px;
  color: var(--accent);
  margin-bottom: 8px;
}

.modal-header h2 {
  font-size: 20px;
}

/* ── Auth Tabs ────────────────────────────────────────────────────────────── */
.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: color .2s, border-color .2s;
}

.auth-tab:hover { color: var(--text-secondary); }
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form.hidden { display: none; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}

.form-group input::placeholder { color: var(--text-muted); }
.form-group input:focus { border-color: var(--border-focus); }

.form-message {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.4;
}

.form-message.hidden { display: none; }
.form-message.error   { background: rgba(239,68,68,.12); color: var(--danger); border: 1px solid rgba(239,68,68,.25); }
.form-message.success { background: rgba(34,197,94,.12); color: var(--success); border: 1px solid rgba(34,197,94,.25); }

/* ── Utilities ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 840px) {
  .camera-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .main { padding: 16px; }
  .modal { margin: 16px; padding: 24px; }
  .header { padding: 0 16px; }
  .landing-hero { padding: 32px 0 24px; }
  .landing-hero h2 { font-size: 22px; }
}
