/* ═══════════════════════════════════════════════════════════
   Видеоаналитика — Dashboard
   Golos Text + JetBrains Mono · Deep Slate Theme
   ═══════════════════════════════════════════════════════════ */

:root {
  /* ── Surfaces ── */
  --bg: #0a0e14;
  --surface-1: #111720;
  --surface-2: #1a2030;
  --surface-3: #242d3d;

  /* ── Borders ── */
  --border: #1e2738;
  --border-hover: #2e3b50;

  /* ── Text ── */
  --text: #d8e0ec;
  --text-2: #8493a8;
  --text-3: #566070;
  --text-muted: #566070;

  /* ── Accent ── */
  --accent: #4b8df8;
  --accent-soft: rgba(75, 141, 248, 0.08);
  --accent-border: rgba(75, 141, 248, 0.25);

  /* ── Semantic ── */
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.06);
  --green-border: rgba(52, 211, 153, 0.20);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.06);
  --red-border: rgba(248, 113, 113, 0.20);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.06);
  --cyan: #22d3ee;
  --orange: #fb923c;
  --orange-soft: rgba(251, 146, 60, 0.06);
  --orange-border: rgba(251, 146, 60, 0.20);

  /* ── Shape ── */
  --r-sm: 5px;
  --r: 8px;
  --r-lg: 12px;

  /* ── Fonts ── */
  --sans: 'Golos Text', 'Segoe UI', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Cascadia Code', 'Consolas', monospace;

  /* ── Motion ── */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 180ms;
}

/* ── Reset ───────────────────────────────────────────────── */

html { color-scheme: dark; }
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ── Header ──────────────────────────────────────────────── */

header {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.logo-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #4b8df8 0%, #7c5cf8 100%);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.logo-mark svg { display: block; }

header h1 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Navigation */

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  margin-left: 1.5rem;
}

.nav-link {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  padding: 0.3rem 0.65rem;
  border-radius: var(--r-sm);
  transition: all var(--dur) var(--ease);
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.badge {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  transition: all var(--dur) var(--ease);
  letter-spacing: 0.01em;
}

.badge-on {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid var(--green-border);
}

.badge-off {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid var(--red-border);
}

/* ── Layout ──────────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: 210px 1fr;
  flex: 1;
  min-height: 300px;
  max-height: calc(100vh - 46px - 340px);
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar {
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-top {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem;
}

.sidebar-bottom {
  flex-shrink: 0;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.section-header h2 {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
}

/* Camera list */

.camera-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.camera-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.55rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  border: 1px solid transparent;
}

.camera-item:hover { background: var(--surface-2); }

.camera-item.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.cam-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
  transition: all var(--dur) var(--ease);
}

.cam-dot.live {
  background: var(--green);
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
}

.cam-dot.inactive {
  background: var(--text-3);
  opacity: 0.5;
}

.cam-active-toggle {
  display: flex;
  gap: .5rem;
  align-items: center;
  font-size: .9rem;
  cursor: pointer;
}
.cam-active-toggle input[type=checkbox] {
  width: 16px; height: 16px;
}

.cam-name {
  flex: 1;
  font-size: 0.8rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
  opacity: 0;
  transition: all var(--dur) var(--ease);
}

.camera-item:hover .btn-del { opacity: 1; }
.btn-del:hover { color: var(--red); }

/* Settings cog in camera list — always fully visible. Was opacity 0.45 but
   user reported they couldn't find it; making it always-on is the safest. */
.btn-cog {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-2);
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  width: 22px;
  height: 22px;
  opacity: 1;
  flex-shrink: 0;
  transition: all var(--dur) var(--ease);
}
.btn-cog:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Add-camera form */

.add-form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.add-form input,
.onvif-helper input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.4rem 0.55rem;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.78rem;
  width: 100%;
  outline: none;
  transition: border-color var(--dur) var(--ease);
}

.add-form input:focus,
.onvif-helper input:focus {
  border-color: var(--accent);
}

.add-form input::placeholder,
.onvif-helper input::placeholder {
  color: var(--text-3);
}

/* ONVIF helper */

