:root {
  color-scheme: light;
  /* Zorin OS's light desktop: soft neutral-gray workspace, white cards,
     GNOME-style near-black text (not pure #000) and Zorin's signature blue
     accent. Named the same as before so every other file's var()
     references keep working unchanged; only the values moved. */
  --bg: #eef1f6;
  --bg-elevated: #ffffff;
  --panel: #ffffff;
  --panel-hover: #f2f5fb;
  --border: #e1e5ec;
  --border-strong: #c7cedb;
  --text: #1c1e21;
  --muted: #6b7280;

  --accent: #0f766e;
  --accent-strong: #14998f;
  --accent-dim: #e1f5f2;

  --danger: #e0203a;
  --danger-strong: #ff4d68;
  --danger-dim: #fdeaee;

  --ok: #1fa971;
  --ok-dim: #e5f7ee;

  --warn: #dc9b16;
  --warn-dim: #fdf3dc;

  /* Generous, consistent rounding - the defining Zorin/GNOME silhouette. */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  /* Soft blurred shadows (not hard offsets) - how Zorin's cards/windows
     actually float above the desktop. */
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.07);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 22px 55px rgba(15, 23, 42, 0.18);

  --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Ubuntu", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: 650; letter-spacing: -0.01em; }

::selection { background: var(--accent-dim); color: var(--text); }

a { color: var(--accent); }
a:visited { color: var(--accent); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ---------------------------------------------------------------- topbar */
/* Reads like a GNOME header bar: a plain white/blurred bar with the nav
   links as soft rounded pills, not a Windows titlebar+toolbar. */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.topbar-logo {
  width: 24px;
  height: 24px;
  flex: none;
}

.conn-status {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.3rem 0.7rem 0.3rem 1.6rem;
  background: var(--panel-hover);
  border-radius: 999px;
  position: relative;
}
.conn-status::before {
  content: "";
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}
.conn-status.online { color: var(--ok); }
.conn-status.offline { color: var(--danger); }

.topbar-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.topbar-nav a {
  position: relative;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  transition: background var(--transition), color var(--transition);
}

/* Floating count badge on a nav link (currently just "Filtered") - how many
   filtered snapshots are sitting there for review, at a glance from any page. */
.nav-badge {
  position: absolute;
  top: -0.3rem;
  right: -0.3rem;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  background: var(--danger);
  border: 2px solid var(--bg-elevated);
  border-radius: 999px;
  line-height: 1;
}
.nav-badge.hidden { display: none; }
.topbar-nav a:hover {
  background: var(--accent-dim);
  color: var(--accent);
}
.topbar-nav a:active {
  background: var(--accent-dim);
}
.topbar-nav .hidden { display: none; }

/* Separates page-navigation links (Evidence/Filtered) from admin-only
   management links (Users/Devices/Settings) - a thin rule reads as clearer
   grouping than an unbroken run of same-looking links. */
.nav-divider {
  width: 1px;
  height: 1.1rem;
  background: var(--border-strong);
  margin: 0 0.25rem;
}

/* Pushed to the far right (margin-left: auto) so identity/status always
   ends up visually separate from the page links, regardless of how many
   admin links a given role can see. */
.nav-identity {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
  padding-left: 0.5rem;
}

.who-am-i {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  padding: 0.3rem 0.1rem;
}

.muted { color: var(--muted); }

/* ---------------------------------------------------------------- layout */
/* Primary content (Pending Alerts - the thing a guard actually acts on) gets
   a dominant left column; History and Live Cameras are secondary/reference
   material, stacked in a narrower sidebar - a clearer hierarchy than three
   equal-weight sections stacked flat, and reads as far more organized. */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  align-items: start;
  gap: 1.25rem;
  padding: 1.25rem;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

/* Single card primitive shared by EVERY page (moved here from users.css,
   where only 4 of the 6 pages could reach it) - one visual language across
   the whole dashboard instead of near-duplicate rules per page. */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
}

