:root {
  --bg: #f4f3ef;
  --panel: #ffffff;
  --ink: #1d2327;
  --ink-2: #4a5359;
  --muted: #8a9196;
  --line: #e4e2dc;
  --line-2: #efeee9;
  --side: #1a2226;
  --side-ink: #c9d1d4;
  --accent: #1f5f5b;
  --accent-2: #2c7a74;
  --accent-soft: #e3efed;
  --on: #1f8a5a;
  --warn: #b7791f;
  --warn-soft: #fbf1df;
  --danger: #b4372f;
  --danger-soft: #f8e6e4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 35, .06), 0 2px 8px rgba(20, 30, 35, .04);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.boot { padding: 80px; text-align: center; color: var(--muted); }

/* ---------- 布局 ---------- */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-ink);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font-weight: 600; font-size: 15px; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--accent-2); display: grid; place-items: center; font-size: 15px; }
.side a.nav {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px;
  color: var(--side-ink); text-decoration: none;
}
.side a.nav:hover { background: rgba(255,255,255,.06); color: #fff; }
.side a.nav.active { background: rgba(255,255,255,.1); color: #fff; }
.side .nav-group { font-size: 12px; color: #7d888d; padding: 14px 10px 4px; }
.side a.nav.sub { padding-left: 18px; font-size: 13px; }
.side a.nav .dot { width: 7px; height: 7px; border-radius: 50%; background: #56626a; flex: none; }
.side a.nav .dot.on { background: #3ec48a; }
.side-foot { margin-top: auto; font-size: 12px; color: #7d888d; padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; }
.side-foot button { background: none; border: 0; color: #9aa6ab; cursor: pointer; padding: 0; }
.side-foot button:hover { color: #fff; }

.main { padding: 28px 36px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; line-height: 1.3; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------- 卡片 ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.panel-head h2 { font-size: 15px; margin: 0; }
.panel-head .hint { color: var(--muted); font-size: 12.5px; }
.panel-body { padding: 16px 18px; }
.panel + .panel { margin-top: 16px; }
.app-grid > .panel, .big-switches > .panel { margin-top: 0; }

.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.app-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.app-card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.app-card h3 { margin: 0; font-size: 16px; }
.app-card .pkg { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; background: #f8f8f5; }
.switch-row .label { font-weight: 500; }
.switch-row .desc { font-size: 12px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { font-size: 12px; color: var(--muted); }
.stat b { display: block; font-size: 17px; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 开关 ---------- */
.toggle { position: relative; display: inline-flex; flex: none; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle .track { width: 44px; height: 24px; border-radius: 12px; background: #cfd3d1; transition: background .15s; position: relative; }
.toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.toggle input:checked + .track { background: var(--on); }
.toggle input:checked + .track::after { transform: translateX(20px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.toggle.warn input:checked + .track { background: var(--warn); }
.toggle.sm .track { width: 36px; height: 20px; }
.toggle.sm .track::after { width: 14px; height: 14px; }
.toggle.sm input:checked + .track::after { transform: translateX(16px); }

/* ---------- 按钮与表单 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; white-space: nowrap; color: var(--ink);
}
.btn:hover { border-color: #c9c6bd; background: #fafaf7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--danger); border-color: #e7c4c0; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #ecebe6; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 6px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12.5px; color: var(--ink-2); }
.field .help { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input {
  height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 0;
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.55; }
.input:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(44,122,116,.15); }
.input.mono { font-family: var(--mono); font-size: 12.5px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; align-items: end; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbfbf9; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fcfcfa; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }

/* ---------- 标签 ---------- */
.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; background: #eeede8; color: var(--ink-2); white-space: nowrap; }
.tag.on { background: #dff2e8; color: #17714a; }
.tag.off { background: #eeede8; color: var(--muted); }
.tag.warn { background: var(--warn-soft); color: #8a5a12; }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }

.notice { display: flex; gap: 10px; padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.6; }
.notice.warn { background: var(--warn-soft); color: #6f4a10; }
.notice.info { background: var(--accent-soft); color: #1c4c48; }
.notice.danger { background: var(--danger-soft); color: #7d2721; }

/* ---------- 选项卡 ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }

/* ---------- 大开关区 ---------- */
.big-switches { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.big-switch { padding: 18px; display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; }
.big-switch h3 { margin: 0 0 4px; font-size: 15px; }
.big-switch p { margin: 0; color: var(--muted); font-size: 13px; }
.big-switch .state { font-size: 13px; margin-top: 8px; }

/* ---------- 协议编辑 ---------- */
.doc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.doc-item { padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; text-align: left; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.doc-item:hover { border-color: var(--accent-2); }
.doc-item .t { font-weight: 500; }
.doc-item .m { font-size: 12px; color: var(--muted); }
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.editor > div { min-width: 0; }
.editor textarea { width: 100%; min-height: 560px; font-family: var(--mono); font-size: 12.5px; }
.seg { display: inline-flex; background: #ecebe6; border-radius: 8px; padding: 3px; }
.seg-btn { border: 0; background: transparent; padding: 4px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.seg-btn.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.fmt-bar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; background: #fafaf7; }
.fmt-bar .btn.sm { height: 26px; padding: 0 8px; }
.fmt-sep { width: 1px; background: var(--line); margin: 2px 4px; }
.visual-editor { min-height: 520px; max-height: 70vh; overflow: auto; border: 1px solid var(--line); border-radius: 0 0 8px 8px; padding: 14px 16px; background: #fff; line-height: 1.75; font-size: 14.5px; outline: none; word-break: break-word; }
.visual-editor:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(44,122,116,.12); }
.visual-editor h1 { font-size: 19px; } .visual-editor h2 { font-size: 17px; margin: 1.2em 0 .4em; } .visual-editor h3 { font-size: 15px; margin: 1em 0 .3em; }
.visual-editor p { margin: .5em 0; }
.visual-editor table { border-collapse: collapse; width: 100%; font-size: 13px; }
.visual-editor td, .visual-editor th { border: 1px solid #ddd; padding: 5px 7px; vertical-align: top; }
.visual-editor:empty::before { content: "在这里输入或粘贴正文…"; color: var(--muted); }
.table td.nowrap { white-space: nowrap; }
.preview-frame { width: 100%; min-height: 600px; height: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.phone-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }

.kv { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px 14px; align-items: center; }
.kv .k { color: var(--muted); font-size: 13px; }
.kv .v { font-family: var(--mono); font-size: 12.5px; word-break: break-all; background: #f7f7f4; padding: 6px 10px; border-radius: 6px; }
pre.code { background: #1c2428; color: #d7e0e3; padding: 14px 16px; border-radius: 8px; overflow-x: auto; font: 12.5px/1.6 var(--mono); margin: 0; }

.sim-result { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
.sim-slot { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sim-slot.yes { background: #eef8f2; border-color: #c8e7d5; }
.sim-slot.no { background: #f7f6f2; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 16px; color: var(--muted); font-size: 13px; }

/* ---------- 版本信息 / 分开关 ---------- */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.warn-text { color: var(--warn); }
.app-card .prod { font-size: 12px; color: var(--accent); font-weight: 500; margin-bottom: 2px; }
a.stat { text-decoration: none; border-radius: 6px; padding: 4px 6px; margin: -4px -6px; }
a.stat:hover { background: #f4f3ef; text-decoration: none; }
.stat i { display: block; font-style: normal; font-size: 11.5px; }
.stat i.warn { color: var(--warn); }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.summary-grid > .panel { margin-top: 0; }
a.panel.summary { display: block; padding: 18px; color: inherit; text-decoration: none; position: relative; }
a.panel.summary:hover { border-color: var(--accent-2); }
.summary h3 { margin: 0; font-size: 15px; }
.summary .big { font-size: 30px; font-weight: 600; line-height: 1.2; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.summary .desc { font-size: 13px; color: var(--muted); }
.summary .go { position: absolute; right: 18px; top: 18px; font-size: 13px; color: var(--accent); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { min-width: 120px; }
.filters select.input { min-width: 140px; }
.input.sm, select.input.sm { height: 28px; font-size: 12.5px; padding: 0 6px; border-radius: 6px; }
.bulk-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 18px; background: var(--accent-soft); color: #1c4c48; font-size: 13px; border-top: 1px solid var(--line-2); }
.table td.ops { text-align: right; white-space: nowrap; }
.table td.ops .btn.sm { padding: 0 7px; }
.table td.detail { font-size: 12.5px; color: var(--ink-2); line-height: 1.7; min-width: 220px; }
.table td.detail s { color: var(--muted); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fbfbf9; }
.flag-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.flag-grid .check { align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; line-height: 1.45; }
.flag-grid .check input { margin-top: 2px; }
.show-cell { white-space: nowrap; }
.show-cell > label, .show-cell > span { display: inline-flex; align-items: center; gap: 5px; margin-right: 10px; font-size: 12.5px; color: var(--ink-2); vertical-align: middle; }
.show-cell .reserved { color: var(--muted); }
.yn { display: inline-block; min-width: 22px; text-align: center; border-radius: 4px; font-size: 11.5px; padding: 0 4px; }
.yn.yes { background: #dff2e8; color: #17714a; }
.yn.no { background: #eeede8; color: var(--muted); }
code.md5 { cursor: help; font-size: 11.5px; }
ol.steps { margin: 14px 0 0; padding-left: 20px; color: var(--ink-2); font-size: 13px; line-height: 1.8; }
.debug-head { padding: 9px 12px; border-radius: 8px; font-weight: 500; }
.debug-head.hit { background: #dff2e8; color: #17714a; }
.debug-head.miss { background: var(--warn-soft); color: #8a5a12; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid.top { align-items: start; }
.table td.remark { min-width: 110px; max-width: 220px; }
.table.zones td.key { min-width: 120px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.two-col > .panel { margin-top: 0; }

/* ---------- 弹窗与提示 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(20, 26, 28, .38); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border-radius: 12px; width: min(520px, 100%); max-height: calc(100vh - 40px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal.wide { width: min(860px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 10px; }
#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.18); animation: toast-in .18s ease-out; }
.toast.err { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(1200px 500px at 20% -10%, #dfe9e6 0%, transparent 60%), var(--bg); }
.login { width: min(380px, 100%); padding: 30px 28px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login .sub { color: var(--muted); margin-bottom: 22px; font-size: 13px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .side .nav-group, .side a.nav.sub { display: none; }
  .brand { padding: 4px 8px; }
  .side-foot { margin-top: 0; margin-left: auto; }
  .main { padding: 20px 16px 50px; }
  .big-switches, .editor, .summary-grid, .two-col, .flag-grid, .form-grid.two { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .kv { grid-template-columns: 1fr; }
}
