:root {
  --bg: #0f1218;
  --panel: #171b24;
  --panel-2: #1e2430;
  --line: #262d3a;
  --text: #e8edf5;
  --muted: #8b97a8;
  --accent: #4c8dff;
  --good: #36c98b;
  --warn: #f2b544;
  --bad: #f2637b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(1200px 600px at 20% 0%, #1b2a48 0%, #0f1218 60%);
  padding: 24px;
}

.login-card {
  width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.brand h1 { font-size: 20px; margin: 0; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 4px;
  background: linear-gradient(135deg, #4c8dff, #36c98b);
  box-shadow: 0 0 18px rgba(76, 141, 255, .8);
}

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

input, select, textarea {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  outline: none;
  width: 100%;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font: inherit;
}

.btn:hover { border-color: #3a4759; }
.btn.primary { background: linear-gradient(135deg, #3b7bf6, #4c8dff); border-color: transparent; font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side-brand { font-weight: 700; padding: 8px 12px 20px; display: flex; align-items: center; gap: 10px; }
nav { display: flex; flex-direction: column; gap: 4px; flex: 1 1 auto; min-height: 0; overflow-y: auto; margin-right: -4px; padding-right: 4px; }
nav::-webkit-scrollbar { width: 6px; }
nav::-webkit-scrollbar-thumb { background: #2c3543; border-radius: 999px; }

.nav-item {
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}

.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: rgba(76, 141, 255, .14); color: #9dc0ff; font-weight: 600; }

/* ---------- 二级菜单（分组 · 手风琴） ---------- */
.nav-group { display: flex; flex-direction: column; }

.nav-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.nav-group-head:hover { background: var(--panel-2); color: var(--text); }
.nav-group.has-active > .nav-group-head { color: #9dc0ff; }

.ng-caret {
  width: 0; height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  opacity: .65;
  transition: transform .18s ease;
}
.nav-group.open .ng-caret { transform: rotate(90deg); }

.nav-sub {
  display: none;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 4px 14px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}
.nav-group.open .nav-sub { display: flex; }
.nav-sub .nav-item { padding: 8px 10px; font-size: 13px; }

/* 顶栏面包屑（分组 › 页面） */
.crumb { color: var(--muted); font-weight: 400; font-size: 13px; margin-right: 8px; }
.crumb::after { content: "›"; margin-left: 8px; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 12px; font-size: 12px; }
.ghost-link { color: var(--muted); text-decoration: none; }
.ghost-link:hover { color: var(--accent); }
.link { background: none; border: 0; color: var(--muted); text-align: left; padding: 0; cursor: pointer; font: inherit; }

.main { flex: 1; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(23, 27, 36, .8);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h2 { margin: 0; font-size: 18px; }
.topbar-right { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 12px; }

.pill { border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; }
.pill.ok { color: var(--good); border-color: rgba(54, 201, 139, .4); }
.pill.bad { color: var(--bad); border-color: rgba(242, 99, 123, .4); }

.view { padding: 24px 28px 60px; }

/* ---------- 卡片 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat .v .unit { font-size: 14px; font-weight: 600; margin-left: 2px; color: var(--muted); }
.stat .v.hg-healthy { color: var(--good); }
.stat .v.hg-degraded { color: var(--warn); }
.stat .v.hg-faulty { color: var(--bad); }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- 信源健康度 ---------- */
.health-body { display: flex; gap: 22px; align-items: center; padding: 2px 2px 14px; flex-wrap: wrap; }
.health-gauge { min-width: 104px; text-align: center; border-right: 1px solid var(--line); padding-right: 22px; }
.hg-score { font-size: 38px; font-weight: 700; line-height: 1.08; }
.hg-score span { font-size: 15px; margin-left: 1px; }
.hg-label { color: var(--muted); font-size: 12px; margin-top: 2px; }
.health-gauge.healthy .hg-score { color: var(--good); }
.health-gauge.degraded .hg-score { color: var(--warn); }
.health-gauge.faulty .hg-score { color: var(--bad); }
.health-main { flex: 1; min-width: 240px; }
.health-bar { display: flex; gap: 2px; height: 12px; border-radius: 999px; overflow: hidden; background: var(--panel-2); border: 1px solid var(--line); }
.health-bar > span { display: block; height: 100%; transition: width .4s ease; }
.hb-healthy { background: var(--good); }
.hb-degraded { background: var(--warn); }
.hb-faulty { background: var(--bad); }
.hb-idle { background: #3a4354; }
.health-legend { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.health-meta { color: var(--muted); font-size: 12px; margin-top: 8px; }
.health-issues { border-top: 1px dashed var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; max-height: 264px; overflow: auto; }
.hi-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.hi-name { min-width: 140px; font-weight: 600; }
.hi-why { color: var(--muted); flex: 1; }
.hi-src { color: var(--muted); font-size: 12px; white-space: nowrap; }

@media (max-width: 720px) {
  .health-gauge { border-right: 0; padding-right: 0; }
  .hi-name { min-width: 100px; }
  .hi-src { display: none; }
}

/* 键值信息网格（系统设置 · 服务器电源等） */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kv-grid > div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.kv-grid .k { color: var(--muted); font-size: 12px; }
.kv-grid .v { margin-top: 4px; font-size: 14px; font-weight: 600; }

.btn:disabled { opacity: .45; cursor: not-allowed; }

/* 关机 / 重启等待层 */
.power-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(6, 9, 14, .92);
  display: grid; place-items: center; padding: 24px;
  text-align: center;
}
.power-card { max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.power-card h3 { margin: 6px 0 0; font-size: 18px; }
.power-card .hint { line-height: 1.8; }
.power-spin {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: power-spin .9s linear infinite;
}
@keyframes power-spin { to { transform: rotate(360deg); } }
.power-count { font-size: 46px; font-weight: 700; color: #9dc0ff; line-height: 1; min-height: 4px; }

/* 监控页进度条 */
.meter { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 12px; }
.meter i { display: block; height: 100%; width: 0; background: var(--good); border-radius: 999px; transition: width .5s ease; }
.meter.warn i { background: var(--warn); }
.meter.bad i { background: var(--bad); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}

.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.panel-head h3 { margin: 0; font-size: 15px; }

.banner {
  border: 1px solid rgba(242, 181, 68, .35);
  background: rgba(242, 181, 68, .08);
  color: #ffd88a;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 13px;
}

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
td.mono, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: #b9c6d8; }
/* 长地址（导入的多信源 URL 可能 130+ 字符）必须可断行，否则会把列撑到上千 px、挤压其他列 */
td .mono { overflow-wrap: anywhere; word-break: break-all; }
.actions .btn { white-space: nowrap; }
/* 应用详情页的展示图（后台编辑缩略图） */
.shot-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.shot-item { position: relative; width: 132px; height: 74px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #000; }
.shot-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot-del { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; font-size: 14px; line-height: 18px; cursor: pointer; }
.shot-del:hover { background: var(--bad); }
/* 频道列表列多、内容长，给最小宽度避免挤压；窄屏由 panel 横向滚动 */
.ch-table { min-width: 1080px; }
.panel { overflow-x: auto; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); white-space: nowrap; }
.badge.good { color: var(--good); border-color: rgba(54, 201, 139, .35); background: rgba(54, 201, 139, .08); }
.badge.warn { color: var(--warn); border-color: rgba(242, 181, 68, .35); background: rgba(242, 181, 68, .08); }
.badge.bad { color: var(--bad); border-color: rgba(242, 99, 123, .35); background: rgba(242, 99, 123, .08); }
.badge.mute { color: var(--muted); }

/* 安装包渠道切换（APP 升级页） */
.au-tabs { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 4px; }
.au-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
  font-size: 14px; font-family: inherit;
}
.au-tab:hover { color: var(--text); border-color: rgba(76, 141, 255, .4); }
.au-tab.active {
  color: #9dc0ff; font-weight: 600;
  border-color: rgba(76, 141, 255, .55); background: rgba(76, 141, 255, .14);
}
.au-tab .hint { font-size: 12px; opacity: .85; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
/* 面板头部工具条里的输入框 / 下拉框按内容取宽，否则会被全局 width:100% 撑成一列 */
.panel-head .actions input,
.panel-head .actions select { width: auto; min-width: 130px; }
.panel-head .actions input[type="search"] { min-width: 160px; }

.logs { max-height: 320px; overflow: auto; font-size: 12px; }
.log-row { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); color: #c3ccda; }
.log-row .t { color: var(--muted); font-family: ui-monospace, monospace; white-space: nowrap; }
.log-row.error { color: #ffb3c0; }
.log-row.warn { color: #ffd88a; }

.empty { color: var(--muted); text-align: center; padding: 32px; }

/* ---------- 套餐卡 ---------- */
.pkg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }

.pkg {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--panel-2);
}

.pkg h4 { margin: 0 0 6px; font-size: 16px; }
.pkg .price { font-size: 22px; font-weight: 700; color: #9dc0ff; }
.pkg .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(6, 9, 14, .7);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}

.modal-card {
  width: 520px; max-width: 100%; max-height: 90vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
}

.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); }

.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 220px; overflow: auto; }
.check { display: flex; flex-direction: row; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; color: var(--text); }
.check input { width: auto; }
.check input[type=checkbox] { width: 16px; height: 16px; margin: 0; flex: 0 0 auto; accent-color: var(--accent); cursor: pointer; }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #232c3b; border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 10px; z-index: 99; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}

/* 跑马灯通知编辑 */
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer; padding: 0; }
.swatch:hover { transform: scale(1.08); }
.n-target { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.n-target .check { flex: 0 0 auto; }
.n-pick { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.n-pick-list { max-height: 200px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.n-pick-list .check { padding: 7px 10px; }

/* 套餐：频道 + 节目源（组播 / 单播 / 其他信号源） */
.src-head-bar { display: flex; align-items: center; gap: 10px; }
.src-head-bar > b { font-size: 13px; }
.src-head-bar .hint { font-size: 12px; }
.src-head-bar #pkg-src-search { width: auto !important; margin-left: auto; min-width: 150px; font-size: 12px; padding: 6px 10px; }
.src-list { border: 1px solid var(--line); border-radius: 10px; max-height: 300px; overflow: auto; background: var(--panel-2); }
.src-row { display: grid; grid-template-columns: minmax(150px, 1.1fr) 72px 190px minmax(160px, 1.4fr); gap: 8px; align-items: center; padding: 6px 10px; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.src-row:last-child { border-bottom: none; }
.src-row.off { opacity: .45; }
.src-row.src-title { position: sticky; top: 0; z-index: 1; background: var(--panel); font-size: 11px; color: var(--muted); padding: 7px 10px; }
.src-chk { display: flex; flex-direction: row; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--text); }
.src-chk input[type=checkbox] { width: 16px; height: 16px; margin: 0; flex: 0 0 auto; accent-color: var(--accent); cursor: pointer; }
.src-chk span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src-row .src-mode, .src-row .src-url { width: 100%; margin: 0; font-size: 12px; padding: 5px 8px; min-width: 0; }
/* 套餐专用频道编号 */
.src-row .src-num { width: 100%; margin: 0; font-size: 12px; padding: 5px 4px; min-width: 0; text-align: center; }
.src-row .src-num.dup { border-color: #e2726e; box-shadow: 0 0 0 2px rgba(226, 114, 110, .16); }
.src-head-bar #pkg-renumber { width: auto !important; white-space: nowrap; }
.pkg .chip-no { font-style: normal; font-weight: 700; font-size: 10px; color: var(--accent); margin-right: 5px; }
.pkg .chip-no.same::after { content: ''; }
.pkg .chip-no.custom { color: #ffd166; }
.chip-mode { font-style: normal; font-weight: 600; font-size: 10px; margin-left: 5px; padding: 1px 5px; border-radius: 999px; }
.chip-mode.multicast { background: rgba(124, 196, 255, .16); color: #9dc0ff; }
.chip-mode.other { background: rgba(255, 209, 102, .16); color: #ffd166; }
@media (max-width: 760px) {
  .src-row { grid-template-columns: 1fr; }
  .src-row.src-title { display: none; }
  .src-head-bar { flex-wrap: wrap; }
  .src-head-bar #pkg-src-search { margin-left: 0; width: 100% !important; }
}

@media (max-width: 860px) {
  .sidebar { width: 78px; padding: 16px 6px; }
  .side-brand { font-size: 0; padding: 8px 6px 16px; }
  .side-brand .brand-dot { margin: 0 auto; }
  .nav-item { text-align: center; font-size: 11px; padding: 8px 2px; }
  .nav-sub { margin: 0 0 4px 4px; padding-left: 4px; }
  .nav-sub .nav-item { font-size: 10px; padding: 6px 2px; }
  .nav-group-head { justify-content: center; font-size: 11px; padding: 8px 2px; }
  .ng-caret { display: none; }
  .side-foot { display: none; }
  .view { padding: 16px; }
  .topbar { padding: 14px 16px; }
}

/* 网络磁盘面板 */
.nd-status { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); margin-bottom: 14px; }
.nd-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nd-bar { height: 8px; border-radius: 999px; background: rgba(255,255,255,.07); margin: 10px 0 6px; overflow: hidden; }
.nd-bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #4c8dff, #36c98b); }