.panel h2 {
  margin: 0 0 1rem 0;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

/* A header row inside a .panel that also needs a trailing element (a count
   badge, an action button) alongside the h2 - .panel h2's own margin is
   cancelled here since panel-header supplies the spacing instead. */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.panel-header h2 { margin: 0; }

.panel-count {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--panel-hover);
  border-radius: 999px;
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0 0.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* Pending Alerts' own count draws the eye when non-zero - it's the one
   number on this page that means "something needs doing right now". */
.panel-count.has-pending {
  background: var(--danger);
  color: #fff;
}

/* History can otherwise grow to dozens of items and push everything else
   off-screen in a narrow sidebar column - contained with its own scroll
   instead, so the sidebar's overall shape stays predictable. */
.history .alert-list {
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.live-camera-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.live-camera-row {
  background: var(--panel-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.live-camera-row:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }

.live-camera-row .room {
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.alert-list:empty::after {
  content: "Nothing here.";
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.5rem 0.1rem;
}

/* ------------------------------------------------------------ alert card */

.alert-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 0.85rem;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.alert-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

.alert-card img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  background: #000;
  cursor: zoom-in;
  border-radius: var(--radius-sm);
}

.alert-card .meta { display: flex; flex-direction: column; gap: 0.3rem; }
.alert-card .device { font-weight: 650; }
.alert-card .room { color: var(--muted); font-size: 0.88rem; }
.alert-card .time { color: var(--muted); font-size: 0.78rem; }
.alert-card .count { font-size: 0.78rem; color: var(--warn); font-weight: 650; }

.alert-card .actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.2rem;
}

/* ------------------------------------------------------------- controls */

button {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-hover);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.05rem;
  cursor: pointer;
  transition: filter var(--transition), transform var(--transition), box-shadow var(--transition);
}
button:hover { filter: brightness(0.97); box-shadow: var(--shadow-sm); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { color: var(--muted); cursor: not-allowed; opacity: 0.6; box-shadow: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

/* Lets an <a> (e.g. a direct-download link) look and behave exactly like a
   button, sized to its content rather than the block/full-width .export-link
   treatment used in the filters form. */
.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  background: var(--panel-hover);
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.05rem;
  cursor: pointer;
  transition: filter var(--transition), transform var(--transition);
}
.btn-link:hover { filter: brightness(0.97); }
.btn-link:active { transform: translateY(1px); }

.btn-confirm { background: var(--danger); color: #fff; }
.btn-confirm:hover { background: var(--danger-strong); }
.btn-dismiss { background: var(--panel-hover); color: var(--text); }
.btn-message { background: var(--accent); color: #fff; }
.btn-message:hover { background: var(--accent-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-strong); }

.status-pill {
  align-self: start;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  color: #fff;
}
.status-pill.pending { background: var(--danger); }
.status-pill.confirmed { background: #7a1230; }
.status-pill.dismissed { background: var(--ok); }
.status-pill.unregistered { background: var(--warn); }
.status-pill.weapon-class { background: var(--accent); }
.status-pill.missed-weapon { background: var(--danger); }
.status-pill.correctly-filtered { background: var(--ok); }
.status-pill.in-evidence { background: #7a1230; }
.status-pill.running { background: var(--ok); }
.status-pill.stopped { background: var(--danger); }

/* ---------------------------------------------------------- toast alerts */
/* Corner notification stack instead of a full-screen blocking modal - the
   rest of the dashboard stays visible/usable. New alerts stack at the top;
   closing a toast only dismisses the notification, not the alert itself
   (it's still sitting in Pending Alerts either way). */

.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  width: min(92vw, 380px);
}

.toast-card {
  background: var(--panel);
  border: 1px solid var(--danger);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0.95rem;
  display: flex;
  gap: 0.75rem;
  animation: toast-pulse 1.6s ease-in-out infinite, toast-enter 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Slides/fades in from the right instead of just appearing - a threat
   notification landing instantly, with no motion at all, is easy to miss
   out of the corner of your eye; a short deliberate motion draws the eye. */
@keyframes toast-enter {
  from { opacity: 0; transform: translateX(24px) scale(0.97); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toast-pulse {
  0%, 100% { box-shadow: var(--shadow-lg), 0 0 0 0 rgba(224, 32, 58, 0.35); }
  50% { box-shadow: var(--shadow-lg), 0 0 0 6px rgba(224, 32, 58, 0); }
}

/* System warning (e.g. the vision validator server going down) - distinct
   amber pulse instead of the weapon-alert red, so it's never mistaken for
   an actual threat notification, and it never plays the alarm sound. */
.toast-card.system-warning {
  border-color: var(--warn);
  animation: toast-pulse-warning 1.6s ease-in-out infinite, toast-enter 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
  padding: 0.95rem;
}
@keyframes toast-pulse-warning {
  0%, 100% { box-shadow: var(--shadow-lg), 0 0 0 0 rgba(220, 155, 22, 0.35); }
  50% { box-shadow: var(--shadow-lg), 0 0 0 6px rgba(220, 155, 22, 0); }
}
.toast-card.system-warning .toast-title { color: var(--warn); }
.toast-card.system-warning .toast-title-icon { color: var(--warn); }

.toast-thumb {
  flex: none;
  width: 76px;
  height: 76px;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: zoom-in;
}
.toast-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.toast-body { flex: 1; min-width: 0; }

.toast-title {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.86rem;
  font-weight: 750;
  letter-spacing: 0.01em;
  color: var(--danger);
}
.toast-title-icon {
  font-size: 1rem;
  line-height: 1;
  color: var(--danger);
}

.toast-meta {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-top: 0.3rem;
  font-size: 0.85rem;
  flex-wrap: wrap;
}
.toast-device { font-weight: 650; }
.toast-room { color: var(--muted); }
.toast-confidence { font-size: 0.78rem; color: var(--warn); margin-top: 0.25rem; font-weight: 650; }

.toast-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.65rem;
}
.toast-actions button {
  flex: 1;
  font-size: 0.78rem;
  padding: 0.4rem 0.5rem;
}

.toast-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.1rem 0.35rem;
  align-self: flex-start;
  flex: none;
}

/* Brief, non-blocking full-screen accent when a new threat toast lands -
   reinforces urgency (something a plain corner toast can miss if you're
   not looking right at it) without reintroducing the old blocking modal:
   pointer-events:none, purely decorative, gone in under a second. */
.threat-flash {
  position: fixed;
  inset: 0;
  z-index: 800;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(224, 32, 58, 0) 55%, rgba(224, 32, 58, 0.28) 100%);
  animation: threat-flash-fade 700ms ease-out forwards;
}
@keyframes threat-flash-fade {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}
.toast-close:hover { color: var(--text); background: var(--panel-hover); border-radius: 999px; }

/* -------------------------------------------------------------- lightbox */
/* True fullscreen viewer: the image fills the entire viewport (letterboxed
   via object-fit: contain, never cropped - this is a verification tool, the
   whole photo has to stay visible). Every control is an absolutely
   positioned overlay on top, not a layout element that shrinks the image. */

.lightbox-overlay { padding: 0; background: rgba(20, 24, 33, 0.92); backdrop-filter: blur(6px); }

.lightbox-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-image-wrap {
  position: relative;
  width: 100%;
  height: 95vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* width:100% + height:95vh (not auto/auto) is what makes the photo actually
   fill the available space - auto/auto only ever caps a large image, it
   never scales a smaller one UP, which is what made this look tiny before.
   object-fit:contain still guarantees no distortion and no cropping. */
.lightbox-bbox {
  position: absolute;
  border: 3px solid var(--danger);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
  border-radius: 2px;
  pointer-events: none;
  /* left/top/width/height are set inline by shared.js's positionLightboxBbox() -
     computed in JS since object-fit:contain letterboxes the image, and a
     plain CSS percentage here would misalign with the visible image area
     whenever the snapshot's aspect ratio doesn't match the viewport's. */
}

.lightbox-content img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.lightbox-counter {
  position: absolute;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  z-index: 1001;
}
.lightbox-counter.hidden { display: none; }

.lightbox-bottom-bar {
  position: absolute;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  max-width: 92vw;
  z-index: 1001;
}

.lightbox-actions {
  display: flex;
  gap: 0.6rem;
}
.lightbox-actions.hidden { display: none; }
.lightbox-actions button {
  font-size: 0.85rem;
  padding: 0.6rem 1.15rem;
}
.lightbox-actions button.active {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.6);
}

.lightbox-caption {
  font-size: 0.82rem;
  color: #fff;
  text-align: center;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
}

.lightbox-close {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  z-index: 1001;
  transition: background var(--transition);
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.28); }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  z-index: 1001;
  transition: background var(--transition);
}
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.28); }
.lightbox-nav:disabled { color: rgba(255, 255, 255, 0.35); cursor: not-allowed; }
.lightbox-nav.hidden { display: none; }
.lightbox-prev { left: 1.25rem; }
.lightbox-next { right: 1.25rem; }

@media (max-width: 640px) {
  .lightbox-nav { width: 40px; height: 40px; font-size: 1.4rem; }
  .lightbox-prev { left: 0.6rem; }
  .lightbox-next { right: 0.6rem; }
}
