@import url("https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  --bg: #0f1115;
  --panel: #151923;
  --panel-alt: #0f131b;
  --accent: #ffb84d;
  --accent-2: #7fd1b9;
  --text: #f6f3ee;
  --muted: #a3a9b6;
  --stroke: rgba(255, 255, 255, 0.08);
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #1b2432 0%, transparent 60%),
    radial-gradient(1000px 700px at 90% 10%, #1a1f28 0%, transparent 65%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.login-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.login-panel {
  width: min(420px, 92vw);
  display: grid;
  gap: 16px;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  opacity: 0.35;
}

.app-shell.pro {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar-scrim {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 15;
}

.sidebar-scrim.visible {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 22px;
  background: rgba(10, 12, 16, 0.85);
  border-right: 1px solid var(--stroke);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand { display: flex; align-items: center; gap: 16px; }

.logo {
  width: 48px; height: 48px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #ff7a59);
  color: #111; font-weight: 700; font-size: 20px;
  display: grid; place-items: center;
}

.title { font-family: "DM Serif Display", serif; font-size: 26px; }
.subtitle { color: var(--muted); font-size: 13px; }

.nav { display: grid; gap: 8px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 14px;
  color: var(--muted); text-decoration: none;
  background: rgba(15, 19, 27, 0.4);
  border: 1px solid transparent;
}

.nav-item.active,
.nav-item:hover {
  color: var(--text);
  border-color: rgba(255, 184, 77, 0.3);
  background: rgba(255, 184, 77, 0.08);
}

.sidebar-footer { margin-top: auto; }

.full { width: 100%; }

.main { padding: 28px 36px 60px; }

.main-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 24px;
}

.page-title { font-size: 28px; font-weight: 600; }
.page-subtitle { color: var(--muted); font-size: 13px; }

.header-actions { display: flex; align-items: center; gap: 12px; }

.status {
  background: rgba(127, 209, 185, 0.15);
  color: var(--accent-2);
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(127, 209, 185, 0.3);
  font-size: 13px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--panel);
  border-radius: 18px;
  padding: 16px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
}

.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 24px; margin-top: 8px; }

.pro-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--stroke);
}

.detail-panel { display: grid; gap: 20px; }

.detail-panel.premium {
  background: linear-gradient(180deg, rgba(20, 24, 32, 0.9), rgba(12, 16, 24, 0.85));
}

.detail-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}

.detail-actions { display: flex; align-items: center; gap: 12px; }

.player.pro {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--stroke);
  aspect-ratio: 16 / 9;
}

.player.pro video { width: 100%; height: 100%; background: #000; object-fit: cover; }

.player-overlay {
  position: absolute;
  top: 12px; right: 12px;
  display: flex; gap: 8px;
}

.badge {
  background: rgba(0,0,0,0.55);
  color: #fff;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid rgba(255,255,255,0.15);
}

.badge.light {
  background: rgba(255,255,255,0.12);
}

.mode-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  padding: 2px;
  border: 1px solid var(--stroke);
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

.mode-btn.active {
  background: rgba(127, 209, 185, 0.2);
  color: var(--accent-2);
}

.timeline-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: rgba(12, 16, 24, 0.6);
}

.timeline-panel.premium {
  background: linear-gradient(180deg, rgba(18, 22, 30, 0.9), rgba(12, 16, 24, 0.7));
}

.timeline-header {
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between; gap: 12px;
}

.range-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

.timeline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.download-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

