:root {
  color-scheme: dark;
  --bg: #101820;
  --panel: #19252f;
  --line: #344654;
  --muted: #b4c4cf;
  --accent: #72dec3;
  --text: #f3f7fa;
  --warning: #ffca78;
  --alarm: #ff8d92;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, sans-serif;
}

header, main, footer {
  max-width: 1200px;
  margin: auto;
  padding: 24px;
}

header {
  display: flex;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

header > div {
  flex: 1;
}

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.8px;
}

h2 {
  font-size: 23px;
  margin: 0 0 8px;
}

h3 {
  font-size: 18px;
  margin: 0 0 12px;
}

p {
  margin: 8px 0 16px;
  color: var(--muted);
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--accent);
}

button, input, select, a.button {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 14px;
  background: #213342;
  color: var(--text);
  text-decoration: none;
}

button, a.button {
  cursor: pointer;
  display: inline-block;
  transition: border-color 0.15s, background-color 0.15s;
}

button:hover, a.button:hover {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.45;
  cursor: wait;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #10291f;
  font-weight: 650;
}

.primary:hover {
  background: #5dcab0;
  border-color: #5dcab0;
}

input {
  width: 100%;
  margin-top: 6px;
}

label {
  display: block;
  color: var(--muted);
}

form {
  display: grid;
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.compact {
  max-width: 460px;
  margin: 40px auto;
}

.badge {
  font-size: 13px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 24px;
}

.notice {
  padding: 14px 18px;
  background: #243936;
  border-radius: 12px;
  margin-bottom: 20px;
  color: #bcf2e3;
  border: 1px solid #2f564f;
}

nav {
  display: flex;
  gap: 10px;
  margin: 20px 0 30px;
}

nav button {
  background: transparent;
  transition: all 0.2s;
}

nav .selected {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(114, 222, 195, 0.08);
}

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

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

.monitor-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 18px;
}

.image-wrap {
  position: relative;
  aspect-ratio: 4/3;
  background: #0b1218;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.metrics-bar {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.metric-pill {
  font-size: 13px;
  padding: 4px 10px;
  background: #14202b;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
}

.metric-pill.good {
  color: var(--accent);
  border-color: rgba(114, 222, 195, 0.4);
}

.metric-pill.warn {
  color: var(--warning);
  border-color: rgba(255, 202, 120, 0.4);
}

.metric-pill.alert {
  color: var(--alarm);
  border-color: rgba(255, 141, 146, 0.4);
}

dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 25px;
}

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

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.track {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  margin: 10px 0;
  background: #14202b;
}

.muted {
  font-size: 14px;
}

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

.checkbox input {
  width: auto;
  margin: 0;
}

.person-form {
  grid-template-columns: 1fr;
  max-width: 700px;
}

.person-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.identifier {
  font-size: 12px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-family: monospace;
}

.event {
  transition: transform 0.15s;
}

.event.alarm {
  border-left: 5px solid var(--alarm);
  animation: pulse-border 2.5s infinite ease-in-out;
}

@keyframes pulse-border {
  0%, 100% { border-left-color: var(--alarm); }
  50% { border-left-color: #ff3344; box-shadow: -3px 0 12px rgba(255, 80, 80, 0.25); }
}

.event.warning {
  border-left: 4px solid var(--warning);
}

.event.info {
  border-left: 4px solid var(--accent);
}

.event img.event-thumb {
  max-width: 100%;
  max-height: 240px;
  margin-top: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.2s, filter 0.2s;
}

.event img.event-thumb:hover {
  transform: scale(1.015);
  filter: brightness(1.08);
}

#enrollment-image {
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

/* Lightbox Modal */
.lightbox-modal {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(20, 31, 41, 0.96);
  color: var(--text);
  padding: 0;
  max-width: 90vw;
  max-height: 90vh;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
}

.lightbox-modal::backdrop {
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(5px);
}

.lightbox-content {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.lightbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}

.lightbox-header h3 {
  margin: 0;
  font-size: 18px;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 26px;
  line-height: 1;
  padding: 0 6px;
  cursor: pointer;
  color: var(--muted);
  border-radius: 6px;
}

.btn-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.lightbox-body {
  padding: 18px 22px;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 250px;
  background: #0b1218;
}

.lightbox-body img {
  max-width: 100%;
  max-height: calc(85vh - 170px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.lightbox-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  gap: 14px;
  flex-wrap: wrap;
}

#message {
  position: sticky;
  bottom: 16px;
  padding: 12px 18px;
  background: #273b4a;
  border-radius: 10px;
  display: none;
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

#message.visible {
  display: block;
}

footer {
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
  margin-top: 35px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 780px) {
  header, main, footer {
    padding: 16px;
  }
  .monitor-grid {
    grid-template-columns: 1fr;
  }
  .toolbar, .person-row {
    align-items: flex-start;
    flex-direction: column;
  }
  .actions button, a.button {
    font-size: 14px;
  }
  header {
    flex-wrap: wrap;
  }
  nav {
    gap: 6px;
  }
  nav button {
    padding: 9px 12px;
  }
  .card {
    padding: 16px;
  }
  .lightbox-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

.live-toolbar { margin: 0.9rem 0; align-items: center; flex-wrap: wrap; }
.live-image { display: block; width: 100%; max-height: 65vh; object-fit: contain; background: #101827; border-radius: 12px; }
#live-panel { padding: 1rem; }
@media (max-width: 600px) { .live-toolbar { align-items: stretch; } #live-panel { padding: 0.5rem; } }
