:root {
  --bg: #111418;
  --panel: #1b2027;
  --line: #2a313a;
  --text: #e8ecf1;
  --dim: #8b95a3;
  --accent: #3d8bfd;
  --ok: #2fbf71;
  --warn: #f0a020;
  --bad: #e5484d;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}
[hidden] { display: none !important; }
button {
  font: inherit; color: #fff; background: var(--accent); border: 0; border-radius: 10px;
  padding: 10px 16px; cursor: pointer;
}
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button:disabled { opacity: .5; }
.hint { color: var(--dim); font-size: 13px; margin: 6px 0; }
.error { color: var(--bad); min-height: 1.5em; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 320px; display: grid; gap: 12px; }
.brand { font-size: 24px; font-weight: 600; text-align: center; margin-bottom: 8px; }
.login input {
  font: inherit; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text);
}

main { padding: env(safe-area-inset-top) 0 calc(64px + env(safe-area-inset-bottom)); }
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}
.title { font-size: 18px; font-weight: 600; }
.arm { padding: 6px 14px; border-radius: 999px; font-size: 14px; }
.arm.on { background: var(--bad); }
.arm.off { background: var(--panel); border: 1px solid var(--line); color: var(--dim); }

.tab { padding: 0 16px 16px; }
.video {
  position: relative; background: #000; border-radius: 12px; overflow: hidden;
  aspect-ratio: 16 / 9;
}
.video img { width: 100%; height: 100%; object-fit: contain; display: block; }
.video:fullscreen, .video.full { border-radius: 0; }
.video.full {
  position: fixed; inset: 0; z-index: 30; aspect-ratio: auto;
}
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--dim); background: rgba(0,0,0,.55); text-align: center; padding: 16px;
  white-space: pre-line;
}
.liveInfo { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; }
.liveInfo #liveFps { margin-left: auto; color: var(--dim); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

.day { color: var(--dim); font-size: 13px; margin: 16px 0 8px; }
.event {
  display: flex; gap: 10px; align-items: center; padding: 8px; margin-bottom: 8px;
  background: var(--panel); border-radius: 12px; cursor: pointer;
}
.event img { width: 120px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: #000; }
.event .time { font-size: 17px; font-weight: 600; }
.event .sub { color: var(--dim); font-size: 13px; }
#moreBtn { width: 100%; margin-top: 8px; }

.card { background: var(--panel); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 4px; font-size: 16px; }
input[type=range] { width: 100%; }
.device { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.device > div { flex: 1; }
.device .sub { color: var(--dim); font-size: 12px; }
.roiBox {
  position: relative; margin-top: 8px; background: #000; border-radius: 8px; overflow: hidden;
  aspect-ratio: 16 / 9; touch-action: none; user-select: none; -webkit-user-select: none;
}
.roiBox img { width: 100%; height: 100%; object-fit: fill; display: block; pointer-events: none; }
.roiRect {
  position: absolute; border: 2px solid var(--warn); background: rgba(240,160,32,.15);
  pointer-events: none;
}

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; z-index: 10;
  background: rgba(17,20,24,.95); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; background: none; border-radius: 0; color: var(--dim); padding: 14px 0;
}
.tabs button.on { color: var(--text); font-weight: 600; }

.viewer {
  position: fixed; inset: 0; z-index: 40; background: #000; overflow-y: auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.viewerTop {
  position: sticky; top: 0; display: flex; gap: 8px; align-items: center;
  padding: 10px 12px; background: rgba(0,0,0,.8);
}
.viewerTop span { flex: 1; font-weight: 600; }
.viewerPhotos img { width: 100%; display: block; margin-bottom: 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #333b45; color: #fff; padding: 8px 14px; border-radius: 10px; z-index: 50;
  max-width: calc(100% - 32px); text-align: center;
}
