:root {
  color-scheme: dark;
  --bg: #091014;
  --panel: #101a20;
  --panel-2: #0c151a;
  --text: #e7f0f2;
  --muted: #8fa1a8;
  --line: #22343c;
  --online: #31d38b;
  --offline: #ff5f57;
  --starting: #f3b34c;
  --accent: #49c6ff;
  --accent-soft: rgba(73, 198, 255, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(73, 198, 255, 0.08), transparent 260px),
    var(--bg);
  color: var(--text);
  font-family: Inter, Arial, Helvetica, sans-serif;
}

.page {
  width: min(1380px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
  font-weight: 700;
}

h2 {
  font-size: 17px;
  text-transform: uppercase;
  letter-spacing: 0;
}

h3 {
  font-size: 15px;
  line-height: 1.2;
}

p,
dd,
dt,
td,
th {
  font-size: 14px;
}

.page-header p,
.camera-card p,
dt {
  color: var(--muted);
}

.button {
  color: var(--text);
  background: var(--accent-soft);
  border: 1px solid rgba(73, 198, 255, 0.38);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 6px;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.arm-toggle {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  cursor: pointer;
  padding: 7px 9px;
  user-select: none;
}

.arm-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.arm-toggle span:first-child,
.arm-toggle strong {
  font-size: 13px;
  line-height: 1;
}

.arm-toggle strong {
  color: var(--online);
  min-width: 58px;
}

.arm-toggle input:not(:checked) ~ strong {
  color: var(--offline);
}

.arm-toggle__track {
  position: relative;
  width: 38px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 95, 87, 0.28);
  border: 1px solid rgba(255, 95, 87, 0.44);
}

.arm-toggle__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.16s ease;
}

.arm-toggle input:checked + .arm-toggle__track {
  background: rgba(49, 211, 139, 0.22);
  border-color: rgba(49, 211, 139, 0.58);
}

.arm-toggle input:checked + .arm-toggle__track::after {
  transform: translateX(18px);
}

.arm-toggle:has(input:focus-visible) {
  outline: 2px solid rgba(73, 198, 255, 0.55);
  outline-offset: 2px;
}

.button--danger {
  background: rgba(255, 95, 87, 0.12);
  border-color: rgba(255, 95, 87, 0.42);
  cursor: pointer;
  font: inherit;
}

.button--danger:hover {
  border-color: rgba(255, 95, 87, 0.78);
}

.button--danger:disabled {
  cursor: wait;
  opacity: 0.58;
}

.section {
  margin-top: 22px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading span {
  color: var(--muted);
  font-size: 13px;
}

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

.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  align-items: start;
}

.camera-card,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

.camera-card {
  overflow: hidden;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.camera-card--expanded {
  grid-column: span 2;
  border-color: rgba(73, 198, 255, 0.52);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
}

.camera-card__top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  min-height: 58px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent);
}

.camera-card__top > div:first-child {
  min-width: 0;
}

.camera-title h3 {
  display: block;
}

.camera-name-form,
.rename-button {
  display: none !important;
}

.editable-camera-name {
  border-radius: 5px;
  cursor: text;
  padding: 0;
  margin: 0;
  outline: none;
}

.editable-camera-name:focus {
  background: rgba(73, 198, 255, 0.1);
  padding: 3px 5px;
  margin: -3px -5px;
  box-shadow: inset 0 0 0 1px rgba(73, 198, 255, 0.38);
}

.camera-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.camera-card__top h3,
.camera-card__top p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.camera-card__top p {
  margin-top: 3px;
  font-size: 12px;
}

.status {
  border-radius: 999px;
  color: #07100c;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 5px 7px;
  text-transform: uppercase;
}

.status--online {
  background: var(--online);
}

.status--offline,
.status--stopped {
  background: var(--offline);
}

.status--starting,
.status--disabled {
  background: var(--starting);
}

.expand-button,
.priority-button {
  border: 1px solid rgba(73, 198, 255, 0.32);
  border-radius: 6px;
  background: rgba(73, 198, 255, 0.1);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  line-height: 1;
  padding: 5px 7px;
}

.expand-button:hover,
.priority-button:hover {
  border-color: rgba(73, 198, 255, 0.72);
}

.priority-button--active {
  background: rgba(49, 211, 139, 0.42);
  border-color: rgba(49, 211, 139, 0.96);
  box-shadow: 0 0 0 1px rgba(49, 211, 139, 0.2), 0 0 16px rgba(49, 211, 139, 0.22);
  color: #ffffff;
  font-weight: 700;
}

.priority-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.preview-wrap {
  position: relative;
  background: var(--panel-2);
}

.preview {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #071014;
  border: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

.preview--missing {
  visibility: hidden;
}

dl {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 10px 12px 12px;
}

.camera-meta {
  min-height: 58px;
}

.camera-details {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.12);
}

.camera-card--expanded .camera-details {
  display: grid;
}

.camera-card--expanded .camera-meta {
  display: none;
}

.camera-card--expanded .preview {
  aspect-ratio: 16 / 8;
}

.camera-details a {
  color: var(--accent);
}

.event-badge {
  display: inline-block;
  border-radius: 999px;
  color: #07100c;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  margin-right: 6px;
  padding: 5px 7px;
  text-transform: uppercase;
  white-space: nowrap;
}

.event-badge--fire {
  background: #ff5f57;
}

.event-badge--smoke {
  background: #a8b3b8;
}

.event-badge--human {
  background: #49c6ff;
}

.event-badge--animal {
  background: #31d38b;
}

.event-badge--car {
  background: #d78cff;
}

.event-badge--other {
  background: #f3b34c;
}

dt {
  margin-bottom: 2px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  line-height: 1.35;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 700;
}

.time-column {
  text-align: right;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

.event-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
}

.event-summary strong {
  font-size: 14px;
  font-weight: 700;
}

.event-summary .event-badge {
  margin-right: 0;
}

.thumb {
  display: block;
  width: 132px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--line);
}

.empty {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 680px) {
  .page {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  h1 {
    font-size: 24px;
  }

  .camera-card--expanded {
    grid-column: span 1;
  }

  .camera-details {
    grid-template-columns: 1fr;
  }

  .camera-actions {
    align-items: flex-end;
    flex-direction: column;
    gap: 6px;
  }

  .expand-button {
    padding: 6px 7px;
  }
}
