/* ==========================================================================
   家长端 H5 · 视觉系统
   主色 #014DB2 深蓝 / 暖白底 / 语义色（在线绿 · 重连黄 · 离线红）
   ========================================================================== */

:root {
  --primary: #014DB2;
  --primary-600: #0A5FD4;
  --primary-700: #013F92;
  --primary-soft: #EAF1FB;

  --navy: #0A1628;
  --bg: #F7F8FA;
  --card: #FFFFFF;
  --line: #EAEAEA;
  --line-2: #F1F2F4;

  --text: #0A1628;
  --text-2: #6B7280;
  --text-3: #9AA3AE;

  --ok: #10B981;
  --ok-bg: #E7F7EF;
  --ok-text: #0E9F6E;
  --warn: #F59E0B;
  --warn-bg: #FEF3E2;
  --warn-text: #B45309;
  --danger: #EF4444;
  --danger-bg: #FDECEC;
  --danger-text: #DC2626;
  --info-text: #35507A;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(10, 22, 40, 0.04), 0 8px 24px rgba(10, 22, 40, 0.06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  background: #EDEFF3;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace; }

/* ---------- 手机外框（桌面居中、移动端铺满） ---------- */
#app {
  position: relative;
  margin: 0 auto;
  max-width: 460px;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 60px rgba(10, 22, 40, 0.12);
  overflow: hidden;
}

@media (max-width: 480px) {
  #app { box-shadow: none; max-width: 100%; }
}

.view { display: none; flex: 1; flex-direction: column; min-height: 0; }
.view.active { display: flex; }

.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ============================ 登录页 ============================ */

#view-login { background: var(--card); }

.login-hero {
  position: relative;
  padding: 20px 24px 32px;
  background: linear-gradient(160deg, #0457C6 0%, #013F92 48%, #062247 100%);
  color: #fff;
  border-radius: 0 0 26px 26px;
}

.status-bar {
  display: flex; align-items: center; justify-content: space-between;
  height: 22px; margin-bottom: 22px;
  font-size: 14px; font-weight: 500; opacity: 0.95;
}
.status-icons { display: flex; gap: 5px; align-items: center; }
.status-icons i { display: block; background: currentColor; border-radius: 1px; }
.si-sig1 { width: 3px; height: 5px; }
.si-sig2 { width: 3px; height: 7px; }
.si-sig3 { width: 3px; height: 9px; opacity: .5; }
.si-bat { width: 20px; height: 9px; border: 1px solid currentColor; border-radius: 2px; background: none; position: relative; }
.si-bat::after { content: ""; position: absolute; inset: 1.5px; width: 70%; background: currentColor; border-radius: 1px; }

.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.brand-badge {
  width: 48px; height: 48px; border-radius: 14px; flex: none;
  background: rgba(255, 255, 255, 0.16);
  display: grid; place-items: center;
}
.brand-name { font-size: 14px; font-weight: 600; }
.brand-sub { font-size: 11px; opacity: 0.68; margin-top: 2px; }

.login-title { font-size: 25px; font-weight: 700; letter-spacing: -0.4px; margin: 0 0 10px; }
.login-desc { font-size: 12.5px; line-height: 1.65; opacity: 0.75; margin: 0; }

.login-body { padding: 26px 24px 32px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 7px; }
.input-wrap {
  display: flex; align-items: center; gap: 10px;
  height: 50px; padding: 0 14px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  transition: border-color .15s, background .15s;
}
.input-wrap:focus-within { border-color: var(--primary); background: #fff; }
.input-wrap input {
  flex: 1; border: none; background: none; outline: none;
  font-size: 15px; font-family: inherit; color: var(--text); min-width: 0;
}
.input-wrap input::placeholder { color: var(--text-3); }
.eye-btn { background: none; border: none; padding: 4px; cursor: pointer; display: grid; place-items: center; }

.row-between { display: flex; align-items: center; justify-content: space-between; }
.checkbox-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.checkbox-row span { font-size: 12.5px; color: var(--text-2); }
.link { color: var(--primary); font-size: 12.5px; font-weight: 500; text-decoration: none; background: none; border: none; cursor: pointer; padding: 0; font-family: inherit; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 52px; border: none; border-radius: 26px;
  font-size: 16px; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(0.985); }
.btn-primary { background: linear-gradient(135deg, var(--primary-600), var(--primary)); color: #fff; box-shadow: 0 6px 18px rgba(1, 77, 178, 0.28); }
.btn-primary:disabled { opacity: 0.55; box-shadow: none; }
.btn-ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
/* 输入框内的按钮（如“获取验证码”）：宽度自适应，避免覆盖输入框 */
.input-wrap .btn { width: auto; flex: none; height: 34px; padding: 0 14px; font-size: 13px; white-space: nowrap; }
.btn-block { margin-top: 6px; }

.tip-card {
  display: flex; gap: 10px; align-items: flex-start;
  margin-top: 20px; padding: 14px;
  background: var(--primary-soft); border-radius: 12px;
}
.tip-card p { margin: 0; font-size: 12px; line-height: 1.6; color: var(--info-text); }
.legal { text-align: center; font-size: 11px; color: var(--text-3); margin-top: 22px; }

.alert {
  display: none; gap: 9px; align-items: flex-start;
  padding: 12px 14px; border-radius: 10px; margin-bottom: 16px;
  font-size: 12.5px; line-height: 1.5;
}
.alert.show { display: flex; }
.alert-error { background: var(--danger-bg); color: var(--danger-text); }
.alert-warn { background: var(--warn-bg); color: var(--warn-text); }
.alert-ok { background: var(--ok-bg); color: var(--ok-text); }

/* ============================ 通用顶栏 ============================ */

.topbar {
  background: #fff; padding: 12px 20px 14px;
  border-bottom: 1px solid var(--line-2);
  position: sticky; top: 0; z-index: 20;
}
.topbar .status-bar { color: var(--navy); margin-bottom: 12px; opacity: 1; height: 18px; font-size: 13px; }
.nav-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.greeting-title { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; margin: 0; }
.greeting-sub { font-size: 12px; color: var(--text-2); margin: 3px 0 0; }

.icon-btn {
  width: 40px; height: 40px; flex: none; border-radius: 50%; border: none;
  background: var(--primary-soft); display: grid; place-items: center; cursor: pointer;
  position: relative;
}
.icon-btn .dot {
  position: absolute; top: 4px; right: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--danger); border: 2px solid var(--primary-soft);
}

/* ============================ 摄像头列表 ============================ */

.content { padding: 16px 20px 24px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 30px; padding: 0 14px; border-radius: 15px;
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 500; font-family: inherit; cursor: pointer;
  background: #fff; color: var(--text-2); border: 1px solid var(--line);
  transition: all .15s;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.group-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 8px; }
.group-head h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-2); }
.group-head span { font-size: 11px; color: var(--text-3); }

