:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --ink: #152034;
  --muted: #68758a;
  --line: #dce4ef;
  --blue: #245bdb;
  --green: #1b8f61;
  --red: #d64545;
  --shadow: 0 12px 32px rgba(32, 50, 79, 0.08);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  max-width: 760px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 14px calc(92px + env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 85% 0%, rgba(84, 126, 235, 0.15), transparent 34%),
    var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
}

button, input, select { font: inherit; }
button, .button-link { touch-action: manipulation; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.app-header {
  display: flex;
  position: sticky;
  z-index: 20;
  top: 0;
  align-items: center;
  justify-content: space-between;
  margin: 0 -14px 14px;
  padding: calc(16px + env(safe-area-inset-top)) 18px 14px;
  border-bottom: 1px solid rgba(220, 228, 239, 0.88);
  background: rgba(244, 247, 251, 0.92);
  backdrop-filter: blur(16px);
}

.app-header h1, .section-heading h2 { margin: 0; }
.app-header h1 { font-size: 24px; letter-spacing: -0.03em; }
.eyebrow { margin: 0 0 3px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: 0.14em; }

.card {
  border: 1px solid rgba(220, 228, 239, 0.9);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings { display: grid; gap: 14px; margin-bottom: 14px; padding: 18px; }
.settings label, .control-grid label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 750; }

input, select {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}

button, .button-link {
  min-height: 46px;
  padding: 0 15px;
  border: 0;
  border-radius: 12px;
  font-weight: 750;
  text-align: center;
  text-decoration: none;
}

button:disabled { opacity: 0.5; }
.primary { background: var(--blue); color: #fff; }
.secondary { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.wide { display: flex; width: 100%; align-items: center; justify-content: center; }
.button-link { display: flex; align-items: center; justify-content: center; }
.icon-button { min-height: 38px; padding: 0 13px; background: #e8eef9; color: var(--blue); }

.hero { margin-bottom: 14px; padding: 20px; }
.hero-top { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; color: var(--muted); font-size: 13px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #98a2b3; }
.status-dot.online { background: #19a26b; box-shadow: 0 0 0 5px rgba(25, 162, 107, 0.12); }
.hero h2 { margin: 4px 0; font-size: clamp(25px, 9vw, 38px); line-height: 1.15; word-break: break-word; }
.package-name { margin: 0; color: var(--muted); font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 17px; }
.chip, .live-state { padding: 6px 10px; border-radius: 999px; background: #edf1f7; color: var(--muted); font-size: 12px; font-weight: 750; }
.chip.good, .live-state.active { background: #e6f6ee; color: var(--green); }
.chip.bad, .live-state.bad { background: #fdecec; color: var(--red); }

.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 13px; }
.metric { display: grid; min-height: 116px; padding: 15px; }
.metric span, .metric small { color: var(--muted); font-size: 12px; }
.metric strong { align-self: center; font-size: 25px; }

.tab-panel { animation: enter 0.18s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 14px;
}
.section-heading.compact { margin-top: 24px; }
.section-heading h2 { font-size: 20px; }

.screen-stage, .camera-stage {
  display: grid;
  min-height: 300px;
  max-height: 62vh;
  place-items: center;
  overflow: hidden;
  border-radius: 18px;
  background: #0c1422;
  color: #9eafc5;
}
.screen-stage img, .camera-stage img, .camera-stage canvas {
  display: block;
  max-width: 100%;
  max-height: 62vh;
  object-fit: contain;
}
.camera-stage canvas { display: none; width: 100%; height: 100%; }
.camera-stage canvas.visible { display: block; }

.control-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.control-grid label { grid-column: span 1; }
.control-grid .wide { grid-column: 1 / -1; }

.list-card { display: grid; gap: 1px; overflow: hidden; }
.list-item { display: grid; gap: 4px; padding: 14px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item strong { font-size: 14px; }
.list-item small { color: var(--muted); }
.clipboard-text { white-space: pre-wrap; overflow-wrap: anywhere; }

.gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.gallery-card { position: relative; overflow: hidden; aspect-ratio: 1; padding: 0; border-radius: 12px; background: #e7edf5; }
.gallery-card img { width: 100%; height: 100%; object-fit: cover; }
.gallery-card span { position: absolute; right: 5px; bottom: 5px; left: 5px; overflow: hidden; color: #fff; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 4px #000; }

.bottom-nav {
  display: grid;
  position: fixed;
  z-index: 30;
  right: max(10px, calc((100vw - 760px) / 2 + 10px));
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: max(10px, calc((100vw - 760px) / 2 + 10px));
  grid-template-columns: repeat(4, 1fr);
  padding: 7px;
  border: 1px solid rgba(211, 221, 234, 0.95);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 16px 40px rgba(23, 36, 57, 0.18);
  backdrop-filter: blur(18px);
}
.bottom-nav button { min-height: 50px; background: transparent; color: var(--muted); }
.bottom-nav button.active { background: #e9efff; color: var(--blue); }

dialog {
  width: min(94vw, 720px);
  max-height: 92vh;
  padding: 14px;
  border: 0;
  border-radius: 20px;
}
dialog::backdrop { background: rgba(8, 15, 28, 0.76); }
.dialog-head { display: flex; justify-content: space-between; margin-bottom: 12px; }
dialog img { display: block; width: 100%; max-height: 70vh; object-fit: contain; margin-bottom: 12px; border-radius: 12px; }

@media (max-width: 380px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .control-grid { grid-template-columns: 1fr; }
}

/* ---------- 情报采集（4.5） ---------- */
.intel-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
}

.intel-toolbar select {
  flex: 1 1 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}

.intel-toolbar .secondary {
  flex: 1 1 calc(50% - 4px);
  min-height: 38px;
}

.intel-toolbar .secondary.active {
  background: #e9efff;
  border-color: var(--blue);
  color: var(--blue);
}

.intel-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 10px;
  -webkit-overflow-scrolling: touch;
}

.intel-tabs .chip {
  flex: 0 0 auto;
  border: 1px solid transparent;
  font-size: 12px;
  cursor: pointer;
}

.intel-tabs .chip.active {
  background: #e9efff;
  border-color: var(--blue);
  color: var(--blue);
  font-weight: 700;
}

#intelStatus {
  margin: 0 0 10px;
  font-size: 12px;
  word-break: break-all;
}

#intelList {
  display: grid;
  gap: 8px;
  padding: 10px;
  max-height: 58vh;
  overflow-y: auto;
}

.intel-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.intel-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.intel-item-head strong {
  font-size: 13px;
  word-break: break-all;
}

.intel-item-meta {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--muted);
}

.intel-item-body {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: #344054;
  white-space: pre-wrap;
  word-break: break-word;
}

.intel-item .secondary {
  margin-top: 8px;
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.intel-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.intel-pager .secondary {
  min-height: 36px;
}

/* 5 个底部页签：等分一行 */
.bottom-nav {
  grid-template-columns: repeat(5, 1fr);
}

.bottom-nav button {
  padding: 0 4px;
  font-size: 13px;
}

body {
  overflow-x: hidden;
}

/* 局域网直连开关 */
.settings .inline-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.settings .inline-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
}
