:root,
html[data-theme="dark"] {
  --bg: #0f1a22;
  --panel: #162430;
  --line: #2a3d4d;
  --text: #e8f0f5;
  --muted: #8aa0b0;
  --accent: #2f8f6b;
  --warn: #c45c26;
  --danger: #b83232;
  --btn: #1c2c38;
  --btn-soft: #234055;
  --tab-active-bg: #1e3444;
  --tab-active-border: #3d5a6e;
  --tag-bg: #243444;
  --tag-fg: #c5d8e6;
  --modal-mask: rgba(5, 10, 14, 0.72);
  --glow-a: #1c3a48;
  --glow-b: #243018;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: "IBM Plex Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
}
html[data-theme="light"] {
  --bg: #e8eef2;
  --panel: #f7fbfd;
  --line: #d0dde5;
  --text: #172229;
  --muted: #6a7c88;
  --accent: #2a6a78;
  --warn: #b8862a;
  --danger: #b04848;
  --btn: #eef3f6;
  --btn-soft: #e2eef2;
  --tab-active-bg: #dce8ee;
  --tab-active-border: #9bb4c2;
  --tag-bg: #e6eef2;
  --tag-fg: #3a5160;
  --modal-mask: rgba(18, 28, 34, 0.45);
  --glow-a: #cfe0e8;
  --glow-b: #d8e8e4;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); min-height: 100%; }
body {
  background:
    radial-gradient(120% 80% at 10% -10%, var(--glow-a) 0%, transparent 55%),
    radial-gradient(90% 60% at 100% 0%, var(--glow-b) 0%, transparent 45%),
    var(--bg);
}
.hidden { display: none !important; }
.view { max-width: 520px; margin: 0 auto; padding: 16px 14px 40px; }
.view.locked .tabs,
.view.locked .panel {
  pointer-events: none;
  opacity: 0.45;
  filter: grayscale(0.15);
}
.top h1 { margin: 0; font-size: 1.45rem; letter-spacing: 0.02em; }
.top .sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.top.bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.top-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.tabs { display: flex; gap: 8px; margin: 12px 0 14px; }
.tab {
  flex: 1; border: 1px solid var(--line); background: transparent; color: var(--muted);
  padding: 10px; border-radius: 8px; font-weight: 600;
}
.tab.active { color: var(--text); background: var(--tab-active-bg); border-color: var(--tab-active-border); }
.field { display: block; margin: 10px 0; font-size: 13px; color: var(--muted); }
.field input, .field select {
  display: block; width: 100%; margin-top: 6px; padding: 12px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font-size: 16px;
}
.filters { display: grid; gap: 10px; margin-bottom: 12px; }
.quick-range {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 12px;
}
.quick-range .chip {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  padding: 10px 8px; border-radius: 8px; font-weight: 600; font-size: 14px;
}
.quick-range .chip.active {
  color: var(--text); background: var(--tab-active-bg); border-color: var(--tab-active-border);
}
.filters input {
  width: 100%; padding: 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 16px;
}
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.btn {
  border: 1px solid var(--line); background: var(--btn); color: var(--text);
  padding: 11px 14px; border-radius: 8px; font-weight: 600; width: 100%;
}
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.soft { background: var(--btn-soft); }
.btn.ghost { width: auto; background: transparent; padding: 8px 10px; }
.err { color: var(--danger); min-height: 1.2em; font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.45; }
.hint a { color: var(--accent); }
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; display: inline-block; vertical-align: -3px;
  animation: spin 0.8s linear infinite; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.list { display: grid; gap: 8px; }
.card {
  text-align: left; width: 100%; border: 1px solid var(--line); background: var(--panel);
  border-radius: 10px; padding: 12px; color: inherit; animation: up 0.35s var(--ease) both;
}
.card .plate { font-size: 1.15rem; font-weight: 700; }
.card .meta { margin-top: 6px; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 10px; }
.card-actions { margin-top: 10px; }
.card-actions .btn { width: auto; min-width: 88px; padding: 8px 14px; font-size: 14px; }
.tag {
  display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 700;
  background: var(--tag-bg); color: var(--tag-fg);
}
.tag.makeup { background: #4a2e12; color: #ffc98a; }
.tag.ok { background: #1d3d30; color: #9de0c0; }
.tag.online { background: #1d3d30; color: #9de0c0; }
.tag.offline { background: #3d1d1d; color: #f0a0a0; }
.tag.fault { background: #3d2a12; color: #ffc98a; }
html[data-theme="light"] .tag.ok,
html[data-theme="light"] .tag.online { background: #e8f5ef; color: #1f7a52; }
html[data-theme="light"] .tag.offline { background: #fdecec; color: #a83232; }
html[data-theme="light"] .tag.fault,
html[data-theme="light"] .tag.makeup { background: #fff4e8; color: #c45c1a; }
.ipc-block { margin-top: 4px; }
.cam-list { display: grid; gap: 4px; margin-top: 6px; }
.cam-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; background: var(--tag-bg); font-size: 12px;
}
.plate-color { font-weight: 700; }
.plate-color.pc-yellow { color: #c9a000; }
.plate-color.pc-blue { color: #1a5fb4; }
.plate-color.pc-green { color: #1a7a3a; }
.plate-color.pc-white { color: #6b7280; }
.plate-color.pc-black { color: #1a1a1a; }
html[data-theme="dark"] .plate-color.pc-yellow { color: #e6c35c; }
html[data-theme="dark"] .plate-color.pc-blue { color: #6ea8ff; }
html[data-theme="dark"] .plate-color.pc-green { color: #5fd68a; }
html[data-theme="dark"] .plate-color.pc-white { color: #d8dee6; }
html[data-theme="dark"] .plate-color.pc-black { color: #9aa3ad; }
.card-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: start;
}
.card-row .plate { margin: 0; }
.dir-tag {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; padding: 4px 8px; border-radius: 6px; font-size: 13px; font-weight: 700;
  background: var(--tag-bg); color: var(--tag-fg);
}
.dir-tag.in { background: #1d3d30; color: #9de0c0; }
.dir-tag.out { background: #3d2a12; color: #ffc98a; }
html[data-theme="light"] .dir-tag.in { background: #e8f5ef; color: #1f7a52; }
html[data-theme="light"] .dir-tag.out { background: #fff4e8; color: #c45c1a; }
.wm-local {
  position: absolute; right: 8px; bottom: 8px; z-index: 2;
  padding: 3px 8px; font-size: 12px; font-weight: 700;
  color: #fff; background: rgba(180, 40, 40, 0.9); letter-spacing: 0.04em;
}

.login-modal {
  position: fixed; inset: 0; z-index: 50;
  background: var(--modal-mask);
  display: flex; align-items: center; justify-content: center;
  padding: 20px 16px;
  backdrop-filter: blur(4px);
}
.login-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 18px 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  animation: up 0.35s var(--ease) both;
}
.login-card h2 { margin: 0; font-size: 1.25rem; }
.login-card > .sub { margin: 6px 0 14px; color: var(--muted); font-size: 13px; }

.lightbox {
  position: fixed; inset: 0; z-index: 40; background: rgba(5, 10, 14, 0.94);
  display: flex; flex-direction: column; padding: 10px 8px 16px;
}
html[data-theme="light"] .lightbox { background: rgba(20, 30, 38, 0.88); }
.lb-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 4px 4px 8px;
}
.lb-meta { flex: 1; min-width: 0; font-size: 13px; line-height: 1.4; color: #d5e4ee; }
.lb-meta strong { display: block; font-size: 1.1rem; margin-bottom: 2px; }
.lb-close {
  border: 0; background: #2a3d4d; color: #fff;
  padding: 8px 12px; border-radius: 6px; flex-shrink: 0;
}
.lb-stage {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 40px 1fr 40px;
  align-items: center; gap: 4px;
}
.lb-nav {
  border: 0; background: rgba(42, 61, 77, 0.85); color: #fff;
  width: 40px; height: 56px; border-radius: 8px; font-size: 28px; line-height: 1;
}
.lb-nav:disabled { opacity: 0.25; }
.lb-body {
  height: 100%; overflow: auto; display: flex; align-items: center; justify-content: center;
}
.lb-body img { max-width: 100%; max-height: 72vh; object-fit: contain; }
.lb-body .hint, .lb-body .err { text-align: center; padding: 20px; }
.lb-caption {
  text-align: center; color: var(--muted); font-size: 13px; padding-top: 8px; min-height: 1.4em;
}
@keyframes up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
