:root {
  --bg: #07111b;
  --panel: #0d1824;
  --panel-2: #122232;
  --line: rgba(255,255,255,0.08);
  --text: #f6fbff;
  --muted: #9fb2c7;
  --accent: #4fe3c1;
  --accent-2: #7aa2ff;
  --danger: #ff6b7a;
  --shadow: 0 20px 50px rgba(0,0,0,0.28);
}
* { box-sizing: border-box; }
html { background: linear-gradient(180deg, #08121b 0%, #061018 100%); }
body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(79,227,193,0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(122,162,255,0.10), transparent 22%),
    linear-gradient(180deg, #08121b 0%, #061018 100%);
}
a { color: inherit; text-decoration: none; }
code { color: #d7e5f6; background: rgba(255,255,255,0.05); padding: 2px 6px; border-radius: 8px; }
.shell { width: min(1320px, calc(100% - 28px)); margin: 0 auto; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 0 10px;
}
.topbar-user { margin-top: 6px; font-size: 13px; }
.brand { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.navlinks { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.navlinks > a, .navlinks form { display: inline-flex; }
.navlinks a { padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,0.05); border: 1px solid transparent; }
.navlinks a:hover { border-color: var(--line); }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; }
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.028));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 20px;
  backdrop-filter: blur(14px);
}
.gradient-card {
  background:
    radial-gradient(circle at top left, rgba(79,227,193,0.12), transparent 30%),
    radial-gradient(circle at bottom right, rgba(122,162,255,0.14), transparent 24%),
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
}
.flash-wrap { display: grid; gap: 12px; margin: 18px 0; }
.flash { padding: 14px 16px; border-radius: 16px; border: 1px solid transparent; }
.flash-success { border-color: rgba(79,227,193,0.25); background: rgba(79,227,193,0.12); }
.flash-danger { border-color: rgba(255,107,122,0.25); background: rgba(255,107,122,0.12); }
.flash-info { background: rgba(103,166,255,0.12); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #08111d; }
.btn-ghost { background: rgba(255,255,255,0.06); color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: rgba(255,107,122,0.14); color: #ffd8de; border: 1px solid rgba(255,107,122,0.35); }
.btn-block { width: 100%; }
.stack { display: grid; }
.gap-md { gap: 14px; }
.gap-lg { gap: 18px; }
.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.cards-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dashboard-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.metric-card span { color: var(--muted); display: block; margin-bottom: 12px; }
.metric-card strong { display: block; font-size: 34px; font-weight: 800; margin-bottom: 8px; }
.metric-card small { color: var(--muted); }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 14px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-head h2, .section-head h3, .public-hero h1, .viewer-head h2 { margin: 0; }
.public-shell > section { margin-bottom: 18px; }
.list-table { display: grid; gap: 10px; }
.list-table.tight { gap: 8px; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,0.04); border: 1px solid var(--line);
}
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid rgba(255,255,255,0.08); text-align: left; white-space: nowrap; font-size: 14px; }
th { color: var(--muted); font-weight: 600; }
.truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.inline-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form-card { max-width: 980px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid label { display: grid; gap: 8px; }
.form-grid input, .form-grid textarea, #cameraSearch {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
}
.compact-grid input { min-height: 46px; }
.check { display: flex !important; align-items: center; gap: 10px; }
.check input { width: 18px; height: 18px; }
.login-page { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: min(460px, 100%); }
.note { margin-top: 18px; background: rgba(255,255,255,0.04); }
.public-shell { padding-bottom: 26px; }
.public-hero {
  margin: 18px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.stats-inline { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.stat-mini { min-width: 160px; padding: 14px 16px; background: rgba(255,255,255,0.06); border-radius: 16px; border: 1px solid var(--line); }
.stat-mini span { display: block; color: var(--muted); margin-bottom: 8px; }
.stat-mini strong { font-size: 28px; }
.public-lower-grid { display: grid; grid-template-columns: minmax(300px, .9fr) minmax(0, 1.6fr); gap: 18px; align-items: stretch; }
.viewer-card { display: grid; gap: 16px; align-content: start; }
.viewer-card-full { width: 100%; }
.viewer-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.viewer-head-single { justify-content: center; text-align: center; }
.viewer-toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  width: min(100%, 980px);
  margin: 0 auto;
}
.viewer-toolbar-text {
  text-align: center;
  font-size: 14px;
}
.viewer-nav-btn {
  min-width: 154px;
  white-space: nowrap;
}
.viewer-nav-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.iframe-wrap {
  aspect-ratio: 16/9; border-radius: 20px; overflow: hidden; background: #000; border: 1px solid var(--line);
}
.iframe-wrap-large { height: min(68vh, 820px); min-height: 420px; width: min(100%, 1280px); margin: 0 auto; }
.iframe-wrap iframe { width: 100%; height: 100%; border: 0; background: #000; display: block; }
.camera-meta { text-align: center; }
#map { height: 560px; border-radius: 18px; overflow: hidden; }
.camera-list { display: grid; gap: 12px; max-height: 560px; overflow: auto; }
.camera-item {
  padding: 14px; border-radius: 16px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); cursor: pointer;
  display: grid; gap: 8px; text-align: left; color: var(--text); font: inherit; width: 100%;
}
.camera-item-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.camera-dot { width: 12px; height: 12px; border-radius: 999px; box-shadow: 0 0 0 4px rgba(255,255,255,0.05); }
.camera-item.active { border-color: rgba(79,227,193,0.5); box-shadow: 0 0 0 1px rgba(79,227,193,0.2) inset; }
.camera-item strong { display: block; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #ffffff; color: #0d1b2a; }
.leaflet-popup-content { margin: 12px 14px; }
.popup-card h4 { margin: 0 0 8px; }
.popup-card p { margin: 0; color: #4b5563; }
.list-card, .map-card { height: 100%; }
.list-card .section-head { align-items: flex-start; }
.camera-marker {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255,255,255,0.96);
  color: var(--marker-color);
  box-shadow: 0 6px 14px rgba(15,23,42,0.18);
  border: 1.6px solid color-mix(in srgb, var(--marker-color) 62%, white 38%);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  backdrop-filter: blur(8px);
}
.camera-marker svg { width: 12px; height: 12px; display: block; }
.camera-marker.active,
.camera-marker:hover {
  transform: translateY(-1px) scale(1.08);
  border-color: var(--marker-color);
  box-shadow: 0 8px 18px rgba(15,23,42,0.22), 0 0 0 3px color-mix(in srgb, var(--marker-color) 18%, white 82%);
}
canvas { width: 100% !important; max-height: 260px; }
@media (max-width: 1200px) {
  .cards-4, .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .public-lower-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .list-card { order: 2; }
  .map-card { order: 3; }
  .iframe-wrap-large { height: min(56vh, 620px); }
}
@media (max-width: 760px) {
  .shell { width: min(100% - 16px, 100%); }
  .topbar, .public-hero, .viewer-head, .section-head { flex-direction: column; align-items: stretch; }
  .cards-4, .dashboard-grid, .public-lower-grid, .form-grid { grid-template-columns: 1fr; }
  .navlinks { justify-content: stretch; }
  .navlinks a, .navlinks form, .navlinks form button { width: 100%; }
  .span-2 { grid-column: auto; }
  .brand { font-size: 20px; }
  .card { border-radius: 20px; padding: 16px; }
  .viewer-head-single { text-align: center; }
  .viewer-toolbar {
    grid-template-columns: 1fr 1fr;
  }
  .viewer-toolbar-text {
    grid-column: 1 / -1;
    order: 3;
    font-size: 13px;
  }
  .viewer-nav-btn {
    min-width: 0;
    width: 100%;
  }
  .iframe-wrap-large { height: 34vh; min-height: 240px; width: 100%; }
  .camera-meta { text-align: center; }
  #map { height: 320px; }
  .camera-marker { width: 19px; height: 19px; }
  .camera-marker svg { width: 10px; height: 10px; }
  .camera-list { max-height: none; }
  .camera-item { padding: 12px; }
  th, td { font-size: 13px; padding: 10px 8px; }
  .truncate { max-width: 140px; }
}
