/* ===== 设计令牌 ===== */
:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f8fafc;
  --text: #1a202c; --muted: #64748b; --border: #e2e8f0; --border-strong: #cbd5e1;
  --primary: #2563eb; --primary-soft: #dbeafe; --primary-text: #1d4ed8;
  --ok: #16a34a; --ok-soft: #dcfce7; --warn: #d97706; --warn-soft: #fef3c7;
  --danger: #dc2626; --danger-soft: #fee2e2; --info: #0891b2;
  --radius: 10px; --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .15);
  --sidebar-w: 204px;
  /* 内容区最宽:列表页随窗口放宽(fluid),表单类页面保持 1600 */
  --page-max: 1600px; --page-max-fluid: 2400px; --topbar-h: 3.4rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #171b21; --surface-2: #1c2129;
    --text: #e6e9ef; --muted: #8b95a5; --border: #2a313b; --border-strong: #3a4350;
    --primary: #3b82f6; --primary-soft: #1e3a8a; --primary-text: #93c5fd;
    --ok: #22c55e; --ok-soft: #14532d; --warn: #f59e0b; --warn-soft: #78350f;
    --danger: #ef4444; --danger-soft: #7f1d1d;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 10px 30px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --surface: #171b21; --surface-2: #1c2129;
  --text: #e6e9ef; --muted: #8b95a5; --border: #2a313b; --border-strong: #3a4350;
  --primary: #3b82f6; --primary-soft: #1e3a8a; --primary-text: #93c5fd;
  --ok: #22c55e; --ok-soft: #14532d; --warn: #f59e0b; --warn-soft: #78350f;
  --danger: #ef4444; --danger-soft: #7f1d1d;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 10px 30px rgba(0,0,0,.6);
}

/* ===== 基础 ===== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
/* 排版基准:rem 全部跟着 html 走。手机上手指要点,按钮和输入框留大一点(见文件末尾) */
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13.5px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 1.15rem; } h2 { font-size: .95rem; } h3 { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
a { color: var(--primary-text); text-decoration: none; }
p { margin: 0; }
.mono { font-family: var(--mono); font-size: .82rem; }
.nowrap { white-space: nowrap; } /* IP、端口之类不能从中间折行 */
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.subtitle { color: var(--muted); font-size: .82rem; margin-top: .1rem; }
.logo { display: block; width: 30px; height: 25px; object-fit: contain; }
.login-brand .logo { width: 42px; height: 34px; }
.support-btn { white-space: nowrap; color: var(--muted); }
.support-btn:hover { color: var(--primary-text); }
/* 登录页右上角:帮助说明 + 建议 / 支持 */
.login-links { position: fixed; top: .9rem; right: 1rem; z-index: 3; display: flex; gap: .5rem; }
.support-float { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--muted); text-decoration: none; border: 1px solid var(--border); border-radius: 999px; padding: .35rem .85rem; background: var(--surface); }
.support-float:hover { color: var(--primary-text); border-color: var(--primary); }
.support-btn svg, .support-float svg { flex: none; }
/* 很窄的屏幕上"帮助说明"只留图标、顶栏间距收紧,给页面标题让地方;标题再放不下就省略号收尾,不压到按钮上 */
@media (max-width: 480px) {
  #btn-help .help-label, #topbar-right .tb-label { display: none; }
  #btn-help { padding-left: .45rem; padding-right: .45rem; }
  .main .topbar { gap: .5rem; } /* 比后面的 .topbar 基础规则更具体:这条写在前面也要生效 */
}
.topbar-title h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== 登录 ===== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 22rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 1.6rem; display: flex; flex-direction: column; gap: .9rem; }
.login-brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; }
.login-card h1 { font-size: 1rem; color: var(--muted); font-weight: 500; }

/* ===== 布局 ===== */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: .8rem .6rem; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: .5rem; padding: .2rem .45rem .7rem; font-weight: 700; font-size: 1rem; }
.brand-name { flex: 1; white-space: nowrap; }
#role-badge { max-width: 7.5rem; overflow: hidden; text-overflow: ellipsis; }
#nav { display: flex; flex-direction: column; gap: .1rem; flex: 1; min-height: 0; overflow-y: auto; }
#nav a { display: flex; align-items: center; gap: .55rem; padding: .42rem .6rem; border-radius: var(--radius-sm); color: var(--text); font-weight: 500; }
#nav a .ic { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex: none; }
#nav a .ic svg { width: 16px; height: 16px; }
#nav a:hover { background: var(--surface-2); }
#nav a.active { background: var(--primary-soft); color: var(--primary-text); }
#nav a.active .ic { color: var(--primary-text); }
.sidebar-foot { display: flex; gap: .4rem; align-items: center; padding-top: .6rem; border-top: 1px solid var(--border); }
.sidebar-foot select { width: auto; padding: .3rem .4rem; }
.sidebar-version { color: var(--muted); font-size: .72rem; padding: .5rem .5rem 0; font-family: var(--mono); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .6rem 1.2rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar-title { flex: 1; min-width: 0; }
#btn-menu { display: none; }
main#page { padding: .95rem 1.2rem 2rem; max-width: var(--page-max); width: 100%; margin: 0 auto; }
main#page[data-layout="fluid"] { max-width: var(--page-max-fluid); }
.backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 19; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .backdrop { display: block; }
  #btn-menu { display: inline-flex; }
  main#page { padding: .8rem; }
  .topbar { padding: .55rem .8rem; }
}

/* ===== 卡片与网格 ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem .95rem; box-shadow: var(--shadow); margin-bottom: .8rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .55rem; flex-wrap: wrap; }
.card-head h2 { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 30rem), 1fr)); gap: .8rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
@media (max-width: 1000px) { .grid-3 { grid-template-columns: 1fr; } }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin-bottom: .8rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem; box-shadow: var(--shadow); }
.stat .k { color: var(--muted); font-size: .78rem; display: flex; align-items: center; gap: .35rem; }
.stat .v { font-size: 1.2rem; font-weight: 650; margin-top: .1rem; letter-spacing: -.01em; }
.stat .s { color: var(--muted); font-size: .75rem; margin-top: .1rem; }
.toolbar { display: flex; align-items: center; gap: .5rem; margin-bottom: .65rem; flex-wrap: wrap; }
.toolbar .grow { flex: 1; min-width: 1rem; }
.toolbar input[type=search] { max-width: 16rem; }
/* 工具栏里的分段按钮(线路页的协议筛选、用户页的状态筛选)放不下时自己折行,不把整页撑出横向滚动 */
.toolbar .seg { flex-wrap: wrap; max-width: 100%; }