#start-time, #end-time {
  background: var(--panel-alt);
  border: 1px solid var(--stroke);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.range-btn {
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

.range-btn.active {
  background: rgba(255, 184, 77, 0.2);
  color: var(--accent);
  border-color: rgba(255, 184, 77, 0.4);
}

#date-picker {
  background: var(--panel-alt);
  border: 1px solid var(--stroke);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.timeline { display: grid; gap: 10px; }

.timeline-track {
  position: relative;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.timeline-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffb84d, #ff7a59);
}

.timeline-cursor {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 18px;
  background: #fff;
  left: 0%;
  transform: translateX(-1px);
}

.timeline-ticks {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  font-size: 11px;
  color: var(--muted);
  gap: 6px;
}

.right-panel .camera-panel {
  position: sticky;
  top: 24px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-row input {
  width: 100%;
  background: var(--panel-alt);
  border: 1px solid var(--stroke);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
}

.camera-list.list {
  display: grid;
  gap: 14px;
  max-height: 620px;
  overflow-y: auto;
  padding-right: 6px;
}

.camera-card {
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 14px;
  background: rgba(15, 19, 27, 0.7);
  display: grid;
  gap: 10px;
}

.camera-card.active {
  border-color: rgba(255, 184, 77, 0.5);
  box-shadow: 0 0 0 1px rgba(255, 184, 77, 0.2);
}

.camera-card .thumb {
  width: 100%;
  height: 120px;
  border-radius: 12px;
  background: linear-gradient(120deg, rgba(255,184,77,0.2), rgba(127,209,185,0.1));
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.camera-card h4 { margin: 0; }

.camera-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.dot { width: 8px; height: 8px; border-radius: 999px; background: #ff6e62; }
.dot.online { background: #7fd1b9; }
.dot.offline { background: #ff6e62; }

.camera-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.btn { padding: 8px 12px; border-radius: 10px; border: none; font-size: 13px; cursor: pointer; }

.btn.start { background: rgba(127, 209, 185, 0.2); color: var(--accent-2); }
.btn.stop { background: rgba(255, 110, 98, 0.2); color: #ff6e62; }
.btn.view { background: rgba(255, 184, 77, 0.2); color: var(--accent); }
.btn.viewer { background: rgba(127, 209, 255, 0.2); color: #7fd1ff; }
.btn.copy { background: rgba(120, 140, 255, 0.2); color: #9aa7ff; }
.btn.delete { background: rgba(255, 110, 98, 0.1); color: #ff6e62; }

.primary {
  margin-top: 16px; padding: 12px 16px; border: none; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #ff6d3c);
  color: #111; font-weight: 600; cursor: pointer;
}

.primary.slim {
  margin-top: 0;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
}

.ghost {
  border: 1px solid var(--stroke);
  background: transparent; color: var(--text);
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
}

.ghost.icon {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 12px;
}

.muted { color: var(--muted); font-size: 12px; }

.recordings { margin-top: 10px; }
.recording-list { display: grid; gap: 10px; }

.recording-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: rgba(15, 19, 27, 0.7);
  border-radius: 12px; border: 1px solid var(--stroke);
}

.recording-item a { color: var(--accent); text-decoration: none; }

.form {
  display: grid;
  gap: 12px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.form input, .form select {
  background: var(--panel-alt);
  border: 1px solid var(--stroke);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  width: 100%;
}

.form input:focus, .form select:focus {
  outline: 2px solid rgba(255, 184, 77, 0.5);
  outline-offset: 2px;
}

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  align-items: end;
}

.modal {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 50;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(8, 10, 14, 0.7);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative; width: min(520px, 92vw);
  background: var(--panel); border: 1px solid var(--stroke);
  border-radius: 20px; padding: 20px; box-shadow: var(--shadow); z-index: 1;
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}

.modal-hint { margin-top: 10px; }

@media (max-width: 1100px) {
  .pro-grid { grid-template-columns: 1fr; }
  .right-panel { order: -1; }
}

@media (max-width: 980px) {
  .main-header { flex-direction: column; align-items: flex-start; }
  .header-actions { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .player.pro { aspect-ratio: 16 / 9; }
  .camera-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timeline-actions { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .download-controls { flex-wrap: wrap; }
}

@media (max-width: 720px) {
  .app-shell.pro { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 240px;
    transform: translateX(-100%); transition: transform 0.25s ease; z-index: 20;
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 20px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel { padding: 16px; border-radius: 18px; }
  .player.pro { border-radius: 14px; }
  .timeline-panel { padding: 12px; }
  .timeline-ticks { grid-template-columns: repeat(3, 1fr); }
  .row { grid-template-columns: 1fr; }
  .camera-list.list { max-height: none; }
  .camera-card .thumb { height: 90px; }
}

@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr; }
  .header-actions { gap: 8px; }
  .status { padding: 6px 10px; font-size: 12px; }
  .range-buttons { gap: 6px; }
  .range-btn { padding: 6px 10px; font-size: 11px; }
  .download-controls { width: 100%; }
  #start-time, #end-time, #date-picker { width: 100%; }
}
