:root {
  color-scheme: dark;
  --bg: #06100c;
  --panel: rgba(14, 31, 24, 0.92);
  --panel-2: rgba(20, 44, 34, 0.92);
  --line: rgba(141, 255, 195, 0.16);
  --text: #f1fff7;
  --muted: #a5c4b4;
  --green: #62ef9d;
  --green-strong: #22c96f;
  --yellow: #ffd05b;
  --red: #ff665f;
  --cyan: #70e6ef;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% -5%, rgba(55, 204, 125, 0.20), transparent 35%),
    radial-gradient(circle at 95% 25%, rgba(48, 147, 132, 0.14), transparent 28%),
    var(--bg);
}

button, input, select { font: inherit; }

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(30px, env(safe-area-inset-bottom));
}

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

.eyebrow, .card-label {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(1.65rem, 6vw, 2.6rem); line-height: 1.05; }
h2 { margin-bottom: 0; font-size: 1.18rem; }
.subtitle { margin: 0; color: var(--muted); line-height: 1.5; }

.status-pill, .mini-pill, .live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(7, 20, 15, 0.84);
  padding: 8px 11px;
  font-size: 0.78rem;
  font-weight: 750;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px currentColor; }
.status-pill.online .status-dot { background: var(--green); }
.status-pill.online { color: var(--green); }
.status-pill.offline { color: #ff9b96; }

.access-card, .camera-card, .panel, .metrics, .navigation-card, .gpu-content-card, .path-guide {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(145deg, var(--panel-2), var(--panel));
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.access-card { padding: 14px; margin-bottom: 14px; }
.access-card label { display: block; margin-bottom: 8px; color: var(--muted); font-weight: 700; }
.inline-control { display: flex; gap: 10px; }
input, select {
  min-width: 0;
  border: 1px solid rgba(138, 255, 193, 0.24);
  border-radius: 12px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.22);
  outline: none;
}
input { flex: 1; padding: 12px 14px; }
select { padding: 8px 9px; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(98, 239, 157, 0.12); }

.camera-card { padding: 10px; margin-bottom: 14px; }
.camera-stage {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  background: #020806;
}
.camera-stage video, .camera-stage #overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.camera-stage #overlay { pointer-events: none; }
.camera-placeholder { position: absolute; inset: 0; display: grid; place-content: center; gap: 7px; text-align: center; color: var(--muted); }
.camera-placeholder strong { color: var(--text); }
.lens-icon { justify-self: center; width: 52px; height: 52px; border: 4px solid var(--green); border-radius: 50%; box-shadow: inset 0 0 0 11px rgba(98,239,157,.15), 0 0 25px rgba(98,239,157,.18); }
.live-badge { position: absolute; left: 10px; top: 10px; color: #07150e; background: var(--green); border: 0; }

.primary-actions, .detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 13px;
  color: var(--text);
  font-weight: 850;
  cursor: pointer;
  touch-action: manipulation;
}
.button:disabled { opacity: 0.42; cursor: default; }
.button.primary { color: #03200f; background: linear-gradient(135deg, #7dffae, #32d377); }
.button.danger { background: rgba(255, 86, 80, 0.18); border-color: rgba(255, 102, 95, 0.48); color: #ffaaa6; }
.button.secondary { background: rgba(98, 239, 157, 0.08); border-color: rgba(98, 239, 157, 0.28); }
.button.small { min-height: 36px; padding: 6px 10px; font-size: 0.84rem; }

.settings-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; padding: 12px 4px 2px; }
.switch-label, .fps-control { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 0.88rem; font-weight: 700; }
.switch-label input { flex: none; width: 19px; height: 19px; accent-color: var(--green-strong); }

.navigation-card { display: grid; grid-template-columns: minmax(150px, .7fr) 1.3fr; align-items: center; gap: 12px 16px; padding: 17px; margin-bottom: 14px; border-left-width: 5px; }
.navigation-card strong { display: block; font-size: 1.5rem; }
.frame-age { display: block; margin-top: 4px; color: var(--cyan); font-size: .75rem; font-weight: 750; }
.road-mode { display: inline-flex; margin-top: 7px; padding: 4px 8px; border: 1px solid rgba(112,230,239,.28); border-radius: 999px; color: var(--cyan); background: rgba(112,230,239,.08); font-size: .7rem; font-weight: 800; }
.road-mode.veto { border-color: rgba(255,102,95,.45); color: #ffaaa6; background: rgba(255,102,95,.10); }
.road-mode.active { border-color: rgba(98,239,157,.38); color: var(--green); background: rgba(98,239,157,.10); }
.navigation-card p { margin: 0; color: var(--muted); text-align: right; line-height: 1.45; }
.local-features { grid-column: 1 / -1; padding-top: 10px; border-top: 1px solid var(--line); color: var(--cyan); font-size: .82rem; line-height: 1.45; }
.navigation-card.info { border-left-color: var(--green); }
.navigation-card.high { border-color: rgba(255, 208, 91, .45); border-left-color: var(--yellow); background: linear-gradient(145deg, rgba(65,50,13,.94), var(--panel)); }
.navigation-card.critical { border-color: rgba(255,102,95,.55); border-left-color: var(--red); background: linear-gradient(145deg, rgba(69,22,20,.96), var(--panel)); animation: danger-pulse 1.2s infinite alternate; }
@keyframes danger-pulse { from { box-shadow: 0 0 0 rgba(255,102,95,0); } to { box-shadow: 0 0 24px rgba(255,102,95,.22); } }

.gpu-content-card { padding: 16px; margin-bottom: 14px; border-left: 5px solid var(--cyan); }
.gpu-content-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.gpu-content-card p { margin: 0; color: var(--text); font-size: 1rem; line-height: 1.6; }

.path-guide { padding: 16px; margin-bottom: 14px; }
.path-guide-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.path-guide-heading > span { max-width: 48%; color: var(--muted); font-size: .76rem; text-align: right; }
.path-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.path-option { min-width: 0; padding: 12px 8px; border: 1px solid var(--line); border-radius: 13px; background: rgba(0,0,0,.16); text-align: center; transition: border-color .2s, background .2s, transform .2s; }
.path-option span, .path-option strong, .path-option small { display: block; }
.path-option span { color: var(--muted); font-size: .78rem; font-weight: 750; }
.path-option strong { margin: 4px 0 2px; font-size: 1.35rem; }
.path-option small { color: var(--muted); font-size: .7rem; }
.path-option.clear { border-color: rgba(112,230,239,.34); }
.path-option.blocked { border-color: rgba(255,102,95,.35); background: rgba(255,102,95,.08); }
.path-option.blocked strong { color: var(--red); }
.path-option.selected { border-color: var(--green); background: rgba(98,239,157,.15); box-shadow: 0 0 22px rgba(98,239,157,.12); transform: translateY(-2px); }
.path-option.selected strong, .path-option.selected small { color: var(--green); }
.path-option.unknown { opacity: .7; }

.dashboard-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 14px; margin-bottom: 14px; }
.panel { padding: 16px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.mini-pill { padding: 6px 9px; color: var(--cyan); }
.mini-pill.paid { color: var(--yellow); }
#spaceMap { width: 100%; height: auto; max-height: 360px; border-radius: 13px; background: #040b08; }
.panel-note { margin: 9px 0 0; color: var(--muted); line-height: 1.5; font-size: .84rem; }
.object-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 344px; overflow-y: auto; }
.object-list li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; padding: 10px; border-radius: 11px; background: rgba(0,0,0,.16); }
.track-id { display: grid; place-content: center; min-width: 35px; height: 29px; border-radius: 8px; background: rgba(112,230,239,.12); color: var(--cyan); font-size: .75rem; font-weight: 850; }
.object-main { min-width: 0; }
.object-main strong, .object-main span { display: block; }
.object-main span { margin-top: 2px; color: var(--muted); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.risk-mark { width: 9px; height: 9px; border-radius: 50%; background: var(--green); }
.risk-mark.medium { background: var(--yellow); }
.risk-mark.high, .risk-mark.critical { background: var(--red); box-shadow: 0 0 10px rgba(255,102,95,.65); }
.empty-item { color: var(--muted); grid-template-columns: 1fr !important; text-align: center; }

.cloud-panel { margin-bottom: 14px; }
.hybrid-control { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; border: 1px solid rgba(255,208,91,.2); border-radius: 12px; background: rgba(255,208,91,.06); }
.hybrid-control > span { color: var(--yellow); font-size: .78rem; text-align: right; }
.detail-result { min-height: 52px; margin-top: 12px; padding: 12px; border-radius: 12px; background: rgba(0,0,0,.17); color: var(--muted); line-height: 1.55; }
.detail-result strong { color: var(--text); }
.detail-result .semantic-line { margin-top: 6px; }
.detail-result.stale { border: 1px solid rgba(255,208,91,.28); color: #ddc982; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden; margin-bottom: 12px; }
.metrics div { padding: 13px; border-right: 1px solid var(--line); }
.metrics div:last-child { border-right: 0; }
.metrics span, .metrics strong { display: block; }
.metrics span { color: var(--muted); font-size: .74rem; }
.metrics strong { margin-top: 4px; font-size: 1rem; }
.notice { margin: 0; min-height: 24px; color: var(--muted); text-align: center; line-height: 1.5; }
.notice.error { color: #ffaaa6; }

@media (max-width: 760px) {
  .hero { align-items: center; }
  .subtitle { font-size: .86rem; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .navigation-card { display: block; }
  .navigation-card p { max-width: none; margin-top: 8px; text-align: left; }
  .local-features { margin-top: 10px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics div:nth-child(2) { border-right: 0; }
  .metrics div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 430px) {
  .app-shell { padding-left: 10px; padding-right: 10px; }
  .hero { gap: 8px; }
  .status-pill { padding: 7px 8px; font-size: .7rem; }
  .settings-row { justify-content: space-between; }
  .settings-row .button { width: 100%; }
  .hybrid-control { align-items: flex-start; flex-direction: column; }
  .hybrid-control > span { text-align: left; }
  .panel { padding: 13px; }
}