.cam-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; margin-bottom: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; transition: border-color .15s, transform .1s;
}
.cam-card:active { transform: scale(0.99); border-color: #D7DEE9; }

.thumb {
  width: 104px; height: 72px; flex: none; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #2A3648, #0F1724);
  position: relative; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .thumb-placeholder { position: absolute; inset: 0; display: grid; place-items: center; opacity: .5; }
.thumb .thumb-tag {
  position: absolute; left: 6px; bottom: 6px;
  font-size: 9px; color: #fff; background: rgba(0,0,0,.55); border-radius: 4px; padding: 2px 5px;
  font-family: ui-monospace, monospace;
}

.cam-info { flex: 1; min-width: 0; }
.cam-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cam-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-meta { font-size: 11px; color: var(--text-3); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  padding: 3px 7px; border-radius: 8px; font-size: 11px; font-weight: 500;
}
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-ok .bdot { background: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-warn .bdot { background: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }
.badge-danger .bdot { background: var(--danger); }
.badge-mute { background: var(--line-2); color: var(--text-2); }
.badge-mute .bdot { background: var(--text-3); }

.chevron { flex: none; color: #C7CDD6; display: grid; place-items: center; }

.apply-card {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer;
}
.apply-icon { width: 34px; height: 34px; flex: none; border-radius: 10px; background: var(--primary-soft); display: grid; place-items: center; }
.apply-title { font-size: 14px; font-weight: 600; }
.apply-desc { font-size: 11px; color: var(--text-2); margin-top: 3px; }

/* ============================ 空状态 ============================ */

.empty-wrap { padding: 34px 20px; display: flex; flex-direction: column; align-items: center; }
.empty-title { font-size: 18px; font-weight: 700; margin: 18px 0 8px; }
.empty-desc { font-size: 12.5px; color: var(--text-2); text-align: center; line-height: 1.65; margin: 0 0 22px; max-width: 300px; }

.info-card { width: 100%; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px; }
.info-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.info-row:last-child { border-bottom: none; }
.info-row .k { font-size: 12.5px; color: var(--text-3); }
.info-row .v { font-size: 12.5px; font-weight: 500; }
.hint { font-size: 11px; color: var(--text-3); text-align: center; margin-top: 16px; line-height: 1.6; }

/* ============================ 底部标签栏 ============================ */

.tabbar {
  flex: none; padding: 8px 14px calc(8px + var(--safe-bottom));
  background: #fff; border-top: 1px solid var(--line-2);
}
.tabbar-pill {
  display: flex; gap: 2px; height: 60px; padding: 4px;
  background: #F2F4F7; border: 1px solid var(--line); border-radius: 31px;
}
.tab {
  flex: 1; border-radius: 26px; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-family: inherit; font-size: 11px; font-weight: 500;
  transition: background .18s, color .18s;
}
.tab.active { background: var(--primary); color: #fff; }

/* ============================ 播放器 ============================ */

#view-player { background: #0A1628; }
.player-top {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: #0A1628; color: #fff;
}
.back-btn { width: 34px; height: 34px; flex: none; border-radius: 50%; border: none; background: rgba(255,255,255,.1); color: #fff; display: grid; place-items: center; cursor: pointer; }
.player-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-sub { font-size: 11px; opacity: .6; margin-top: 2px; }

.stage { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #05080F; }
.stage video { width: 100%; height: 100%; display: block; background: #05080F; object-fit: contain; }
.stage-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #fff; pointer-events: none; background: rgba(5,8,15,.72); }
.stage-overlay.hide { display: none; }
.stage-overlay .ov-title { font-size: 13px; font-weight: 500; }
.stage-overlay .ov-desc { font-size: 11px; opacity: .6; text-align: center; max-width: 260px; line-height: 1.6; }
.spinner { width: 26px; height: 26px; border: 2.5px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.stage-chips { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; pointer-events: none; }
.chip-live { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 7px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .5px; }
.chip-live .ldot { width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.chip-res { padding: 4px 8px; border-radius: 7px; background: rgba(255,255,255,.18); color: #fff; font-size: 10px; font-family: ui-monospace, monospace; }

.player-body { flex: 1; background: var(--bg); border-radius: 18px 18px 0 0; margin-top: -14px; position: relative; padding: 20px; }

.title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.title-row h2 { margin: 0; font-size: 17px; font-weight: 700; }
.meta-line { font-size: 11px; color: var(--text-3); margin-top: 6px; }

.section-card { margin-top: 14px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.stream-line { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.stream-line .l { font-weight: 600; }
.stream-line .r { color: var(--ok-text); font-family: ui-monospace, monospace; font-size: 11px; }
.progress { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin: 10px 0 8px; background: #E9EBEF; }
.progress .fill { background: var(--primary); }
.time-row { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); font-family: ui-monospace, monospace; }

.actions { display: flex; gap: 10px; margin-top: 14px; }
.action-btn {
  flex: 1; height: 44px; border-radius: 11px; border: 1px solid var(--line); background: #fff;
  display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 6px;
  font-size: 12.5px; font-weight: 500; font-family: inherit; color: var(--navy); cursor: pointer;
}
.action-btn:active { background: #F7F8FA; }

.note {
  display: flex; gap: 10px; align-items: flex-start; margin-top: 14px;
  padding: 14px; background: var(--primary-soft); border-radius: 12px;
}
.note p { margin: 0; font-size: 11.5px; line-height: 1.6; color: var(--info-text); }

/* 回看抽屉 */
.sheet-mask { position: fixed; inset: 0; background: rgba(10,22,40,.45); z-index: 60; display: none; }
.sheet-mask.show { display: block; }
.sheet {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(100%);
  bottom: 0; width: 100%; max-width: 460px; max-height: 76vh;
  background: #fff; border-radius: 20px 20px 0 0; z-index: 61;
  display: flex; flex-direction: column; transition: transform .26s cubic-bezier(.32,.72,0,1);
  padding-bottom: var(--safe-bottom);
}
.sheet.show { transform: translateX(-50%) translateY(0); }
.sheet-head { padding: 18px 20px 12px; border-bottom: 1px solid var(--line-2); }
.sheet-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.sheet-head p { margin: 4px 0 0; font-size: 11.5px; color: var(--text-3); }
.sheet-body { flex: 1; overflow-y: auto; padding: 14px 20px 20px; }

.day-list { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.rec-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 14px; margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; background: #fff;
}
.rec-row:active { background: #F7F8FA; }
.rec-row .t { font-size: 13px; font-weight: 500; }
.rec-row .m { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: rgba(10,22,40,.9); color: #fff; font-size: 13px;
  padding: 11px 18px; border-radius: 10px; opacity: 0; transition: all .22s; z-index: 90;
  pointer-events: none; max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 全屏(横屏)播放 */
#app.fs-player #view-player { position: fixed; inset: 0; z-index: 80; }
#app.fs-player .player-body { display: none; }
#app.fs-player .stage { aspect-ratio: auto; height: calc(100vh - 58px); }

/* ============================ 平台广告位 ============================ */

.ad-bar {
  position: absolute;
  left: 0; right: 0;
  height: 50px;
  z-index: 80;
  display: none;
  overflow: hidden;
  background: #fff;
}
.ad-bar.show { display: block; }
.ad-bar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ad-bar .ad-link { display: block; height: 100%; }
#adBarTop { top: 0; border-bottom: 1px solid var(--line-2); }
#adBarBottom { bottom: var(--ad-bottom-offset, 0px); border-top: 1px solid var(--line-2); }

/* 广告条占位：内容让位，避免被广告条遮挡 */
body.ad-top-on .view { padding-top: 50px; }
body.ad-bottom-on .scroll .content { padding-bottom: 58px; }
body.ad-bottom-on .login-body { padding-bottom: 58px; }
body.ad-bottom-on .player-body { padding-bottom: 58px; }
#app.fs-player .ad-bar { display: none !important; }

/* 开屏广告 */
.splash-ad {
  position: absolute;
  inset: 0;
  z-index: 200;
  background: #05080F;
  display: flex;
  flex-direction: column;
}
.splash-ad a { flex: 1; display: block; min-height: 0; cursor: pointer; }
.splash-ad img { width: 100%; height: 100%; object-fit: contain; display: block; }
.splash-skip {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 14px;
  padding: 6px 14px;
  border: none;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  z-index: 201;
}
/* 代码广告沙盒 iframe */
.ad-frame { width: 100%; height: 100%; border: 0; display: block; background: transparent; }
.ad-bar .ad-frame { object-fit: cover; }
.splash-ad .ad-frame { object-fit: contain; }

/* ============================ 登录方式切换 / 机构选择 ============================ */

.seg-tabs{display:flex;background:var(--bg);border:1px solid var(--line);border-radius:12px;padding:4px;gap:4px}
.seg-tab{flex:1;border:none;background:transparent;padding:9px 0;font-size:14px;color:var(--text-2);border-radius:9px;cursor:pointer;font-family:inherit}
.seg-tab.active{background:var(--card);color:var(--primary);font-weight:500;box-shadow:0 1px 3px rgba(10,22,40,.08)}

.org-card{display:flex;align-items:center;justify-content:space-between;gap:12px;background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:14px 16px;margin-bottom:10px;cursor:pointer}
.org-card:active{border-color:var(--primary)}
.org-card .org-name{font-size:15px;font-weight:500;color:var(--text)}
.org-card .org-code{font-size:12px;color:var(--text-3);font-family:ui-monospace,Menlo,Consolas,monospace;margin-top:2px}
.org-card .org-status{flex:none;font-size:12px;padding:3px 10px;border-radius:999px}
.org-status-ok{background:var(--ok-bg);color:var(--ok-text)}
.org-status-wait{background:var(--warn-bg);color:var(--warn-text)}
.org-status-no{background:var(--danger-bg);color:var(--danger-text)}
.org-search-item{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 12px;border:1px solid var(--line);border-radius:var(--radius-sm);margin-bottom:8px;background:var(--card)}
.org-search-item .n{font-size:14px;color:var(--text)}
.org-search-item .c{font-size:12px;color:var(--text-3);font-family:ui-monospace,Menlo,Consolas,monospace}