.onvif-helper {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.help-text {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Main Content ────────────────────────────────────────── */

.main-content {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

/* Stats strip */

.stats-strip {
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  height: 44px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 0;
}

.stats-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  padding: 0 0.5rem 0 0.25rem;
  white-space: nowrap;
  min-width: 50px;
}

.stats-camera {
  border-bottom: none;
  background: var(--surface-2);
  height: 38px;
}

.stats-camera .stat-val { font-size: 0.9rem; }

.stat-pill {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 0.75rem;
  height: 26px;
  border-left: 2px solid var(--pill-accent, var(--border));
  animation: fade-up 0.4s var(--ease) both;
}

.stat-pill:nth-child(1) { animation-delay: 0s; }
.stat-pill:nth-child(2) { animation-delay: 0.05s; }
.stat-pill:nth-child(3) { animation-delay: 0.1s; }
.stat-pill:nth-child(4) { animation-delay: 0.15s; }
.stat-pill:nth-child(5) { animation-delay: 0.2s; }

.stat-val {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.stat-lbl {
  font-size: 0.68rem;
  color: var(--text-3);
  white-space: nowrap;
}

.spacer { flex: 1; }

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.55rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  transition: all var(--dur) var(--ease);
}

.btn-export:hover {
  border-color: var(--border-hover);
  color: var(--text);
  background: var(--surface-2);
}

.btn-export svg { flex-shrink: 0; }

/* Video */

.video-wrapper {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#video-feed {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  pointer-events: none;
}

#overlay.drawing { pointer-events: all; }

.no-stream {
  position: absolute;
  color: var(--text-3);
  font-size: 0.85rem;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.no-stream.hidden { display: none; }

/* Toolbar */

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.75rem;
  background: var(--surface-1);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.55rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 500;
  transition: all var(--dur) var(--ease);
  white-space: nowrap;
}

.tool-btn svg { flex-shrink: 0; }

.tool-btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-hover);
  color: var(--text);
}

.tool-btn.active {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
}

.tool-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.tool-btn-danger { color: var(--red); }
.tool-btn-danger:hover:not(:disabled) {
  background: var(--red-soft);
  border-color: var(--red-border);
  color: var(--red);
}

.tool-btn-excl { color: var(--orange); }
.tool-btn-excl:hover:not(:disabled) {
  background: var(--orange-soft);
  border-color: var(--orange-border);
  color: var(--orange);
}

.tool-btn-save { color: var(--green); }
.tool-btn-primary { color: var(--green); }
.tool-btn-save:hover:not(:disabled),
.tool-btn-primary:hover:not(:disabled) {
  background: var(--green-soft);
  border-color: var(--green-border);
  color: var(--green);
}

.tool-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 0.1rem;
}

.mode-label {
  font-size: 0.72rem;
  color: var(--amber);
  font-weight: 500;
  margin-right: 0.2rem;
  min-width: 0;
}

.camera-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-3);
}

/* ── Bottom Sections (shared) ────────────────────────────── */

.bottom-section {
  padding: 0.6rem 1rem;
  background: var(--surface-1);
  border-top: 1px solid var(--border);
}

.bottom-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.bottom-header h2 {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
}

.count-badge {
  font-family: var(--mono);
  font-size: 0.65rem;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  padding: 0.05rem 0.4rem;
  border-radius: 99px;
  font-weight: 500;
}

/* ── Visitors Gallery ────────────────────────────────────── */

.visitors-grid {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
}

.visitor-card {
  flex-shrink: 0;
  width: 105px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  transition: all var(--dur) var(--ease);
  animation: fade-up 0.3s var(--ease) both;
}

.visitor-card:hover {
  border-color: var(--accent-border);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.visitor-photo {
  width: 105px;
  height: 105px;
  object-fit: cover;
  background: var(--bg);
  display: block;
}

.visitor-placeholder {
  width: 105px;
  height: 105px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text-3);
  font-size: 2rem;
}

.visitor-info { padding: 0.3rem 0.4rem; }

.visitor-name {
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.visitor-stats {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--text-2);
  margin-top: 0.05rem;
}

.visitor-last {
  font-size: 0.6rem;
  color: var(--text-3);
}

.empty-visitors {
  color: var(--text-3);
  font-size: 0.78rem;
  padding: 0.3rem;
}

/* ── History ─────────────────────────────────────────────── */

.filters {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.filters label {
  font-size: 0.72rem;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.filters input[type="date"],
.filters select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.22rem 0.4rem;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.75rem;
  outline: none;
  transition: border-color var(--dur) var(--ease);
}

.filters input:focus,
.filters select:focus {
  border-color: var(--accent);
}

/* Table */

.table-wrap {
  overflow: auto;
  max-height: 150px;
  border-radius: var(--r);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

thead th {
  text-align: left;
  padding: 0.38rem 0.65rem;
  color: var(--text-3);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface-2);
  white-space: nowrap;
}

tbody tr { transition: background var(--dur) var(--ease); }
tbody tr:hover { background: var(--surface-2); }

tbody td {
  padding: 0.32rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

tbody td code {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-2);
  background: var(--surface-3);
  padding: 0.08rem 0.28rem;
  border-radius: 3px;
}

.empty-row {
  text-align: center;
  color: var(--text-3);
  padding: 1.2rem !important;
}

/* Pagination */

.pagination {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.35rem;
  justify-content: center;
}

#page-info {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-3);
}