/* ===== 表格 ===== */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; min-width: 640px; }
/* 中文名称每个字之间都能断行,自动列宽一挤就成了一字一行:名称列至少留约 6 个字,放不下整表横向滚动 */
table.grid td.primary-cell { min-width: 6.5em; }
.grid th, .grid td { padding: .45rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.grid th { background: var(--surface-2); font-weight: 600; font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; position: sticky; top: 0; z-index: 2; }
/* 英文表头是大写加字距,多词的("DURATION (DAYS)" 之类)很宽:英文界面里允许在空格处折行,窄窗口下表格不必横向滚动。中文表头不折(一字一行很难看) */
:lang(en) .grid:not(.ext-grid) th { white-space: normal; }
.grid tbody tr:hover { background: var(--surface-2); }
.grid tbody tr:last-child td { border-bottom: none; }
.grid tbody tr.dragging { opacity: .4; }
.grid td.handle { cursor: grab; color: var(--muted); user-select: none; width: 1.5rem; }
.grid td.actions { white-space: nowrap; text-align: right; width: 1%; }
.grid td.actions .btn { margin-left: .25rem; }
.grid .primary-cell { font-weight: 500; }
.grid .sub-cell { color: var(--muted); font-size: .76rem; margin-top: .1rem; }
.grid td.num { font-family: var(--mono); font-size: .82rem; }
/* 服务器等信息密集的表:不设最小宽度,长文本用省略号,不让整表出横向滚动条 */
table.grid.tight { min-width: 0; table-layout: fixed; }
.grid.tight th, .grid.tight td { padding: .38rem .55rem; }
.grid.tight td { word-break: break-word; }
.grid .ellip { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid.tight .btn.sm { padding: .22rem .5rem; }
.btn.xs{padding:.05rem .3rem;font-size:.85rem;line-height:1.2;color:var(--muted)}
.btn.xs:hover{color:var(--text)}
/* 表格下方的分页条:上一页 · 页码 · 下一页,右侧选每页条数 */
.pager { display: flex; align-items: center; gap: .6rem; padding: .6rem .2rem 0; }
/* 真正为空时的引导(与"搜索无结果"分开):一句话说明 + 一个动作 */
.empty-guide { text-align: center; padding: 1.8rem 1rem; }
.empty-guide p { color: var(--muted); margin: 0 auto 1rem; max-width: 34rem; line-height: 1.6; }
/* 配置完成后的 Star 卡片:一行,轻量 */
.star-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.star-card .hint { margin: .15rem 0 0; }
.pager select { padding: .2rem .35rem; font: inherit; font-size: .8rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
/* 服务器表:窄列给定宽度,余下宽度留给名称/地址/状态三列 */
.grid.nodes .c-reach { width: 10.5rem; }
.grid.nodes .c-sync, .grid.nodes .c-core { width: 7.5rem; }
.grid.nodes .c-online { width: 3.5rem; }
.grid.nodes .c-act { width: 11.5rem; }
/* 英文按钮更宽、副机多一颗"重置证书"时一行放不下:折到第二行,不顶出表格 */
.grid.nodes td.actions { white-space: normal; }
.grid.nodes td.actions .btn { margin-block: .1rem; }
/* 窗口窄时先隐藏在线、同步两列(.c-p3),名称 / 地址 / 状态三列不会被挤成一字一行,也就不用整表横向滚动 */
table.grid.nodes { min-width: 0; }
/* ===== 窄屏表格:列表的每一行排成一张卡片 =====
   名称当标题(勾选框在它左边),其余每格一行:左边列名(app.js 按表头补到 data-label)、右边内容;没有列名的(操作按钮)靠右。
   拖动排序的把手在手机上用不了,藏掉;键值表、接口文档、连接列表不在此列 */
@media (max-width: 700px) {
  .table-wrap:has(> table.grid:not(.kv):not(.api-doc):not(.conns)) { overflow: visible; background: transparent; border: none; box-shadow: none; }
  table.grid:not(.kv):not(.api-doc):not(.conns) { display: block; min-width: 0; }
  table.grid:not(.kv):not(.api-doc):not(.conns) thead { display: none; }
  table.grid:not(.kv):not(.api-doc):not(.conns) tbody { display: block; }
  table.grid:not(.kv):not(.api-doc):not(.conns) tr { display: flex; flex-wrap: wrap; align-items: center; margin-bottom: .65rem; padding: .3rem .85rem .45rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
  table.grid:not(.kv):not(.api-doc):not(.conns) tbody tr:hover { background: var(--surface); }
  table.grid:not(.kv):not(.api-doc):not(.conns) tr.selected { border-color: var(--primary); }
  table.grid:not(.kv):not(.api-doc):not(.conns) td { display: block; flex: 1 1 100%; min-width: 0; padding: .42rem 0; border: none; border-top: 1px dashed var(--border); text-align: right; word-break: break-word; }
  table.grid:not(.kv):not(.api-doc):not(.conns) td::after { content: ''; display: table; clear: both; }
  table.grid:not(.kv):not(.api-doc):not(.conns) td[data-label]::before { content: attr(data-label); float: left; font-family: var(--font); margin-right: .8rem; font-size: .76rem; line-height: 1.7; color: var(--muted); text-align: left; }
  table.grid:not(.kv):not(.api-doc):not(.conns) td.handle { display: none; }
  table.grid:not(.kv):not(.api-doc):not(.conns) td:has(> input[type=checkbox]:only-child) { order: -2; flex: 0 0 auto; padding-right: .6rem; border-top: none; }
  table.grid:not(.kv):not(.api-doc):not(.conns) td:has(> input[type=checkbox]:only-child)::before { display: none; }
  table.grid:not(.kv):not(.api-doc):not(.conns) td.primary-cell { order: -1; flex: 1 1 calc(100% - 2.6rem); padding: .5rem 0; border-top: none; text-align: left; font-size: .95rem; font-weight: 600; }
  table.grid:not(.kv):not(.api-doc):not(.conns) td.primary-cell::before { display: none; }
  table.grid:not(.kv):not(.api-doc):not(.conns) td[data-span] { text-align: center; border-top: none; }
  table.grid.tight td { word-break: break-word; }
  table.grid .ellip { display: inline-block; max-width: 100%; vertical-align: bottom; }
  .subtitle { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  /* 工具栏:占位的空白不再至少 12rem(会把按钮一个个挤到新行);开头的说明文字(修订号、提示)独占一行,按钮在下面靠右排在一起 */
  .toolbar .grow { min-width: 0; }
  .toolbar > .muted.small:first-child { flex-basis: 100%; }
}

/* ===== 控件 ===== */
input, select, textarea { width: 100%; padding: .36rem .55rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type=checkbox] { width: auto; accent-color: var(--primary); }
textarea { min-height: 5rem; font-family: var(--mono); font-size: .82rem; }
textarea.code-area { min-height: 11rem; white-space: pre; overflow: auto; line-height: 1.45; tab-size: 2; }
.up-plans { margin-bottom: .6rem; padding-bottom: .6rem; border-bottom: 1px solid var(--border); }
.up-plans-title { margin-bottom: .35rem; font-size: .85rem; }
select.sm, input.sm { padding: .24rem .45rem; font-size: .82rem; }
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .38rem .75rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-weight: 500; line-height: 1.2; transition: filter .15s, background .15s; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); background: var(--primary); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: .24rem .5rem; font-size: .8rem; }
.btn.icon { padding: .28rem .42rem; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: default; pointer-events: none; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: none; background: transparent; padding: .26rem .6rem; font: inherit; font-size: .8rem; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--primary); color: #fff; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 20px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(16px); }
.row { display: flex; gap: .5rem; align-items: center; }
.row input { flex: 1; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .6rem .85rem; }
.form-grid > .full, .form-grid label.full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .2rem; }
.field .label { font-size: .8rem; color: var(--muted); font-weight: 500; }
.field .help { font-size: .74rem; color: var(--muted); line-height: 1.35; }
.field .count { align-self: flex-end; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.field .count.over { color: var(--danger); font-weight: 600; }
.field.check { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; }
.field.check input { width: auto; }
.field.check .help { flex-basis: 100%; }
/* 说明很长的勾选项:勾选框和文字同一行,文字自己换行(不整段掉到勾选框下面) */
.field.check.check-wrap { flex-wrap: nowrap; align-items: flex-start; }
.field.check.check-wrap > input { margin-top: .2rem; flex: none; }
.field.check.check-wrap > span { flex: 1; min-width: 0; }
/* 落地页 logo(设置 → 订阅页、代理面板 我的账号):预览 + 上传 / 恢复默认,上传即生效,和上面的「保存」分开 */
.logo-field { display: flex; flex-direction: column; gap: .35rem; margin-top: .85rem; padding-top: .75rem; border-top: 1px dashed var(--border); }
.logo-field .label { font-size: .8rem; color: var(--muted); font-weight: 500; }
.logo-field .help { font-size: .74rem; color: var(--muted); line-height: 1.35; }
.logo-row { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem .85rem; }
.logo-preview { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; min-height: 54px; }
/* 按落地页的浅色、深色两种背景各画一块(颜色与 logo 尺寸照 sub/page.html),不跟面板自己的主题走 */
.logo-preview .lp { margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; min-width: 6.5rem; min-height: 54px; padding: .45rem .7rem .35rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.logo-preview .lp[hidden] { display: none; }
.logo-preview .lp.light { background: #f4f6f9; color: #64748b; }
.logo-preview .lp.dark { background: #0f1216; color: #8b95a5; border-color: #2a313b; }
.logo-preview .lp img { display: block; height: 28px; width: auto; max-width: 160px; object-fit: contain; }
.logo-preview .lp img.custom { height: 32px; padding: 2px 4px; border-radius: 6px; max-width: 168px; box-sizing: border-box; }
.logo-preview .lp.dark img.custom { background: #f4f6f9; }
.logo-preview .lp figcaption { font-size: .68rem; line-height: 1; }
details.adv summary { cursor: pointer; color: var(--muted); font-size: .82rem; margin-bottom: .4rem; }
.hint { color: var(--muted); font-size: .8rem; margin-top: .5rem; }
.err { color: var(--danger); font-size: .85rem; min-height: 1.2rem; }
.confirm-text { font-size: .95rem; padding: .25rem 0 .5rem; }
.check-list { max-height: min(40vh, 18rem); overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .4rem .6rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .25rem .75rem; background: var(--surface-2); }
.check-list label { display: flex; gap: .4rem; align-items: center; font-size: .82rem; }
/* 线路的分流规则:一行 = 序号 / 匹配方式 / 匹配内容 / 出口 / 排序删除;最后一行是"其余流量 → 线路的上游"。
   按编辑框自己的宽度排(容器查询),不看整个窗口 */
.rr-box { container-type: inline-size; }
#f-rr { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .55rem .75rem .65rem; margin-top: .55rem; background: var(--surface-2); }
#f-rr .hint { margin: .5rem 0 0; }
.rr-row { display: grid; grid-template-columns: 1.4rem 10rem minmax(0, 1fr) 9.5rem 5.4rem; gap: .5rem; align-items: start; padding: .5rem 0; border-top: 1px solid var(--border); }
.rr-head { padding: 0 0 .35rem; border-top: none; font-size: .74rem; font-weight: 500; color: var(--muted); }
.rr-no { display: flex; align-items: center; justify-content: center; min-height: 2.15rem; font-size: .78rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.rr-row textarea { min-height: 2.15rem; resize: vertical; line-height: 1.35; }
.rr-row textarea.bad { border-color: var(--danger); }
.rr-err { grid-column: 3 / -1; margin-top: -.15rem; font-size: .76rem; color: var(--danger); }
/* 查应用域名得来的规则:匹配方式那格显示应用名,下面小字是匹配方式 */
.rr-type-cell { min-width: 0; }
.rr-name { display: flex; flex-direction: column; justify-content: center; min-height: 2.15rem; padding: .15rem .65rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); line-height: 1.25; }
.rr-name b { font-weight: 600; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-name small { font-size: .7rem; color: var(--muted); }
/* "按规则分流"那一行右边的查应用域名:编辑框够宽时和勾选框同一行,窄了折到下面占满一行 */
.rr-top { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .5rem 1rem; }
.rr-top > .field.check { flex: 1 1 15rem; min-width: 0; }
.rr-lookup { flex: 1 1 18rem; display: flex; gap: .4rem; align-items: center; min-width: 0; }
.rr-lookup[hidden] { display: none; }
.rr-lookup input { flex: 1 1 auto; min-width: 0; }
.rr-lookup .btn { flex: none; }
.rr-lookup-msg { margin: .45rem 0 0; font-size: .78rem; color: var(--muted); line-height: 1.55; }
.rr-lookup-msg button.link { border: 0; background: none; padding: 0 .15rem; font: inherit; color: var(--primary-text); text-decoration: underline; cursor: pointer; }
.rr-ops { display: flex; justify-content: flex-end; gap: .1rem; }
.rr-ops .btn { padding: .32rem .48rem; }
.rr-ops .btn:disabled { opacity: .3; }
.rr-rest { align-items: center; }
.rr-rest-label { font-size: .84rem; font-weight: 500; }
.rr-rest-to { padding: .42rem .65rem; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); font-size: .84rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-empty { padding: .7rem 0; border-top: 1px solid var(--border); font-size: .82rem; color: var(--muted); text-align: center; }
.rr-add { width: 100%; margin-top: .35rem; padding: .45rem; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: transparent; color: var(--primary); font: inherit; font-size: .84rem; cursor: pointer; transition: background .15s, border-color .15s; }
.rr-add:hover { border-color: var(--primary); background: var(--primary-soft); }
@container (max-width: 640px) { /* 窄:第一行 序号 / 匹配方式 / 排序删除,下面匹配内容、问题、出口各占一行 */
  .rr-head { display: none; }
  .rr-row { grid-template-columns: 1.2rem minmax(0, 1fr) auto; grid-template-areas: "no type ops" ". val val" ". err err" ". to to"; }
  .rr-row > .rr-no { grid-area: no; }
  .rr-row > .rr-type, .rr-row > .rr-type-cell { grid-area: type; }
  .rr-row > .rr-ops { grid-area: ops; }
  .rr-row > .rr-values { grid-area: val; }
  .rr-row > .rr-to { grid-area: to; }
  .rr-row > .rr-err { grid-area: err; margin-top: 0; }
  .rr-rest { grid-template-columns: 1.2rem auto minmax(0, 1fr); grid-template-areas: none; }
  .rr-rest > .rr-no { grid-area: auto; }
  .rr-rest .muted { display: none; }
}

/* ===== 徽章与状态 ===== */
.badge { display: inline-block; font-size: .72rem; padding: .12rem .5rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; vertical-align: middle; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.primary { background: var(--primary-soft); color: var(--primary-text); border-color: transparent; }
.badge.node { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); margin-right: .35rem; vertical-align: middle; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: .3rem; min-width: 90px; }
.progress .bar { height: 100%; background: var(--primary); transition: width .3s; }
.progress.warn .bar { background: var(--warn); }
.progress.danger .bar { background: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; max-width: 100%; min-width: 0; } /* 不比所在的格子宽:里面很长的名字截断(见 .badge),不把整行撑出屏幕 */
.chip { font-size: .76rem; padding: .15rem .5rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.empty { color: var(--muted); text-align: center; padding: 1.5rem; font-size: .85rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; font-size: .85rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; } /* 地址之类的长串在窄屏上折行,不把页面撑出横向滚动 */

/* 菜单 */
details.menu { position: relative; display: inline-block; }
details.menu summary { list-style: none; cursor: pointer; }
details.menu summary::-webkit-details-marker { display: none; }
details.menu .menu-list { position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); min-width: 10rem; z-index: 30; padding: .3rem; display: flex; flex-direction: column; }
details.menu .menu-list.fixed { position: fixed; z-index: 60; }
details.menu .menu-list button { text-align: left; border: none; background: transparent; padding: .45rem .7rem; border-radius: 4px; font: inherit; cursor: pointer; color: var(--text); }
details.menu .menu-list button:hover { background: var(--surface-2); }
details.menu .menu-list button.danger { color: var(--danger); }
details.menu .menu-list hr { border: none; border-top: 1px solid var(--border); margin: .25rem 0; }

/* ===== 抽屉 ===== */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(var(--drawer-w, 32rem), 100vw); background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 40; transform: translateX(100%); transition: transform .2s; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer.over { z-index: 60; }
.check-list.one-col { grid-template-columns: 1fr; }
tr.ext-hidden .primary-cell > a { text-decoration: line-through; opacity: .55; }
.node-list { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.node-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-width: 0; }
.node-row label { min-width: 0; }
.node-fam { width: auto; flex: none; padding: .1rem .3rem; font-size: .76rem; }
.field > select.node-fam { max-width: 12rem; }
.hint.warn { color: var(--warn, #b45309); }
.hint.ok { color: var(--ok); }
.hint.bad { color: var(--danger); }
button.chip { cursor: pointer; color: inherit; }
button.chip:hover { border-color: var(--primary); }
.ext-name { display: flex; align-items: center; gap: .4rem; }
.ext-name > span { min-width: 5em; }
.ext-url { max-width: 13rem; word-break: break-all; }
.ext-table > thead > tr > th, .ext-table > tbody > tr > td { padding-left: .55rem; padding-right: .55rem; }
@media (max-width: 720px) { .ext-url { max-width: none; } }
.cert-opts { display: flex; flex-direction: column; gap: .5rem; }
.cert-opt { display: flex; gap: .55rem; width: 100%; padding: .5rem .65rem; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: inherit; font: inherit; cursor: pointer; transition: border-color .15s, background .15s; }
.cert-opt:hover:not(:disabled) { border-color: var(--primary); }
.cert-opt:disabled { opacity: .6; cursor: default; }
.cert-opt.current { border-color: var(--primary); background: var(--primary-soft); }
.cert-opt-check { flex: 0 0 1rem; color: var(--primary); font-weight: 700; }
.cert-opt-main { flex: 1; min-width: 0; word-break: break-word; }
.cert-opt-sub { display: block; margin-top: .2rem; color: var(--muted); font-size: .8rem; }
.cert-opt-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
details.cert-log > summary { display: flex; align-items: center; gap: .5rem; cursor: pointer; list-style: none; }
details.cert-log > summary::-webkit-details-marker { display: none; }
details.cert-log > summary::after { content: "▾"; margin-left: auto; color: var(--muted); font-size: .8rem; }
details.cert-log[open] > summary { margin-bottom: .5rem; }
details.cert-log[open] > summary::after { content: "▴"; }
.cert-uses { display: flex; flex-direction: column; }
.cert-use { display: flex; align-items: center; gap: .6rem; padding: .42rem 0; border-bottom: 1px solid var(--border); }
.cert-use:last-child { border-bottom: none; }
.cert-use-label { flex: 0 0 5rem; color: var(--muted); font-size: .85rem; }
.cert-use-cur { flex: 1; min-width: 0; word-break: break-word; }
.cert-pick-btn { width: 100%; justify-content: space-between; text-align: left; }
.drawer-head { display: flex; align-items: center; gap: .6rem; padding: .65rem .95rem; border-bottom: 1px solid var(--border); }
.drawer-head h2 { flex: 1; font-size: 1rem; }
.drawer-body { padding: .8rem .95rem 1.6rem; overflow-y: auto; flex: 1; }
.drawer-body section { margin-bottom: .95rem; }
.drawer-body h3 { margin-bottom: .4rem; }
.sub-box { display: flex; align-items: center; gap: .5rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .4rem .6rem; margin-bottom: .4rem; }
.sub-box code { flex: 1; font-family: var(--mono); font-size: .76rem; word-break: break-all; }
.qr { display: block; width: 150px; height: 150px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: #fff; margin: .5rem 0; }
.ip-list { display: flex; flex-direction: column; gap: .3rem; }
.ip-list .ip { display: flex; justify-content: space-between; align-items: center; font-family: var(--mono); font-size: .82rem; background: var(--surface-2); padding: .35rem .6rem; border-radius: var(--radius-sm); }

/* ===== 弹窗 / toast ===== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 1rem; z-index: 50; }
.modal-box { width: 100%; max-width: 36rem; max-height: 92vh; max-height: min(92vh, 64rem); max-height: min(92dvh, 64rem); display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0; box-shadow: var(--shadow-lg); }
.modal-box.wide { max-width: min(56rem, 96vw); }
.modal-box.xl { max-width: min(76rem, 96vw); }
.modal-box > h2 { margin: 0; padding: 1rem 1.1rem .7rem; font-size: 1rem; flex: none; }
#modal-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 0 1.1rem .6rem; }
#modal-body > h3:first-child { margin-top: 0; }
#modal-err { flex: none; padding: 0 1.1rem; min-height: 0; }
#modal-err:not(:empty) { padding-top: .3rem; padding-bottom: .2rem; }
.modal-box h3 { margin: .9rem 0 .35rem; }
.modal-box h2 + h3 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin: 0; padding: .65rem 1.1rem; border-top: 1px solid var(--border); flex: none; }
.toast { position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .6rem 1.1rem; border-radius: 8px; z-index: 100; font-size: .9rem; box-shadow: var(--shadow-lg); }
.toast.ok { background: var(--ok); color: #fff; }
.toast.err { background: var(--danger); color: #fff; }
.toast.warn { background: var(--warn); color: #fff; }

/* ===== 图表 ===== */
.chart-wrap { position: relative; }
.chart { width: 100%; height: 190px; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .ylab, .chart .xlab { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
.chart .area.up { fill: var(--primary); opacity: .18; }
.chart .area.down { fill: var(--ok); opacity: .18; }
.chart .line.up { fill: none; stroke: var(--primary); stroke-width: 1.5; }
.chart .line.down { fill: none; stroke: var(--ok); stroke-width: 1.5; }
.chart .cursor { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart-tip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); padding: .4rem .6rem; border-radius: 6px; font-size: .76rem; font-family: var(--mono); white-space: nowrap; }
.chart-tip .tt { opacity: .7; margin-bottom: .15rem; }
.chart-legend { display: flex; gap: 1rem; font-size: .78rem; color: var(--muted); margin-top: .35rem; }
.lg::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }
.lg.up::before { background: var(--primary); } .lg.down::before { background: var(--ok); }

/* 日志 */
pre.log { background: #0b0e13; color: #cbd5e1; font-family: var(--mono); font-size: .76rem; padding: .65rem .75rem; border-radius: var(--radius-sm); max-height: 320px; overflow: auto; margin: 0; white-space: pre-wrap; word-break: break-all; line-height: 1.45; }
pre.log .warn { color: #fbbf24; } pre.log .error { color: #f87171; } pre.log .debug { color: #64748b; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: .7rem; }
.tabs button { border: none; background: transparent; padding: .38rem .75rem; font: inherit; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--primary-text); border-color: var(--primary); font-weight: 500; }
.ua { color: var(--muted); font-size: .74rem; max-width: 26rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.grid tbody tr.selected { background: var(--primary-soft); }
.batch-bar { background: var(--primary-soft); border-radius: var(--radius-sm); padding: .45rem .7rem; position: sticky; top: calc(var(--topbar-h) + .3rem); z-index: 4; box-shadow: var(--shadow); }

/* 运维任务卡片 */
.task-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .6rem; }
.task { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .55rem .7rem; background: var(--surface-2); display: flex; flex-direction: column; gap: .4rem; }
.task-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.task .row { margin-top: auto; align-items: center; gap: .4rem; }

/* 快速开始 */
.quickstart { border-color: var(--primary); }
.qs-list { margin: .6rem 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .35rem .9rem; }
.qs-list li { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; }
.qs-list li.done a { color: var(--muted); text-decoration: line-through; }
.qs-mark { width: 1.3rem; height: 1.3rem; border-radius: 50%; display: inline-grid; place-items: center; font-size: .75rem; background: var(--warn-soft); color: var(--warn); font-weight: 700; }
.qs-list li.done .qs-mark { background: var(--ok-soft); color: var(--ok); }
/* 可排序表头 */
.grid th.sortable { cursor: pointer; user-select: none; }
.grid th.sortable:hover { color: var(--text); }
.grid th.sorted { color: var(--primary-text); }

/* 换机向导 */
.mig-steps { margin: .5rem 0 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: .6rem; }
.mig-steps li { border-left: 3px solid var(--primary-soft); padding-left: .8rem; }
.mig-steps .sub-box { margin-top: .4rem; }

a.stat { color: inherit; text-decoration: none; display: block; }
a.stat:hover { border-color: var(--primary); }
.stat.bad { border-color: var(--danger); }
.stat.bad .s { color: var(--danger); }

/* 流量排行 */
.top-list { display: flex; flex-direction: column; gap: .35rem; margin-top: .5rem; }
.top-row { display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) minmax(3rem, 30%) auto; gap: .6rem; align-items: center; font-size: .85rem; }
.top-rank { color: var(--muted); font-family: var(--mono); text-align: right; }
.top-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.top-bar div { height: 100%; background: var(--primary); border-radius: 4px; }
.top-val { white-space: nowrap; }
@media (max-width: 700px) { .top-row { grid-template-columns: 1.6rem minmax(0, 1fr) auto; } .top-bar { display: none; } }

/* 顶部常驻警示(默认密码等) */
.alert-bar { display: flex; align-items: center; gap: .8rem; margin: .7rem 1.2rem 0; padding: .4rem .75rem; border: 1px solid var(--danger); background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm); font-weight: 500; }
.alert-bar.warn{background:var(--warn-bg,#fff7ed);color:var(--warn-fg,#9a3412);border-color:var(--warn-bd,#fdba74)}
[data-theme="dark"] .alert-bar.warn{background:#3a2410;color:#fdba74;border-color:#7c3f10}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .alert-bar.warn { background: #3a2410; color: #fdba74; border-color: #7c3f10; } }
.alert-bar{display:flex;align-items:center;justify-content:space-between;gap:.8rem;flex-wrap:wrap}
.alert-bar span { flex: 1; }
@media (max-width: 900px) { .alert-bar { margin: .6rem .8rem 0; } }

/* 柱状流量图 */
.chart-summary { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; font-size: .85rem; margin: 0 0 .4rem; }
.chart-summary .chart-legend { margin-left: auto; }
svg.chart.bars { width: 100%; height: auto; display: block; }
svg.chart.bars .hit { fill: transparent; }
svg.chart.bars .seg.down { fill: var(--ok); opacity: .85; }
svg.chart.bars .seg.up { fill: var(--primary); opacity: .85; }
svg.chart.bars g.bar.hot .seg { opacity: 1; }
svg.chart.bars g.bar.hot .hit { fill: var(--surface-2); }
svg.chart.bars .grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
svg.chart.bars .ylab, svg.chart.bars .xlab { fill: var(--muted); font-size: 11px; font-family: var(--mono); }

/* 管理员页:2FA 与外部 API */
.totp-setup { display: flex; gap: 1.2rem; align-items: flex-start; flex-wrap: wrap; margin-top: .6rem; }
.totp-setup img.qr { width: 150px; height: 150px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; padding: 6px; }
.totp-side { flex: 1; min-width: 260px; }
.totp-side .label { font-size: .8rem; color: var(--muted); margin-bottom: .3rem; }
.sub-title { font-size: .9rem; margin: 1rem 0 .4rem; }
pre.code { white-space: pre-wrap; word-break: break-all; }
table.api-doc td.mono { font-family: var(--mono); font-size: .78rem; white-space: nowrap; }

/* 副机只读:由主机下发的页面隐藏增删改入口 */
.alert-bar.info { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); margin: 0 0 .9rem; }
.node-readonly [data-act$=".add"], .node-readonly [data-act$=".edit"], .node-readonly [data-act$=".del"], .node-readonly [data-act$=".delete"],
.node-readonly [data-act$=".bulk"], .node-readonly [data-act$=".batch"], .node-readonly [data-act$=".preset"], .node-readonly [data-act$=".plan"],
.node-readonly [data-act$=".reset"], .node-readonly [data-act$=".extend"], .node-readonly [data-act$=".renew"], .node-readonly [data-act$=".import"],
.node-readonly [data-act$=".toggle"], .node-readonly [data-act$=".clone"], .node-readonly [data-act$=".sort"], .node-readonly [data-act$=".refresh"],
.node-readonly .batch-bar, .node-readonly details.menu, .node-readonly input[type=checkbox].sel { display: none !important; }

/* 最近入站连接:一行一条,定宽列 + 省略号,不横向滚动(详见文件末尾「概况」) */
table.grid.conns { min-width: 0; table-layout: fixed; }
table.grid.conns th, table.grid.conns td { white-space: nowrap; padding: .38rem .7rem; font-size: .82rem; overflow: hidden; text-overflow: ellipsis; }

/* 在线设备:IP 右侧列出它正在使用的线路 */
.ip-list .ip { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.ip-lines { display: flex; gap: .25rem; flex-wrap: wrap; justify-content: flex-end; }



/* 代理详情:一个用户两行(概要 + 订阅地址),不用表格也就没有横向滚动条 */
.rs-users { display: flex; flex-direction: column; gap: .35rem; }
.rs-u { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .35rem .5rem; }
.rs-u-head { display: flex; align-items: baseline; gap: .5rem; font-size: .82rem; }
.rs-u-head .rs-u-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-u-head .muted { font-size: .76rem; white-space: nowrap; }
.rs-u-sub { display: flex; align-items: center; gap: .4rem; margin-top: .25rem; }
.rs-u-sub code { flex: 1; min-width: 0; font-family: var(--mono); font-size: .72rem; background: var(--surface-2); border-radius: var(--radius-sm); padding: .2rem .35rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-u .ip-list { margin-top: .25rem; }
.rs-u .ip-list .ip { font-size: .74rem; padding: .15rem .4rem; }
/* 线路标签紧凑些,36 条也就三四行 */
.rs-lines .chip { font-size: .72rem; padding: .1rem .4rem; }

/* 版本号旁的更新提示:平时不出现,有新版本才亮一个小箭头 */
.sidebar-version { display: flex; align-items: center; gap: .35rem; }
.update-dot { display: inline-flex; align-items: center; gap: .2rem; border: 1px solid var(--primary); background: transparent; color: var(--primary); border-radius: 999px; padding: 0 .35rem; height: 18px; cursor: pointer; line-height: 1; }
.update-dot svg { width: 12px; height: 12px; }
.update-dot:hover { background: var(--primary); color: #fff; }
.confirm-text { white-space: pre-line; }


/* 外部节点:展开面板 */
tr.ext-sub > td { padding: 0 .5rem .9rem; background: rgba(127, 127, 127, .05); }
.ext-panel { padding-top: .5rem; }
.ext-tools input[type=search] { max-width: 16rem; }
.ext-grid th, .ext-grid td { padding: .3rem .5rem; font-size: .85rem; }
.ext-toggle { min-width: 1.6rem; padding: 0 .3rem; margin-right: .35rem; }
.grid.kv td:first-child { width: 11rem; white-space: nowrap; }
.ext-val { word-break: break-all; }
.ext-link { margin-top: .8rem; display: grid; gap: .3rem; }
.ext-results { padding-left: 1.2rem; }
.ext-results li { margin: .25rem 0; }

/* ===== 大陆连通检测 ===== */
/* 表格里的一格:整格可点,打开明细抽屉 */
button.reach-cell { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; border-radius: var(--radius-sm); }
button.reach-cell:hover .badge { filter: brightness(.97); }
button.reach-cell:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sub-cell.link { color: var(--primary-text); }
.rc-row { display: flex; gap: .25rem; margin-top: .3rem; flex-wrap: wrap; }
.rc { display: inline-flex; align-items: baseline; gap: .2rem; font-size: .7rem; line-height: 1.5; padding: 0 .32rem; border-radius: 4px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.rc b { font-family: var(--mono); font-weight: 600; }
.rc.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.rc.weak { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.rc.down { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.spin { display: inline-block; width: .72rem; height: .72rem; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -1px; animation: mui-spin .8s linear infinite; }
@keyframes mui-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } }
.reach-sum { white-space: nowrap; }
.ok-text { color: var(--ok); } .danger-text { color: var(--danger); } .warn-text { color: var(--warn); }
/* 抽屉:结论条 + 分运营商 + 历史 */
.reach-hero { border-left: 3px solid var(--border-strong); background: var(--surface-2); border-radius: var(--radius-sm); padding: .6rem .85rem; margin-bottom: .8rem; }
.reach-hero .v { font-weight: 650; font-size: 1.02rem; margin-bottom: .2rem; }
.reach-hero p { color: var(--muted); font-size: .85rem; line-height: 1.5; }
.reach-hero.ok { border-left-color: var(--ok); } .reach-hero.warn { border-left-color: var(--warn); } .reach-hero.danger { border-left-color: var(--danger); }
.reach-meta { margin-bottom: .2rem; }
.reach-g { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .45rem .65rem; margin-bottom: .4rem; }
.reach-g-head { display: flex; align-items: center; gap: .55rem; }
.reach-g-name { flex: 1; font-weight: 500; }
.reach-g details { margin-top: .3rem; }
.reach-g summary { cursor: pointer; color: var(--muted); font-size: .78rem; }
.reach-probes { list-style: none; margin: .35rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .2rem; }
.reach-probes li { display: flex; justify-content: space-between; gap: .6rem; font-size: .78rem; }
.reach-probes li .ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.reach-hist { display: flex; gap: 3px; flex-wrap: wrap; }
.reach-hist i { width: 13px; height: 13px; border-radius: 3px; background: var(--border-strong); }
.reach-hist i.ok { background: var(--ok); } .reach-hist i.warn { background: var(--warn); } .reach-hist i.danger { background: var(--danger); }
/* 导航"服务器"上的红点 */
#nav a.has-alert { position: relative; }
#nav a.has-alert::after { content: ""; position: absolute; right: .7rem; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
@media (max-width: 700px) { .reach-sum { display: none; } }

/* 手机:字和控件留大一点,手指好点 */
@media (max-width: 700px) {
  body { font-size: 14px; }
  input, select, textarea { padding: .44rem .6rem; }
  .btn { padding: .44rem .8rem; }
  .btn.sm { padding: .3rem .6rem; }
  #nav a { padding: .55rem .7rem; }
}

/* 换套餐:变更前后两栏(窄屏上下排)、变了的值加粗、影响提示;用户详情里的套餐记录 */
.pc-preview { margin-top: .7rem; border-top: 1px dashed var(--border); padding-top: .6rem; }
.pc-preview h3 { margin: 0 0 .35rem; font-size: .85rem; }
.pc-cols dd.chg { font-weight: 600; color: var(--primary-text); }
.pc-warn { margin: .5rem 0 0; padding-left: 1.1rem; font-size: .8rem; line-height: 1.5; }
.pc-warn li.warn { color: var(--warn); }
.pc-warn li.bad, .pc-bad { color: var(--danger); font-weight: 500; }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.plan-ops { list-style: none; margin: 0; padding: 0; font-size: .8rem; }
.plan-ops li { padding: .35rem 0; border-bottom: 1px dashed var(--border); line-height: 1.5; }
.plan-ops li:last-child { border-bottom: none; }
details.api-list { margin-top: .6rem; }
@media (max-width: 700px) { .pc-cols { grid-template-columns: 1fr; } }
/* ===== 主机容灾:服务器列表的角色标签与小卡片、设为主机的确认框与进度、设置页 ===== */
button.role-chip { display: inline-flex; align-items: center; gap: .22rem; font: inherit; font-size: .72rem; line-height: 1.35; padding: .12rem .42rem .12rem .55rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); cursor: pointer; white-space: nowrap; vertical-align: middle; margin-right: .25rem; }
button.role-chip .caret { font-size: .6rem; opacity: .75; }
button.role-chip:hover { filter: brightness(.96); }
button.role-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button.role-chip[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--primary-soft); }
button.role-chip.k-master { background: var(--primary-soft); color: var(--primary-text); border-color: transparent; }
button.role-chip.k-standby { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
button.role-chip.k-lost { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.ha-pop { position: fixed; z-index: 70; width: min(22rem, calc(100vw - 1rem)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .75rem .9rem; font-size: .84rem; line-height: 1.55; }
.ha-pop:focus { outline: none; }
.ha-pop h4 { margin: 0 0 .3rem; font-size: .88rem; font-weight: 600; }
.ha-pop p { margin: .25rem 0; color: var(--text); }
.ha-pop p.muted { color: var(--muted); }
.ha-pop .actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem; }
.ha-pop .why { color: var(--warn); font-size: .78rem; margin-top: .35rem; }
.ha-pop .why:empty { display: none; }
.ha-plan { margin: .1rem 0 .7rem; padding-left: 1.15rem; line-height: 1.6; }
.ha-plan li { margin: .18rem 0; }
.ha-note { border-left: 3px solid var(--border-strong); background: var(--surface-2); border-radius: var(--radius-sm); padding: .5rem .7rem; margin: .4rem 0 .7rem; font-size: .85rem; }
.ha-note ul { margin: .25rem 0 0; padding-left: 1.1rem; }
.ha-note.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.ha-note.bad { border-left-color: var(--danger); background: var(--danger-soft); }
.ha-note.ok { border-left-color: var(--ok); background: var(--ok-soft); }
.ha-steps { list-style: none; padding: 0; margin: .6rem 0; display: grid; gap: .4rem; }
.ha-steps li { display: flex; align-items: center; gap: .55rem; color: var(--muted); }
.ha-steps li .ic { width: 1.1rem; text-align: center; }
.ha-steps li.done { color: var(--ok); }
.ha-steps li.cur { color: var(--text); font-weight: 500; }
.ha-steps li.fail { color: var(--danger); }
.ha-modes { margin: .6rem 0 .8rem; }
.ha-modes label { display: flex; gap: .6rem; align-items: flex-start; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .55rem .7rem; margin-bottom: .45rem; cursor: pointer; line-height: 1.5; }
.ha-modes label.sel { border-color: var(--primary); background: var(--primary-soft); }
.ha-modes input[type=radio] { width: auto; margin-top: .25rem; accent-color: var(--primary); }
.ha-sub { margin: .9rem 0 .4rem; font-size: .85rem; font-weight: 600; color: var(--muted); }
.ha-check { list-style: none; padding: 0; margin: .2rem 0 .6rem; display: grid; gap: .3rem; }
.ha-check li { display: grid; grid-template-columns: 1.2rem 1fr; gap: .35rem; font-size: .85rem; line-height: 1.5; }
.ha-check li .ic { font-weight: 700; text-align: center; }
.ha-check li.lv-ok .ic { color: var(--ok); }
.ha-check li.lv-warn .ic { color: var(--warn); }
.ha-check li.lv-bad .ic { color: var(--danger); }
.ha-check li.lv-info .ic { color: var(--muted); }
.ha-pause { gap: .4rem; flex-wrap: wrap; align-items: center; margin: .3rem 0 .6rem; }
.ha-adv summary { cursor: pointer; color: var(--muted); margin: .4rem 0; }
.field.check.inline { display: inline-flex; margin: 0 0 0 .6rem; }
.alert-bar.ha-info { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }
.alert-bar.ha-info a { text-decoration: underline; }
@media (max-width: 700px) { .ha-pop { font-size: .88rem; } }
/* 从卡片点「去设置」跳过来:标题和保存按钮别被吸顶的顶栏盖住 */
#ha-card { scroll-margin-top: 4.5rem; }
.ha-steps li.cur.warn { color: var(--warn); }
.ha-ack { margin: .2rem 0 .6rem; }
.ha-abandon { border-top: 1px solid var(--border); margin-top: .6rem; padding-top: .5rem; }
.ha-abandon .row { margin-top: .4rem; }
.fp { word-break: break-all; }
/* 「去 Cloudflare 创建 ↗」和下一行的手动步骤 */
.cf-link { display: flex; flex-direction: column; gap: .15rem; margin-top: .3rem; font-size: .8rem; line-height: 1.45; }
.cf-link a { color: var(--primary-text); text-decoration: underline; width: fit-content; }
.cf-link .cf-steps { color: var(--muted); }

/* ===================== 排版:大数据量下不溢出、不无限拉长 ===================== */
/* 顶部提示条和内容区同宽、左缘对齐;文字至多两行(手机三行),全文在 title;手机上按钮换到下一行 */
.main { --page-cur: var(--page-max); --page-pad: 1.2rem; }
.main:has(> #page[data-layout="fluid"]) { --page-cur: var(--page-max-fluid); }
@media (max-width: 900px) { .main { --page-pad: .8rem; } }
.main > .alert-bar { margin-left: max(var(--page-pad), calc((100% - var(--page-cur)) / 2 + var(--page-pad))); margin-right: max(var(--page-pad), calc((100% - var(--page-cur)) / 2 + var(--page-pad))); }
/* 只截重载失败、证书、大陆连通这三条(名单可能很长,全文在 title);更新回滚、容灾这类要看全文的不截 */
.main > :is(#reload-bar, #cert-bar, #reach-bar-top) > span:first-child { min-width: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
@media (max-width: 700px) {
  .main > .alert-bar { flex-direction: column; align-items: stretch; gap: .35rem; }
  .main > :is(#reload-bar, #cert-bar, #reach-bar-top) > span:first-child { -webkit-line-clamp: 3; }
  .main > .alert-bar > .row, .main > .alert-bar > .btn { align-self: flex-end; }
}
/* 主机容灾的顶部条:一次性提示最多同时露两条、其余折叠成「还有 N 条」,由 ha.js 的 haNotices 管(这里不按数量藏,藏了展开也看不到)。
   概况页上失联、写操作暂停这两条由「需要处理」那一行代替 */
.main:has(> #page[data-page="dashboard"]) > .alert-bar:is([data-ha="ha-lost"], [data-ha="ha-frozen"]) { display: none; }

/* 长表:宽屏时表格自带限高滚动区,表头吸在区域顶部,横向滚动条始终在视口里;手机仍是卡片 + 页面滚动 */
@media (min-width: 701px) {
  .table-wrap.fill { overflow: auto; max-height: max(18rem, calc(100vh - var(--topbar-h) - var(--fill-reserve, 7.5rem))); max-height: max(18rem, calc(100dvh - var(--topbar-h) - var(--fill-reserve, 7.5rem))); }
}
/* 列优先级:窗口不够宽时先藏 c-p3,再藏 c-p2(表头与单元格同名 class) */
@media (min-width: 701px) and (max-width: 1239px) { .grid .c-p3 { display: none; } }
@media (min-width: 701px) and (max-width: 1099px) { .grid .c-p2 { display: none; } }
/* 单元格里很长的一段(上游名):一行省略,全文在 title */
.cell-clip { display: inline-block; max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
@media (min-width: 701px) and (max-width: 1239px) { .cell-clip { max-width: 6.5rem; } }
/* 手机卡片里不截断:触屏点不出 title,上游名等要能看全 */
@media (max-width: 700px) { .cell-clip { display: inline; max-width: none; white-space: normal; overflow: visible; } }
.pc-err { color: var(--danger); font-size: .85rem; padding: .5rem 0; }
label.switch.sm { width: 28px; height: 16px; vertical-align: middle; }
label.switch.sm span::before { width: 12px; height: 12px; }
label.switch.sm input:checked + span::before { transform: translateX(12px); }
.grid-2.pc-cols { grid-template-columns: 1fr 1fr; }
@media (max-width: 700px) { .grid-2.pc-cols { grid-template-columns: 1fr; } }

/* chip 折叠:前 N 个 + 「+N」;展开后在原地限高滚动 */
.fold:not(.open) > .fold-x { display: none; }
.fold-x { display: contents; }
.chip.more { cursor: pointer; background: transparent; border-style: dashed; color: var(--primary-text); font: inherit; font-size: .76rem; line-height: inherit; }
/* 展开后限高滚动只在宽屏;手机上原地展开(内滚区和页面滚动抢手势) */
@media (min-width: 701px) { .chips.fold.open { max-height: 18rem; overflow-y: auto; align-content: flex-start; } }
td .chips { display: inline-flex; vertical-align: middle; }

/* 抽屉:默认 32rem,宽的 46rem;大屏再放宽 */
.drawer.wide { --drawer-w: 46rem; }
@media (min-width: 1800px) { .drawer { --drawer-w: 34rem; } .drawer.wide { --drawer-w: 56rem; } }

/* 长勾选列表:筛选 / 全选 / 全不选 / 计数 */
.cl-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; margin-bottom: .35rem; }
.cl-tools .cl-q { flex: 1 1 10rem; max-width: 16rem; }

/* 线路 × 服务器选择器:搜索 + 服务器筛选(可换行 / 下拉)+ 按线路分组的三态勾选 + 服务器 chip */
.lp-head { display: flex; flex-wrap: wrap; gap: .4rem .5rem; align-items: center; margin-bottom: .45rem; }
.lp-head .lp-q { flex: 1 1 12rem; max-width: 18rem; }
.lp-head select.lp-node { width: auto; max-width: 16rem; }
.lp-head .lp-only { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.lp-head .lp-count { white-space: nowrap; }
.lp-nodetabs { display: flex; flex-wrap: wrap; gap: .3rem; }
.lp-nodetabs button { border: 1px solid var(--border-strong); background: transparent; border-radius: var(--radius-sm); padding: .2rem .55rem; font: inherit; font-size: .8rem; color: var(--muted); cursor: pointer; white-space: nowrap; }
.lp-nodetabs button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.lp-nodetabs button.active .muted { color: inherit; opacity: .8; }
.lp-body { max-height: min(55vh, 30rem); overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.lp-body > .check-list { max-height: none; border: none; background: transparent; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.lp-body > .hint { margin: 0; padding: .6rem .7rem; }
.lp-line { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .2rem .5rem; align-items: center; padding: .35rem .6rem; border-bottom: 1px solid var(--border); }
.lp-line:last-child { border-bottom: none; }
.lp-line > label { display: flex; align-items: center; gap: .4rem; min-width: 0; font-size: .84rem; }
.lp-line .lp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lp-line .lp-n { font-size: .76rem; color: var(--muted); white-space: nowrap; }
.lp-line .lp-x { border: none; background: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0 .2rem; }
.lp-nodes { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .25rem; padding-left: 1.6rem; }
.lp-chip { font: inherit; font-size: .76rem; cursor: pointer; color: var(--muted); }
.lp-chip.on { background: var(--primary-soft); color: var(--primary-text); border-color: transparent; }
.lp-chip:disabled { cursor: default; opacity: .6; }
.up-list-wrap > .check-list { max-height: min(55vh, 30rem); }

/* 外部节点展开面板:自身不把外表撑宽(contain),子表限高滚动、表头吸顶、前两列吸左 */
.ext-panel { contain: inline-size; scroll-margin-top: calc(var(--topbar-h) + .5rem); }
@supports not (contain: inline-size) { .ext-panel { width: 0; min-width: 100%; } }
.ext-tools { row-gap: .4rem; }
.ext-tools .ext-row2 { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; flex-basis: 100%; }
.ext-grid th.sortable { cursor: pointer; }
.ext-sum { display: flex; flex-direction: column; align-items: flex-start; gap: .05rem; line-height: 1.25; }
.ext-sum .sub { font-size: .72rem; color: var(--muted); white-space: nowrap; }
/* 汇总格本身是个按钮(点开看逐台延迟):去掉浏览器默认的灰底边框,悬停时下划线提示能点 */
button.ext-sum { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
button.ext-sum:hover .sub, button.ext-sum:hover .muted { text-decoration: underline; }
/* 手机卡片里其它值都靠右,汇总格也靠右 */
@media (max-width: 700px) { button.ext-sum { margin-left: auto; align-items: flex-end; text-align: right; } }
.ext-more { display: flex; justify-content: center; padding: .5rem; }
.ext-cols .menu-list { max-height: 60vh; overflow: auto; min-width: 14rem; }
.ext-cols .menu-list label { display: flex; align-items: center; gap: .4rem; padding: .25rem .5rem; font-size: .82rem; white-space: nowrap; }
@media (min-width: 701px) {
  .ext-grid > thead th { position: sticky; top: 0; z-index: 3; }
  .ext-grid > * > tr > :nth-child(1) { position: sticky; left: 0; z-index: 2; width: 2.4rem; min-width: 2.4rem; background: var(--surface); }
  .ext-grid > * > tr > :nth-child(2) { position: sticky; left: 2.4rem; z-index: 2; min-width: 13rem; background: var(--surface); box-shadow: 1px 0 0 var(--border); }
  .ext-grid > thead > tr > :nth-child(-n+2) { z-index: 4; background: var(--surface-2); }
  .ext-grid > tbody > tr:hover > :nth-child(-n+2) { background: var(--surface-2); }
}
@media (max-width: 700px) { .ext-grid .srv, .ext-view { display: none !important; } }

/* 上游延迟列:服务器多时的汇总 */
.up-sum { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }

/* ===================== 概况 ===================== */
/* 栅格:列数由容器宽度决定(1024 宽 2 列、1440 宽 3 列、1920 宽 4 列、2560 宽 5 列);dense 回填 span-2 换行留下的洞 */
.dash-grid { container-type: inline-size; display: grid; gap: .8rem; align-items: start; grid-auto-flow: row dense;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 25.5rem), 1fr)); }
.dash-grid > * { margin: 0; min-width: 0; }
.dash-grid > .span-all { grid-column: 1 / -1; }
@container (min-width: 51.8rem) { .dash-grid > .span-2 { grid-column: span 2; } }
/* 核心日志在最后一行补满:3 列时整行,4 列时 3 格;2 列、5 列时 1 格正好排满 */
@container (min-width: 78.1rem) and (max-width: 104.35rem) { .dash-grid > .dash-log-card { grid-column: 1 / -1; } }
@container (min-width: 104.4rem) and (max-width: 130.65rem) { .dash-grid > .dash-log-card { grid-column: span 3; } }
.dash-grid .card-head h2 { min-width: 0; }
/* 手机上标题按自己的宽度排,放不下时把右边的分段按钮 / 刷新换到下一行,不再把标题挤成一字一行 */
@media (max-width: 700px) { .dash-grid .card-head h2 { flex: 1 1 auto; } }
/* 统计条是网格里占整行的一项:2×3 / 3×2 / 一行 6 张,单数时最后一张占满一行 */
.dash-grid > .stats { margin: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dash-grid > .stats > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
@container (min-width: 40rem) { .dash-grid > .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } .dash-grid > .stats > .stat:last-child:nth-child(odd) { grid-column: auto; } }
@container (min-width: 66rem) { .dash-grid > .stats { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); } }
.stat { min-width: 0; }
.stat .k, .stat .v, .stat .s { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .k { display: block; }
.stat.warn { border-color: var(--warn); } .stat.warn .s { color: var(--warn); }
.stats.stale { opacity: .7; }
/* 三行共用一套列(subgrid):标签列按最长的标签定宽,英文的 Memory 不会压到进度条上,三条进度条照样对齐。
   不认识 subgrid 的浏览器丢掉后一条,用前一条的固定列宽(每行各自成网格,标签列定宽才能对齐) */
.meters { display: grid; grid-template-columns: max-content minmax(0, 1fr) 2.6rem; gap: .25rem .35rem; margin-top: .3rem; }
.meter { grid-column: 1 / -1; display: grid; grid-template-columns: 4.2em minmax(0, 1fr) 2.6rem; column-gap: .35rem; grid-template-columns: subgrid; align-items: center; font-size: .74rem; color: var(--muted); }
.meter .progress { margin: 0; min-width: 0; }
.meter > span:last-child { text-align: right; font-family: var(--mono); }
/* 卡片头的小字:人数、口径、过期徽章 */
.h-count, .scope { font-weight: 500; color: var(--muted); font-size: .8rem; margin-left: .3rem; }
.dash-stale { margin-left: .4rem; font-weight: 500; }
.card-foot { margin-top: .5rem; font-size: .8rem; display: flex; gap: .8rem; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.dash-err { color: var(--danger); font-size: .85rem; padding: .6rem 0; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.dash-err .msg { min-width: 0; overflow-wrap: anywhere; }
.dash-loading { color: var(--muted); font-size: .82rem; padding: .8rem 0; }
.row.wrap { flex-wrap: wrap; gap: .35rem; }
.help-tip { display: inline-grid; place-items: center; width: 1.05rem; height: 1.05rem; border-radius: 50%; border: 1px solid var(--border-strong); color: var(--muted); font-size: .7rem; font-weight: 500; cursor: help; vertical-align: 1px; margin-left: .2rem; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.dash-q { width: 11rem; max-width: 100%; }
.seg.sm button { padding: .18rem .5rem; font-size: .76rem; }

/* 需要处理:每类一行,按严重程度排;桌面按宽度排成 2 / 3 / 4 列 */
.attn { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem .8rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 30rem), 1fr)); }
.attn li { display: flex; align-items: flex-start; gap: .55rem; padding: .4rem .6rem; border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.attn .sev { flex: none; width: .55rem; height: .55rem; margin-top: .42rem; border-radius: 50%; background: var(--muted); }
.attn li.bad .sev { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.attn li.warn .sev { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.attn li.info { background: transparent; border: 1px dashed var(--border); }
.attn .what { flex: 1; min-width: 0; font-size: .85rem; }
.attn .ttl { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attn .parts { color: var(--muted); font-size: .8rem; }
.attn .parts a { color: var(--primary-text); }
.attn .names { display: block; color: var(--muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attn .acts { flex: none; display: flex; gap: .4rem; align-items: center; font-size: .8rem; white-space: nowrap; }
.attn-ok { color: var(--ok); font-size: .85rem; font-weight: 500; }
.attn-card.ok { padding-top: .5rem; padding-bottom: .5rem; }
.attn-card.ok .card-head { margin-bottom: 0; }
.attn-card.ok .attn { margin-top: .45rem; }
.attn-ignored { margin-top: .45rem; }
@media (max-width: 700px) {
  .attn li { padding: .35rem .5rem; gap: .45rem; flex-wrap: wrap; }
  .attn .acts { font-size: .76rem; margin-left: 1rem; }
  .attn .parts { font-size: .74rem; }
  .attn .ttl { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
}

/* 快速开始做完:和 Star 合成一行 */
.qs-done { display: flex; align-items: center; gap: .5rem .8rem; flex-wrap: wrap; }
.qs-done .grow { flex: 1; }
.qs-opt { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }

/* 当前在线:名字过长省略;展开 / 搜索结果在 18rem 里滚动 */
#dash-online .chip { display: inline-flex; align-items: center; max-width: 15rem; gap: .15rem; }
#dash-online .chip .cn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@media (min-width: 701px) { .chips.scroll { max-height: 18rem; overflow-y: auto; align-content: flex-start; } }

/* 上游巡检:一条上游一行 */
.up-bad { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.up-bad li { display: grid; grid-template-columns: minmax(0, max-content) auto minmax(0, 1fr); gap: .5rem; align-items: center; font-size: .84rem; }
.up-bad .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--danger); }
.up-bad .err { color: var(--muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 700px) { .up-bad li { grid-template-columns: minmax(0, 1fr) auto; } .up-bad .err { grid-column: 1 / -1; } }

/* 最近入站连接:定宽列,展开全部时限高滚动、表头吸顶;窄屏两行紧凑排 */
table.grid.conns col.c-ip { width: 30%; } table.grid.conns col.c-user { width: 20%; } table.grid.conns col.c-line { width: 26%; }
table.grid.conns col.c-cnt { width: 4.2rem; } table.grid.conns col.c-last { width: 6.5rem; }
table.grid.conns.srv col.c-ip { width: 26%; } table.grid.conns.srv col.c-user { width: 16%; } table.grid.conns.srv col.c-line { width: 22%; } table.grid.conns.srv col.c-srv { width: 16%; }
table.grid.conns .ipc { display: flex; align-items: center; gap: .3rem; min-width: 0; }
table.grid.conns .ipv { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
table.grid.conns .ipc .badge { flex: none; }
table.grid.conns tr.rej td { background: color-mix(in srgb, var(--danger-soft) 45%, transparent); }
.conns-wrap.capped { max-height: 26rem; overflow: auto; }
.conns-tools { display: flex; align-items: center; gap: .5rem; margin-bottom: .45rem; flex-wrap: wrap; }
@media (max-width: 700px) {
  table.grid.conns { table-layout: auto; display: block; }
  table.grid.conns colgroup, table.grid.conns thead { display: none; }
  table.grid.conns tbody { display: block; }
  table.grid.conns tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: .05rem .55rem; padding: .4rem .6rem; border-bottom: 1px solid var(--border); }
  table.grid.conns td { display: block; padding: 0; border: none; max-width: 100%; }
  table.grid.conns td.ip { flex: 1 1 60%; min-width: 0; white-space: normal; }
  table.grid.conns td.last { margin-left: auto; color: var(--muted); }
  table.grid.conns td.user, table.grid.conns td.line, table.grid.conns td.srv, table.grid.conns td.cnt { font-size: .76rem; color: var(--muted); flex: 0 1 auto; min-width: 0; max-width: 46%; white-space: nowrap; }
}

/* 最近操作 / 代理名单:一行一条,省略号 + title */
.audit-list, .mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .32rem; font-size: .84rem; }
.audit-list li { display: grid; grid-template-columns: 5.4rem minmax(0, 1fr); gap: .6rem; }
.audit-list .when { color: var(--muted); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audit-list .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list li { display: flex; gap: .5rem; align-items: center; justify-content: space-between; min-width: 0; }
.mini-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* 数据面:6 行,长的省略 */
.kv { grid-template-columns: auto minmax(0, 1fr); }
.kv dd.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
button.badge { cursor: pointer; font: inherit; font-size: .72rem; }

/* 核心日志:可折起(手机默认折起,折起时不轮询) */
.dash-log-card.collapsed pre.log, .dash-log-card.collapsed .card-foot, .dash-log-card.collapsed #dash-loglevel { display: none; }
.dash-log-card.collapsed .card-head { margin-bottom: 0; }

/* 设置页:分组卡片多栏排(瀑布流) */
.masonry { column-width: 34rem; column-gap: .8rem; }
.masonry > .card { break-inside: avoid; }
.stat .s:empty::before { content: "\00a0"; }

/* 外部 API 附加密钥:权限两列勾选(手机一列),每项一行名称一行说明 */
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .35rem .8rem; margin-top: .6rem; }
.perm-item { display: flex; gap: .45rem; align-items: flex-start; padding: .4rem .5rem; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.perm-item input { margin-top: .15rem; flex: none; }
.perm-item span { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.perm-item b { font-weight: 600; font-size: .85rem; }
.perm-item small { font-size: .74rem; line-height: 1.35; }
.api-keys td { vertical-align: middle; }
#apiip-list { width: 100%; font-family: var(--mono); font-size: .82rem; }
@media (max-width: 700px) { .perm-grid { grid-template-columns: 1fr; } }

/* 限时彩蛋的位置(见 js/xmas.js):空着不占位 */
.xmas-slot { display: inline-flex; align-items: center; }
.xmas-slot:empty { display: none; }

/* 线路详情:四格概要、可选服务器的流量图、各服务器一行一台(多了限高滚动)、在线用户与 IP(分页 + 折叠) */
.drawer-head h2 { min-width: 0; overflow-wrap: anywhere; }
.ld-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; margin-bottom: .95rem; }
.ld-tile { display: flex; flex-direction: column; gap: .1rem; min-width: 0; padding: .5rem .65rem; background: var(--surface-2); border-radius: var(--radius-sm); }
.ld-tile > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ld-tile .lb { font-size: .74rem; color: var(--muted); }
.ld-tile b { font-size: 1.05rem; }
.ld-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; }
.drawer-body .ld-head h3 { margin: 0 auto 0 0; min-width: 0; }
.ld-head select { width: auto; max-width: 14rem; }
.ld-head input[type=search] { width: 14rem; max-width: 100%; }
.ld-slist { display: flex; flex-direction: column; gap: .15rem; }
.ld-slist.capped { max-height: 18rem; overflow-y: auto; }
.ld-srow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(3rem, 18%) 5.4rem minmax(0, 11rem) 4.8rem; gap: .6rem; align-items: center; width: 100%; padding: .32rem .5rem; border: 1px solid transparent; border-radius: var(--radius-sm); background: none; font: inherit; font-size: .84rem; color: inherit; text-align: left; }
button.ld-srow { cursor: pointer; }
button.ld-srow:hover { background: var(--surface-2); }
.ld-srow.on { border-color: var(--primary); background: var(--primary-soft); }
.ld-srow .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ld-srow.bad .nm { color: var(--muted); font-weight: 400; }
.ld-srow.off .err { color: var(--muted); }
.ld-bar { display: block; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.ld-bar > span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.ld-srow .val { text-align: right; white-space: nowrap; }
.ld-srow .ud { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ld-srow .on-n { text-align: right; white-space: nowrap; color: var(--muted); font-size: .78rem; }
.ld-srow .err { grid-column: 2 / 5; color: var(--danger); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ld-olist { display: flex; flex-direction: column; }
.ld-olist.capped { max-height: 24rem; overflow-y: auto; }
.ld-orow { display: grid; grid-template-columns: minmax(0, 12rem) minmax(0, 1fr); gap: .25rem .7rem; align-items: start; padding: .32rem .2rem; border-bottom: 1px solid var(--border); font-size: .84rem; }
.ld-olist.srv .ld-orow { grid-template-columns: minmax(0, 10rem) minmax(0, 8rem) minmax(0, 1fr); }
.ld-orow .nm, .ld-orow .srv { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.55rem; }
.ld-orow .srv { color: var(--muted); font-size: .78rem; }
.ld-orow .ips { min-width: 0; }
.ld-orow .ips .chip { font-size: .74rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 700px) {
  .ld-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ld-srow { grid-template-columns: minmax(0, 1fr) auto auto; }
  .ld-srow .ld-bar, .ld-srow .ud { display: none; }
  .ld-srow.bad { grid-template-columns: minmax(0, 1fr) auto; }
  .ld-srow.bad .err { grid-column: 1 / -1; grid-row: 2; white-space: normal; }
  .ld-slist.capped, .ld-olist.capped { max-height: none; overflow: visible; }
  .ld-orow, .ld-olist.srv .ld-orow { grid-template-columns: minmax(0, 1fr) auto; }
  .ld-orow .srv { max-width: 9rem; text-align: right; }
  .ld-orow .ips { grid-column: 1 / -1; }
  .ld-head select { max-width: 100%; }
}

/* 线路的中转入口(勾选才展开):一条一块 —— 第一行「入口 中转:端口 → 出口 地址:端口  暂停 删除」,第二行订阅节点名与要做的事 */
.fw-box { container-type: inline-size; }
#f-fw { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .2rem .75rem .6rem; margin-top: .5rem; background: var(--surface-2); }
.fw-item { display: flex; flex-direction: column; gap: .3rem; padding: .55rem 0; border-top: 1px solid var(--border); }
.fw-item:first-child { border-top: none; }
.fw-path { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .45rem; min-width: 0; }
.fw-no { flex: none; width: 1.4rem; text-align: center; font-size: .78rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.fw-lab { flex: none; font-size: .74rem; color: var(--muted); white-space: nowrap; }
.fw-from { display: flex; gap: .35rem; flex: 0 1 auto; min-width: 0; }
.fw-from:has(> .fw-host:not([hidden])) { flex: 1 1 18rem; } /* 别处的中转:地址框占剩下的宽度 */
.fw-from select { flex: 0 1 11rem; min-width: 0; }
.fw-from input { flex: 1 1 8rem; min-width: 0; }
.fw-from > [hidden] { display: none; }
.fw-colon { color: var(--muted); }
.fw-port { flex: none; width: 5.6rem; }
.fw-arrow { flex: none; color: var(--muted); font-size: 1rem; }
.fw-exit { display: flex; align-items: center; min-width: 0; flex: 0 1 auto; }
.fw-exit select { min-width: 0; }
.fw-exit-name { font-weight: 600; font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fw-dest-wrap { display: flex; align-items: center; min-width: 0; flex: 0 1 auto; font-family: var(--mono); font-size: .78rem; color: var(--muted); }
.fw-dest { border: 0; background: none; padding: 0; font: inherit; color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; cursor: pointer; }
.fw-dest:not(:disabled):hover { color: var(--primary-text); }
.fw-dest:disabled { cursor: default; }
.fw-target { width: 9rem; padding: .2rem .4rem; font-family: var(--mono); font-size: .78rem; }
.fw-dest-wrap [hidden] { display: none; }
.fw-tail { display: flex; align-items: center; gap: .4rem; margin-left: auto; }
.fw-pause { display: flex; align-items: center; gap: .25rem; font-size: .8rem; color: var(--muted); white-space: nowrap; cursor: pointer; }
.fw-result { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1.1rem; padding-left: 1.85rem; font-size: .8rem; min-width: 0; }
.fw-nn { display: inline-flex; align-items: baseline; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.fw-nn .lab { color: var(--muted); margin-right: .4rem; white-space: nowrap; }
.fw-nn b { font-weight: 500; overflow-wrap: anywhere; }
.fw-name { width: 8rem; min-width: 4rem; padding: 0 .2rem; font-size: .8rem; font-weight: 500; border: 0; border-bottom: 1px dashed var(--border-strong); border-radius: 0; background: transparent; }
.fw-name:focus { border-bottom-color: var(--primary); outline: none; box-shadow: none; }
.fw-todo { flex: 1 1 16rem; min-width: 0; color: var(--muted); }
.fw-note { padding-left: 1.85rem; font-size: .76rem; color: var(--warn); }
.fw-note.bad { color: var(--danger); }
.fw-note[hidden] { display: none; }
.fw-item.paused .fw-from, .fw-item.paused .fw-port, .fw-item.paused .fw-exit, .fw-item.paused .fw-dest-wrap, .fw-item.paused .fw-result { opacity: .5; }
.fw-foot { margin: .5rem 0 0; }
/* 展开后最上面的小图:用户 → 中转 → 出口 → 网站 */
.fw-flow { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: .5rem 0 .15rem; }
.fw-flow-node { padding: .16rem .62rem; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: .8rem; font-weight: 500; white-space: nowrap; }
.fw-flow-node.relay { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }
.fw-flow-node.exit { border-color: var(--ok); color: var(--ok); }
.fw-flow-arrow { color: var(--muted); }
.fw-flow-note { margin: .3rem 0 .15rem; }
.fw-paren[hidden], .fw-dest-port[hidden] { display: none; }
#f-fw-add { margin-top: .4rem; }
.fw-badge { font-size: .7rem; padding: .05rem .4rem; margin-left: .3rem; vertical-align: 1px; cursor: help; }
@container (max-width: 560px) { /* 窄:不缩进,暂停和删除不顶到最右 */
  .fw-result, .fw-note { padding-left: 0; }
  .fw-from { flex-basis: 100%; }
  .fw-tail { margin-left: 0; }
}
.ld-fw { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .45rem; margin: -.35rem 0 .95rem; min-width: 0; }
.ld-fw .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ld-fw .chip.off, .chip.off { opacity: .6; }
.ld-orow .ips .chip.via { border-color: var(--primary); color: var(--primary-text); }

/* 面板换到新地址(panelmove.js) */
.pm-mask { z-index: 90; }
.pm-box { max-width: 30rem; }
.pm-body { padding: 0 1.1rem .4rem; display: flex; flex-direction: column; gap: .55rem; }
.pm-url { font-size: .9rem; overflow-wrap: anywhere; }
.pm-state { display: flex; align-items: center; gap: .55rem; margin: 0; font-size: .86rem; color: var(--muted); }
.pm-state.warn-text { color: var(--warn); }
.pm-spin { flex: none; width: 1rem; height: 1rem; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: pm-spin .8s linear infinite; }
@keyframes pm-spin { to { transform: rotate(360deg); } }
.pm-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1.1rem 1rem; }

/* 主机容灾:接任时接管什么(两个选项沿用模式选择的样式);选了接管订阅才出现的 DNS 接口 */
.ha-dns-box { margin: .55rem 0 .2rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.ha-dns-box[hidden] { display: none; }
.ha-dns-box > .hint:first-child { margin-top: 0; }
/* 「测试」按钮和「清掉凭据」:窄屏时勾选框换到下一行,不被 .row input 撑开 */
.ha-dns-act { column-gap: .9rem; }
.ha-dns-act .field.check { flex-wrap: nowrap; margin: 0; }
.ha-dns-act .field.check input { flex: none; }
