:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: #0d1b2d;
  --panel-raised: #12243a;
  --line: #203952;
  --text: #eef6ff;
  --muted: #8ca5bd;
  --cyan: #35d0c4;
  --blue: #5ea5ff;
  --amber: #ffbd59;
  --red: #ff6b6b;
  --green: #5fe39a;
  font-family: Inter, "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 85% 0%, rgb(40 104 145 / 30%), transparent 32rem),
    linear-gradient(145deg, #06101c, #09182a 52%, #07121f);
}

button,
input,
select {
  font: inherit;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.55rem;
  padding: 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: #10233a;
  font-size: 0.84rem;
  text-decoration: none;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 0.72rem 1rem;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.primary {
  color: #06131b;
  background: linear-gradient(135deg, var(--cyan), #8ff3df);
  font-weight: 800;
}

button.secondary {
  color: var(--text);
  border: 1px solid var(--line);
  background: #10233a;
}

code {
  color: #b8f4ed;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.4rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: rgb(5 15 27 / 76%);
  backdrop-filter: blur(16px);
}

.topbar h1,
.section-heading h2,
.rules-panel h2 {
  margin: 0;
  letter-spacing: -0.03em;
}

.topbar h1 {
  font-size: clamp(1.5rem, 2.2vw, 2.2rem);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--cyan);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.topbar-actions,
.event-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.session-field,
.camera-controls label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.85rem;
}

input,
select {
  min-height: 2.55rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: #091727;
  outline: none;
}

input {
  padding: 0 0.75rem;
}

select {
  max-width: 19rem;
  padding: 0 0.65rem;
}

input:focus,
select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgb(53 208 196 / 12%);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.toggle input {
  min-height: auto;
  accent-color: var(--cyan);
}

main {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 4vw, 3rem) 4rem;
}

.banner {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 0.9rem;
}

.banner.warning {
  border-color: rgb(255 189 89 / 45%);
  color: #ffdaa1;
  background: rgb(120 75 10 / 24%);
}

.banner.muted {
  color: var(--muted);
  background: rgb(16 35 58 / 74%);
}

.camera-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.1rem;
}

.camera-card,
.event-section,
.rules-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(160deg, rgb(15 32 53 / 96%), rgb(8 22 38 / 96%));
  box-shadow: 0 22px 70px rgb(0 0 0 / 20%);
}

.camera-card {
  overflow: hidden;
}

.camera-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
}

.camera-heading h2 {
  margin: 0.45rem 0 0;
  font-size: 1rem;
}

.role-tag,
.connection {
  display: inline-block;
  border-radius: 999px;
  padding: 0.27rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 800;
}

.role-tag.high {
  color: #d7e6ff;
  background: rgb(94 165 255 / 17%);
}

.role-tag.medium {
  color: #dffff5;
  background: rgb(53 208 196 / 15%);
}

.connection {
  color: var(--muted);
  background: #0a1726;
}

.connection.online {
  color: var(--green);
  background: rgb(95 227 154 / 10%);
}

.connection.fault {
  color: var(--red);
  background: rgb(255 107 107 / 10%);
}

.video-shell {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-block: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgb(255 255 255 / 2%) 1px, transparent 1px),
    linear-gradient(rgb(255 255 255 / 2%) 1px, transparent 1px),
    #020810;
  background-size: 28px 28px;
}

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

.capture-canvas {
  display: none;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 0.35rem;
  text-align: center;
  color: #afc4d8;
  background: rgb(2 8 16 / 58%);
}

.video-placeholder span {
  font-size: 1.05rem;
  font-weight: 700;
}

.video-placeholder small {
  color: var(--muted);
}

.camera-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  border-top: 1px solid var(--line);
  background: var(--line);
}

.metrics div {
  min-width: 0;
  padding: 0.8rem 0.9rem;
  background: #0a192a;
}

.metrics dt {
  margin-bottom: 0.32rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.metrics dd {
  margin: 0;
  overflow: hidden;
  font-size: 0.86rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-section,
.rules-panel {
  margin-top: 1.1rem;
  padding: 1.15rem;
}

.section-heading,
.rules-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.event-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.event-card {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr) minmax(12rem, auto);
  align-items: center;
  gap: 1rem;
  padding: 0.85rem;
  border: 1px solid #1d334a;
  border-radius: 12px;
  background: #091727;
}

.event-card.info {
  border-style: dashed;
  opacity: 0.8;
}

.event-level {
  display: inline-flex;
  justify-content: center;
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 900;
}

.event-level.high {
  color: #ffd1d1;
  background: rgb(255 107 107 / 18%);
}

.event-level.medium {
  color: #ffe1ae;
  background: rgb(255 189 89 / 15%);
}

.event-level.low {
  color: #cff7ff;
  background: rgb(94 165 255 / 14%);
}

.event-level.info {
  color: #d5e2ee;
  background: rgb(140 165 189 / 12%);
}

.event-main strong {
  display: block;
  margin-bottom: 0.3rem;
}

.event-main p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.event-meta {
  color: var(--muted);
  font-size: 0.74rem;
}

.event-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.event-side a,
.event-side button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  color: var(--text);
  background: #10233a;
  font-size: 0.74rem;
  text-decoration: none;
}

.event-side button {
  cursor: pointer;
}

.empty-state {
  padding: 2.4rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 12px;
}

.rule-summary {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.rule-chip {
  padding: 0.38rem 0.58rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #091727;
}

.notification {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 10;
  max-width: min(30rem, calc(100vw - 3rem));
  padding: 0.9rem 1rem;
  border: 1px solid rgb(255 107 107 / 45%);
  border-radius: 11px;
  color: #ffd6d6;
  background: #37131a;
  box-shadow: 0 12px 40px rgb(0 0 0 / 35%);
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .event-card {
    grid-template-columns: 1fr;
  }

  .event-side {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .topbar-actions,
  .camera-controls,
  .section-heading,
  .rules-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .session-field,
  .camera-controls label {
    align-items: stretch;
    flex-direction: column;
  }

  select {
    max-width: none;
  }
}