/* ── Shared Buttons ──────────────────────────────────────── */

.btn-primary {
  padding: 0.38rem 0.7rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  transition: all var(--dur) var(--ease);
}

.btn-primary:hover { background: rgba(75, 141, 248, 0.15); }

.btn-full { width: 100%; }

.btn-secondary {
  padding: 0.28rem 0.55rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.78rem;
  transition: all var(--dur) var(--ease);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-hover);
  color: var(--text);
}

.btn-secondary:disabled { opacity: 0.3; cursor: default; }

.btn-icon {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--text-2);
  font-size: 1rem;
  padding: 0.15rem 0.3rem;
  border-radius: var(--r-sm);
  transition: all var(--dur) var(--ease);
}

.btn-icon:hover {
  color: var(--text);
  background: var(--surface-2);
}

/* ── Utilities ───────────────────────────────────────────── */

.hidden { display: none !important; }

/* ── Scrollbars ──────────────────────────────────────────── */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }

/* ── Modal ────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  z-index: 100;
  animation: modal-bg-in 0.2s var(--ease);
}

.modal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 460px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  animation: modal-in 0.25s var(--ease);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
}

.modal-close {
  font-size: 1.2rem;
  color: var(--text-3);
}

.modal-body {
  padding: 0.75rem 1rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
}

/* Discovery specific */

.discover-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-2);
  font-size: 0.82rem;
  padding: 0.5rem 0;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-hover);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

.discover-creds {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.creds-row {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.creds-row input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.38rem 0.55rem;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.8rem;
  outline: none;
  transition: border-color var(--dur) var(--ease);
}

.creds-row input:focus { border-color: var(--accent); }
.creds-row input::placeholder { color: var(--text-3); }

.discover-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.discover-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: all var(--dur) var(--ease);
}

.discover-item:hover { border-color: var(--border-hover); }
.discover-item.added { border-color: var(--green-border); background: var(--green-soft); }
.discover-item.error { border-color: var(--red-border); }

.discover-ip {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
}

.discover-type {
  font-size: 0.7rem;
  color: var(--text-3);
  flex: 1;
}

.discover-msg {
  font-size: 0.72rem;
  margin-left: auto;
}

.discover-msg.ok { color: var(--green); }
.discover-msg.err { color: var(--red); }

.discover-add-btn {
  padding: 0.22rem 0.5rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all var(--dur) var(--ease);
  margin-left: auto;
}

.discover-add-btn:hover { background: rgba(75, 141, 248, 0.15); }
.discover-add-btn:disabled { opacity: 0.3; cursor: default; }

.discover-empty, .discover-error {
  font-size: 0.82rem;
  color: var(--text-3);
  padding: 0.5rem 0;
}

.discover-error { color: var(--red); }

/* ── Chart Section ──────────────────────────────────────── */

.chart-section .chart-wrap {
  height: 180px;
  position: relative;
}

.chart-section canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ── Toast Notifications ────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  padding: 0.6rem 1rem;
  border-radius: var(--r);
  font-size: 0.82rem;
  font-weight: 500;
  z-index: 200;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s var(--ease);
  max-width: 360px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-warning {
  background: var(--amber);
  color: #000;
  border: 1px solid rgba(251, 191, 36, 0.5);
}

.toast-info {
  background: var(--accent);
  color: #fff;
}

/* ── Page Layout (for visitor/analytics pages) ──────────── */

.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem;
}

.page-title-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.page-title-bar h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.page-title-bar .count-badge {
  font-size: 0.75rem;
}

/* Filter bar */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filter-bar label {
  font-size: 0.75rem;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.filter-bar input,
.filter-bar select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.3rem 0.5rem;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.78rem;
  outline: none;
  transition: border-color var(--dur) var(--ease);
}

.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--accent);
}

.filter-bar .search-input {
  min-width: 160px;
}

/* Visitor grid (page version, larger cards) */

.visitors-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.6rem;
}

.visitor-page-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  transition: all var(--dur) var(--ease);
  cursor: pointer;
  animation: fade-up 0.3s var(--ease) both;
}

.visitor-page-card:hover {
  border-color: var(--accent-border);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.visitor-page-card .photo {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg);
  display: block;
}

.visitor-page-card .placeholder {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text-3);
  font-size: 2.5rem;
}

.visitor-page-card .info {
  padding: 0.45rem 0.55rem;
}

.visitor-page-card .name {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.visitor-page-card .meta {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-2);
  margin-top: 0.1rem;
}

