:root {
  --bg-0: #e6eef2;
  --bg-1: #d5e3ea;
  --panel: rgba(247, 251, 253, 0.92);
  --card: #f8fbfd;
  --sider: #1a262e;
  --sider-2: #24333d;
  --accent: #2a6a78;
  --accent-2: #3a8a9a;
  --text: #172229;
  --muted: #6a7c88;
  --line: #d0dde5;
  --ok: #2a8a68;
  --warn: #b8862a;
  --bad: #b04848;
  --font: "IBM Plex Sans", "Source Han Sans SC", "Noto Sans SC", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow: 0 10px 28px rgba(22, 40, 52, 0.08);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  font-family: var(--font); color: var(--text);
  background:
    radial-gradient(900px 480px at 8% -8%, #cfe0e8 0%, transparent 55%),
    radial-gradient(700px 420px at 100% 0%, #d8e8e4 0%, transparent 50%),
    linear-gradient(165deg, var(--bg-0), var(--bg-1));
}
#app { height: 100%; }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.55; }
}

.anim-enter { animation: fade-up 0.55s var(--ease) both; }
.stagger > * { animation: fade-up 0.45s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: 0.02s; }
.stagger > *:nth-child(2) { animation-delay: 0.06s; }
.stagger > *:nth-child(3) { animation-delay: 0.1s; }
.stagger > *:nth-child(4) { animation-delay: 0.14s; }
.stagger > *:nth-child(5) { animation-delay: 0.18s; }
.stagger > *:nth-child(6) { animation-delay: 0.22s; }
.stagger > *:nth-child(7) { animation-delay: 0.26s; }
.stagger > *:nth-child(8) { animation-delay: 0.3s; }
.stagger > *:nth-child(n+9) { animation-delay: 0.34s; }

@media (prefers-reduced-motion: reduce) {
  .anim-enter, .stagger > *, .drawer, .drawer-body, .card {
    animation: none !important;
    transition: none !important;
  }
}

.login-view {
  min-height: 100%; display: grid; place-items: center;
  background:
    linear-gradient(140deg, rgba(26, 38, 46, 0.92), rgba(42, 106, 120, 0.78)),
    radial-gradient(ellipse at 30% 20%, #4aa0ad 0%, transparent 45%);
}
.login-panel {
  width: min(420px, 92vw); padding: 40px 36px 32px;
  background: var(--panel); backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: var(--shadow);
}
.brand { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: 0.04em; color: var(--sider); }
.sub { margin: 8px 0 12px; color: var(--muted); }
.hint { margin: 0 0 20px; font-size: 12px; color: var(--muted); line-height: 1.45; }
.login-panel label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.login-panel input, .filters input, .filters select {
  width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line);
  background: #fff; font: inherit; color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-panel input:focus, .filters input:focus, .filters select:focus {
  outline: none; border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(58, 138, 154, 0.18);
}

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 8px 14px; font: inherit; cursor: pointer;
  transition: transform 0.18s var(--ease), background 0.18s, border-color 0.18s, color 0.18s;
}
.btn:hover { transform: translateY(-1px); border-color: #b7c9d3; }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  width: 100%; margin-top: 8px; padding: 12px;
}
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: #425563; color: #d7e2ea; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.06); }
.btn.soft { background: #eef5f7; border-color: #c5d7df; color: var(--accent); }
.btn.danger { color: var(--bad); border-color: #e0b0b0; background: #fff7f7; }
.btn.icon { padding: 6px 12px; }
.err { color: var(--bad); min-height: 1.2em; }

.main-view {
  display: grid; grid-template-columns: 220px 1fr;
  height: 100%; min-height: 100%;
  animation: fade-in 0.35s var(--ease);
  overflow: hidden;
}
.workspace {
  display: flex; flex-direction: column;
  min-width: 0; height: 100%; min-height: 0; overflow: hidden;
}
.content {
  padding: 22px 28px 20px; flex: 1; min-height: 0;
  overflow: auto; display: flex; flex-direction: column;
}
.panel {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
}
.panel.hidden { display: none !important; }

.announce-bar {
  margin: 0 0 14px;
  border: 1px solid var(--line);
  background: linear-gradient(90deg, #f3f9fb, #eef6f4);
  animation: fade-up 0.35s var(--ease) both;
}
.announce-bar.level-warn {
  background: linear-gradient(90deg, #fff8ef, #fff3e0);
  border-color: #ecd9b8;
}
.announce-bar.level-urgent {
  background: linear-gradient(90deg, #fff5f5, #ffecec);
  border-color: #e8bcbc;
}
.announce-inner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 14px;
}
.announce-badge {
  flex: none; font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  padding: 3px 8px; border: 1px solid var(--line); background: #fff; color: var(--accent);
}
.announce-bar.level-warn .announce-badge { color: #9a6b1f; border-color: #e0c48a; }
.announce-bar.level-urgent .announce-badge { color: var(--bad); border-color: #e0b0b0; }
.announce-text {
  flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 6px 10px;
  align-items: baseline; font-size: 13px; line-height: 1.45; color: var(--text);
}
.announce-text strong { font-weight: 600; }
.announce-edit { flex: none; margin-left: auto; }
.announce-empty {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 14px; padding: 8px 12px;
  border: 1px dashed var(--line); background: rgba(247, 251, 253, 0.8);
}
.field textarea {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 8px 10px; font: inherit; resize: vertical; min-height: 88px;
}

.feed-bar {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  border-top: 1px solid var(--line); background: rgba(247, 251, 253, 0.96);
  min-height: 150px; max-height: 210px;
}
.feed-col { padding: 10px 16px 12px; overflow: hidden; display: flex; flex-direction: column; }
.feed-nodes { border-right: 1px solid var(--line); }
.feed-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  margin-bottom: 8px; font-size: 13px;
}
.feed-list { overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.feed-item {
  display: grid; gap: 2px; padding: 6px 8px; border: 1px solid var(--line);
  background: #fff; font-size: 12px; animation: fade-up 0.35s var(--ease) both;
}
.feed-item .t { color: var(--muted); }
.feed-item .m { color: var(--text); }
.feed-item.online .m { color: var(--ok); }
.feed-item.offline .m { color: var(--bad); }
.feed-item.bill { cursor: pointer; }
.feed-item.bill:hover { border-color: var(--accent-2); }
.feed-empty { font-size: 12px; color: var(--muted); padding: 8px 0; }
.tag.demo {
  color: #7a5a12; border-color: #e0c48a; background: #fff8e8;
  font-size: 11px; vertical-align: middle;
}
.card.demo-card { border-color: #e6d3a8; background: linear-gradient(180deg, #fffdf8, #fff); }
.plate-cell .tag.demo { margin-left: 4px; }

@media (max-width: 960px) {
  .feed-bar { grid-template-columns: 1fr; max-height: 280px; }
  .feed-nodes { border-right: 0; border-bottom: 1px solid var(--line); }
}
.sider {
  background: linear-gradient(180deg, var(--sider), var(--sider-2));
  color: #dce6ee; padding: 24px 16px; display: flex; flex-direction: column; gap: 18px;
  height: 100%; min-height: 0; align-self: stretch; box-sizing: border-box;
}
.brand-side { font-size: 20px; font-weight: 700; padding: 0 8px; letter-spacing: 0.03em; }
.sider nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav {
  text-align: left; border: 0; background: transparent; color: #a9bac6;
  padding: 12px 14px; font: inherit; cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.nav.active, .nav:hover { background: rgba(255, 255, 255, 0.06); color: #fff; border-left-color: var(--accent-2); }
.user-box { font-size: 13px; color: #9aafbd; display: grid; gap: 8px; padding: 8px; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 16px; flex: none; }
.topbar h1 { margin: 0; font-size: 24px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-menu { position: relative; margin-left: 4px; }
.user-menu-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 8px 12px; font: inherit; cursor: pointer; min-width: 120px;
}
.user-menu-btn:hover { border-color: var(--accent-2); }
.user-menu-name {
  max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600; font-size: 13px;
}
.user-menu-caret { color: var(--muted); font-size: 11px; }
.user-menu-drop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 200px; background: #fff; border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(22, 40, 52, 0.12); padding: 6px;
}
.user-menu-meta {
  padding: 8px 10px 10px; font-size: 12px; color: var(--muted); line-height: 1.45;
  border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.user-menu-item {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 10px 12px; font: inherit; color: var(--text); cursor: pointer;
}
.user-menu-item:hover { background: #f0f6f8; }
.user-menu-item.danger { color: var(--bad); }
.user-menu-item.hidden { display: none !important; }
.page-sub { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.filters { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.filters input, .filters select { width: auto; min-width: 200px; margin: 0; }
.check { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.check.tight { margin: 0 4px; white-space: nowrap; }

.query-panel {
  background: var(--card); border: 1px solid var(--line); padding: 14px 16px 12px;
  margin-bottom: 14px; box-shadow: 0 4px 14px rgba(22, 40, 52, 0.04);
}
.query-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.query-row.secondary { margin-top: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); min-width: 140px; }
.field.grow { flex: 1; min-width: 220px; }
.field input[type="date"], .field > input {
  margin: 0; width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  background: #fff; font: inherit; color: var(--text);
}
.query-actions { display: flex; gap: 8px; align-items: center; }

.chip-input {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  min-height: 42px; padding: 6px 8px; border: 1px solid var(--line); background: #fff;
}
.chip-input:focus-within { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(58, 138, 154, 0.15); }
.chip-input input {
  border: 0 !important; outline: none; box-shadow: none !important;
  flex: 1; min-width: 140px; margin: 0 !important; padding: 6px 4px !important;
  background: transparent !important;
}
.chips { display: contents; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; background: #eef5f7; border: 1px solid #c5d7df;
  font-family: var(--mono); font-size: 13px; color: var(--sider);
  animation: fade-up 0.25s var(--ease) both;
}
.chip button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font: inherit; line-height: 1; padding: 0 2px;
}
.chip button:hover { color: var(--bad); }
.chip.fav { border-color: #b8d4c8; background: #f1faf5; }

.quick-plates { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.quick-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.quick-bar { display: flex; flex-wrap: wrap; gap: 8px; min-height: 28px; }
.quick-item {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; padding: 5px 10px;
  font-family: var(--mono); font-size: 12px; cursor: pointer;
  transition: transform 0.15s var(--ease), border-color 0.15s, background 0.15s;
}
.quick-item:hover { transform: translateY(-1px); border-color: var(--accent-2); background: #f3fafb; }
.quick-item.active { background: #e8f4f6; border-color: var(--accent); color: var(--accent); }
.quick-empty { font-size: 12px; color: var(--muted); }

.preset-pick select {
  margin: 0; min-width: 140px; width: auto; padding: 8px 10px;
  border: 1px solid var(--line); background: #fff; font: inherit;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.query-toolbar { justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.scope-dd {
  position: relative;
  min-width: 140px;
}
.scope-dd > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  color: var(--text);
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scope-dd > summary::-webkit-details-marker { display: none; }
.scope-dd > summary::after {
  content: "▾";
  margin-left: 8px;
  color: var(--muted);
  font-size: 11px;
}
.scope-dd[open] > summary {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(58, 138, 154, 0.12);
}
.scope-dd-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  width: min(320px, 80vw);
  max-height: 280px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 10px 28px rgba(20, 40, 50, 0.12);
}
.scope-dd-hint { margin: 0 0 8px; font-size: 12px; line-height: 1.4; }
.device-scope.compact {
  display: flex; flex-direction: column; gap: 6px;
  max-height: none; overflow: visible;
}
.device-scope.compact label { margin: 0; }
.preset-manage-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto; }
.preset-manage-item {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); background: #fff;
}
.preset-manage-item .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.preset-manage-item .ops { display: flex; gap: 6px; flex-shrink: 0; }
.modal-quick { max-height: 88px; overflow: auto; }
.preset-modal-body { width: min(640px, 94vw); }
.detail-fav-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.device-scope {
  display: flex; flex-wrap: wrap; gap: 8px; max-height: 120px; overflow: auto;
  padding: 8px; border: 1px solid var(--line); background: #fff;
}
.device-scope label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text); padding: 4px 8px;
  border: 1px solid var(--line); background: #f7fbfd; cursor: pointer;
}
.device-scope label.on { border-color: var(--accent); background: #e8f4f6; }
.device-scope.modal-devices { max-height: 180px; }

.modal {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0; pointer-events: none; transition: opacity 0.25s var(--ease);
}
.modal.open { opacity: 1; pointer-events: auto; }
.modal-mask { position: absolute; inset: 0; background: rgba(18, 28, 34, 0.4); backdrop-filter: blur(2px); }
.modal-body {
  position: relative; z-index: 1;
  width: min(560px, 94vw); max-height: min(86vh, 720px); overflow: auto;
  background: #f7fbfd; padding: 22px; border: 1px solid var(--line);
  box-shadow: var(--shadow);
  margin: 0;
}
/* 避免 anim-enter 的 translateY 把弹窗顶出中心 */
.modal-body.anim-enter {
  animation: modal-in 0.3s var(--ease) both;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.pager-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.pager { display: flex; align-items: center; gap: 8px; }
.pager select { margin: 0; width: auto; min-width: 0; padding: 8px 10px; }
.page-label { font-size: 13px; color: var(--muted); min-width: 64px; text-align: center; }
.load-hint { font-size: 12px; color: var(--accent); min-height: 1.2em; margin-top: 4px; }
.load-hint.done { color: var(--muted); }
.card.new-flash { box-shadow: 0 0 0 2px rgba(58, 138, 154, 0.35); }

.table-wrap {
  background: var(--card); border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(22, 40, 52, 0.04); overflow: auto;
  flex: 1; min-height: 180px; max-height: none;
}
#recordsPanel .query-panel { flex: none; }
#recordsPanel .pager-bar { flex: none; }
#devicesPanel .stat-row,
#devicesPanel .filters { flex: none; }
#devicesPanel .card-grid { flex: 1; min-height: 0; overflow: auto; align-content: start; }
.btn:disabled {
  opacity: 0.45; cursor: not-allowed; pointer-events: none;
}
.data-table { width: 100%; border-collapse: collapse; background: transparent; }
.data-table th, .data-table td {
  padding: 11px 14px; border-bottom: 1px solid var(--line);
  text-align: left; font-size: 13px; white-space: nowrap;
}
.data-table th { color: var(--muted); font-weight: 500; background: #eef3f7; position: sticky; top: 0; z-index: 1; }
.data-table th.sortable {
  cursor: pointer; user-select: none; white-space: nowrap;
}
.data-table th.sortable:hover { color: var(--text); background: #e4eef3; }
.data-table th.sortable .sort-ind {
  display: inline-block; margin-left: 4px; font-size: 10px; color: var(--muted); opacity: 0.55;
}
.data-table th.sortable.sorted .sort-ind { opacity: 1; color: var(--accent); font-weight: 700; }
.data-table tbody tr { cursor: pointer; transition: background 0.15s; }
.data-table tbody tr:hover td { background: #f0f6f8; }
.data-table tbody tr.selected td { background: #e5f2f5; }
.data-table tbody tr.new-flash td { animation: fade-up 0.35s var(--ease); background: #eef8fa; }
.data-table .plate-cell { font-family: var(--mono); font-weight: 600; letter-spacing: 0.03em; }
.plate-color { font-weight: 700; letter-spacing: 0.04em; }
.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; }

.detail-modal { z-index: 32; }
.detail-modal-body {
  width: min(1120px, 96vw);
  max-height: min(90vh, 860px);
  padding: 18px 20px 22px;
}
.detail-modal-body .drawer-head { margin-bottom: 14px; align-items: flex-start; }
.detail-modal-body .drawer-head h2 { font-size: 17px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.detail-card {
  background: #fff; border: 1px solid var(--line); padding: 16px;
  box-shadow: 0 6px 18px rgba(22, 40, 52, 0.05); min-height: 180px;
  max-height: min(68vh, 640px); overflow: auto;
}
.detail-media {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin: 0 0 14px;
}
.detail-media.empty-media {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 12px; border: 1px dashed var(--line); background: #fff;
}
.thumb-card {
  position: relative;
  display: block; width: 100%; padding: 0; border: 1px solid var(--line);
  background: #101820; cursor: pointer; text-align: left; overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}
.wm-local {
  position: absolute; right: 6px; bottom: 6px; z-index: 2;
  padding: 2px 6px; font-size: 11px; font-weight: 700;
  color: #fff; background: rgba(180, 40, 40, 0.88);
  pointer-events: none; letter-spacing: 0.04em;
}
.fault-reason { color: #c45c1a; }
.site-detail { margin-top: 10px; }
.site-detail summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.site-ipc-list { display: grid; gap: 8px; margin-top: 8px; }
.site-ipc {
  padding: 8px 10px; border: 1px solid var(--line); background: #fafbfc; font-size: 12px;
  display: grid; gap: 4px;
}
.cam-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}
.cam-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
}
.cam-item.bad { border-color: #efc08a; background: #fff7ee; }
.cam-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link {
  display: block; padding: 10px 14px; color: #c5d4de; text-decoration: none;
  font-size: 13px;
}
.nav-link:hover { color: #fff; }
.thumb-card:hover { border-color: var(--accent-2); transform: translateY(-1px); }
.thumb-label {
  display: block; padding: 4px 8px; font-size: 11px; color: #c5d4de;
  background: rgba(0, 0, 0, 0.35);
}
.thumb-card img {
  display: block; width: 100%; height: 168px; object-fit: cover;
  opacity: 0; transition: opacity 0.3s; background: #1a242c;
}
.thumb-card img.ready { opacity: 1; }
.ph-frame {
  position: relative; width: 100%; aspect-ratio: 720 / 405;
  background: #7aa8d4; overflow: hidden;
}
.ph-frame .ph-base {
  display: block; width: 100%; height: 100%; object-fit: cover;
  opacity: 1;
}
.ph-frame .ph-site {
  position: absolute; left: 10px; top: 8px; z-index: 1;
  max-width: 70%; padding: 4px 8px; border-radius: 2px;
  background: rgba(20, 40, 50, 0.78); color: #e6f0f5;
  font-size: 12px; line-height: 1.3; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.ph-frame .ph-plate {
  position: absolute; right: 10px; bottom: 10px; z-index: 1;
  padding: 6px 12px; border-radius: 4px;
  background: #1e5ac8; color: #fff; border: 2px solid #f0f0f0;
  font-size: 16px; font-weight: 700; letter-spacing: 0.06em;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.ph-frame .ph-tag {
  position: absolute; left: 10px; bottom: 10px; z-index: 1;
  font-size: 11px; color: rgba(230, 240, 245, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}
.img-block .ph-frame { margin-top: 6px; }
.thumb-card.ph-thumb { background: transparent; }
.thumb-card.ph-thumb .ph-frame { height: 168px; aspect-ratio: auto; }
.thumb-card.ph-thumb .ph-plate { font-size: 13px; padding: 4px 8px; }
.detail-card h3 {
  margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--sider);
  padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.kv { display: grid; grid-template-columns: 76px 1fr; gap: 6px 10px; font-size: 13px; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--text); word-break: break-all; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.history-list { display: flex; flex-direction: column; gap: 8px; max-height: none; overflow: visible; }
.history-item {
  display: grid; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); background: #fff;
  cursor: pointer; transition: border-color 0.15s, transform 0.15s;
}
.history-item:hover { border-color: var(--accent-2); transform: translateY(-1px); }
.history-item .t { font-size: 12px; color: var(--muted); }
.history-item .m { font-size: 13px; }
.site-online { display: inline-flex; align-items: center; gap: 6px; }

@media (max-width: 1100px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.stat-row {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px;
}
.stat {
  background: var(--card); border: 1px solid var(--line); padding: 14px 16px;
  box-shadow: 0 4px 14px rgba(22, 40, 52, 0.04);
}
.stat .n { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.stat .l { margin-top: 4px; font-size: 12px; color: var(--muted); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.card-grid.records {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 16px 16px 14px;
  box-shadow: 0 6px 18px rgba(22, 40, 52, 0.05);
  display: flex; flex-direction: column; gap: 12px;
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease), border-color 0.22s;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: #b9ccd6;
}
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-title { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.3; }
.card-id { margin: 4px 0 0; font-size: 12px; color: var(--muted); word-break: break-all; }
.card-meta { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.card-meta strong { color: var(--text); font-weight: 500; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }

.dir-cell { font-weight: 650; }
.dir-cell.dir-in { color: #1f7a52; }
.dir-cell.dir-out { color: #c45c1a; }
.plate-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; font-size: 12px; border: 1px solid var(--line);
  background: #fff; white-space: nowrap;
}
.tag.ok { color: var(--ok); border-color: #a7d7c3; background: #f2faf6; }
.tag.warn { color: var(--warn); border-color: #e6c98a; background: #fffaf0; }
.tag.bad { color: var(--bad); border-color: #e0a5a5; background: #fff6f6; }
.tag.online { color: #1f7a52; border-color: #8fd0b0; background: #eef8f3; }
.tag.offline { color: #a83232; border-color: #e0a5a5; background: #fff5f5; }
.tag.fault { color: #c45c1a; border-color: #efc08a; background: #fff7ee; }
.dot {
  width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block;
}
.tag.online .dot { animation: pulse-dot 1.8s ease-in-out infinite; }
.stat.stat-online .n { color: #1f7a52; }
.stat.stat-offline .n { color: #a83232; }
.stat.stat-fault .n { color: #c45c1a; }

.empty {
  grid-column: 1 / -1; padding: 48px 20px; text-align: center;
  color: var(--muted); border: 1px dashed var(--line); background: rgba(255, 255, 255, 0.45);
  animation: fade-in 0.4s var(--ease);
}

.drawer {
  position: fixed; inset: 0; z-index: 40;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s var(--ease);
}
.drawer.open {
  opacity: 1; pointer-events: auto;
}
.drawer-mask {
  position: absolute; inset: 0; background: rgba(18, 28, 34, 0.4);
  backdrop-filter: blur(2px);
}
.drawer-body {
  position: absolute; right: 0; top: 0; height: 100%; width: min(720px, 96vw);
  background: #f7fbfd; padding: 22px 22px 28px;
  box-shadow: -12px 0 36px rgba(0, 0, 0, 0.14);
  overflow: auto;
  transform: translateX(18px);
  transition: transform 0.3s var(--ease);
}
.drawer.open .drawer-body { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-meta { margin-bottom: 16px; line-height: 1.5; }
.drawer-meta .plate { font-size: 22px; }
.img-block {
  position: relative;
  margin-bottom: 14px; padding: 10px; background: #fff; border: 1px solid var(--line);
  animation: fade-up 0.4s var(--ease) both;
}
.img-block img {
  display: block; max-width: 100%; margin-top: 8px;
  opacity: 0; transition: opacity 0.35s var(--ease);
}
.img-block img.ready { opacity: 1; }

.lightbox {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 16, 22, 0.92);
  display: flex; flex-direction: column; padding: 16px 20px 20px;
}
.lb-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 10px;
}
.lb-meta {
  display: flex; flex-direction: column; gap: 2px; color: #e8f0f5; font-size: 14px;
  min-width: 0;
}
.lb-meta strong { font-size: 22px; letter-spacing: 0.03em; }
.lb-close { flex-shrink: 0; }
.lb-stage {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: 56px 1fr 56px; align-items: center; gap: 12px;
}
.lb-nav {
  width: 56px; height: 72px; border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08); color: #fff; font-size: 36px; line-height: 1;
  border-radius: 8px; cursor: pointer;
}
.lb-nav:hover { background: rgba(255,255,255,0.16); }
.lb-nav:disabled { opacity: 0.25; cursor: default; }
.lb-body {
  height: 100%; display: flex; align-items: center; justify-content: center;
  overflow: auto;
}
.lb-body img {
  max-width: min(96vw, 1400px); max-height: 78vh; object-fit: contain;
  opacity: 0; transition: opacity 0.25s; background: #111;
}
.lb-body img.ready { opacity: 1; }
.lb-body .err { color: #f0a0a0; }
.lb-placeholder { color: #d5e2ea; text-align: center; }
.lb-placeholder .ph-frame { max-width: 720px; margin: 12px auto 0; }
.lb-caption {
  text-align: center; color: #a8bbc8; font-size: 13px; margin-top: 10px; min-height: 1.4em;
}
.spinner {
  width: 18px; height: 18px; 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); } }

@media (max-width: 860px) {
  .main-view { grid-template-columns: 1fr; }
  .sider { flex-direction: row; align-items: center; gap: 12px; padding: 12px 14px; }
  .sider nav { flex-direction: row; flex: 1; overflow: auto; }
  .user-box { display: none; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
