* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: #f3f1ea; color: #222; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; }
.scroll-wrap { overflow-x: auto; }
.page { min-width: 1280px; max-width: 1680px; margin: 0 auto; padding: 0 16px 24px; }
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 24px; background: #fff; border-bottom: 2px solid #2e7d32; padding: 10px 16px; margin: 0 -16px 16px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-size: 20px; font-weight: 700; }
.brand-sub { font-size: 12px; color: #666; }
.live-dot { width: 12px; height: 12px; border-radius: 50%; background: #999; flex: none; }
.live-dot.on { background: #16a34a; box-shadow: 0 0 0 4px rgba(22,163,74,.2); }
.live-dot.warn { background: #d97706; }
.live-text { font-size: 12px; color: #666; }
.anchors { display: flex; gap: 12px; flex-wrap: wrap; }
.anchors a { color: #2e7d32; text-decoration: none; }
.anchors a:hover { text-decoration: underline; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.clock { font-variant-numeric: tabular-nums; color: #555; }
.btn { border: 1px solid #ccc; background: #fff; border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.btn:hover { background: #f0f0f0; }
.btn.primary { background: #2e7d32; color: #fff; border-color: #2e7d32; }
.btn.primary:hover { background: #256b29; }
.btn.danger { color: #b91c1c; border-color: #e5a8a8; }
.btn.small { padding: 2px 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 16px; margin-bottom: 16px; align-items: stretch; }
.row1 .map-card { flex: 7; }
.row1 .verdict { flex: 5; }
.card { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.08); margin-bottom: 16px; }
.card h2 { margin: 0 0 10px; font-size: 17px; }
.card h3 { margin: 14px 0 6px; font-size: 14px; }
.note { color: #888; font-size: 12px; }
.hidden { display: none !important; }
.health { display: flex; align-items: center; gap: 20px; }
.health-score { font-size: 44px; font-weight: 800; color: #2e7d32; }
.health-score small { font-size: 16px; color: #888; }
.health-status { font-size: 20px; font-weight: 700; }
.device-scores { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.device-scores span { background: #f3f1ea; border-radius: 6px; padding: 4px 8px; font-size: 13px; }
.map-wrap { position: relative; line-height: 0; }
.map-wrap img { width: 100%; height: auto; aspect-ratio: 1206 / 724; border-radius: 8px; display: block; }
.map-point { position: absolute; transform: translate(-50%, -50%); border: none; border-radius: 999px; color: #fff; font-size: 12px; padding: 4px 8px; cursor: pointer; line-height: 1.2; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.map-point .cnt { background: rgba(255,255,255,.9); color: #222; border-radius: 999px; padding: 0 5px; margin-left: 4px; font-weight: 700; }
.area-popup { position: absolute; z-index: 20; width: 300px; background: #fff; border: 1px solid #ddd; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); padding: 10px 12px; line-height: 1.5; }
.area-popup h4 { margin: 0 0 6px; }
.area-popup .popup-close { float: right; border: none; background: none; cursor: pointer; font-size: 16px; }
.area-popup button.play { display: block; width: 100%; text-align: left; border: 1px solid #e5e5e5; background: #fafafa; border-radius: 6px; padding: 5px 8px; margin: 4px 0; cursor: pointer; }
.area-popup button.play:hover { background: #eef6ee; }
.area-popup button.play:disabled { color: #999; cursor: default; }
.insight-list { margin: 0; padding-left: 18px; }
.insight-list li { margin: 6px 0; }
.env-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.env-device { border: 1px solid #eee; border-radius: 8px; padding: 10px; }
.env-device h3 { margin-top: 0; }
.metric-row { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; border-bottom: 1px dashed #f0f0f0; font-size: 13px; }
.metric-row .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: 12px; background: #eee; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.over { background: #fee2e2; color: #991b1b; }
.badge.unknown { background: #eee; color: #666; }
.badge.live { background: #dcfce7; color: #166534; }
.badge.conn { background: #fef3c7; color: #92400e; }
.badge.fail { background: #fee2e2; color: #991b1b; }
.collapse-bar { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
#trendWrap { margin-top: 12px; }
.trend-tabs, .wall-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.tab-btn.active { background: #2e7d32; color: #fff; border-color: #2e7d32; }
.trend-chart { margin-bottom: 14px; }
.trend-chart canvas { width: 100%; height: 180px; background: #fcfcf8; border: 1px solid #eee; border-radius: 8px; }
.trend-legend { font-size: 12px; color: #555; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.trend-legend i { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-right: 3px; }
.feed-summary { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.feed-forms { display: flex; gap: 16px; flex-wrap: wrap; }
.mini-form { border: 1px solid #eee; border-radius: 8px; padding: 12px; flex: 1; min-width: 300px; }
.mini-form label { display: block; margin: 6px 0; font-size: 13px; }
.mini-form input, .mini-form select { width: 100%; padding: 5px 8px; border: 1px solid #ccc; border-radius: 6px; margin-top: 2px; }
.form-msg { font-size: 12px; color: #2e7d32; margin-left: 8px; }
.forecast-out { margin-top: 8px; font-size: 13px; background: #f3f1ea; border-radius: 6px; padding: 8px; }
.batch-card { border: 1px solid #eee; border-radius: 8px; padding: 12px; margin: 12px 0; }
.batch-card h3 { margin: 0 0 6px; }
.table-scroll { overflow: auto; max-height: 420px; border: 1px solid #eee; border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { border-bottom: 1px solid #f0f0f0; padding: 5px 8px; text-align: left; }
th { background: #f8f8f5; position: sticky; top: 0; }
.legacy-box { margin-top: 14px; }
.legacy-banner { background: #fef3c7; border: 1px solid #fde68a; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.log-box { margin-top: 14px; }
.log-box summary { cursor: pointer; font-weight: 700; margin-bottom: 8px; }
.dahua-state { padding: 8px 10px; border-radius: 8px; margin-bottom: 10px; font-size: 13px; }
.dahua-state.warn { background: #fef3c7; border: 1px solid #fde68a; }
.dahua-state.ok { background: #dcfce7; border: 1px solid #bbf7d0; }
.cam-group { margin-bottom: 14px; }
.cam-group h3 { border-left: 4px solid #2e7d32; padding-left: 8px; }
.cam-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px dashed #f0f0f0; flex-wrap: wrap; }
.cam-row .nm { flex: 1; min-width: 200px; }
.cam-row.disabled { color: #999; }
.wall-box { border: 1px solid #ddd; border-radius: 10px; padding: 8px; background: #111; min-height: 300px; margin-bottom: 14px; }
.wall-box.layout-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wall-box.layout-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.wall-cell { position: relative; background: #000; border-radius: 6px; overflow: hidden; aspect-ratio: 16 / 9; }
.wall-cell video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.wall-cell .cell-bar { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; padding: 4px 6px; background: linear-gradient(rgba(0,0,0,.6), transparent); color: #fff; font-size: 12px; }
.wall-cell .cell-bar button { background: rgba(255,255,255,.85); border: none; border-radius: 4px; cursor: pointer; }
.wall-empty { color: #888; padding: 40px; text-align: center; grid-column: 1 / -1; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.player-box { background: #fff; border-radius: 12px; width: min(900px, 96vw); overflow: hidden; }
.player-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #eee; font-weight: 700; }
.player-head .badge { margin-left: 4px; }
.player-head button:last-child, .player-head .spacer { margin-left: auto; }
.player-body { padding: 12px; }
.player-body video { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 8px; }
.player-msg { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: #fef3c7; font-size: 13px; }
.admin-box { background: #fff; border-radius: 12px; width: min(860px, 96vw); max-height: 90vh; overflow: auto; }
#adminBody { padding: 14px; }
.admin-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.admin-tabs .tab-btn.active { background: #2e7d32; color: #fff; border-color: #2e7d32; }
.admin-box input, .admin-box select, .admin-box textarea { padding: 5px 8px; border: 1px solid #ccc; border-radius: 6px; }
.admin-box textarea { width: 100%; }
.footer { text-align: center; color: #888; font-size: 12px; padding: 12px 0; }

.pick-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.picker-box { background: #fff; border-radius: 12px; width: min(860px, 96vw); max-height: 90vh; overflow: auto; }
.picker-box .player-head { position: sticky; top: 0; background: #fff; z-index: 1; }
.picker-body { padding: 14px; }
.picker-body .cam-group:last-child { margin-bottom: 0; }

.village-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.village-pane { white-space: pre-line; line-height: 1.8; }