.visitor-page-card .time {
  font-size: 0.65rem;
  color: var(--text-3);
}

/* Visitor detail */

.visitor-detail {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
}

.visitor-detail .profile-photo {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: var(--r);
  background: var(--surface-2);
}

.visitor-detail .profile-placeholder {
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 4rem;
}

.visitor-detail .profile-info h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.visitor-detail .profile-meta {
  color: var(--text-2);
  font-size: 0.82rem;
  margin-bottom: 1rem;
}

.detail-stats {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.detail-stat {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0.55rem 0.75rem;
  min-width: 100px;
}

.detail-stat .val {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.detail-stat .lbl {
  font-size: 0.68rem;
  color: var(--text-3);
  margin-top: 0.1rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-2);
  font-size: 0.82rem;
  text-decoration: none;
  margin-bottom: 1rem;
  transition: color var(--dur) var(--ease);
}

.back-link:hover { color: var(--accent); }

/* Analytics page */

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.analytics-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem;
}

.analytics-card.full-width {
  grid-column: 1 / -1;
}

.analytics-card h3 {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 0.75rem;
}

.analytics-card .chart-container {
  height: 220px;
  position: relative;
}

/* Funnel visualization */

.funnel {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.funnel-step {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.funnel-bar {
  height: 28px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  padding: 0 0.65rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  min-width: 40px;
  transition: width 0.5s var(--ease);
}

.funnel-label {
  font-size: 0.78rem;
  color: var(--text-2);
  white-space: nowrap;
  min-width: 90px;
}

/* Heatmap canvas */

.heatmap-container {
  position: relative;
  background: var(--bg);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.heatmap-container img {
  width: 100%;
  display: block;
  opacity: 0.4;
}

.heatmap-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Comparison */

.compare-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.compare-col {
  text-align: center;
}

.compare-col .date-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-3);
  margin-bottom: 0.35rem;
}

.compare-col .big-num {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 600;
}

.compare-col .sub {
  font-size: 0.72rem;
  color: var(--text-2);
}

/* Page pagination */

.page-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1rem;
}

/* ── Animations ──────────────────────────────────────────── */

@keyframes fade-up {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes modal-bg-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* Camera settings modal */
.settings-section { margin-bottom: 1rem; }
.settings-row { display: grid; grid-template-columns: 1fr 130px; gap: .75rem; align-items: center; padding: .35rem 0; border-bottom: 1px solid var(--border); }
.settings-row label { font-size: .82rem; color: var(--text-2); }
.settings-row input[type=number] { padding: .35rem .5rem; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r); color: var(--text); text-align: right; font-variant-numeric: tabular-nums; font-size: .85rem; }
.quality-toggle { display: flex; flex-direction: column; gap: .35rem; padding: .35rem 0; }
.quality-toggle label { display: flex; gap: .5rem; align-items: center; font-size: .85rem; cursor: pointer; }
.help-text { font-size: .75rem; color: var(--text-muted); }
.help-text code { background: var(--bg-2); padding: 1px 4px; border-radius: 3px; }


/* Per-period analytics block */
.range-section { margin-top: 1rem; }
.range-controls {
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: end;
  padding: .5rem 1rem; background: var(--surface);
  border-radius: var(--r); border: 1px solid var(--border);
  margin-bottom: .75rem;
}
.range-controls label {
  display: flex; flex-direction: column; gap: .25rem;
  font-size: .75rem; color: var(--text-2);
}
.range-controls input[type=datetime-local],
.range-controls select {
  padding: .35rem .5rem;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text);
  font-size: .85rem;
}
.range-summary {
  display: flex; gap: .75rem; padding: .5rem 0; flex-wrap: wrap;
}
.range-chart-wrap {
  background: var(--surface); border-radius: var(--r);
  padding: .75rem; margin-bottom: 1rem; height: 90px;
  border: 1px solid var(--border);
}
.range-results {
  display: grid; gap: .75rem;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.range-card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden;
  text-decoration: none; color: var(--text);
  transition: all var(--dur) var(--ease);
}
.range-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.range-card img {
  width: 100%; height: 140px; object-fit: cover; background: var(--bg-2);
}
.range-noimg {
  height: 140px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-2); color: var(--text-3); font-size: .8rem;
}
.range-card-info {
  display: flex; flex-direction: column; gap: 2px;
  padding: .5rem .75rem; font-size: .8rem;
}
.range-card-vid {
  font-family: monospace; font-weight: 600; font-size: .82rem;
  color: var(--accent);
}
.range-card-time { color: var(--text-2); font-variant-numeric: tabular-nums; }
.range-card-meta { color: var(--text-3); font-size: .75rem; }
