:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #1b2024;
  --panel-strong: #242b30;
  --surface: #111518;
  --line: #374148;
  --text: #f5f7f8;
  --muted: #a9b3b9;
  --accent: #41c783;
  --warning: #ffb454;
  --danger: #ff5f57;
  --focus: #8bd3ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

h1,
h2,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1;
}

h2 {
  font-size: 18px;
}

button,
.button,
input {
  font: inherit;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--panel-strong);
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

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

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

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06140c;
}

button.warning {
  background: var(--warning);
  border-color: var(--warning);
  color: #211300;
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #230403;
}

input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #0d1012;
  color: var(--text);
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 22px clamp(18px, 5vw, 48px);
  background: #15191c;
  border-bottom: 1px solid var(--line);
}

.app-header p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 16px;
  overflow-wrap: anywhere;
}

.header-actions,
.toolbar,
.section-title,
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.header-actions {
  align-content: flex-start;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.85fr);
  gap: 18px;
  padding: 18px clamp(18px, 5vw, 48px) 42px;
}

.main-column,
.side-column {
  display: grid;
  align-content: start;
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stream {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid #000;
  border-radius: 6px;
  background: #050607;
  object-fit: contain;
}

.toolbar {
  margin-top: 14px;
}

.notice {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.notice.error,
.form-error {
  color: var(--danger);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.pill.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #06140c;
}

.section-title {
  justify-content: space-between;
  margin-bottom: 12px;
}

.filters {
  align-items: end;
  margin-bottom: 12px;
}

.filters label {
  flex: 1 1 180px;
}

video {
  display: block;
  width: 100%;
  margin: 12px 0;
  border: 1px solid #000;
  border-radius: 6px;
  background: #050607;
}

.recordings,
.events {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
}

.events {
  max-height: 320px;
}

.recording-row,
.event-row,
.metric {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.recording-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
}

.recording-row strong,
.event-row strong {
  display: block;
  overflow-wrap: anywhere;
}

.recording-row span,
.event-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.event-row {
  padding: 10px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.metric {
  min-height: 72px;
  padding: 10px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-value {
  margin-top: 5px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-panel {
  display: grid;
  gap: 14px;
  width: min(390px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.login-panel h1 {
  font-size: 28px;
}

@media (max-width: 980px) {
  .app-header {
    position: static;
    flex-direction: column;
  }

  .layout {
    grid-template-columns: 1fr;
  }
}

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

  .recording-row {
    align-items: stretch;
    flex-direction: column;
  }
}
