/* AppFast 管理控制台 —— 中性灰阶 + 单一品牌色的后台视觉系统 */

:root {
    /* ── 刻度（与主题无关） ── */
    --r-sm: 4px;
    --r: 6px;
    --r-md: 8px;
    --r-lg: 12px;
    --topnav-h: 56px;
    --sidenav-w: 240px;
    --rail-w: 64px;
    --dur: 160ms;
    --ease: cubic-bezier(.2, 0, 0, 1);
    /* 拉丁字母和数字用 Inter（本地文件，见下面 @font-face），中文回退系统字体 */
    --font: "Inter Var", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
    --mono: "SF Mono", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
    /* 字号倍率：所有字号和 px 行高都写成 calc(Npx * var(--fs))；宽高、间距、断点不乘，字变大布局不变。
       档位存在管理员账号上（admins.font_size），head 里的脚本据此写 data-font，切换见 _theme_menu.html、app.js */
    --fs: 1;
    --fs-user: 1;
}
:root[data-font="m"] { --fs: 1.15; --fs-user: 1.15; }
:root[data-font="l"] { --fs: 1.3; --fs-user: 1.3; }

/* ── 语义色：浅色（默认）。业务样式只用这些名字；旧的 --n-* / --brand-* 在下面映射过来 ── */
:root, :root[data-theme="light"] {
    color-scheme: light;
    --bg: #F1F3F5;              /* 页面底色 */
    --surface: #FFFFFF;         /* 卡片、表格、弹窗 */
    --surface-2: #F7F8FA;       /* 卡片里的浅底区（代码、说明条、表头） */
    --text: #1C2530;
    --text-strong: #121A23;
    --text-soft: #3B4552;
    --text-2: #56606C;          /* 次级文字 */
    --text-3: #87919C;          /* 弱化文字 */
    --divider: #E9ECF0;         /* 行与行之间的细线 */
    --border: #DFE3E8;
    --border-strong: #B9C1CB;
    --hover: #EDF0F3;
    --selected: #E2E6EB;        /* 侧栏当前项 */
    --brand: #1A5FCC;
    --brand-hover: #154EAA;
    --brand-text: #1757BF;      /* 品牌色文字（浅底上） */
    --brand-bg: #E8F0FC;
    --brand-bd: #C6D8F5;
    --chart-select: rgba(26, 95, 204, .12);  /* 图表框选：半透明，框住的曲线还看得见 */
    --focus: rgba(26, 95, 204, .28);
    --overlay: rgba(15, 23, 42, .42);
    --ok: #2F7D32;   --ok-bg: #E4F2E2;   --ok-bd: #BFDDBB; --ok-ic: #3B9441;
    --warn: #9A5B00; --warn-bg: #FCEFD3; --warn-bd: #F2D59A; --warn-ic: #D08A11;
    --err: #B3261E;  --err-bg: #FBE5E4;  --err-bd: #F2C2BF; --err-ic: #D33A32; --err-hover: #9A1F18;
    --neutral-bg: #E6E9ED; --neutral-ic: #8A939E;
    --sh-1: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
    --sh-2: 0 4px 12px rgba(16, 24, 40, .1);
    --sh-pop: 0 12px 36px rgba(16, 24, 40, .18), 0 2px 6px rgba(16, 24, 40, .06);
    /* 深蓝顶栏（两种主题都深色） */
    --topbar-bg: #13233D;
    --topbar-text: #FFFFFF;
    --topbar-muted: rgba(255, 255, 255, .72);
    --topbar-field: rgba(255, 255, 255, .1);
    --topbar-field-hover: rgba(255, 255, 255, .16);
    --topbar-line: rgba(255, 255, 255, .22);
    /* 图表 */
    --chart-down: #1A5FCC;
    --chart-up: #3B9441;
    --chart-line: #2A78D6;
    --chart-err: #D33A32;
    --chart-direct-down: #B26A00;  /* 直连（不经节点）：虚线，默认隐藏 */
    --chart-direct-up: #8248C9;
    --chart-grid: #E9ECF0;
    --chart-axis: #56606C;
    --diff-del-mark: #F5C2BE;
    --diff-add-mark: #B7E0B9;
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4 6.5l4 4 4-4' fill='none' stroke='%2356606C' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
/* ── 深色：显式选深色，或「跟随系统」且系统是深色（head 里的脚本据此写 data-theme，这里不重复判断） ── */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0D141E;
    --surface: #161F2B;
    --surface-2: #121A25;
    --text: #E8EDF3;
    --text-strong: #F5F8FB;
    --text-soft: #C7D0DA;
    --text-2: #A3AEBB;
    --text-3: #6F7B89;
    --divider: #222C3A;
    --border: #2A3647;
    --border-strong: #3E4C60;
    --hover: #1E2938;
    --selected: #243142;
    --brand: #4C8DF0;
    --brand-hover: #6FA4F5;
    --brand-text: #7EAEF7;
    --brand-bg: rgba(76, 141, 240, .15);
    --brand-bd: rgba(126, 174, 247, .32);
    --chart-select: rgba(76, 141, 240, .2);
    --focus: rgba(96, 165, 250, .4);
    --overlay: rgba(2, 6, 23, .66);
    --ok: #7CCB7F;   --ok-bg: rgba(76, 175, 80, .14);  --ok-bd: rgba(124, 203, 127, .32); --ok-ic: #4CAF50;
    --warn: #F2BE5C; --warn-bg: rgba(242, 166, 35, .14); --warn-bd: rgba(242, 190, 92, .32); --warn-ic: #E09B1F;
    --err: #F28B85;  --err-bg: rgba(229, 72, 64, .15);  --err-bd: rgba(242, 139, 133, .32); --err-ic: #E5534B; --err-hover: #D0443C;
    --neutral-bg: #243142; --neutral-ic: #7A8696;
    --sh-1: none;
    --sh-2: 0 6px 18px rgba(0, 0, 0, .45);
    --sh-pop: 0 14px 40px rgba(0, 0, 0, .55), 0 0 0 1px #2A3647;
    --topbar-bg: #0A111B;
    --topbar-field: rgba(255, 255, 255, .08);
    --topbar-field-hover: rgba(255, 255, 255, .13);
    --topbar-line: rgba(255, 255, 255, .16);
    --chart-down: #5B9BF5;
    --chart-up: #5DBB63;
    --chart-line: #6FA4F5;
    --chart-err: #F07167;
    --chart-direct-down: #F0A944;
    --chart-direct-up: #B48CF2;
    --chart-grid: #222D3C;
    --chart-axis: #A3AEBB;
    --diff-del-mark: rgba(242, 139, 133, .38);
    --diff-add-mark: rgba(124, 203, 127, .36);
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4 6.5l4 4 4-4' fill='none' stroke='%23A3AEBB' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ── 旧名字 → 语义 Token（页面级样式仍在用这些名字，换主题时跟着变） ── */
:root {
    --n-0: var(--surface);
    --n-25: var(--surface-2);
    --n-50: var(--hover);
    --n-100: var(--divider);
    --n-200: var(--border);
    --n-300: var(--border-strong);
    --n-400: var(--text-3);
    --n-600: var(--text-2);
    --n-700: var(--text-soft);
    --n-800: var(--text);
    --n-900: var(--text-strong);
    --brand-50: var(--brand-bg);
    --brand-100: var(--brand-bd);
    --brand-500: var(--brand);
    --brand-600: var(--brand);
    --brand-700: var(--brand-text);
}

@font-face {
    font-family: "Inter Var";
    src: url("vendor/inter/inter-latin-var.woff2") format("woff2");
    font-weight: 100 900; font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2212, U+2215;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
/* 手机 / 平板：页面不能拖着晃——横向（有元素比屏幕宽时 Safari 会让整页横向跑）和上下拖过头的回弹（iOS 会露出深色底和刷新菊花）都关掉；
   表格等需要横滑的都在自己的 .table-wrap 里滚。overscroll-behavior 需要 iOS / iPadOS 16+ */
html, body { overscroll-behavior: none; }
html { overflow-x: hidden; }
/* iOS Safari 会把宽表格、长段落里的字自动放大（text autosizing），同一页字号忽大忽小；关掉，按样式表的字号显示 */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    font: calc(14px * var(--fs))/calc(20px * var(--fs)) var(--font);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-text); text-decoration: none; }
a:hover { color: var(--brand-hover); text-decoration: underline; }
:root[data-theme="dark"] a:hover { color: var(--text-strong); }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
::selection { background: var(--brand-bd); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; } }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.icon { width: 16px; height: 16px; flex: none; }

/* ---------- 顶部导航：深蓝底、白字（浅色 / 深色主题都是深色顶栏） ---------- */
.topnav {
    position: sticky; top: 0; z-index: 100;
    height: calc(var(--topnav-h) + env(safe-area-inset-top));
    display: flex; align-items: center; gap: 14px;
    padding: env(safe-area-inset-top) max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
    background: var(--topbar-bg);
    color: var(--topbar-muted);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--topbar-text); font-size: calc(17px * var(--fs)); font-weight: 500; letter-spacing: .01em; white-space: nowrap; }
.brand:hover { color: var(--topbar-text); text-decoration: none; }
.brand-mark {
    width: 26px; height: 26px; border-radius: 6px;
    display: grid; place-items: center;
    border: 1.5px solid rgba(255, 255, 255, .85); color: #fff;
    font-size: calc(11px * var(--fs)); font-weight: 700; letter-spacing: .3px;
}
.topnav-divider { width: 1px; height: 20px; background: var(--topbar-line); }
/* 汉堡按钮只在窄屏出现（见文件末尾的窄屏段） */
.nav-burger { display: none; }
.topnav-title { font-size: calc(13.5px * var(--fs)); color: var(--topbar-muted); white-space: nowrap; }

.topnav-right { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: calc(13.5px * var(--fs)); }
.topnav-user { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px; border-radius: var(--r); color: var(--topbar-text); white-space: nowrap; }
.topnav-user:hover { background: var(--topbar-field-hover); color: var(--topbar-text); text-decoration: none; }
.topnav-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    display: grid; place-items: center;
    background: rgba(255, 255, 255, .14); color: #fff; font-size: calc(12px * var(--fs)); font-weight: 600;
}
.topnav-logout {
    height: 32px; padding: 0 12px; border: 1px solid var(--topbar-line); border-radius: var(--r);
    background: transparent; color: var(--topbar-muted); font: 500 calc(13px * var(--fs))/calc(18px * var(--fs)) var(--font); cursor: pointer;
    white-space: nowrap;
}
.topnav-logout:hover { background: var(--topbar-field-hover); color: #fff; }
/* 顶栏图标按钮（主题切换） */
.topnav-icon {
    display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
    border: 0; border-radius: var(--r); background: transparent; color: var(--topbar-muted); cursor: pointer; list-style: none;
}
.topnav-icon::-webkit-details-marker { display: none; }
.topnav-icon:hover, details[open] > .topnav-icon { background: var(--topbar-field-hover); color: #fff; }
.theme-menu { position: relative; }
.theme-menu-list {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 120;
    min-width: 150px; padding: 4px; display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--sh-pop); color: var(--text);
}
.theme-menu .menu-item { display: flex; align-items: center; gap: 8px; }
.theme-menu .menu-item[aria-checked="true"] { color: var(--brand-text); font-weight: 600; }
.theme-menu .menu-item[aria-checked="true"]::after { content: ""; margin-left: auto; width: 5px; height: 9px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: calc(100vh - var(--topnav-h)); }
.nav-backdrop { display: none; }
/* 侧栏：和页面同底色、不画边框；条目大一号，当前项灰色胶囊 + 品牌色图标 */
.sidenav {
    position: sticky; top: var(--topnav-h);
    width: var(--sidenav-w); flex-shrink: 0;
    height: calc(100vh - var(--topnav-h));
    display: flex; flex-direction: column;
    background: var(--bg);
    transition: width var(--dur) var(--ease);
}
.sidenav-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 12px 16px 16px; }
.sidenav-section { padding: 0; }
.sidenav-section + .sidenav-section { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.sidenav-section-title {
    padding: 4px 12px 6px;
    font-size: calc(13px * var(--fs)); font-weight: 600;
    color: var(--text-2);
}
/* 可折叠的分组（运营后台）：标题是 summary，右边一个箭头，收起时朝右 */
.sidenav-group > summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; border-radius: var(--r); user-select: none; }
.sidenav-group > summary::-webkit-details-marker { display: none; }
.sidenav-group > summary:hover { color: var(--text); }
.sidenav-caret { width: 13px; height: 13px; transition: transform var(--dur) var(--ease); }
.sidenav-group[open] .sidenav-caret { transform: rotate(90deg); }
.sidenav-group:not([open]) { padding-bottom: 2px; }
.sidenav-link {
    display: flex; align-items: center; gap: 12px;
    min-height: 40px; padding: 8px 12px; margin-bottom: 2px;
    border-radius: var(--r-md);
    color: var(--text); font-size: calc(14.5px * var(--fs)); font-weight: 500; line-height: calc(20px * var(--fs));
}
.sidenav-link .icon { width: 20px; height: 20px; color: var(--text-2); }
.sidenav-link:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.sidenav-link.active { background: var(--selected); color: var(--text-strong); font-weight: 600; }
.sidenav-link.active .icon { color: var(--brand); }
.sidenav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidenav-ext { width: 13px; height: 13px; margin-left: auto; opacity: .55; }
.sidenav-foot { flex: none; padding: 8px 12px 16px 16px; }
.rail-toggle {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 36px; padding: 6px 12px;
    border: 0; border-radius: var(--r-md); background: none; color: var(--text-2); font: 500 calc(13px * var(--fs))/calc(20px * var(--fs)) var(--font); cursor: pointer;
}
.rail-toggle:hover { background: var(--hover); color: var(--text); }
.rail-toggle .icon { width: 18px; height: 18px; }
/* 图标栏：桌面可手动收起；961–1279px（iPad 横屏、小笔记本）默认收起，见 app.js 的 sidenav-rail */
@media (min-width: 961px) {
    html.nav-rail .sidenav { width: var(--rail-w); }
    html.nav-rail .sidenav-scroll { padding-left: 10px; padding-right: 10px; }
    html.nav-rail .sidenav-label, html.nav-rail .sidenav-section-title, html.nav-rail .sidenav-ext, html.nav-rail .rail-text { display: none; }
    html.nav-rail .sidenav-link, html.nav-rail .rail-toggle { justify-content: center; padding-left: 0; padding-right: 0; }
    html.nav-rail .sidenav-group > summary { display: none; }
    html.nav-rail .sidenav-foot { padding-left: 10px; padding-right: 10px; }
    html.nav-rail .rail-toggle .icon { transform: scaleX(-1); }
}
/* 抽屉里的头部（关闭按钮）只在窄屏出现 */
.sidenav-head { display: none; }

.main { flex: 1; min-width: 0; padding: 24px 32px 56px; }
/* 内容区填满可用宽度；各个网格靠 auto-fit 自己增减列，宽屏是多出几列而不是把列拉长 */
.main-inner { width: 100%; }

/* ---------- 面包屑 / 页头 ---------- */
.breadcrumbs {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    margin-bottom: 10px; color: var(--text-3); font-size: calc(13px * var(--fs));
}
.breadcrumbs a { color: var(--text-2); }
.breadcrumbs a:hover { color: var(--brand-text); }
.breadcrumbs svg { color: var(--n-300); }

/* ---------- 实体身份色 ----------
   客户页和服务码页结构刻意一致（学一次会两个），所以必须靠颜色和徽章让人一眼分清
   身在哪一层：客户改的是默认值、会波及一批服务码；服务码改的只是它自己。 */
.entity-customer { --entity: var(--brand-text); --entity-bg: var(--brand-bg); --entity-bd: var(--brand-bd); }
.entity-service { --entity: #0B7A72; --entity-bg: #E0F3F0; --entity-bd: #B5E0DA; }
:root[data-theme="dark"] .entity-service { --entity: #4FC9BC; --entity-bg: rgba(79, 201, 188, .13); --entity-bd: rgba(79, 201, 188, .32); }

.page-entity { border-left: 3px solid var(--entity); padding-left: 16px; }
.entity-badge {
    display: inline-block; margin-bottom: 4px; padding: 1px 9px;
    border: 1px solid var(--entity-bd); border-radius: 4px;
    background: var(--entity-bg); color: var(--entity);
    font-size: calc(11.5px * var(--fs)); font-weight: 600; letter-spacing: .04em;
}
.entity-scope {
    display: flex; align-items: flex-start; gap: 8px;
    margin: 12px 0 18px; padding: 9px 12px;
    border: 1px solid var(--entity-bd); border-radius: var(--r);
    background: var(--entity-bg); color: var(--n-800); font-size: calc(13px * var(--fs));
}
.entity-scope svg { flex: none; margin-top: 2px; color: var(--entity); }
.entity-scope b { color: var(--entity); }
/* tab 下划线跟随实体色 */
.entity-customer .tabs .tab.active, .entity-service .tabs .tab.active {
    color: var(--text-strong); border-bottom-color: var(--entity);
}

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 0 0 20px; }
.page-header h1 { font-size: calc(26px * var(--fs)); line-height: calc(32px * var(--fs)); font-weight: 600; letter-spacing: -.015em; color: var(--text-strong); word-break: break-all; }
.page-header .desc { margin-top: 6px; color: var(--text-2); font-size: calc(14px * var(--fs)); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- 提示条 ---------- */
.flash {
    display: flex; align-items: flex-start; gap: 10px;
    margin-bottom: 16px; padding: 10px 12px;
    border: 1px solid; border-radius: var(--r);
    font-size: calc(13px * var(--fs));
}
.flash svg { flex-shrink: 0; margin-top: 2px; }
.flash-text { flex: 1; padding-top: 1px; }
.flash-success { background: var(--ok-bg); border-color: var(--ok-bd); color: var(--ok); }
.flash-error { background: var(--err-bg); border-color: var(--err-bd); color: var(--err); }
.flash-success .flash-text, .flash-error .flash-text { color: var(--n-800); }
.flash-close {
    flex-shrink: 0; padding: 0 2px; border: 0; background: none;
    color: var(--n-400); font-size: calc(16px * var(--fs)); line-height: calc(18px * var(--fs)); cursor: pointer;
}
.flash-close:hover { color: var(--n-700); }

/* 操作结果 Toast（app.js 的 appToast）：固定在视口右上角，成功自动消失、失败常驻 */
.app-toasts {
    position: fixed; top: 16px; right: 16px; z-index: 1000;
    display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none;
}
.app-toast {
    display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; pointer-events: auto;
    border: 1px solid; border-radius: var(--r-md); font-size: calc(13.5px * var(--fs)); background: var(--surface);
    box-shadow: var(--sh-pop);
    animation: app-toast-in .18s ease-out;
}
.app-toast svg { flex-shrink: 0; margin-top: 2px; }
.app-toast-text { flex: 1; padding-top: 1px; color: var(--n-800); overflow-wrap: anywhere; }
.app-toast.is-success { border-color: var(--ok-bd); background: var(--ok-bg); color: var(--ok); }
.app-toast.is-error { border-color: var(--err-bd); background: var(--err-bg); color: var(--err); }
@keyframes app-toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .app-toast { animation: none; } }

/* 卡片组：宽屏下并排，窄屏自动堆叠。只读型页面（概览）用它，避免一列细长条 + 右侧大片留白 */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 16px; align-items: start; }
.card-grid > .box { margin-bottom: 0; }
/* 网格里的卡片自己不留下边距，由网格统一和下面的内容隔开，否则最高的那张会贴住下一块 */
.card-grid { margin-bottom: 16px; }
/* 并排的几张卡等高，底边对齐 */
.card-grid.even { align-items: stretch; }

/* ---------- 容器 ---------- */
.box {
    margin-bottom: 20px; overflow: hidden;
    background: var(--surface);
    border: 1px solid transparent; border-radius: var(--r-lg);
    box-shadow: var(--sh-1);
}
:root[data-theme="dark"] .box { border-color: var(--border); }
.box-header {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
    padding: 20px 24px 16px;
}
.box-header + .box-body, .box-header + .table-tools { padding-top: 0; }
.box-header h1 { font-size: calc(22px * var(--fs)); line-height: calc(28px * var(--fs)); font-weight: 600; letter-spacing: -.015em; color: var(--text-strong); }
.box-header h2 { font-size: calc(17px * var(--fs)); line-height: calc(24px * var(--fs)); font-weight: 600; color: var(--text-strong); }
.counter { color: var(--text-3); font-weight: 400; }
.box-desc { margin-top: 4px; color: var(--text-2); font-size: calc(13px * var(--fs)); line-height: calc(20px * var(--fs)); }
/* 标题区占满剩余宽度，说明和规则表才能铺满整行 */
.box-header > div:first-child { flex: 1; min-width: 0; }
.box-body { padding: 16px 24px 24px; }
.box-footer { padding: 16px 24px; border-top: 1px solid var(--divider); background: var(--surface-2); }
.box-footer h3 { margin-bottom: 12px; font-size: calc(13px * var(--fs)); font-weight: 600; color: var(--n-700); }

/* ---------- 分区：一个 box 内的独立语义块 ---------- */
.section { padding: 20px 24px; border-top: 1px solid var(--divider); }
.section:first-child { border-top: 0; }
.section-head { margin-bottom: 16px; }
.section-head h3 { font-size: calc(15px * var(--fs)); font-weight: 600; letter-spacing: -.005em; }
.section-head .hint { margin-top: 4px; color: var(--n-600); font-size: calc(13px * var(--fs)); line-height: calc(20px * var(--fs)); }
/* 分区的规则说明：一行一条「要点 + 说明」，铺满整行，替代挤在标题下的长段落 */
.section-rules {
    display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px;
    margin: 12px 0 0; padding: 12px 16px;
    background: var(--n-25); border: 1px solid var(--n-100); border-radius: var(--r);
    font-size: calc(13px * var(--fs)); line-height: calc(20px * var(--fs));
}
.section-rules dt { color: var(--n-800); font-weight: 500; }
.section-rules dd { margin: 0; color: var(--n-600); }
.section-actions {
    display: flex; align-items: center; justify-content: flex-end; gap: 8px;
    margin-top: 18px; padding-top: 16px;
    border-top: 1px solid var(--n-100);
}

/* 整个 tab 一个保存按钮：吸底，长表单滚到哪都点得到 */
.save-bar {
    position: sticky; bottom: 12px; z-index: 20;
    display: flex; align-items: center; gap: 12px;
    margin: 4px 0 16px; padding: 12px 16px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(160%) blur(8px);
    -webkit-backdrop-filter: saturate(160%) blur(8px);
    border: 1px solid var(--border); border-radius: var(--r-lg);
    box-shadow: 0 6px 20px rgba(16, 24, 40, .12);
}
.save-bar .save-hint { flex: 1; min-width: 0; color: var(--n-600); font-size: calc(13px * var(--fs)); }
.section > .table-wrap { margin: 0 -24px; }
.section > .table-wrap + .section-actions { margin-top: 0; border-top: 0; padding-top: 16px; }

/* 分区内的说明条 */
.alert-inline {
    display: flex; align-items: flex-start; gap: 8px;
    margin-bottom: 16px; padding: 10px 12px;
    border: 1px solid var(--n-200); border-radius: var(--r);
    background: var(--n-25); color: var(--n-700); font-size: calc(13px * var(--fs));
}
.alert-inline svg { flex-shrink: 0; margin-top: 2px; color: var(--n-400); }
.alert-inline.warn { background: var(--warn-bg); border-color: var(--warn-bd); color: var(--n-800); }
.alert-inline.warn svg { color: var(--warn); }
/* 已删除（软删除）的客户 / 服务码页顶部：说明 + 恢复按钮；手机上按钮换行撑满 */
.deleted-banner { align-items: center; flex-wrap: wrap; }
.deleted-banner > span { flex: 1 1 280px; min-width: 0; }
.deleted-banner form { margin-left: auto; }
@media (max-width: 640px) {
    .deleted-banner form { flex: 1 1 100%; margin-left: 0; }
    .deleted-banner .btn { width: 100%; min-height: 44px; justify-content: center; }
}

/* ---------- 表格 ---------- */
.table-tools {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 12px 16px; padding: 0 24px 16px;
}
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
/* 表格拖动排序（app.js 的 [data-reorder-url]）：行首把手 */
.table .col-drag { width: 28px; padding-right: 0; }
.table .drag-handle { width: 28px; padding-right: 0; color: var(--n-400); cursor: grab; user-select: none; letter-spacing: -3px; }
.table .drag-handle:hover { color: var(--n-700); }
.table tr.dragging { opacity: .45; }
.table tbody.reorder-saving { opacity: .6; pointer-events: none; }
/* 服务码列表多选后的批量操作条（ui.bulk_apply_bar）：勾选了才出现，贴在表格上方，浅色底和表格区分开 */
.bulk-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
    margin: 0 24px 12px; padding: 8px 12px;
    border: 1px solid var(--brand-bd); border-radius: var(--r-md); background: var(--brand-bg);
}
.bulk-bar[hidden] { display: none; }
.bulk-bar .bulk-count { font-size: calc(13px * var(--fs)); color: var(--n-800); }
.bulk-bar .bulk-sep { width: 1px; height: 18px; background: var(--n-200); }
.bulk-bar .bulk-label { font-size: calc(13px * var(--fs)); color: var(--n-600); }
.bulk-bar .bulk-clear { margin-left: auto; }
.table .col-check { width: 32px; padding-right: 0; }

/* 卡片底部并排的几组小表单（服务码模版 tab 的新建 / 从全局复制）：每组字段和按钮一行，组之间竖线隔开 */
.footer-forms { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 32px; }
.footer-form + .footer-form { padding-left: 32px; border-left: 1px solid var(--n-200); }
.inline-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.inline-fields .field { width: 170px; }
.inline-fields .field.wide { width: 230px; }
.inline-fields .field select, .inline-fields .field input { width: 100%; }
.search { position: relative; width: 300px; max-width: 100%; }
.search svg { position: absolute; left: 10px; top: 8px; color: var(--n-400); pointer-events: none; }
.search input[type="search"] { padding-left: 32px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table { font-variant-numeric: tabular-nums; }
.table th {
    padding: 10px 12px; text-align: left; white-space: nowrap; vertical-align: bottom;
    font-size: calc(13px * var(--fs)); font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--border-strong);
}
.table th.sortable a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.table th.sortable a:hover { color: var(--brand-text); }
.table th.sortable .sort-mark { font-size: calc(9px * var(--fs)); color: var(--text-3); min-width: 9px; }
.table th.num.sortable a { flex-direction: row-reverse; }
.table td { padding: 12px; vertical-align: middle; border-bottom: 1px solid var(--divider); white-space: nowrap; max-width: 36em; overflow: hidden; text-overflow: ellipsis; }
/* 表格单元格一律不折行：超出 36em 的文字省略（电脑悬停显示全文，触屏点一下展开，见 app.js 的 table-cell-expand）；
   整句说明（失败原因、备注、指南）显式加 .cell-wrap 才允许折行。 */
.table td.cell-wrap, .table .cell-wrap, .guide-table td, .sql-cell { white-space: normal; overflow-wrap: anywhere; }
.table td.cell-open { white-space: normal; overflow-wrap: anywhere; max-width: none; }
.table td.col-actions, .table td.num, .table td.col-check, .table td.col-drag { max-width: none; overflow: visible; }
.table th:first-child, .table td:first-child { padding-left: 24px; }
.table th:last-child, .table td:last-child { padding-right: 24px; }
.table tbody tr:hover td { background: var(--surface-2); }
/* 行里的实体名（客户、服务码、节点…）加粗 */
.table td a:not(.btn):not(.icon-btn):not(.muted):not(.menu-item) { font-weight: 600; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.empty-row:hover td { background: transparent; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.col-actions { text-align: right; white-space: nowrap; }
.table .mono { white-space: nowrap; }
/* 数字、流量（「1.2 GB」中间有空格）不拆行 */
.table .num { white-space: nowrap; }
/* 分组表（在线客户端按服务码）：每组一个 tbody，组头一行横跨整表 */
.table tr.group-row th {
    padding-top: 7px; padding-bottom: 7px; white-space: normal;
    font-size: calc(12.5px * var(--fs)); font-weight: 500; letter-spacing: 0; color: var(--text-soft); background: var(--surface-2); border-bottom-width: 1px;
}
.sort-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: calc(12.5px * var(--fs)); }
.sort-links a.active { font-weight: 600; }
/* 简单列表：每格一行不折（节点名「lax-sdn-pop-1」按连字符也会被拆），多出来的宽度全给 .cell-flex 那一列（长文本省略号，悬停看全文），
   不再按文字多少把空白匀给每一列；窄屏整表横向滚动 */
.table-fit td { white-space: nowrap; }
/* 失败原因是整句话：固定 260px 宽、在里面折行，否则会被挤成一字一行 */
.table-fit .log-detail { white-space: normal; width: 260px; }
.table-fit .cell-flex { width: 100%; min-width: 200px; max-width: 0; overflow: hidden; text-overflow: ellipsis; }
.table-fit .cell-clip { max-width: 22em; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1180px) { .table-fit th, .table-fit td { padding-left: 8px; padding-right: 8px; } .table-fit th:first-child, .table-fit td:first-child { padding-left: 14px; } .table-fit th:last-child, .table-fit td:last-child { padding-right: 14px; } }

/* ---------- 空状态 ---------- */
.empty-state { padding: 40px 20px; text-align: center; color: var(--n-600); }
.empty-state .empty-icon {
    width: 36px; height: 36px; margin: 0 auto 12px;
    display: grid; place-items: center;
    border-radius: 50%; background: var(--hover); color: var(--text-3);
}
.empty-state b { display: block; margin-bottom: 4px; color: var(--n-800); font-size: calc(14px * var(--fs)); font-weight: 600; }
.empty-state p { font-size: calc(13px * var(--fs)); max-width: 46ch; margin: 0 auto; }
.empty-state .actions { justify-content: center; margin-top: 16px; }

/* ---------- 继承（跟随客户） ---------- */
.inherit-chip {
    display: flex; align-items: flex-start; gap: 7px;
    margin-top: 6px; padding: 6px 9px;
    border: 1px solid var(--n-200); border-radius: var(--r);
    background: var(--n-25);
    font-size: calc(12px * var(--fs)); line-height: calc(16px * var(--fs)); color: var(--n-700);
    cursor: pointer;
}
.inherit-chip:hover { border-color: var(--n-300); }
.inherit-chip input { flex-shrink: 0; width: 13px; height: 13px; margin: 1px 0 0; accent-color: var(--brand-600); cursor: pointer; }
.inherit-chip b { font-weight: 600; }
.inherit-chip small { display: block; margin-top: 1px; color: var(--n-400); }
.inherit-tag {
    display: inline-block; margin-left: 6px; padding: 0 6px;
    border: 1px solid var(--n-200); border-radius: 10px;
    background: var(--n-25); color: var(--n-600);
    font-size: calc(11px * var(--fs)); line-height: calc(17px * var(--fs)); font-weight: 500; white-space: nowrap;
}

/* ---------- 页内 tab ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1.5px solid var(--border); }
.tabs .tab {
    padding: 11px 12px; margin-bottom: -1.5px;
    color: var(--text-2); font-size: calc(14.5px * var(--fs)); font-weight: 500;
    border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs .tab:hover { color: var(--text); text-decoration: none; }
.tabs .tab.active { color: var(--text-strong); border-bottom-color: var(--brand); font-weight: 600; }
@media (max-width: 960px) { .tabs { overflow-x: auto; } }

/* 二级导航：分段控件样式，和一级 tab 的下划线明显不同层 */
.subtabs {
    display: flex; flex-wrap: wrap; gap: 3px;
    margin: -4px 0 18px; padding: 3px;
    width: fit-content; max-width: 100%;
    background: var(--neutral-bg); border-radius: var(--r-md);
}
.subtabs .subtab {
    padding: 6px 14px; border-radius: var(--r);
    color: var(--text-2); font-size: calc(13.5px * var(--fs)); font-weight: 500; white-space: nowrap;
}
.subtabs .subtab:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.subtabs .subtab.active {
    background: var(--surface); color: var(--text-strong);
    font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, .12);
}
@media (max-width: 960px) { .subtabs { overflow-x: auto; flex-wrap: nowrap; } }

/* ---------- 分页 ---------- */
.pagination { display: flex; align-items: center; gap: 2px; }
.pagination a, .pagination span {
    min-width: 28px; height: 28px; padding: 0 7px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--r-sm); color: var(--n-700); font-size: calc(13px * var(--fs));
}
.pagination a:hover { background: var(--n-50); color: var(--n-900); text-decoration: none; }
.pagination .active { background: var(--brand-bg); color: var(--brand-text); font-weight: 600; }
.pagination .gap { color: var(--n-400); }
.pagination .nav { font-size: calc(15px * var(--fs)); }
.pagination .disabled { color: var(--n-300); }
.pagination .pg-total { display: none; color: var(--n-600); }
/* 表格下面再放一份分页条：长表看到底不用回到顶上翻页 */
.table-tools-bottom { justify-content: flex-end; padding-top: 14px; padding-bottom: 14px; border-top: 1px solid var(--n-100); }
/* 触屏（手机、平板）：28px 的按钮手指点不准，放大到 44px 的触控区，间距拉开 */
@media (pointer: coarse), (max-width: 960px) {
    .pagination { gap: 6px; }
    .pagination a, .pagination span { min-width: 40px; height: 40px; padding: 0 10px; font-size: calc(15px * var(--fs)); border-radius: var(--r); }
    .pagination a { border: 1px solid var(--n-200); background: var(--n-0); }
    .pagination .gap { min-width: 24px; border: 0; }
    .pagination .nav { font-size: calc(22px * var(--fs)); }
    .pagination .disabled { border: 1px solid var(--n-100); background: var(--n-25); }
    .pagination .active { border-color: var(--brand-100); }
}
/* 手机：页码按钮放不下，只留「‹ 当前页 / 总页数 ›」 */
@media (max-width: 640px) {
    .pagination a:not(.nav):not(.active), .pagination .gap { display: none; }
    .pagination .pg-total { display: inline-flex; min-width: 0; padding: 0 4px 0 0; }
    .pagination .active { min-width: 0; border: 0; background: none; padding-right: 2px; font-size: calc(16px * var(--fs)); }
    .table-tools-bottom { justify-content: center; }
}

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 36px; padding: 6px 14px;
    border: 1.5px solid var(--border-strong); border-radius: var(--r);
    background: var(--surface); color: var(--text);
    font: 600 calc(14px * var(--fs))/calc(20px * var(--fs)) var(--font); white-space: nowrap;
    cursor: pointer; text-decoration: none;
    transition: background-color var(--dur), border-color var(--dur), color var(--dur);
}
.btn:hover { background: var(--hover); border-color: var(--text-3); color: var(--text-strong); text-decoration: none; }
.btn:active { background: var(--selected); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn .icon { width: 15px; height: 15px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn-primary:active { background: var(--brand-hover); }
:root[data-theme="dark"] .btn-primary:hover { background: #3B7BE0; border-color: #3B7BE0; }
.btn-danger { color: var(--err); border-color: var(--err-bd); }
.btn-danger:hover { background: var(--err-bg); border-color: var(--err); color: var(--err); }
.btn-danger.solid { background: var(--err-ic); border-color: var(--err-ic); color: #fff; }
.btn-danger.solid:hover { background: var(--err-hover); border-color: var(--err-hover); color: #fff; }
.btn-link { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-2); }
.btn-link:hover { border-color: transparent; background: var(--hover); }
.btn-sm { min-height: 30px; padding: 4px 11px; font-size: calc(13px * var(--fs)); }
.link-btn { padding: 0; border: 0; background: none; font: inherit; color: var(--brand-text); cursor: pointer; }
.link-btn:hover { color: var(--brand-hover); text-decoration: underline; }
.link-btn.danger { color: var(--err); }
.link-btn.danger:hover { color: var(--err-hover); }
.row-actions { display: inline-flex; align-items: flex-start; gap: 2px; }
/* 行操作里把删除和其它按钮隔开一点，免得误点 */
.row-actions-gap { width: 12px; }
/* 列表行操作：28px 方形图标按钮，平时灰、悬停染色；删除类悬停变红 */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--r);
    background: transparent; color: var(--n-400); cursor: pointer;
    transition: background-color .12s, color .12s;
}
.icon-btn .icon { width: 16px; height: 16px; }
.icon-btn:hover, .inline-popover[open] > .icon-btn { background: var(--brand-bg); color: var(--brand-text); }
.icon-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.icon-btn.danger:hover { background: var(--err-bg); color: var(--err); }
.icon-btn.ok:hover { background: var(--ok-bg); color: var(--ok); }
.icon-btn.warn:hover { background: var(--warn-bg); color: var(--warn); }
.inline-form { display: inline; margin: 0; }

/* ---------- 表单 ---------- */
input[type="text"], input[type="email"], input[type="number"], input[type="password"], input[type="search"], input[type="datetime-local"],
select, textarea {
    width: 100%; min-height: 36px; padding: 6px 10px;
    border: 1.5px solid var(--border-strong); border-radius: var(--r);
    background: var(--surface); color: var(--text);
    font: calc(14px * var(--fs))/calc(20px * var(--fs)) var(--font);
}
textarea { min-height: 76px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--focus);
}
input:disabled, select:disabled, textarea:disabled {
    background: var(--surface-2); color: var(--text-3); cursor: not-allowed; border-color: var(--border);
}
select {
    appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
    background: var(--surface) var(--select-arrow) no-repeat right 9px center;
}
select[multiple] { padding: 4px; background-image: none; cursor: default; }
.mono, .mono-input { font-family: var(--mono); font-size: calc(13px * var(--fs)); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; gap: 18px 20px; }
.form-grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
/* 固定三列：上下几个网格字段数不同也能列对齐（auto-fit 会把少的那排拉满） */
.form-grid.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-full { grid-column: 1 / -1; }
.field { min-width: 0; }
.field-head { margin-bottom: 6px; }
.field-label { display: block; font-size: calc(13.5px * var(--fs)); font-weight: 600; color: var(--text); }
.field-label .optional { color: var(--n-400); font-weight: 400; }
.field-label + input { margin-top: 6px; }  /* 不走 ui.field 宏的简单表单（登录页） */
.field-desc { margin-top: 2px; color: var(--text-2); font-size: calc(12.5px * var(--fs)); line-height: calc(17px * var(--fs)); }
/* 每个字段占两行轨道：标题区（标签 + 说明）一行、控件区一行，用 subgrid 共享父网格的轨道。
   同一行里标题区按最高的那个对齐，有没有说明、控件下面有没有补充内容，输入框都落在同一条水平线上。
   非 .field 的子项（复选框、操作条等）也占两行，保证字段始终从奇数行开始、配对不乱。 */
.form-grid > *, .form-row > * { grid-row: span 2; }
.form-grid > .field, .form-row > .field { display: grid; grid-template-rows: subgrid; row-gap: 0; }

/* 属性卡片：每个属性单独一张卡，标题、说明、控件、「跟随客户」都收在卡里，不和相邻属性挤在一起 */
.form-grid.attr-cards { gap: 16px; align-items: stretch; }
.attr-cards > .field {
    padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface);
}
.attr-cards > .field .field-head { margin-bottom: 10px; }
.attr-cards > .field .field-body { display: flex; flex-direction: column; }
.attr-cards > .field .field-body > .inherit-chip { margin-top: auto; }
.attr-cards > .field .field-body > :not(.inherit-chip) { margin-bottom: 10px; }
.attr-cards .inherit-chip {
    margin: 0 -16px -14px; padding: 9px 16px;
    border: 0; border-top: 1px solid var(--n-100); border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* 操作卡片：几个互不相关的动作各占一张卡，危险操作用红色描边区分 */
.action-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.action-card {
    display: flex; flex-direction: column; gap: 12px;
    padding: 16px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface);
}
.action-card h4 { margin: 0; font-size: calc(14px * var(--fs)); font-weight: 600; color: var(--n-800); }
.action-card p { margin: 4px 0 0; color: var(--n-600); font-size: calc(12px * var(--fs)); line-height: calc(18px * var(--fs)); }
.action-card .action-card-body { flex: 1; }
.action-card .action-row { display: flex; gap: 8px; align-items: center; }
.action-card .action-row select { flex: 1; min-width: 0; }
.action-card .action-row .btn { flex-shrink: 0; }
.action-card.danger { border-color: var(--err-bd); background: linear-gradient(var(--err-bg), var(--surface) 60%); }
.action-card.danger h4 { color: var(--err); }

/* 添加规则一类的多字段行：网格排布，取代原先的一行横排。输入框对齐见上面 .field 的 subgrid。 */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px 20px; align-items: start; }
.form-row .narrow { grid-column: span 1; max-width: 120px; }
.form-row .span-2 { grid-column: span 2; }
.form-row .span-full { grid-column: 1 / -1; }
.form-row-actions {
    grid-column: 1 / -1;
    display: flex; align-items: center; gap: 14px;
    margin-top: 2px; padding-top: 14px; border-top: 1px solid var(--n-100);
}
.form-row-actions .btn { margin-left: auto; }

/* 规则卡片：一条规则一张卡，从属设置直接嵌在开关下面，不跟别的规则混在一起 */
.rule-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.rule-card {
    padding: 14px 16px;
    border: 1px solid var(--n-200); border-radius: var(--r);
    background: var(--n-0);
}
.rule-card.wide { grid-column: 1 / -1; }
.rule-card > .checkbox b { font-size: calc(13.5px * var(--fs)); }
.rule-body {
    margin: 12px 0 0 22px; padding-top: 12px;
    border-top: 1px dashed var(--n-200);
    display: grid; gap: 14px;
}
.rule-body.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* 客户可用节点下的授权出口 IP（customers/_node_picker.html）：一个节点可能有几百个 IP，默认收起 */
.ip-pickers { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--n-100); display: grid; gap: 10px; }
.ip-pickers-head b { display: block; font-size: calc(13px * var(--fs)); }
.ip-pickers-head small { color: var(--n-600); font-size: calc(12px * var(--fs)); }
.ip-picker { border: 1px solid var(--n-200); border-radius: var(--r); background: var(--n-0); }
.ip-picker > summary {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 10px 14px; cursor: pointer; list-style: none; font-size: calc(13px * var(--fs));
}
.ip-picker > summary::-webkit-details-marker { display: none; }
.ip-picker > summary:hover { background: var(--n-25); }
.ip-picker-title { min-width: 200px; }
.ip-picker-count {
    padding: 1px 8px; border-radius: 999px; font-size: calc(12px * var(--fs));
    background: var(--brand-50); color: var(--brand-700); white-space: nowrap;
}
.ip-picker-preview { flex: 1; min-width: 0; font-size: calc(12px * var(--fs)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ip-picker-toggle { margin-left: auto; color: var(--brand-600); font-size: calc(12px * var(--fs)); }
.ip-picker[open] .ip-picker-toggle { color: var(--n-600); }
.ip-picker[open] .ip-picker-toggle::before { content: "收起 · "; }
.ip-picker-body { padding: 12px 14px 14px; border-top: 1px dashed var(--n-200); }
.ip-picker-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.ip-picker-tools input[type="search"] { flex: 0 1 260px; }
.ip-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 12px;
    max-height: 320px; overflow-y: auto; padding: 4px;
    border: 1px solid var(--n-100); border-radius: var(--r); background: var(--n-25);
}
.ip-opt { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 4px; font-size: calc(12.5px * var(--fs)); cursor: pointer; }
.ip-opt:hover { background: var(--n-50); }
.ip-opt[hidden] { display: none; }
.ip-opt input { width: 13px; height: 13px; margin: 0; accent-color: var(--brand-600); }
.ip-opt:has(input:checked) { color: var(--brand-700); font-weight: 600; }

/* 平台之类的小集合多选：全部平铺，不用滚动的 select multiple */
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 11px;
    border: 1px solid var(--n-300); border-radius: 999px;
    background: var(--n-0); color: var(--n-700);
    font-size: calc(13px * var(--fs)); cursor: pointer; user-select: none;
}
.choice:hover { border-color: var(--n-400); background: var(--n-25); }
.choice input { width: 13px; height: 13px; margin: 0; accent-color: var(--brand-600); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-700); font-weight: 500; }
.choice:has(input:disabled) { opacity: .55; cursor: not-allowed; }

/* ---------- 搜索多选（ui.multi_picker）：数据集、资源包这类可能很多的选项 ---------- */
.picker { position: relative; }
/* 没有脚本时：就是一个可滚动的勾选列表 */
.picker-panel {
    max-height: 240px; overflow-y: auto; padding: 4px;
    border: 1px solid var(--n-300); border-radius: var(--r); background: var(--n-0);
}
.picker-group { padding: 8px 8px 4px; color: var(--n-600); font-size: calc(12px * var(--fs)); font-weight: 600; }
.picker-option {
    display: flex; align-items: center; gap: 8px; padding: 5px 8px;
    border-radius: 4px; font-size: calc(13px * var(--fs)); cursor: pointer;
}
.picker-option:hover, .picker-option.is-active { background: var(--n-50); }
.picker-option input { width: 13px; height: 13px; margin: 0; flex: none; accent-color: var(--brand-600); }
.picker-option:has(input:checked) { color: var(--brand-700); }
.picker-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-value { margin-left: auto; color: var(--n-400); font: calc(12px * var(--fs)) var(--mono); }
.picker-empty { padding: 8px; color: var(--n-600); font-size: calc(13px * var(--fs)); }
/* 有脚本时：上面一个像输入框的控件（已选标签 + 搜索框），列表变成弹出层 */
.picker-control {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
    min-height: 32px; padding: 3px 6px;
    border: 1px solid var(--n-300); border-radius: var(--r); background: var(--n-0); cursor: text;
}
.picker-control:hover { border-color: var(--n-400); }
.picker.is-open .picker-control, .picker-control:focus-within { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }
.picker:has(.picker-option input:disabled) .picker-control { background: var(--n-50); color: var(--n-400); cursor: not-allowed; box-shadow: none; border-color: var(--n-200); }
.picker-chip {
    display: inline-flex; align-items: center; gap: 2px; max-width: 100%;
    padding: 1px 2px 1px 8px; border-radius: 4px;
    background: var(--brand-50); color: var(--brand-700); font-size: calc(12.5px * var(--fs)); line-height: calc(20px * var(--fs));
}
.picker-chip button {
    width: 18px; height: 18px; padding: 0; border: 0; border-radius: 3px;
    background: none; color: inherit; font-size: calc(14px * var(--fs)); line-height: 1; cursor: pointer;
}
.picker-chip button:hover { background: var(--brand-100); }
.picker-control input.picker-search {
    flex: 1 0 120px; width: auto; min-height: 24px; padding: 0 4px;
    border: 0; box-shadow: none; background: none;
}
/* 弹出层用 fixed 定位（位置由脚本按控件算）：.box 有 overflow: hidden，absolute 会被卡片裁掉 */
.picker.is-enhanced .picker-panel {
    position: fixed; z-index: 50;
    box-shadow: var(--sh-2);
}
.picker.is-enhanced:not(.is-open) .picker-panel { display: none; }

/* ---------- 客户选择（ui.customer_picker）：服务端搜索的单选 ---------- */
.combo { position: relative; }
.combo-panel { position: fixed; z-index: 50; box-shadow: var(--sh-2); }
.combo-panel .picker-option { cursor: pointer; }

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px 20px; }
.checkbox { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.checkbox input { flex-shrink: 0; width: 14px; height: 14px; margin: 3px 0 0; accent-color: var(--brand-600); cursor: pointer; }
.checkbox b { display: block; font-size: calc(13px * var(--fs)); font-weight: 600; }
.checkbox small { display: block; color: var(--n-600); font-size: calc(12px * var(--fs)); line-height: calc(16px * var(--fs)); }

.inline-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.inline-fields .field { flex: 1 1 160px; }
.inline-fields .field.narrow { flex: 0 0 96px; }
.inline-fields .field.narrow-select { flex: 0 0 220px; }
.inline-fields .field.w-md { flex: 0 1 320px; }
.inline-fields .checkbox { padding-bottom: 6px; }

.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-bottom: 16px; }
.box-footer .form-actions, .section-actions .form-actions { margin: 0; }

/* ---------- 键值对 ---------- */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px 28px; margin: 0; }
.kv-grid > div { min-width: 0; }
.kv-grid dt { margin-bottom: 3px; font-size: calc(12px * var(--fs)); font-weight: 500; color: var(--n-600); }
.kv-grid dd { margin: 0; font-size: calc(13.5px * var(--fs)); color: var(--n-800); word-break: break-all; }
.kv-grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.kv-grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ---------- 状态 / 徽标 ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: calc(13.5px * var(--fs)); font-weight: 500; white-space: nowrap; color: var(--text); }
.status::before {
    content: ""; flex: none; width: 15px; height: 15px; border-radius: 50%;
    background: var(--neutral-ic) no-repeat center / 11px 11px;
}
.status-success::before { background-color: var(--ok-ic); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E"); }
.status-warn::before { background-color: var(--warn-ic); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M12 6v7.5M12 18h.01'/%3E%3C/svg%3E"); }
.status-error::before { background-color: var(--err-ic); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M7.5 7.5l9 9M16.5 7.5l-9 9'/%3E%3C/svg%3E"); }
.status-stopped { color: var(--text-2); }
.status-stopped::before { background-color: var(--neutral-ic); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M7 12h10'/%3E%3C/svg%3E"); }
/* 带底色的状态胶囊（汇总处用） */
.status.pill { height: 24px; padding: 0 9px 0 4px; border-radius: 999px; background: var(--neutral-bg); font-size: calc(13px * var(--fs)); font-weight: 600; }
.status-success.pill { background: var(--ok-bg); color: var(--ok); }
.status-warn.pill { background: var(--warn-bg); color: var(--warn); }
.status-error.pill { background: var(--err-bg); color: var(--err); }
.badge {
    display: inline-block; padding: 0 8px;
    border: 0; border-radius: 999px;
    background: var(--neutral-bg); color: var(--text-2);
    font-size: calc(12px * var(--fs)); font-weight: 600; line-height: calc(20px * var(--fs)); white-space: nowrap;
}
.badge-online { display: inline-flex; align-items: center; gap: 5px; background: var(--ok-bg); color: var(--ok); margin-left: 4px; }
.badge-online::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok-ic); }
.badge-blue { background: var(--brand-bg); color: var(--brand-text); }
/* 已签约客户的标记（宏 ui.vip_badge）：黄底标记名；列表标记列里和普通标记对齐，详情页跟在标题客户名后面 */
.badge-vip { border: 1px solid var(--warn-bd); background: var(--warn-bg); color: var(--warn); line-height: calc(18px * var(--fs)); }
.page-header h1 .badge-vip { margin-left: 10px; position: relative; top: -3px; vertical-align: middle; word-break: normal; }
/* 客户列表名称列：名称过长时省略 */
.cust-name-line { display: flex; align-items: center; min-width: 0; }
.cust-name-line > .row-link { min-width: 0; }
.muted { color: var(--text-3); }
/* IP 后面的归属地（宏 ui.ip），用正文字体、灰色 */
.ip-geo { font-family: var(--font); font-size: calc(12px * var(--fs)); color: var(--text-3); white-space: nowrap; }

/* ---------- 仪表盘 ---------- */
/* 指标卡下限 160px：iPad 横屏主区域只有 700px 宽，4 张卡要能排成一行；手机 2 列，窄到放不下 2 张才单列 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat {
    padding: 18px 20px;
    background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg);
    box-shadow: var(--sh-1); color: var(--text);
}
:root[data-theme="dark"] .stat { border-color: var(--border); }
a.stat:hover { border-color: var(--border-strong); text-decoration: none; }
a.stat .stat-label { color: var(--brand-text); }
.stat-label { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-size: calc(14px * var(--fs)); font-weight: 600; }
.stat-label .icon { color: var(--text-3); }
.stat-value { margin-top: 8px; font-size: calc(28px * var(--fs)); line-height: calc(34px * var(--fs)); font-weight: 600; letter-spacing: -.02em; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.stat-sub { margin-top: 4px; color: var(--text-2); font-size: calc(12.5px * var(--fs)); }
/* 服务码概览：状态、到期时间这类文字值用小一号，不然一行放不下 */
.stat-value.sm { font-size: calc(20px * var(--fs)); line-height: calc(34px * var(--fs)); font-weight: 600; letter-spacing: -.01em; }
.stat-unit { font-size: calc(14px * var(--fs)); font-weight: 500; color: var(--text-2); letter-spacing: 0; }
.dash-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; align-items: start; }
.dash-cols .box { margin-bottom: 0; }

.quick-links { display: flex; flex-wrap: wrap; gap: 8px; }

/* 用量进度条 */
.meter { height: 6px; border-radius: 3px; background: var(--neutral-bg); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 3px; background: var(--brand); }
.meter.warn > span, .meter-warn > span { background: var(--warn-ic); }
.meter.over > span, .meter-err > span { background: var(--err-ic); }


/* 页头 actions 里的内联表单：下拉不撑满整行 */
.action-inline { display: inline-flex; align-items: center; gap: 8px; }
.select-inline { width: auto; min-width: 110px; }

/* ---------- 下发配置预览 ---------- */
.config-json {
    max-height: 70vh; margin: 0; padding: 14px 16px; overflow: auto;
    border: 1px solid var(--n-200); border-radius: var(--r);
    background: var(--n-25); color: var(--n-800);
    font: calc(12.5px * var(--fs))/1.6 var(--mono);
    /* 配置里有很长的域名列表，允许折行，否则只能一路横拉 */
    white-space: pre-wrap; word-break: break-all;
    tab-size: 4;
}

/* ---------- 设备使用说明 ---------- */
.guide-scope { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.guide-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 32px; align-items: start; }
/* 目录全部展开、自己不滚动：跟正文一起滚，翻下去后用右下角的「返回目录」回来 */
.guide-toc {
    align-self: start;
    display: grid; gap: 1px; padding-right: 12px; border-right: 1px solid var(--n-100); font-size: calc(13px * var(--fs));
}
/* 返回目录：往下翻过一屏后出现在右下角 */
.guide-totop {
    position: fixed; right: 24px; bottom: 24px; z-index: 20; display: none;
    padding: 8px 14px; border: 1px solid var(--n-200); border-radius: 999px; background: var(--n-0);
    box-shadow: var(--sh-2); color: var(--n-700); font-size: calc(13px * var(--fs)); text-decoration: none;
}
.guide-totop.show { display: inline-block; }
.guide-totop:hover { color: var(--brand-600); border-color: var(--brand-600); }
.guide-toc-title { margin-bottom: 6px; color: var(--n-400); font-size: calc(12px * var(--fs)); font-weight: 600; letter-spacing: .04em; }
.guide-toc a { display: block; padding: 3px 8px; border-radius: var(--r); color: var(--n-700); text-decoration: none; }
.guide-toc a:hover { background: var(--n-50); color: var(--brand-600); }
.guide-toc-ch { margin-top: 6px; font-weight: 600; }
.guide-toc-ch span { display: inline-block; min-width: 26px; color: var(--n-400); font-weight: 500; }
.guide-toc-sub { padding-left: 34px !important; color: var(--n-600) !important; font-size: calc(12.5px * var(--fs)); }
.guide { max-width: 960px; min-width: 0; }
.guide-chapter {
    display: flex; align-items: baseline; gap: 10px;
    margin: 40px 0 6px; padding-bottom: 8px; border-bottom: 1px solid var(--n-200);
    font-size: calc(18px * var(--fs)); scroll-margin-top: 16px;
}
.guide > .guide-chapter:first-child { margin-top: 0; }
.guide-no { color: var(--brand-600); font-size: calc(14px * var(--fs)); font-weight: 600; }
.guide-lead { margin: 0 0 14px !important; color: var(--n-600); font-size: calc(13.5px * var(--fs)) !important; line-height: 1.6; }
.guide h3 { margin: 22px 0 8px; font-size: calc(14.5px * var(--fs)); color: var(--n-900); scroll-margin-top: 16px; }
.guide h4 { margin: 16px 0 6px; font-size: calc(13px * var(--fs)); color: var(--n-800); }
.guide p { margin: 0 0 8px; color: var(--n-600); font-size: calc(13px * var(--fs)); line-height: 1.6; }
.guide .alert-inline { margin: 8px 0 12px; }
.guide .table-wrap { margin-bottom: 12px; }
.guide-table td { vertical-align: top; font-size: calc(13px * var(--fs)); line-height: 1.55; }
.guide-table td.mono, .guide-table .mono { white-space: normal; overflow-wrap: anywhere; }
.guide-table td .guide-cmd { margin: 0; }
.guide-table td .guide-cmd + .guide-cmd { margin-top: 6px; }
.guide-def { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--n-50); color: var(--n-700); font: calc(12px * var(--fs))/calc(18px * var(--fs)) var(--mono); }
.guide-tag {
    display: inline-block; padding: 0 8px; border: 1px solid var(--n-200); border-radius: 10px;
    background: var(--n-25); color: var(--n-600); font-size: calc(12px * var(--fs)); line-height: calc(20px * var(--fs)); white-space: nowrap;
}
.guide-tag.ro { border-color: var(--n-200); color: var(--n-600); }
.guide-tag.wr { border-color: var(--brand-600); color: var(--brand-600); }
.guide-tag.go { border-color: var(--err); color: var(--err); }
.guide-list { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 4px; color: var(--n-700); font-size: calc(13px * var(--fs)); line-height: 1.6; }
/* 步骤卡片：横排，窄屏和 -v 变竖排 */
.guide-steps {
    counter-reset: step; list-style: none; margin: 0 0 14px; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px;
}
.guide-steps > li {
    counter-increment: step; position: relative; padding: 12px 14px 12px 46px;
    border: 1px solid var(--n-200); border-radius: var(--r); background: var(--n-0);
    display: grid; gap: 4px; align-content: start;
}
.guide-steps > li::before {
    content: counter(step); position: absolute; left: 14px; top: 12px;
    width: 22px; height: 22px; border-radius: 50%; background: var(--brand-600); color: #fff;
    font-size: calc(12px * var(--fs)); font-weight: 600; line-height: calc(22px * var(--fs)); text-align: center;
}
.guide-steps > li > b { color: var(--n-900); font-size: calc(13.5px * var(--fs)); }
.guide-steps > li > span { color: var(--n-600); font-size: calc(12.5px * var(--fs)); line-height: 1.6; overflow-wrap: anywhere; }
.guide-steps-v { grid-template-columns: 1fr; }
.guide-steps-v .guide-cmd { margin: 6px 0 0; }
/* apply 流程：带箭头的横排四步 */
.guide-flow { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px; }
.guide-flow > li {
    position: relative; padding: 10px 12px; border: 1px solid var(--n-200); border-top: 3px solid var(--brand-600);
    border-radius: var(--r); background: var(--n-25); display: grid; gap: 4px; align-content: start;
}
.guide-flow > li + li::before { content: "→"; position: absolute; left: -18px; top: 50%; transform: translateY(-50%); color: var(--n-400); }
.guide-flow > li > b { font-size: calc(13px * var(--fs)); color: var(--n-900); }
.guide-flow > li > span { font-size: calc(12.5px * var(--fs)); color: var(--n-600); line-height: 1.55; overflow-wrap: anywhere; }
.guide-cmd { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.guide-cmd pre {
    flex: 1; min-width: 0; margin: 0; padding: 9px 12px; overflow-x: auto;
    border: 1px solid var(--n-200); border-radius: var(--r); background: var(--n-25); color: var(--n-800);
    font: calc(12.5px * var(--fs))/1.6 var(--mono); white-space: pre-wrap; word-break: break-all;
}
@media (max-width: 960px) {
    .guide-layout { grid-template-columns: 1fr; gap: 16px; }
    .guide-toc {
        position: static; max-height: none; display: flex; flex-wrap: wrap; gap: 4px 6px;
        padding: 0 0 12px; border-right: 0; border-bottom: 1px solid var(--n-100);
    }
    .guide-toc-title, .guide-toc-sub { display: none !important; }
    .guide-totop { right: 16px; bottom: 16px; }
    .guide-toc-ch { margin-top: 0; }
    .guide-flow { grid-template-columns: 1fr; gap: 18px; }
    .guide-flow > li + li::before { content: "↓"; left: 50%; top: -16px; transform: translateX(-50%); }
}
/* 手机：手册里的表格改成一行一张卡片，第一格当标题，其余每格一行、前面用小字标列名（data-label 由 guide.html 的脚本按表头填） */
@media (max-width: 760px) {
    .guide .table-wrap { overflow-x: visible; }
    .guide-table, .guide-table tbody, .guide-table tr, .guide-table td { display: block; width: auto !important; }
    .guide-table thead { display: none; }
    .guide-table tr { padding: 10px 0; border-bottom: 1px solid var(--n-100); }
    .guide-table tbody tr:last-child { border-bottom: 0; }
    .guide-table td, .table.guide-table td:first-child, .table.guide-table td:last-child { padding: 2px 4px; border: 0; max-width: none; }
    .guide-table td:first-child { color: var(--n-900); font-weight: 600; }
    .guide-table td[data-label]:not(:first-child)::before {
        content: attr(data-label); display: block; color: var(--n-400); font-size: calc(11.5px * var(--fs)); font-weight: 400;
    }
    .guide-table tbody tr:hover td { background: transparent; }
}

/* ---------- 登录页 ---------- */
.login-wrap { display: flex; justify-content: center; padding: 80px 16px; }
.login-box { width: 100%; max-width: 380px; }
.login-form { display: grid; gap: 16px; }
.login-submit { width: 100%; margin-top: 4px; }
.login-box .flash { margin-bottom: 16px; }

/* ---------- 操作日志 ---------- */
.log-detail { margin-top: 2px; color: var(--err); font-size: calc(12px * var(--fs)); line-height: calc(16px * var(--fs)); max-width: 320px; }
.log-params summary { color: var(--brand-600); cursor: pointer; font-size: calc(13px * var(--fs)); }
.log-params pre {
    max-width: 420px; max-height: 240px; margin: 6px 0 0; padding: 8px 10px; overflow: auto;
    border: 1px solid var(--n-200); border-radius: var(--r); background: var(--n-25);
    font: calc(12px * var(--fs))/calc(16px * var(--fs)) var(--mono); white-space: pre-wrap; word-break: break-all;
}

/* 不用 flex 布局：iOS Safari 里 auto 高度 + max-height 的 flex 列容器会把 flex:1 的 pre 压成 0 高，只剩标题栏 */
.params-dialog {
    width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 48px); padding: 0; overflow: hidden;
    border: 1px solid var(--n-200); border-radius: var(--r-lg); background: var(--surface); color: var(--text);
    box-shadow: var(--sh-pop);
}
.params-dialog::backdrop { background: var(--overlay); }
.params-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--n-100); }
.params-dialog-title { min-width: 0; font-size: calc(15px * var(--fs)); font-weight: 600; overflow-wrap: anywhere; }
.params-dialog-head .btn { flex: none; min-height: 36px; padding: 0 16px; }
.params-dialog-body {
    margin: 0; padding: 14px 18px 18px; overflow: auto; max-height: calc(100vh - 48px - 64px);
    font: calc(14px * var(--fs))/calc(22px * var(--fs)) var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; background: var(--n-25);
}

/* ---------- 窄屏 ---------- */
@media (max-width: 960px) {
    /* 侧边栏收成抽屉：默认滑出屏幕，点顶栏汉堡推进来，点遮罩或任意链接（会跳页）关掉 */
    .nav-burger {
        display: grid; place-items: center;
        width: 36px; height: 36px; margin-left: -6px; flex: none;
        border-radius: var(--r); color: var(--topbar-muted); cursor: pointer;
    }
    .nav-burger:hover { background: var(--topbar-field-hover); color: #fff; }
    .sidenav {
        position: fixed; top: var(--topnav-h); left: 0; bottom: 0; z-index: 90;
        width: min(300px, 86vw); height: auto;
        background: var(--surface);
        transform: translateX(-100%);
        transition: transform .2s var(--ease);
        box-shadow: var(--sh-pop);
    }
    .sidenav-scroll { padding: 12px 12px 16px; }
    .sidenav-foot { display: none; }
    .nav-toggle:checked ~ .layout .sidenav { transform: none; }
    .nav-backdrop {
        position: fixed; top: var(--topnav-h); right: 0; bottom: 0; left: 0; z-index: 80;
        background: var(--overlay);
    }
    .nav-toggle:checked ~ .layout .nav-backdrop { display: block; }

    .main { padding: 20px; }
    .page-header { flex-direction: column; align-items: stretch; }
    .form-grid, .form-grid.cols-3, .form-grid.grid-3, .checkbox-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .kv-grid, .kv-grid.cols-3, .kv-grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
    .rule-grid { grid-template-columns: 1fr; }
    .rule-body.cols-2 { grid-template-columns: 1fr; }
    .dash-cols { grid-template-columns: 1fr; }
    .card-grid { grid-template-columns: 1fr; }
    .form-row .narrow { max-width: none; }

    /* 表格给一个下限宽度，靠 .table-wrap 横向滚动整体查看。
       否则 auto 布局会把列压到一个字一行（「洋帆物流」竖着排），比滚动难读得多。 */
    /* 空状态没有列要撑，留着下限宽度只会把居中的提示文字推出屏幕 */
    .table:has(.empty-row) { min-width: 0; }
    /* 等宽字体的 x 高比正文大一截，13px 挤在窄表格里显得比中文还大；缩一号并禁止折行，
       长匹配规则整条留在一行，跟着表格一起横向滚。 */
    .table .mono { font-size: calc(12px * var(--fs)); }
    .empty-state { padding: 32px 16px; }
}

/* ---------- 手机 ---------- */
@media (max-width: 640px) {
    /* 顶栏在 390px 下装不下「品牌 + 管理控制台 + 用户名 + 退出」，
       会在固定 48px 高度里折行溢出。砍掉纯装饰的副标题，用户名只留头像。 */
    .topnav { gap: 8px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
    .brand { font-size: calc(16px * var(--fs)); }
    .topnav-divider, .topnav-title, .topnav-username { display: none; }
    .topnav-right { gap: 4px; }
    .topnav-user { padding: 0 4px; }
    .topnav-logout { padding: 0 10px; }

    .main { padding: 16px 14px calc(40px + env(safe-area-inset-bottom)); }
    /* auto-fit 的 minmax 下限比可用宽度还大时会横向溢出，手机上一律单列 */
    .kv-grid, .kv-grid.cols-3, .kv-grid.cols-2 { grid-template-columns: 1fr; }
    .box-header, .table-tools { padding-left: 14px; padding-right: 14px; }
    .box-body { padding: 14px; }
    .box-footer, .section { padding: 14px; }
    .section > .table-wrap { margin: 0 -14px; }
    .section-rules { grid-template-columns: 1fr; gap: 0; }
    .section-rules dd + dt { margin-top: 6px; }
    .table th:first-child, .table td:first-child { padding-left: 14px; }
    .table th:last-child, .table td:last-child { padding-right: 14px; }
    .page-header h1 { font-size: calc(20px * var(--fs)); line-height: calc(26px * var(--fs)); }
    .page-header .desc { font-size: calc(13px * var(--fs)); }
}

/* ---------- 单选卡片 / 卡片小标题 ----------
   认证方式这种「二选一、每个选项都要一句话解释」的场景用，比下拉一眼看得清后果。 */
.option-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.option-card {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 14px 16px;
    border: 1px solid var(--n-200); border-radius: var(--r);
    background: var(--n-0); cursor: pointer;
}
.option-card:hover { border-color: var(--n-300); background: var(--n-25); }
.option-card input { flex: none; width: 14px; height: 14px; margin: 3px 0 0; accent-color: var(--entity, var(--brand-600)); cursor: pointer; }
.option-card b { display: block; font-size: calc(13.5px * var(--fs)); font-weight: 600; }
.option-card small { display: block; margin-top: 2px; color: var(--n-600); font-size: calc(12px * var(--fs)); line-height: calc(17px * var(--fs)); }
.option-card:has(input:checked) {
    border-color: var(--entity, var(--brand-500)); background: var(--entity-bg, var(--brand-50));
    box-shadow: inset 0 0 0 1px var(--entity, var(--brand-500));
}

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h4 { margin: 0; font-size: calc(13.5px * var(--fs)); font-weight: 600; }
.card-head p { margin-top: 2px; color: var(--n-600); font-size: calc(12px * var(--fs)); line-height: calc(16px * var(--fs)); }
.card-head .status { flex: none; font-size: calc(12px * var(--fs)); }
.card-fields { display: grid; gap: 14px; }
.form-grid.tight { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px 16px; }
.static-value { display: flex; align-items: center; min-height: 32px; font-size: calc(13.5px * var(--fs)); }
[hidden] { display: none !important; }

/* ---------- 企业登录方式：每种一张卡片，单选，选中的才展开参数 ---------- */
.lp-list { display: grid; gap: 12px; }
.lp-card { border: 1px solid var(--n-200); border-radius: var(--r); background: var(--n-0); }
.lp-card:has(.lp-toggle:checked) { border-color: var(--entity-bd, var(--brand-100)); box-shadow: inset 3px 0 0 var(--entity, var(--brand-500)); }
.lp-head { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; cursor: pointer; }
.lp-head .lp-toggle { flex: none; width: 15px; height: 15px; margin: 2px 0 0; accent-color: var(--entity, var(--brand-600)); cursor: pointer; }
.lp-title { flex: 1; min-width: 0; }
.lp-title b { display: block; font-size: calc(13.5px * var(--fs)); font-weight: 600; }
.lp-title small { display: block; margin-top: 2px; color: var(--n-600); font-size: calc(12px * var(--fs)); line-height: calc(17px * var(--fs)); }
.lp-head .status { flex: none; font-size: calc(12px * var(--fs)); }
.lp-body { padding: 14px 16px 16px 41px; border-top: 1px dashed var(--n-200); }
.lp-body .alert-inline { margin-bottom: 14px; }
.lp-body .alert-inline code { word-break: break-all; }
.lp-sub { margin: 16px 0 10px; font-size: calc(12.5px * var(--fs)); font-weight: 600; color: var(--n-700); }
.lp-sub:first-child { margin-top: 0; }
.lp-sub .muted { font-weight: 400; }
.lp-check { align-self: end; padding-bottom: 6px; }
@media (max-width: 640px) { .lp-body { padding-left: 16px; } }

/* ---------- 表格行里就地展开的小表单（如「重置密码」）。
   不做浮层：表格外面的 .table-wrap 横向可滚动，浮层会被裁掉 ---------- */
.inline-popover > summary { list-style: none; }
.inline-popover > summary::-webkit-details-marker { display: none; }
.inline-popover .popover-form { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.popover-form input { width: 220px; }
/* 备份列表「内容」列里的备注：备注文字 + 笔形图标，点开在下方编辑 */
.backup-note { display: inline-block; vertical-align: middle; margin-left: 4px; }
.backup-note > summary { display: inline-flex; align-items: center; gap: 4px; min-height: 24px; cursor: pointer; color: var(--n-600); }
.backup-note > summary:hover, .backup-note[open] > summary { color: var(--brand-text); }
.backup-note > summary .cell-note:empty { display: none; }
.backup-note .popover-form input { width: min(220px, 60vw); }
.input-with-action { display: flex; gap: 8px; }
.input-with-action input { flex: 1; }

/* 可折叠的 box（如设备安装进度）：标题栏就是开关 */
.box-collapsible > summary { list-style: none; cursor: pointer; }
.box-collapsible > summary::-webkit-details-marker { display: none; }
.box-collapsible > summary h2::before { content: "▸ "; color: var(--n-400); }
.box-collapsible[open] > summary h2::before { content: "▾ "; }

/* 批量新建后跳回列表，刚建的几行淡绿底 */
.table tr.row-new > td { background: var(--ok-bg); }
.cell-sub { font-size: calc(12px * var(--fs)); line-height: calc(16px * var(--fs)); margin-top: 2px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 页头「更多 ▾」下拉菜单（页头不在横向滚动容器里，可以用浮层） ---------- */
.more-menu { position: relative; display: inline-block; }
.more-menu > summary { list-style: none; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-menu[open] > summary { background: var(--n-50); border-color: var(--n-400); }
.more-menu-list {
    position: absolute; right: 0; top: calc(100% + 4px); z-index: 40;
    min-width: 190px; padding: 4px; display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--sh-pop);
}
.more-menu-list form { margin: 0; }
/* 页头里的小表单弹层（全局配置模版的改名称、复制配置到…）：浮在按钮下面，不把页头撑高 */
.page-header .inline-popover { position: relative; display: inline-block; }
.page-header .inline-popover[open] > summary { background: var(--n-50); border-color: var(--n-400); }
.page-header .inline-popover .popover-form {
    position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; margin: 0; padding: 10px;
    background: var(--n-0); border: 1px solid var(--n-200); border-radius: var(--r); box-shadow: var(--sh-2);
}
.menu-item {
    display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r-sm);
    background: none; font: inherit; color: var(--n-800); text-align: left; white-space: nowrap; cursor: pointer;
}
a.menu-item:hover, .menu-item:hover { background: var(--n-50); color: var(--n-900); text-decoration: none; }
.menu-item.danger { color: var(--err); }
.menu-item.danger:hover { background: var(--err-bg); color: var(--err); }
.menu-item:disabled { color: var(--n-400); background: none; cursor: not-allowed; }
.menu-sep { margin: 4px 0; border: 0; border-top: 1px solid var(--n-100); }
.menu-form { display: flex; gap: 6px; align-items: center; padding: 6px 10px; }
.menu-form input[type=text] { width: 160px; }
.menu-label { padding: 6px 10px 0; font-size: calc(12px * var(--fs)); color: var(--n-600); }

/* ---------- 域名加速查询 ---------- */
.domain-query-form { padding: 0 20px 16px; }
.domain-query-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; font-size: calc(13px * var(--fs)); }
.domain-query-note { padding: 0 20px; }

/* ---------- 服务码线路检查（service_codes/route_check.html） ----------
   查询区：桌面上输入框和「平台 + 检查」并排，手机上纵向、控件撑满；结果是 data-cards 表格（手机变卡片）。 */
.rc-form { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 16px 24px; padding: 20px 24px; }
.rc-form-main, .rc-form-side { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rc-form textarea { width: 100%; min-height: 88px; font-family: var(--mono); font-size: calc(13px * var(--fs)); line-height: calc(20px * var(--fs)); }
.rc-form .field-desc { margin: 0; }
.rc-form-side select { width: 100%; }
.rc-form-side .btn { width: 100%; margin-top: 10px; justify-content: center; }
.rc-results.is-loading > :not(.box-header) { opacity: .5; transition: opacity .15s; }
.rc-summary { font-variant-numeric: tabular-nums; }
.rc-basis { padding-top: 0; }
.rc-note { padding: 0 24px 12px; }
.rc-table { table-layout: fixed; width: 100%; }
.rc-table th:nth-child(1) { width: 22%; }
.rc-table th:nth-child(2) { width: 20%; }
.rc-table th:nth-child(3) { width: 26%; }
.rc-table td { vertical-align: top; line-height: calc(20px * var(--fs)); }
.rc-table .mono { white-space: normal; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.rc-target { color: var(--text-strong); font-weight: 500; }
.rc-node { color: var(--text-strong); }
.rc-sub { display: block; margin-top: 2px; color: var(--text-3); font-size: calc(12px * var(--fs)); }
.rc-facts { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: calc(13px * var(--fs)); color: var(--text-2); }
.rc-facts .status { font-size: inherit; }
.rc-ips { margin-top: 6px; font-size: calc(13px * var(--fs)); }
.rc-ips > summary { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; color: var(--brand); cursor: pointer; list-style: none; }
.rc-ips > summary::-webkit-details-marker { display: none; }
.rc-ips > summary::before { content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); transition: transform .15s; }
.rc-ips[open] > summary::before { transform: rotate(45deg); }
.rc-ips > .rc-facts { margin-top: 4px; padding-left: 12px; border-left: 2px solid var(--border); }
.rc-foot { margin: 0; color: var(--text-3); font-size: calc(12px * var(--fs)); }
@media (max-width: 960px) {
    .rc-form { grid-template-columns: minmax(0, 1fr) 180px; }
}
@media (max-width: 640px) {
    .rc-form { grid-template-columns: 1fr; padding: 16px; }
    .rc-form textarea, .rc-form select { font-size: calc(16px * var(--fs)); }
    .rc-form-side .btn { min-height: 44px; }
    .rc-ips > summary { min-height: 44px; }
    .rc-kbd-hint { display: none; }
    .rc-basis-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px 16px; }
    .table.rc-table[data-cards] > tbody > tr > td.rc-empty { display: none; }
    .rc-note { padding: 0 16px 12px; }
}

/* ---------- 观测数据（流量与访问）---------- */
.obs-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 16px; }
.obs-toolbar .obs-periods { margin: 0; }
.obs-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.obs-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px;
    border: 1px solid var(--brand-100); border-radius: 999px; background: var(--brand-50);
    color: var(--brand-700); font-size: calc(12.5px * var(--fs));
}
.obs-chip-label { color: var(--n-600); }
.obs-chip button {
    width: 20px; height: 20px; border: 0; border-radius: 50%; background: transparent;
    color: var(--brand-700); font-size: calc(15px * var(--fs)); line-height: calc(20px * var(--fs)); cursor: pointer;
}
.obs-chip button:hover { background: var(--brand-100); }
.obs-loading { color: var(--n-400); font-size: calc(12.5px * var(--fs)); }
.obs-download { margin-left: auto; }
.obs.is-loading [data-role="body"] { opacity: .55; transition: opacity .15s; }
.obs-error { margin-bottom: 16px; }
.obs-chart { min-height: 260px; }
.obs-chart .uplot { font-family: inherit; }
.obs-chart .u-legend { font-size: calc(12px * var(--fs)); color: var(--n-700); }
.uplot .u-select { background: var(--chart-select); }
.obs-chart .u-over { cursor: crosshair; }
.obs-nodes { margin: 0 0 14px; }
.obs-rate-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px 16px; margin-bottom: 14px; }
.obs-rate-stat-label { color: var(--n-600); font-size: calc(12px * var(--fs)); }
.obs-rate-stat-value { margin-top: 2px; font-size: calc(17px * var(--fs)); line-height: calc(24px * var(--fs)); font-weight: 600; color: var(--n-900); font-variant-numeric: tabular-nums; }
.obs-swatch { display: inline-block; width: 10px; height: 2px; margin-right: 6px; vertical-align: middle; border-radius: 1px; }
.obs-empty { display: grid; place-items: center; height: 260px; color: var(--n-400); font-size: calc(13px * var(--fs)); }
.obs-grid { margin-bottom: 16px; }
.obs-stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.obs-stack > .box { margin-bottom: 0; }
.obs-stack > .box:last-child { flex: 1; }  /* 和左边的域名表底边对齐：左边高时设备表拉长，右边高时域名表被 .even 拉长 */
.obs-notes:empty { display: none; }
.obs-note { margin: 0 0 10px; color: var(--n-600); font-size: calc(12.5px * var(--fs)); }
.obs-table .obs-empty-cell { padding: 28px 12px; text-align: center; color: var(--n-400); }
.obs-pick {
    padding: 0; border: 0; background: none; font: inherit; color: var(--brand-600);
    text-align: left; cursor: pointer; word-break: break-all;
}
.obs-pick:hover { text-decoration: underline; }
.obs-pick.active { font-weight: 600; color: var(--brand-700); }
.obs-pick.active:not(.quiet)::after { content: " ✓"; }
.obs-pick.quiet.active { font-weight: inherit; }
.obs-table td.num, .obs-table th.num, .obs-table td.mono { white-space: nowrap; }
.table tbody tr.obs-row-active td { background: var(--brand-50); }
.obs-badge { margin-left: 6px; }
.obs-sub { font-size: calc(12px * var(--fs)); }

/* ---------- 服务器状态 ---------- */
.meter-ok > span { background: var(--ok-ic); }
.stat .meter { margin-top: 8px; }
.meter-row { display: flex; align-items: center; gap: 10px; }
.meter-row .meter { flex: 1; }
.meter-row > span { min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); font-weight: 600; }
.text-err { color: var(--err); font-weight: 600; }
.cell-sub { margin-top: 2px; font-size: calc(12px * var(--fs)); font-family: inherit; }
.kv-grid .kv-wide { grid-column: 1 / -1; }
.checkbox-inline { display: inline-flex; align-items: center; gap: 6px; font-size: calc(13px * var(--fs)); color: var(--n-600); }
.sql-cell summary { cursor: pointer; white-space: normal; word-break: break-all; }
.sql-cell pre { margin: 8px 0 0; padding: 10px; max-height: 260px; overflow: auto; white-space: pre-wrap;
    word-break: break-all; background: var(--n-25); border: 1px solid var(--n-100); border-radius: var(--r); font-size: calc(12px * var(--fs)); }

/* ---------- 运维工具 · 客户端诊断 ---------- */
.diag-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.diag-banner { margin-bottom: 16px; padding: 12px 16px; border: 1px solid; border-radius: var(--r); font-size: calc(13.5px * var(--fs)); }
.diag-banner.diag-critical { background: var(--err-bg); border-color: var(--err-bd); }
.diag-banner.diag-warning { background: var(--warn-bg); border-color: var(--warn-bd); }
.diag-banner.diag-ok { background: var(--ok-bg); border-color: var(--ok-bd); }
.diag-finding { margin-bottom: 12px; padding: 12px 16px; background: var(--n-25); border-left: 4px solid var(--n-300); border-radius: var(--r-sm); }
.diag-finding:last-child { margin-bottom: 0; }
.diag-finding p { margin: 6px 0 0; word-break: break-all; }
.diag-finding.diag-critical { border-left-color: var(--err); }
.diag-finding.diag-warning { border-left-color: var(--warn); }
.diag-cols { margin-bottom: 16px; }
.diag-details > summary { padding: 14px 20px; cursor: pointer; font-weight: 600; }
.diag-pre { margin: 0; padding: 0 20px 16px; max-height: 360px; overflow: auto; font-family: var(--mono); font-size: calc(12px * var(--fs)); white-space: pre-wrap; word-break: break-all; }
.diag-timeline { max-height: 480px; overflow-y: auto; }
.diag-timeline tr.diag-bad td { background: var(--err-bg); }

/* ---------- 顶栏全局搜索 ----------
   深色顶栏里的输入框 + 白底下拉结果。下拉框由 app.js 填充，键盘 ↑↓ 选、回车打开、Esc 关，/ 聚焦。 */
.gsearch { position: relative; flex: 0 1 420px; min-width: 0; margin-left: 16px; }
.gsearch > .icon { position: absolute; left: 11px; top: 11px; z-index: 1; color: var(--topbar-muted); pointer-events: none; }
.gsearch input[type="search"] {
    width: 100%; height: 38px; padding: 0 36px 0 34px;
    border: 0; border-radius: var(--r);
    background: var(--topbar-field); color: #fff; font: calc(14px * var(--fs))/calc(20px * var(--fs)) var(--font);
}
.gsearch input[type="search"]:hover { background: var(--topbar-field-hover); }
.gsearch input[type="search"]::placeholder { color: var(--topbar-muted); }
.gsearch input[type="search"]:focus { outline: none; background: var(--surface); color: var(--text); box-shadow: 0 0 0 3px rgba(255, 255, 255, .22); }
.gsearch input[type="search"]:focus::placeholder { color: var(--text-3); }
.gsearch:focus-within > .icon { color: var(--text-3); }
.gsearch-key {
    position: absolute; right: 9px; top: 10px;
    min-width: 18px; height: 18px; padding: 0 5px; border: 1px solid var(--topbar-line); border-radius: var(--r-sm);
    color: var(--topbar-muted); font: calc(11px * var(--fs))/calc(16px * var(--fs)) var(--mono); text-align: center; pointer-events: none;
}
.gsearch:focus-within .gsearch-key { display: none; }
.gsearch-panel {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 120;
    min-width: 360px; max-height: min(70vh, 560px); overflow-y: auto;
    padding: 6px 0; border: 1px solid var(--border); border-radius: var(--r-lg);
    background: var(--surface); color: var(--text); box-shadow: var(--sh-pop);
}
.gsearch-group { padding: 8px 14px 4px; color: var(--n-400); font-size: calc(12px * var(--fs)); font-weight: 600; }
.gsearch-item {
    display: flex; align-items: baseline; gap: 8px; padding: 6px 14px;
    color: var(--n-800); font-size: calc(13px * var(--fs)); line-height: calc(18px * var(--fs));
}
.gsearch-item:hover, .gsearch-item.is-active { background: var(--brand-50); color: var(--brand-700); text-decoration: none; }
.gsearch-title { flex: none; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.gsearch-sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--n-400); font-size: calc(12px * var(--fs)); }
.gsearch-item .badge { flex: none; }
.gsearch-more { color: var(--brand-600); font-size: calc(12px * var(--fs)); }
.gsearch-empty, .gsearch-foot { padding: 10px 14px; color: var(--n-400); font-size: calc(12px * var(--fs)); }
.gsearch-foot { margin-top: 4px; border-top: 1px solid var(--n-100); }
.gsearch-foot kbd, .box-desc kbd {
    padding: 0 4px; border: 1px solid var(--n-200); border-radius: var(--r-sm); background: var(--n-25); font: calc(11px * var(--fs))/calc(16px * var(--fs)) var(--mono);
}

/* 结果页 */
.search-hits { margin: 0; padding: 0 0 8px; list-style: none; }
.search-hits a { display: flex; align-items: baseline; gap: 10px; padding: 8px 20px; color: var(--n-800); }
.search-hits a:hover { background: var(--n-25); text-decoration: none; }
.search-hit-title { font-weight: 500; color: var(--brand-600); }
.search-hit-sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--n-400); font-size: calc(13px * var(--fs)); }

@media (max-width: 640px) {
    .gsearch { flex: 1 1 auto; margin-left: 0; }
    .gsearch-key { display: none; }
    .gsearch-panel { position: fixed; top: calc(var(--topnav-h) + 4px); left: 8px; right: 8px; min-width: 0; }
    .search-hits a { padding: 8px 14px; flex-wrap: wrap; }
}

/* ---------- 全局热键：g 之后的提示条、g h / ? 打开的热键列表 ---------- */
.hotkey-hint {
    position: fixed; right: 20px; bottom: 20px; z-index: 130;
    padding: 8px 12px; border-radius: var(--r);
    background: var(--topbar-bg); color: rgba(255, 255, 255, .85); font-size: calc(13px * var(--fs)); box-shadow: var(--sh-2);
}
.hotkey-hint kbd, .hotkey-dialog kbd {
    display: inline-block; min-width: 20px; padding: 0 5px; border: 1px solid var(--n-300); border-radius: var(--r-sm);
    background: var(--n-25); color: var(--n-800); font: calc(12px * var(--fs))/calc(18px * var(--fs)) var(--mono); text-align: center;
}
.hotkey-hint kbd { border-color: rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .1); color: #fff; }
.hotkey-dialog {
    width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 64px); padding: 0;
    border: 1px solid var(--n-200); border-radius: var(--r-lg); background: var(--surface); color: var(--text);
    box-shadow: var(--sh-pop);
}
.hotkey-dialog::backdrop { background: var(--overlay); }
.hotkey-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--n-100); }
.hotkey-head h2 { font-size: calc(15px * var(--fs)); font-weight: 600; }
.hotkey-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 28px; padding: 12px 20px 20px; }
.hotkey-grid h3 { margin: 10px 0 6px; color: var(--n-400); font-size: calc(12px * var(--fs)); font-weight: 600; }
.hotkey-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: calc(13px * var(--fs)); }
.hotkey-row > span:last-child { flex: none; }

/* 确认框 / 提示框（app.js 的 appDialog，代替浏览器 confirm / alert），外框沿用热键弹窗 */
.app-dialog {
    width: min(460px, calc(100vw - 32px)); padding: 0;
    border: 1px solid var(--n-200); border-radius: var(--r-lg); background: var(--surface); color: var(--text);
    box-shadow: var(--sh-pop);
}
.app-dialog::backdrop { background: var(--overlay); }
.app-dialog-main { display: flex; gap: 14px; padding: 20px 22px 4px; }
.app-dialog-icon {
    flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    background: var(--brand-50); color: var(--brand-600);
}
.app-dialog-icon .icon { width: 18px; height: 18px; }
.app-dialog.is-danger .app-dialog-icon { background: var(--err-bg); color: var(--err); }
.app-dialog-text { min-width: 0; flex: 1; }
.app-dialog-title { margin: 6px 0 0; color: var(--n-900); font-size: calc(15px * var(--fs)); font-weight: 600; line-height: calc(22px * var(--fs)); overflow-wrap: anywhere; }
.app-dialog-message {
    margin-top: 8px; max-height: 50vh; overflow: auto; color: var(--n-600); font-size: calc(13px * var(--fs)); line-height: calc(20px * var(--fs));
    white-space: pre-line; overflow-wrap: anywhere;
}
.app-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 22px 20px; }

/* 列表里双击某行弹出的编辑框（app.js）：载入该行编辑页的表单，标题栏沿用热键弹窗的样式 */
.edit-dialog {
    width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 64px); padding: 0;
    border: 1px solid var(--n-200); border-radius: var(--r-lg); background: var(--surface); color: var(--text);
    box-shadow: var(--sh-pop);
}
.edit-dialog::backdrop { background: var(--overlay); }
.edit-dialog-body { padding: 16px 20px 20px; }
.edit-dialog-body .box { margin: 0; border: 0; box-shadow: none; }
.edit-dialog-body .box-header { display: none; }
.edit-dialog-body .box-body { padding: 0; }
.edit-dialog-body .form-actions { margin: 16px 0 0; }

/* 四个业务主列表：列宽由内容决定，每行文字都不折行；长名称 / 备注靠 .cell-ellipsis 省略（悬停或点按看全文）。
   容器放不下就整表横滚（≤960px 首列冻结），不再把列压成一个字一行。 */
.table-list { table-layout: auto; width: 100%; }
.table-list th, .table-list td { padding-left: 10px; padding-right: 10px; white-space: nowrap; }
.table-list .cell-ellipsis {
    display: block; min-width: 0; max-width: 22em; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.table-list .cell-sub { max-width: 100%; }
.table-list .list-datetime { display: inline-flex; flex-direction: column; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-list .list-datetime span + span { font-size: calc(12px * var(--fs)); line-height: calc(16px * var(--fs)); }
.table-list td.cell-flex-col { width: 100%; }

/* 设备列表按设备、网络、归属分组，长文本始终限制在所属单元格内。 */
.table-devices td { padding-top: 16px; padding-bottom: 16px; vertical-align: top; }
.table-devices .device-line { min-height: 20px; }
.table-devices .device-presence { margin-left: 8px; font-size: calc(12px * var(--fs)); }
.table-devices .device-model {
    margin-top: 4px; font-size: calc(12px * var(--fs)); line-height: calc(18px * var(--fs));
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22em;
}
.table-devices .device-note {
    margin-top: 4px; font-size: calc(12px * var(--fs)); line-height: calc(18px * var(--fs)); color: var(--n-600);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22em;
}
.table-devices .device-secondary { display: block; margin-top: 5px; font-size: calc(12px * var(--fs)); line-height: calc(18px * var(--fs)); }
.table-devices .device-customer { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 18em; line-height: calc(20px * var(--fs)); }
.table-devices .device-code { white-space: nowrap; }
.table-devices .device-traffic { font-size: calc(14px * var(--fs)); line-height: calc(20px * var(--fs)); font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-devices .device-traffic-heading a { color: var(--n-600); }
.table-devices .device-traffic-heading a.active { color: var(--brand-600); }
/* 标记列（第一列）：只放一个短标记，不占宽；手机卡片里排到 SN 后面，标题仍是 SN */
@media (min-width: 641px) { .table-devices .col-tag { width: 1%; } }
@media (max-width: 640px) {
    .table-devices > tbody > tr > td.card-title { order: -1; }
}

/* 服务码列表沿用设备列表的分组与主次信息排版。 */
.table-service-codes td { padding-top: 16px; padding-bottom: 16px; vertical-align: top; }
.table-service-codes .sc-secondary { display: block; margin-top: 5px; font-size: calc(12px * var(--fs)); line-height: calc(18px * var(--fs)); }
.table-service-codes .sc-customer,
.table-service-codes .sc-source,
.table-service-codes .sc-person { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 18em; }
.table-service-codes .sc-node { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 14em; }
.table-service-codes .sc-note {
    margin-top: 5px; font-size: calc(12px * var(--fs)); line-height: calc(18px * var(--fs)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 20em;
}
/* 绑定设备的备注最多两行，悬停看全 */
.table-service-codes .sc-device { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 14em; }
.table-service-codes .sc-traffic { font-size: calc(14px * var(--fs)); line-height: calc(20px * var(--fs)); font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-service-codes .sc-group-heading a { color: var(--n-600); }
.table-service-codes .sc-group-heading a.active { color: var(--brand-600); }
.table-service-codes .sc-expiry { white-space: nowrap; }
.table-service-codes .sc-expiry .inherit-tag { margin: 5px 0 0; }
.table-customers td { vertical-align: top; }
.table-customers .cust-group-heading a { color: var(--n-600); }
.table-customers .cust-group-heading a.active { color: var(--brand-600); }
/* 标记列（第一列）：只放一个短标记，不占宽；手机卡片里排到客户名后面，标题仍是客户名 */
@media (min-width: 641px) { .table-customers .col-tag { width: 1%; } }
.table-customers .cell-ellipsis { max-width: 16em; }
/* 窄桌面放不下：创建时间让位（合同详情里有），手机是卡片不受影响 */
@media (min-width: 641px) and (max-width: 1360px) {
    .table-customers thead th:last-child, .table-customers tbody tr:not(.empty-row) > td:last-child { display: none; }
}
/* 客户（公司）详情 */
.gp-page > .box-list:not(:last-child) { margin-bottom: 20px; }
.gp-summary { overflow: hidden; }
.gp-stats { display: grid; grid-template-columns: minmax(0, 1.5fr) repeat(2, minmax(0, .75fr)) repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; background: var(--divider); }
.gp-stat { min-width: 0; padding: 18px 24px; background: var(--surface); }
.gp-stat dd { margin: 0; }
.gp-stat-label { color: var(--text-2); font-size: calc(12.5px * var(--fs)); line-height: calc(18px * var(--fs)); }
.gp-stat .gp-stat-value { margin-top: 6px; color: var(--text-strong); font-size: calc(26px * var(--fs)); line-height: calc(32px * var(--fs)); font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gp-unit { margin-left: 4px; color: var(--text-2); font-size: calc(13px * var(--fs)); font-weight: 500; letter-spacing: 0; }
.gp-stat .gp-stat-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin-top: 4px; color: var(--text-2); font-size: calc(12px * var(--fs)); line-height: calc(18px * var(--fs)); }
.gp-notice { display: flex; align-items: flex-start; gap: 8px; margin: -8px 0 20px; padding: 10px 14px; color: var(--warn); background: var(--warn-bg); border: 1px solid var(--warn-bd); border-radius: var(--r-lg); font-size: calc(13px * var(--fs)); line-height: calc(20px * var(--fs)); }
.gp-notice .icon { flex: none; margin-top: 2px; }

/* 带宽池表：和上面的合同表同一套 .table-list（手机自动变卡片）；数字等宽、主值一行、补充一行小字 */
.table.gp-pool-table td { vertical-align: top; white-space: normal; font-variant-numeric: tabular-nums; }
.table.gp-pool-table .list-sub { white-space: normal; }
.table.gp-pool-table .nw { white-space: nowrap; }
.gp-pool-table .col-key { min-width: 140px; }
.gp-members-count { display: none; }
.gp-pool-name { color: var(--text-strong); font-weight: 600; overflow-wrap: anywhere; }
.gp-pool-table .list-sub { margin-top: 2px; white-space: normal; }
.gp-pool-table .list-sub .badge { vertical-align: 1px; }
.gp-members { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; color: var(--text); font-size: calc(13px * var(--fs)); line-height: calc(20px * var(--fs)); }
.gp-members li { white-space: nowrap; }
.gp-v { color: var(--text-strong); font-weight: 500; white-space: nowrap; }
.gp-col-peak { min-width: 128px; }
.gp-peak { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.gp-pct { color: var(--text-2); font-size: calc(12px * var(--fs)); line-height: calc(18px * var(--fs)); white-space: nowrap; }
.gp-pct.is-hot { color: var(--warn); font-weight: 500; }
.gp-pct.is-over { color: var(--err); font-weight: 500; }
.gp-pool-table .meter { height: 4px; margin-top: 6px; }
.gp-pool-table .col-actions { width: 1%; vertical-align: middle; }
/* 平板：合同列收进带宽池名下面一行（各合同在哪个池，上面的合同表里有） */
@media (min-width: 641px) and (max-width: 1100px) {
    .gp-pool-table .gp-col-members { display: none; }
    .gp-members-count { display: block; }
}
.gp-empty { padding: 14px 24px 20px; border-top: 1px solid var(--divider); }
.gp-empty-lead { color: var(--text-2); font-size: calc(13px * var(--fs)); line-height: calc(20px * var(--fs)); }
.gp-empty-lead b { color: var(--text); font-weight: 600; }
.gp-modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 12px 0 0; }
.gp-modes > div { padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--divider); border-radius: var(--r-md); }
.gp-modes dt { color: var(--text); font-size: calc(13px * var(--fs)); line-height: calc(20px * var(--fs)); font-weight: 500; }
.gp-modes dd { margin: 2px 0 0; color: var(--text-2); font-size: calc(12px * var(--fs)); line-height: calc(18px * var(--fs)); }
.gp-page .table-wrap { position: relative; }
.gp-contracts .col-key { min-width: 200px; white-space: normal; }
.gp-contracts .cust-name-line { flex-wrap: wrap; gap: 4px 8px; }
.gp-contracts .cust-name-line .cell-ellipsis { max-width: none; white-space: normal; overflow: visible; word-break: keep-all; overflow-wrap: anywhere; }
.gp-contracts .list-sub { max-width: 190px; white-space: normal; }
.gp-contracts td { font-variant-numeric: tabular-nums; }
.gp-contracts .badge-vip, .gp-contracts .badge { flex: none; }
.gp-contracts select { width: 100%; min-width: 140px; max-width: 170px; }
.gp-impact { margin-top: 4px; color: var(--warn); font-size: calc(12px * var(--fs)); line-height: calc(16px * var(--fs)); white-space: normal; max-width: 170px; }
.gp-dialog { width: min(520px, calc(100vw - 32px)); }
.gp-dialog-move { overflow: visible; }
.gp-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--divider); }
.gp-dialog-head h2 { color: var(--text-strong); font-size: calc(16px * var(--fs)); line-height: calc(24px * var(--fs)); font-weight: 600; }
.gp-dialog-head .icon-btn { color: var(--text-2); font-size: calc(20px * var(--fs)); line-height: 1; }
.gp-dialog-body { display: grid; gap: 16px; padding: 20px 24px; }
.gp-dialog-body input:not([type=checkbox]), .gp-dialog-body select { width: 100%; }
.gp-dialog-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--divider); }
.gp-foot-gap { flex: 1; min-width: 0; font-size: calc(12px * var(--fs)); }
.gp-danger:not(:disabled) { color: var(--err); }
.gp-checks { margin: 0; padding: 0; border: 0; min-width: 0; }
.gp-checks legend { padding: 0; margin-bottom: 8px; color: var(--text); font-size: calc(13px * var(--fs)); font-weight: 500; }
.gp-checks label { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 1px solid var(--divider); border-bottom-width: 0; cursor: pointer; font-variant-numeric: tabular-nums; }
.gp-checks label:first-of-type { border-radius: 8px 8px 0 0; }
.gp-checks label:last-of-type { border-bottom-width: 1px; border-radius: 0 0 8px 8px; }
.gp-checks label:hover { background: var(--hover); }
.gp-checks label > span:first-of-type { flex: 1; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 1023px) {
    .gp-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .gp-stat-main { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
    .gp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .gp-stat { padding: 14px 16px; }
    .gp-stat .gp-stat-value { font-size: calc(24px * var(--fs)); line-height: calc(30px * var(--fs)); }
    .gp-empty { padding: 12px 16px 16px; }
    .gp-modes { grid-template-columns: minmax(0, 1fr); }
    .gp-contracts .list-sub { max-width: none; }
    #pool-save-bar .btn, .gp-dialog-foot .btn, .gp-pool-table .btn { min-height: 44px; }
    .gp-contracts select { max-width: none; font-size: 16px; min-height: 44px; }
    .gp-impact { max-width: none; }
    #pool-save-bar { flex-wrap: wrap; bottom: calc(8px + env(safe-area-inset-bottom)); }
    #pool-save-bar .save-hint { flex-basis: 100%; }
    #pool-save-bar .btn { flex: 1; }
    .gp-dialog { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-width: 1px 0 0; border-radius: 12px 12px 0 0; overflow: auto; }
    .gp-dialog-head, .gp-dialog-body { padding-left: 16px; padding-right: 16px; }
    .gp-dialog-body { min-height: 180px; }
    .gp-dialog-body input:not([type=checkbox]), .gp-dialog-body select { font-size: 16px; min-height: 44px; }
    .gp-dialog-foot { flex-wrap: wrap; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
    .gp-foot-gap { flex-basis: 100%; order: -1; }
    .gp-dialog-foot .btn { flex: 1; }
}
.table-customers .group-row td { font-weight: 600; }
.table-customers .group-row .list-sub { font-weight: 400; }
/* 一家公司多份合同：公司行浅底，合同行用连接线挂在公司名下面。--tree-x 跟随大屏加宽的单元格内边距 */
.table-customers { --tree-x: 10px; --tree-mid: calc(12px + 10px * var(--fs)); }
.table-customers .contract-row .cell-ellipsis { max-width: calc(16em - 30px); }   /* 缩进占的宽度扣回来，不把列撑宽 */
@media (min-width: 1800px) { .table-customers { --tree-x: 18px; } }
@media (min-width: 2300px) { .table-customers { --tree-x: 28px; } }
.table-customers > tbody > tr.group-row > td { background: var(--surface-2); }
.table-customers > tbody > tr.group-row:hover > td { background: var(--hover); }
.table-customers > tbody > tr.contract-row.is-last > td { border-bottom-color: var(--border); }
.table-customers > tbody > tr.contract-row:last-child > td { border-bottom: 0; }
@media (min-width: 641px) {
    .table-customers .contract-row > .col-key { position: relative; overflow: visible; padding-left: calc(var(--tree-x) + 30px); }
    .table-customers .contract-row > .col-key::before,
    .table-customers .contract-row > .col-key::after { content: ""; position: absolute; left: calc(var(--tree-x) + 7px); background: var(--border-strong); pointer-events: none; }
    .table-customers .contract-row > .col-key::before { top: 0; bottom: -1px; width: 1px; }
    .table-customers .contract-row.is-last > .col-key::before { bottom: auto; height: var(--tree-mid); }
    .table-customers .contract-row > .col-key::after { top: var(--tree-mid); width: 14px; height: 1px; }
}
@media (max-width: 640px) {
    .table-customers > tbody > tr > td.card-hide { display: none !important; }
    .table-customers > tbody > tr.group-row { background: var(--surface-2); }
    .table-customers.table-list > tbody > tr.contract-row { padding-left: 36px; }
    .table-customers > tbody > tr.contract-row::before,
    .table-customers > tbody > tr.contract-row::after { content: ""; position: absolute; left: 18px; background: var(--border-strong); pointer-events: none; }
    .table-customers > tbody > tr.contract-row::before { top: 0; bottom: -1px; width: 1px; }
    .table-customers > tbody > tr.contract-row.is-last::before { bottom: auto; height: calc(14px + 10px * var(--fs)); }
    .table-customers > tbody > tr.contract-row::after { top: calc(14px + 10px * var(--fs)); width: 12px; height: 1px; }
}
@media (max-width: 640px) {
    .table-customers > tbody > tr > td.card-title { order: -1; }
}
.table .list-sub { margin-top: 2px; font-size: calc(12px * var(--fs)); line-height: calc(18px * var(--fs)); white-space: nowrap; }
/* 整行可点进详情（app.js 的 table[data-row-link]）；行里真正的链接是 a.row-link，键盘和读屏走它 */
.table[data-row-link] tbody tr:not(.empty-row) { cursor: pointer; }

/* 客户、设备、服务码三个主列表的每页条数是按一屏放得下定的，卡片下面只留 16px：
   普通页面底下的 56px 内边距加卡片 16px 下边距，会让刚好放得下的列表多出一截空白滚动。 */
.main:has(.box-list) { padding-bottom: 16px; }
.box-list { margin-bottom: 0; }

/* 客户 / 服务码 / 设备 / 配额列表不设最小宽度：列宽取内容，容器放不下就横滚。 */
/* 标题区和操作按钮在手机上放不下一行：按钮换到标题下面，否则标题被挤成一字一行 */
@media (max-width: 640px) {
    .box-header { flex-wrap: wrap; }
    .box-header > div:first-child { flex-basis: 100%; }
}

/* ---------- 服务码对比：左右分栏 diff，样子照代码文件对比 ---------- */
.cmp-errors { margin-top: 16px; }
.diff-legend { padding: 0 4px; border-radius: var(--r-sm); }
.diff-legend.del { background: var(--err-bg); color: var(--err); }
.diff-legend.add { background: var(--ok-bg); color: var(--ok); }
.diff-heads { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.diff-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
.diff-stat { font: 600 calc(13px * var(--fs)) var(--mono); }
.diff-stat-add { color: var(--ok); }
.diff-stat-del { color: var(--err); }
.diff-wrap { overflow-x: auto; border-top: 1px solid var(--n-100); }
.diff {
    width: 100%; min-width: 720px; border-collapse: collapse; table-layout: fixed;
    font: calc(12.5px * var(--fs))/calc(20px * var(--fs)) var(--mono); color: var(--n-800);
}
.diff .diff-no-col { width: 52px; }
.diff thead th {
    padding: 6px 12px; border-bottom: 1px solid var(--n-200); background: var(--n-25);
    font-weight: 600; text-align: left; color: var(--n-700);
}
.diff thead th + th { border-left: 1px solid var(--n-200); }
.diff td { padding: 0 10px; vertical-align: top; }
.diff .diff-no {
    padding: 0 8px; text-align: right; color: var(--n-400); background: var(--n-25);
    user-select: none; border-right: 1px solid var(--n-100);
}
.diff td.diff-code { white-space: pre-wrap; word-break: break-all; tab-size: 4; }
/* 右半边的行号和左半边的代码之间画一条分隔线 */
.diff .diff-code + .diff-no { border-left: 1px solid var(--n-200); }
.diff .diff-code.del { background: var(--err-bg); }
.diff .diff-code.add { background: var(--ok-bg); }
.diff .diff-code.empty { background: var(--n-50); }
.diff .del mark { background: var(--diff-del-mark); color: inherit; border-radius: 2px; }
.diff .add mark { background: var(--diff-add-mark); color: inherit; border-radius: 2px; }
.diff-delete .diff-no:first-child, .diff-replace .diff-no:first-child { background: var(--err-bd); color: var(--err); }
.diff-insert .diff-code + .diff-no, .diff-replace .diff-code + .diff-no { background: var(--ok-bd); color: var(--ok); }
.diff-fold td { padding: 0; background: var(--brand-50); }
.diff-expand {
    display: flex; align-items: center; gap: 6px; width: 100%; padding: 3px 12px;
    border: 0; background: none; color: var(--brand-600); font: calc(12px * var(--fs))/calc(18px * var(--fs)) var(--font); text-align: left; cursor: pointer;
}
.diff-expand:hover { background: var(--brand-100); }
.diff-expand .icon { width: 14px; height: 14px; }
@media (max-width: 960px) { .diff-heads { grid-template-columns: 1fr; } }

/* ---------- 设备取配置记录（_device_logs.html） ----------
   各列按内容取宽、不折行，表格多出来的宽度按内容比例分给各列，不让某一列独占一大片空白。
   只有备注会折行：限宽、最多两行再省略；设备 ID、IP 过长省略。鼠标悬停都能看全文。
   按所在容器的宽度排版而不是屏幕宽度：portal 总览里它在半宽卡片里，大屏上也一样窄。 */
.device-logs-wrap { container-type: inline-size; }
.table-device-logs td { white-space: nowrap; }
.table-device-logs .dl-remark { white-space: normal; }
.table-device-logs .dl-clamp {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
    min-width: 6em; max-width: 16em; overflow: hidden; overflow-wrap: anywhere;
}
/* 失败原因放在「失败」下面一行，限宽折行，不把整列撑开 */
.table-device-logs .dl-reason {
    display: block; width: max-content; max-width: 240px; margin-top: 2px;
    font-size: calc(12px * var(--fs)); line-height: calc(16px * var(--fs)); white-space: normal; overflow-wrap: anywhere;
}
.table-device-logs .dl-cut { display: inline-block; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
/* iOS 的设备 ID 是 36 位 UUID，前 23 位足够区分；IP 列连归属地一起，太长（IPv6）就省略 */
.table-device-logs .dl-device { max-width: 23ch; }
.table-device-logs .dl-ip { max-width: 28ch; }
/* 够宽时设备 ID 整条显示 */
@container (min-width: 1200px) { .table-device-logs .dl-device { max-width: none; } }
@container (max-width: 900px) {
    .table-device-logs th, .table-device-logs td { padding-left: 8px; padding-right: 8px; }
    .table-device-logs .dl-extra { display: none; }
    /* 日期、时刻上下两行，省下一截宽度 */
    .table-device-logs .dl-time span { display: block; line-height: calc(18px * var(--fs)); }
    .table-device-logs .dl-time span + span { font-size: calc(12px * var(--fs)); }
    .table-device-logs .dl-reason { max-width: 120px; }
    .table-device-logs .dl-clamp { max-width: 12em; }
    /* 归属地换到 IP 下面一行 */
    .table-device-logs .dl-ip { max-width: 15ch; }
    .table-device-logs .dl-ip .ip-geo { display: block; }
}

/* ── 设备详情「网络」tab：工作模式卡片、按接口分组的横向表单、右侧配置摘要 ── */
.net-form [hidden] { display: none !important; }
.net-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.net-aside { position: sticky; top: calc(var(--topnav-h) + 16px); }
@media (max-width: 1180px) {
    .net-layout { grid-template-columns: minmax(0, 1fr); }
    .net-aside { position: static; }
}

/* 工作模式：单选卡片 */
.mode-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.mode-card {
    position: relative; display: flex; flex-direction: column; gap: 4px;
    padding: 12px 14px; cursor: pointer;
    border: 1px solid var(--n-200); border-radius: var(--r);
    background: var(--n-0);
    transition: border-color .12s, box-shadow .12s, background .12s;
}
.mode-card:hover { border-color: var(--n-400); }
.mode-card input { position: absolute; opacity: 0; pointer-events: none; }
.mode-card.is-selected { border-color: var(--brand-500); background: var(--brand-50); box-shadow: 0 0 0 1px var(--brand-500) inset; }
.mode-card:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--brand-100); }
.mode-card.is-selected:has(input:focus-visible) { box-shadow: 0 0 0 1px var(--brand-500) inset, 0 0 0 3px var(--brand-100); }
.mode-card-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: calc(13.5px * var(--fs)); font-weight: 600; color: var(--n-900); }
.mode-card-title .badge { white-space: nowrap; }
.mode-card-desc { font-size: calc(12px * var(--fs)); line-height: calc(17px * var(--fs)); color: var(--n-600); }
.mode-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.mode-card-tags span {
    padding: 0 6px; border-radius: var(--r-sm);
    background: var(--n-50); color: var(--n-700);
    font: 500 calc(11px * var(--fs))/calc(18px * var(--fs)) var(--mono);
}
.mode-card.is-selected .mode-card-tags span { background: var(--n-0); color: var(--brand-700); }
.net-mode-warn { margin-top: 12px; }

/* 接口分组 */
.net-groups { display: flex; flex-direction: column; overflow: hidden; }
.net-group { margin-top: -1px; padding: 14px 0 6px; border-top: 1px solid var(--n-100); }
.net-group-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.net-group-head h3 { font-size: calc(13px * var(--fs)); font-weight: 600; color: var(--n-900); }
.net-group-desc { font-size: calc(12px * var(--fs)); color: var(--n-400); }
.net-port {
    display: inline-block; min-width: 38px; padding: 0 6px; text-align: center;
    border: 1px solid var(--n-300); border-radius: var(--r-sm);
    background: var(--n-25); color: var(--n-700);
    font: 600 calc(11px * var(--fs))/calc(18px * var(--fs)) var(--mono); letter-spacing: .02em;
}
.net-empty { margin: 0; font-size: calc(13px * var(--fs)); color: var(--n-600); }

/* 横向表单行：左标签、右控件 */
.net-row { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 4px 16px; align-items: start; padding: 6px 0; }
.net-label { padding-top: 6px; font-size: calc(13px * var(--fs)); color: var(--n-700); }
.net-opt { margin-left: 6px; font-size: calc(11.5px * var(--fs)); color: var(--n-400); }
.net-control { min-width: 0; }
.net-help { margin: 4px 0 0; font-size: calc(12px * var(--fs)); line-height: calc(17px * var(--fs)); color: var(--n-400); }
.net-static { display: inline-block; padding-top: 6px; font-size: calc(13px * var(--fs)); color: var(--n-600); }
@media (max-width: 640px) {
    .net-row { grid-template-columns: minmax(0, 1fr); }
    .net-label { padding-top: 0; }
}
.net-form input.net-w-ip { width: 148px; }
.net-form input.net-w-xs { width: 96px; }
.net-form input.net-w-md { width: 100%; max-width: 320px; }
.net-form .net-addr { flex-wrap: nowrap; }
.net-addr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.net-addr-sep { color: var(--n-400); font-family: var(--mono); }
.net-inline-label { font-size: calc(12.5px * var(--fs)); color: var(--n-600); }
.net-prefix { min-width: 28px; font-size: calc(12.5px * var(--fs)); color: var(--n-600); }
.net-prefix.is-bad { color: var(--err); font-family: var(--font); }
.net-secret { display: flex; align-items: center; gap: 4px; max-width: 380px; }
.net-secret input { flex: 1; }

/* 分段按钮（单选） */
.seg { display: inline-flex; border: 1px solid var(--n-300); border-radius: var(--r); overflow: hidden; background: var(--n-0); }
.seg label { position: relative; cursor: pointer; }
.seg label + label { border-left: 1px solid var(--n-300); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 5px 14px; font-size: calc(13px * var(--fs)); line-height: calc(20px * var(--fs)); color: var(--n-700); white-space: nowrap; }
.seg label:hover span { background: var(--n-25); }
.seg input:checked + span { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.seg input:focus-visible + span { box-shadow: 0 0 0 2px var(--brand-500) inset; }

/* 开关 */
.switch { display: inline-flex; align-items: center; gap: 10px; padding-top: 5px; cursor: pointer; }
.switch input {
    appearance: none; -webkit-appearance: none; position: relative; flex-shrink: 0;
    width: 32px; height: 18px; margin: 0; border-radius: 9px;
    background: var(--n-300); cursor: pointer; transition: background .15s;
}
.switch input::before {
    content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, .25); transition: transform var(--dur);
}
.switch input:checked { background: var(--brand); }
.switch input:checked::before { transform: translateX(14px); }
.switch input:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.switch-text { font-size: calc(13px * var(--fs)); color: var(--n-600); }
.switch-text::after { content: attr(data-off); }
.switch input:checked + .switch-text::after { content: attr(data-on); }

/* 商用模式接口表 */
.net-ports { width: 100%; border-collapse: collapse; font-size: calc(13px * var(--fs)); }
.net-ports th {
    padding: 6px 10px; text-align: left; font-size: calc(12px * var(--fs)); font-weight: 500; color: var(--n-600);
    background: var(--n-25); border-bottom: 1px solid var(--n-200);
}
.net-ports td { padding: 8px 10px; border-bottom: 1px solid var(--n-100); vertical-align: middle; white-space: nowrap; }
.net-ports tr:last-child td { border-bottom: 0; }
.net-ports th:first-child, .net-ports td:first-child { width: 150px; }
.net-ports th:nth-child(2), .net-ports td:nth-child(2) { width: 90px; }

/* 右侧摘要 */
.net-summary { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px 12px; margin: 0; font-size: calc(13px * var(--fs)); }
.net-summary dt { color: var(--n-600); }
.net-summary dd { margin: 0; min-width: 0; color: var(--n-900); overflow-wrap: anywhere; }
.net-summary .mono { white-space: nowrap; }
.net-summary dd .net-port { min-width: 0; margin-bottom: 4px; }
.net-apply h3 { margin-bottom: 8px; }
.net-apply p { margin: 4px 0 0; font-size: calc(12.5px * var(--fs)); color: var(--n-600); }
.net-apply .net-apply-help { margin-top: 10px; font-size: calc(12px * var(--fs)); line-height: calc(17px * var(--fs)); color: var(--n-400); }

/* ── 设备详情「服务安装」tab：服务列表（沿用网络 tab 的 net-* 布局） ── */
.svc-list { display: flex; flex-direction: column; border: 1px solid var(--n-200); border-radius: var(--r); overflow: hidden; }
.svc-item { padding: 14px 16px; background: var(--n-0); }
.svc-item + .svc-item { border-top: 1px solid var(--n-100); }
.svc-item.is-disabled { background: var(--n-25); }
.svc-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.svc-id { min-width: 0; }
.svc-name { font-size: calc(14px * var(--fs)); font-weight: 600; color: var(--n-900); }
.svc-code { margin-left: 6px; font-size: calc(12px * var(--fs)); font-weight: 400; color: var(--n-600); }
.svc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; font-size: calc(12.5px * var(--fs)); color: var(--n-600); }
.svc-meta .status { font-size: calc(12.5px * var(--fs)); }
.svc-source { color: var(--n-400); }
/* 设备详情「服务」tab 的运行状态（core/service_status.py） */
.svc-status-box { margin-top: 16px; }
.svc-status + .svc-status { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--n-100); }
.svc-status-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 12px; font-size: calc(13px * var(--fs)); }
.svc-status-head .status { font-size: calc(12.5px * var(--fs)); }
.svc-drift {
    display: inline-block; padding: 0 6px; border-radius: var(--r-sm);
    font-size: calc(11.5px * var(--fs)); font-weight: 500; line-height: calc(18px * var(--fs)); border: 1px solid transparent;
}
.svc-drift.ok { background: var(--ok-bg); border-color: var(--ok-bd); color: var(--ok); }
.svc-drift.warn { background: var(--warn-bg); border-color: var(--warn-bd); color: var(--warn); }
.svc-policy input:disabled + span { color: var(--n-400); cursor: not-allowed; background: var(--n-50); }
.svc-mark { margin-left: 2px; color: var(--warn); font-weight: 700; }
.svc-params { margin-top: 12px; padding: 6px 14px; border-radius: var(--r); background: var(--n-25); border: 1px solid var(--n-100); }
.net-summary dd > div + div { margin-top: 4px; }

/* ── 设备详情「基本信息」tab ── */
.info-model { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; font-size: calc(12.5px * var(--fs)); color: var(--n-600); }
.info-model .status { font-size: calc(12.5px * var(--fs)); }
.net-form textarea.info-remark { width: 100%; max-width: 560px; min-height: 88px; }
.info-summary { grid-template-columns: 72px minmax(0, 1fr); }
.info-readonly { display: inline-block; padding-top: 6px; font-size: calc(13.5px * var(--fs)); color: var(--n-900); }

/* ── 设备管理各栏目（型号、安装服务、型号安装脚本、常驻脚本）：沿用 net-* 版式，补列表身份单元、能力标签、脚本编辑框、侧栏参考 ── */
.ident-main { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-weight: 600; color: var(--n-900); }
.ident-main a { font-weight: 600; }
.ident-sub { margin-top: 2px; font-size: calc(12px * var(--fs)); line-height: calc(17px * var(--fs)); color: var(--n-600); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ident-sub.wrap { white-space: normal; }
.ident-main .badge { font-weight: 500; }
.num-link { font-variant-numeric: tabular-nums; font-weight: 600; }
.num-link.zero { color: var(--n-400); font-weight: 400; }

.cap-list { display: flex; flex-wrap: wrap; gap: 4px; }
.cap {
    display: inline-flex; align-items: center; gap: 5px; padding: 0 7px;
    border: 1px solid var(--n-200); border-radius: var(--r-sm);
    background: var(--n-25); color: var(--n-400);
    font-size: calc(11.5px * var(--fs)); font-weight: 500; line-height: calc(20px * var(--fs)); white-space: nowrap;
}
.cap::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--n-300); }
.cap.on { border-color: var(--ok-bd); background: var(--ok-bg); color: var(--ok); }
.cap.on::before { background: var(--ok); }
.chip-mono {
    display: inline-block; padding: 0 6px; border-radius: var(--r-sm);
    background: var(--n-50); color: var(--n-700); font: 500 calc(11.5px * var(--fs))/calc(20px * var(--fs)) var(--mono); white-space: nowrap;
}

/* 脚本编辑框：标题栏 + 无边框 textarea */
.code-field { border: 1px solid var(--n-300); border-radius: var(--r); overflow: hidden; background: var(--n-0); }
.code-field:hover { border-color: var(--n-400); }
.code-field:focus-within { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }
.code-field-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 6px 12px; border-bottom: 1px solid var(--n-100); background: var(--n-25);
    font-size: calc(12px * var(--fs)); color: var(--n-600);
}
.code-field-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--n-800); }
.code-lang {
    padding: 0 5px; border-radius: var(--r-sm); background: var(--n-100); color: var(--n-600);
    font: 600 calc(10.5px * var(--fs))/calc(16px * var(--fs)) var(--mono); text-transform: uppercase; letter-spacing: .04em;
}
.code-field-meta { display: inline-flex; gap: 12px; color: var(--n-400); font-variant-numeric: tabular-nums; }
.code-field textarea, .code-field textarea:hover, .code-field textarea:focus {
    display: block; width: 100%; margin: 0; padding: 10px 12px; border: 0; border-radius: 0; box-shadow: none;
    line-height: calc(19px * var(--fs)); tab-size: 4; white-space: pre; overflow-wrap: normal; overflow-x: auto; resize: vertical;
}
.code-stack { display: flex; flex-direction: column; gap: 12px; }
.net-group .code-field { margin: 4px 0 10px; }

/* 编辑页右侧：档案 + 参考 */
.net-aside > .box + .box { margin-top: 16px; }
.ref-tokens { margin: 0; font-size: calc(12.5px * var(--fs)); }
.ref-tokens dt { display: flex; flex-wrap: wrap; gap: 4px; }
.ref-tokens dt + dd { margin: 3px 0 0; color: var(--n-600); line-height: calc(18px * var(--fs)); }
.ref-tokens dd + dt { margin-top: 10px; }
code.ph {
    display: inline-block; padding: 0 5px; border: 1px solid var(--brand-100); border-radius: var(--r-sm);
    background: var(--brand-50); color: var(--brand-700); font: 500 calc(11.5px * var(--fs))/calc(17px * var(--fs)) var(--mono);
}
.ref-points { margin: 0; font-size: calc(12.5px * var(--fs)); line-height: calc(18px * var(--fs)); }
.ref-points dt { font-weight: 600; color: var(--n-800); }
.ref-points dd { margin: 2px 0 10px; color: var(--n-600); }
.ref-points dd:last-child { margin-bottom: 0; }
.ref-links { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: calc(13px * var(--fs)); }
.ref-links li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ref-links .status { font-size: calc(12px * var(--fs)); }
.param-preview { margin-top: 10px; }
.param-preview .net-ports td { white-space: normal; }
.net-form select.net-w-md { width: 100%; max-width: 320px; }
.net-form .net-w-lg { width: 100%; max-width: 560px; }
.list-summary { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 0 20px 12px; font-size: calc(12.5px * var(--fs)); color: var(--n-600); }
.list-summary b { color: var(--n-900); font-variant-numeric: tabular-nums; }
.table-catalog { table-layout: auto; width: 100%; }
.table-catalog td { vertical-align: top; }
.table-catalog td.col-actions { vertical-align: middle; }
.table-catalog .list-datetime { display: inline-flex; flex-direction: column; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-catalog .list-datetime span + span { font-size: calc(12px * var(--fs)); line-height: calc(16px * var(--fs)); }
.cell-note { font-size: calc(12.5px * var(--fs)); line-height: calc(18px * var(--fs)); color: var(--n-700); overflow-wrap: anywhere; }
.ident-main.ident-plain { font-weight: 500; }
.net-help.net-lead { margin: 0 0 8px; }
.net-help.net-after { margin-top: 12px; }

/* ── 客户「配额与带宽」tab：用量指标、带单位的输入框、筛选标签、服务码配额表（分组与表单行沿用上面的 net-*）── */
.q-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
/* 4 张卡一行至少要 760px 的主区域：有侧栏时视口 ≥1084px，侧栏收起（≤960px）时视口 ≥800px；其余宽度两列 */
@media (min-width: 961px) and (max-width: 1083px) { .q-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 799px) { .q-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .q-kpis { grid-template-columns: minmax(0, 1fr); } }
/* 一行四张但主区域只有 760~860px（iPad 横屏、竖屏）：数值缩一号，「128.4 GB / 500 GB」才不会折行 */
@media (min-width: 800px) and (max-width: 960px), (min-width: 1084px) and (max-width: 1279px) {
    .q-kpis:not(.q-kpis-5) .q-kpi-value { font-size: calc(20px * var(--fs)); line-height: calc(26px * var(--fs)); }
}
/* 概览五张指标卡：宽屏一行五张；三张一行（第二行两张）；小平板竖屏（≤799px）两列，落单的最后一张占满一行；手机单列 */
.q-kpis-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 1600px) { .q-kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 799px) {
    .q-kpis-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .q-kpis-5 .q-kpi:last-child { grid-column: 1 / -1; }
}
@media (max-width: 640px) { .q-kpis-5 { grid-template-columns: minmax(0, 1fr); } }
.q-kpi {
    display: flex; flex-direction: column; gap: 8px; padding: 18px 20px;
    background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
:root[data-theme="dark"] .q-kpi { border-color: var(--border); }
.q-kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: calc(13.5px * var(--fs)); font-weight: 600; color: var(--text-2); }
.q-kpi-value { font-size: calc(26px * var(--fs)); line-height: calc(32px * var(--fs)); font-weight: 600; letter-spacing: -.02em; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.q-kpi-of { font-size: calc(13px * var(--fs)); font-weight: 500; letter-spacing: 0; color: var(--n-400); }
.q-kpi .meter { margin-top: 2px; }
.q-kpi-foot { margin-top: auto; font-size: calc(12px * var(--fs)); color: var(--n-400); }
.q-kpi-foot a { color: var(--brand-600); }
.q-pill {
    padding: 0 8px; border-radius: 999px;
    background: var(--neutral-bg); color: var(--text-2); font-size: calc(12px * var(--fs)); font-weight: 600; line-height: calc(20px * var(--fs)); white-space: nowrap;
}
.q-pill.is-ok { background: var(--ok-bg); color: var(--ok); }
.q-pill.is-warn { background: var(--warn-bg); color: var(--warn); }
.q-pill.is-err { background: var(--err-bg); color: var(--err); }

/* 数值 + 单位：输入框右侧接一个单位块 */
.q-unit { display: inline-flex; align-items: stretch; }
.q-unit input[type="number"] { width: 132px; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.q-unit > span {
    display: inline-flex; align-items: center; padding: 0 10px;
    border: 1px solid var(--n-300); border-left: 0; border-radius: 0 var(--r) var(--r) 0;
    background: var(--n-25); color: var(--n-600); font-size: calc(12.5px * var(--fs)); white-space: nowrap;
}
.q-unit-sm input[type="number"] { width: 84px; min-height: 28px; padding-top: 3px; padding-bottom: 3px; }
.q-static { color: var(--n-900); font-variant-numeric: tabular-nums; }
.net-row[hidden] { display: none; }

/* 右侧摘要、规则 */
.q-summary { grid-template-columns: 72px minmax(0, 1fr); }
.q-summary dd .muted { font-size: calc(12px * var(--fs)); }
.q-rules ul { margin: 0; padding-left: 16px; font-size: calc(12.5px * var(--fs)); line-height: calc(19px * var(--fs)); color: var(--n-600); }
.q-rules li + li { margin-top: 6px; }
.q-rules-link { margin: 12px 0 0; font-size: calc(12.5px * var(--fs)); }

/* 服务码配额表 */
.q-toolbar { padding: 0 20px 12px; }
.q-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.q-chips a {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
    border: 1px solid var(--n-200); border-radius: 14px; background: var(--n-0);
    color: var(--n-700); font-size: calc(12.5px * var(--fs)); line-height: calc(18px * var(--fs)); text-decoration: none;
}
.q-chips a:hover { border-color: var(--n-400); }
.q-chips a span { min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--n-50); color: var(--n-600); font-size: calc(11.5px * var(--fs)); text-align: center; font-variant-numeric: tabular-nums; }
.q-chips a.is-active { border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.q-chips a.is-active span { background: var(--n-0); color: var(--brand-700); }
.q-bulk { flex-wrap: wrap; row-gap: 8px; }
.q-bulk-item { display: inline-flex; align-items: center; gap: 6px; }
.q-table td { vertical-align: middle; }
.q-nowrap { white-space: nowrap; }
.q-usage { min-width: 180px; }
.q-usage-line { display: flex; align-items: baseline; gap: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.q-usage .meter { margin-top: 5px; max-width: 200px; height: 4px; }
.q-dot { display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--n-300); vertical-align: 2px; }
.q-dot.is-on { background: var(--ok); }
.q-tag {
    display: inline-block; margin-left: 6px; padding: 0 6px;
    border: 1px solid var(--brand-100); border-radius: 10px; background: var(--brand-50);
    color: var(--brand-700); font-size: calc(11px * var(--fs)); line-height: calc(17px * var(--fs)); font-weight: 500; white-space: nowrap; vertical-align: 1px;
}

/* 服务码配额表列宽：按比例分配，大屏下各列间距均匀，不会挤在一边留一大片空 */
.q-table { table-layout: auto; width: 100%; }
.q-table .q-col-check { width: 44px; }
.q-table .cell-ellipsis { display: block; max-width: 22em; }
.q-usage .meter { max-width: 240px; }
/* 大屏：一张卡里的几个分组并排（有几组就几列），不再一列排到底、右半边空着 */
@media (min-width: 1760px) {
    .q-groups { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0 28px; }
    .q-groups .net-group { margin-top: 0; padding-top: 6px; border-top: 0; }
    .q-groups .net-group + .net-group { padding-left: 28px; border-left: 1px solid var(--n-100); }
    .q-groups .net-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
    .q-groups .net-label { padding-top: 0; }
}

/* 客户详情各 tab 共用（概览、服务码模版、节点与出口、认证、管理员） */
.q-form .net-control > input:not([type="checkbox"]):not([type="radio"]),
.q-form .net-control > select,
.q-form .net-control > .input-with-action { width: 100%; max-width: 440px; }
.q-form .net-control > textarea { width: 100%; max-width: 640px; }
/* 客户备注：BMS 会写入试用 / 合同信息和客户需求，给足高度；内容多时随内容长高（支持 field-sizing 的浏览器），最高 60vh 后滚动 */
.q-form .net-control > textarea.q-remark {
    max-width: 880px; min-height: calc(220px * var(--fs)); max-height: 60vh;
    field-sizing: content; line-height: calc(22px * var(--fs));
}
@media (max-width: 640px) {
    .q-form .net-control > textarea.q-remark { min-height: calc(180px * var(--fs)); font-size: calc(16px * var(--fs)); }
}
.q-kpi-value.q-kpi-text { font-size: calc(20px * var(--fs)); }
.q-sub { margin-top: 3px; font-size: calc(12px * var(--fs)); line-height: calc(17px * var(--fs)); color: var(--n-400); }
.q-sub .status { font-size: calc(12px * var(--fs)); }
.q-links, .q-rules ul.q-links { margin: 0; padding: 0; list-style: none; font-size: calc(13px * var(--fs)); line-height: calc(22px * var(--fs)); }
.q-links a { color: var(--brand-600); }
.q-aside-link { margin: 0 0 12px; font-size: calc(13px * var(--fs)); overflow-wrap: anywhere; }
.box-body.q-rules ul { padding-left: 16px; }
.q-table .cell-ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 服务码 / 模版详情的配置类 tab（配额与带宽、日志与观测、DNS、入站、出站、路由）：
   字段统一排成横向行——左标签，右控件，说明在控件下方。覆盖三处：分区里直属 form-grid 的字段、
   路由的内置分流开关卡片、DNS / 路由表下面的「添加」表单。只改样式不动 ui.field 的结构；弹窗、编辑页不受影响。 ── */
.sc-hform .section > .form-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
@media (min-width: 1600px) {
    .sc-hform .section > .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 48px; }
}
.sc-hform .section > .form-grid > .span-full, .sc-hform .section > .form-grid > .span-2 { grid-column: 1 / -1; }
:is(.sc-hform .section > .form-grid, .sc-hform .rule-card, .sc-hform .box-footer > .form-row) > .field {
    display: grid; grid-template-columns: 180px minmax(0, 1fr); grid-template-rows: auto; column-gap: 16px; align-items: start;
    padding: 8px 0;
}
:is(.sc-hform .section > .form-grid, .sc-hform .rule-card, .sc-hform .box-footer > .form-row) > .field[hidden] { display: none; }
:is(.sc-hform .section > .form-grid, .sc-hform .rule-card, .sc-hform .box-footer > .form-row) > .field > .field-head { display: contents; }
:is(.sc-hform .section > .form-grid, .sc-hform .rule-card, .sc-hform .box-footer > .form-row) > .field .field-label {
    grid-column: 1; grid-row: 1 / span 2; padding-top: 6px; font-weight: 500; color: var(--n-700);
}
:is(.sc-hform .section > .form-grid, .sc-hform .rule-card, .sc-hform .box-footer > .form-row) > .field > .field-body { grid-column: 2; grid-row: 1; min-width: 0; max-width: 520px; }
:is(.sc-hform .section > .form-grid, .sc-hform .box-footer > .form-row) > .field.span-full > .field-body,
:is(.sc-hform .section > .form-grid, .sc-hform .box-footer > .form-row) > .field.span-2 > .field-body { max-width: 720px; }
:is(.sc-hform .section > .form-grid, .sc-hform .rule-card, .sc-hform .box-footer > .form-row) > .field .field-desc {
    grid-column: 2; grid-row: 2; max-width: 520px; margin-top: 4px; font-size: calc(12px * var(--fs)); line-height: calc(17px * var(--fs)); color: var(--n-400);
}
.sc-hform .field .inherit-chip { margin-top: 6px; }

/* 路由「内置分流开关」：卡片改成一列横向行，开关的从属设置缩进在下面 */
.sc-hform .rule-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
.sc-hform .rule-card { padding: 2px 0; border: 0; border-radius: 0; background: none; }
.sc-hform .rule-card + .rule-card { border-top: 1px solid var(--n-100); }
.sc-hform .rule-body {
    margin: 2px 0 10px 196px; padding: 12px 16px; max-width: 760px;
    border: 0; border-left: 2px solid var(--brand-100); border-radius: 0 var(--r) var(--r) 0; background: var(--n-25);
}
.sc-hform .rule-body .field-label { font-weight: 500; color: var(--n-700); }

/* DNS 服务器 / DNS 规则 / 路由规则下面的「添加」表单：一列横向行，按钮对齐控件列 */
.sc-hform .box-footer > .form-row { display: block; }
.sc-hform .box-footer > .form-row > .field.narrow { max-width: none; }
.sc-hform .box-footer > .form-row > .field.narrow > .field-body { max-width: 140px; }
.sc-hform .box-footer > .form-row > .form-row-actions { margin: 6px 0 0 196px; padding-top: 12px; max-width: 520px; }
.sc-hform .box-footer > h3 { font-size: calc(14px * var(--fs)); color: var(--n-900); }

@media (max-width: 640px) {
    :is(.sc-hform .section > .form-grid, .sc-hform .rule-card, .sc-hform .box-footer > .form-row) > .field { grid-template-columns: minmax(0, 1fr); }
    :is(.sc-hform .section > .form-grid, .sc-hform .rule-card, .sc-hform .box-footer > .form-row) > .field .field-label { grid-row: auto; padding-top: 0; }
    :is(.sc-hform .section > .form-grid, .sc-hform .rule-card, .sc-hform .box-footer > .form-row) > .field > .field-body,
    :is(.sc-hform .section > .form-grid, .sc-hform .rule-card, .sc-hform .box-footer > .form-row) > .field .field-desc { grid-column: 1; grid-row: auto; }
    .sc-hform .rule-body, .sc-hform .box-footer > .form-row > .form-row-actions { margin-left: 0; }
}
.sc-hform .section > .kv-grid { margin-top: 12px; }
.q-summary .mono { white-space: normal; overflow-wrap: anywhere; }

/* 设备备份：文件内容、当前选中的文件 */
.code-view { margin: 0; padding: 12px 14px; max-height: 70vh; overflow: auto; background: var(--n-50); border: 1px solid var(--n-200);
    border-radius: var(--r-md); font: calc(12.5px * var(--fs))/1.55 var(--mono); white-space: pre; }
.table tr.row-active td { background: var(--n-50); }

/* 设备 core 日志查看页：过滤条一行排开、窄屏换行；日志默认自动换行（长行在手机上也读得全），可切回不换行横向滚动 */
.core-log-filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.core-log-filter input[type="search"] { flex: 1 1 240px; min-width: 0; }
.core-log-filter .core-log-wrap { margin-left: auto; }
.core-log-count { margin: 0 0 8px; }
.core-log-view { max-height: 75vh; max-height: 75dvh; }
.core-log-view.is-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 640px) {
    /* iOS Safari 聚焦字号小于 16px 的输入框会整页放大 */
    .core-log-filter input[type="search"] { flex-basis: 100%; font-size: calc(16px * var(--fs)); min-height: 44px; }
    .core-log-filter .btn { min-height: 44px; }
    .core-log-filter .core-log-wrap { margin-left: 0; }
    .core-log-view { font-size: calc(12px * var(--fs)); padding: 10px; }
}

/* ---------- 总览（运营数据看板） ----------
   固定列数的网格按视口分档，同一行的卡片靠 grid 的 stretch 等高；图表区、表格区都是固定高度，
   表格没数据时空状态在同样高的区域里居中，行多了在卡片里滚动。说明文字单行省略（完整内容在 title），
   免得哪张卡的说明多折一行就比旁边高。
   分档（视口宽度，含 232px 侧栏）：<700 手机（指标两列，其余单列）；700–1000 窄平板（同上，字号正常）；
   1000–1240 平板横屏 / 小笔记本（图表两列）；1240–1700 常见笔记本 / 显示器（指标四列、表格两列、节点占整行）；
   1700–2000 大显示器（三张表并排）；≥2000 超宽 / 大屏（指标八列、图表四列）。
   注意无头 Chrome 的窗口最小 500px 宽，截图验证手机版式要用 body{max-width:390px} 模拟。 */
.dash-alert { margin-bottom: 16px; }
.dash-status { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 16px; }
.dash-pill {
    display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 4px;
    border-radius: 999px; background: var(--surface);
    color: var(--text-2); font-size: calc(12.5px * var(--fs)); font-weight: 500; line-height: calc(20px * var(--fs)); font-variant-numeric: tabular-nums;
    box-shadow: var(--sh-1);
}
:root[data-theme="dark"] .dash-pill { background: var(--surface-2); box-shadow: 0 0 0 1px var(--border); }
.dash-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--neutral-ic) no-repeat center / 10px 10px; }
.dash-dot.is-ok { background-color: var(--ok-ic); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E"); }
.dash-dot.is-warn { background-color: var(--warn-ic); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M12 6v7.5M12 18h.01'/%3E%3C/svg%3E"); }
.dash-dot.is-err { background-color: var(--err-ic); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M7.5 7.5l9 9M16.5 7.5l-9 9'/%3E%3C/svg%3E"); }
.dash-section {
    margin: 8px 0 12px; font-size: calc(15px * var(--fs)); line-height: calc(20px * var(--fs)); font-weight: 600;
    color: var(--text-strong);
}
.dash-kpis + .dash-section, .dash-charts + .dash-section { margin-top: 24px; }
.nowrap { white-space: nowrap; }

/* 指标卡：默认手机两列；卡片是纵向 flex，小字贴底，同一行等高 */
.dash-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.dash-kpis .stat { display: flex; flex-direction: column; min-width: 0; }
.dash-kpis .stat-value { overflow-wrap: anywhere; }
.dash-kpis .stat-value.warn { color: var(--warn); }
.dash-kpis .stat-value.err { color: var(--err); }
.dash-kpis .stat-sub { margin-top: auto; padding-top: 3px; }
.stat-value .delta { display: inline-flex; align-items: center; height: 20px; margin-left: 6px; padding: 0 7px; border-radius: 999px; background: var(--neutral-bg); vertical-align: 5px; font-size: calc(12px * var(--fs)); font-weight: 600; letter-spacing: 0; color: var(--text-2); }
.stat-value .delta.up { background: var(--ok-bg); color: var(--ok); }
.stat-value .delta.down { background: var(--warn-bg); color: var(--warn); }

/* 卡片：纵向 flex，表格 / 图表区撑满剩余高度 */
.dash-card { display: flex; flex-direction: column; margin-bottom: 0; min-width: 0; }
.dash-card > .box-header { flex: none; }
.dash-card .box-header > div:first-child { min-width: 0; }
.dash-card .box-desc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-card > .box-body, .dash-card > .table-wrap { flex: 1; min-height: 0; }

/* 图表：一格一张，固定高度（绘图区 220 + 图例） */
.dash-charts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.dash-chart { height: 252px; overflow: hidden; }
.dash-chart .uplot { font-family: inherit; }
.dash-chart .u-legend { font-size: calc(12px * var(--fs)); color: var(--n-700); }
.dash-empty { display: grid; place-items: center; height: 220px; color: var(--n-400); font-size: calc(13px * var(--fs)); }

/* 表格面板：固定高度（表头 + 8 行），多的在面板里滚动、表头吸顶；空状态撑满居中 */
.dash-panels { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.dash-panel > .table-wrap { flex: none; height: 384px; overflow: auto; }  /* flex: none：别让 .dash-card 的 flex: 1 把固定高度顶掉 */
.dash-panel .table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); }
.dash-panel .table:has(tr.empty-row) { height: 100%; }
.dash-panel .table tr.empty-row td { vertical-align: middle; border-bottom: 0; }
.dash-panel .empty-state { padding: 16px 20px; }
/* 数字列不折行：窄面板里宁可名称列折行、或在面板里横向滚，也别让「67.1 GiB」拆成两行 */
.dash-panel .table td.num, .dash-panel .table th.num, .dash-panel .meter-row { white-space: nowrap; }
.dash-panel .meter-row { min-width: 90px; }
.dash-panel.dash-ops > .table-wrap { height: auto; min-height: 120px; }
.dash-tag { font-size: calc(11.5px * var(--fs)); }

@media (max-width: 699px) {
    .dash-kpis .stat { padding: 12px 14px; }
    .dash-kpis .stat-value { font-size: calc(22px * var(--fs)); line-height: calc(28px * var(--fs)); }
    .dash-kpis .stat-value.sm { font-size: calc(15px * var(--fs)); line-height: calc(28px * var(--fs)); }
    .dash-kpis .stat-sub, .dash-kpis .stat-label { font-size: calc(11.5px * var(--fs)); }
    .dash-chart { height: 232px; }
    .dash-empty { height: 200px; }
    .dash-panel > .table-wrap { height: 340px; }
}
@media (min-width: 1000px) {
    .dash-charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* 表格面板 1240 起才并排：1024 的主区域只有 730px 宽，两张表各 350px 会把数字挤成两行 */
@media (min-width: 1240px) {
    .dash-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
    .dash-panels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-panel-wide { grid-column: 1 / -1; }
}
@media (min-width: 1700px) {
    .dash-panels { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr); }
    .dash-panel-wide { grid-column: auto; }
}
@media (min-width: 2000px) {
    .dash-kpis { grid-template-columns: repeat(8, minmax(0, 1fr)); }
    .dash-charts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- 数据中心（报表） ---------- */
/* 时间工具条（数据中心各报表共用）：所有控件同高 --ctl-h（电脑 36px、触屏 40px）。
   电脑 / 平板：第一行「时间段分段控件 …… 导出」，第二行「起止日期（合成一个输入框）+ 查询 + 时段说明」；
   手机：时间段等分一行 / 日期占满一行 / 时段说明 + 导出。 */
.report-tools {
    --ctl-h: 36px;
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "presets presets export" "range label label";
    align-items: center; gap: 12px 16px; padding: 14px 20px; border-bottom: 1px solid var(--n-100);
}
@media (pointer: coarse) { .report-tools { --ctl-h: 40px; } }
.report-tools .report-presets { grid-area: presets; margin: 0; padding: 3px; gap: 2px; min-width: 0; max-width: 100%; justify-self: start; }
.report-presets .subtab { display: inline-flex; align-items: center; height: calc(var(--ctl-h) - 6px); padding: 0 14px; }
.report-range { grid-area: range; display: flex; align-items: center; gap: 8px; min-width: 0; }
/* 起止日期合成一个带边框的输入框：中间一个「至」分隔，聚焦时整体高亮（iOS 的日期框原生样式高度不一，统一抹平） */
.report-dates {
    display: flex; align-items: center; min-width: 0; height: var(--ctl-h);
    border: 1px solid var(--n-300); border-radius: var(--r); background: var(--n-0); overflow: hidden;
}
.report-dates:focus-within { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }
.report-dates input[type="date"] {
    -webkit-appearance: none; appearance: none; flex: none; width: 140px; min-width: 0; max-width: 100%;
    height: 100%; min-height: 0; margin: 0; padding: 0 10px; border: 0; border-radius: 0; background: transparent; box-shadow: none;
    color: var(--n-800); font: calc(13.5px * var(--fs))/calc(20px * var(--fs)) var(--font); text-align: left;
}
.report-dates input[type="date"]:focus { outline: none; box-shadow: none; }
.report-dates input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.report-dates-sep {
    flex: none; align-self: stretch; display: flex; align-items: center; padding: 0 8px;
    background: var(--n-25); border-left: 1px solid var(--n-200); border-right: 1px solid var(--n-200); color: var(--n-600); font-size: calc(12.5px * var(--fs));
}
.report-range .btn, .report-export {
    flex: none; height: var(--ctl-h); min-height: 0; padding: 0 16px;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.report-label { grid-area: label; min-width: 0; font-size: calc(12.5px * var(--fs)); }
.report-export { grid-area: export; justify-self: end; }
/* 卡片够宽（按卡片自己的宽度算，不是屏幕宽度）时排成一行，三档：
   ≥740px（iPad 竖屏 / 横屏）紧凑版：时间段、日期、查询、图标式导出按钮一行，时段说明省掉（和日期框内容重复）；
   ≥1000px 宽松版：按钮和日期框放大、导出带文字；≥1240px 再带上时段说明（占剩余宽度，放不下省略号）。 */
.box:has(> .report-tools) { container-type: inline-size; }
.report-export-text { white-space: nowrap; }
@container (min-width: 740px) {
    .report-tools { grid-template-columns: auto auto minmax(0, 1fr) auto; grid-template-areas: "presets range label export"; gap: 12px; padding: 14px; }
    .report-label { display: none; }
    .report-range { gap: 6px; }
    .report-presets .subtab { padding: 0 9px; }
    .report-dates input[type="date"] { width: 124px; padding: 0 8px; }
    .report-range .btn { padding: 0 14px; }
    .report-export { width: var(--ctl-h); padding: 0; }
    .report-export-text { display: none; }
}
@container (min-width: 1000px) {
    .report-tools { gap: 12px 16px; padding: 14px 20px; }
    .report-range { gap: 8px; }
    .report-presets .subtab { padding: 0 14px; }
    .report-dates input[type="date"] { width: 140px; padding: 0 10px; }
    .report-range .btn { padding: 0 16px; }
    .report-export { width: auto; padding: 0 16px; }
    .report-export-text { display: inline; }
}
@container (min-width: 1240px) {
    .report-label { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
/* 图上手指纵向滑动照常滚页面，不带着页面横向晃 */
.dash-chart .u-over { touch-action: pan-y; }
/* 筛选条：搜索框和客户框随宽度伸缩，手机上搜索独占一行、客户 + 状态并排 */
.report-filters { flex: 1 1 360px; flex-wrap: nowrap; min-width: 0; }
.report-filters .search { flex: 1 1 200px; width: auto; min-width: 0; max-width: 340px; }
.report-filters .filter-field { flex: 1 1 180px; min-width: 0; max-width: 300px; }
.report-filters select { flex: none; }
/* 列表头部：计数 + 分页永远靠右，换行后也不掉到左边 */
.table-tools > .pagination, .table-tools > .report-count { margin-left: auto; }
/* 数据中心表格：每格一行不折，放不下整表横滑；客户名、出口这类长文本限宽省略 */
.report-table td { white-space: nowrap; }
.report-table .cell-clip { max-width: 20em; overflow: hidden; text-overflow: ellipsis; }
.report-table .meter-row { min-width: 150px; }
.report-alert { margin: 14px 20px 0; }
.report-count { font-size: calc(12.5px * var(--fs)); white-space: nowrap; }
/* 客户端统计的四张指标卡：平板和桌面始终一行四张（通用 .stat-grid 在窄屏会掉成单列 / 每行三张），手机两列 */
.stat-grid.report-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.report-kpis .stat { min-width: 0; padding: 14px 16px; }
.report-kpis .stat-sub { overflow-wrap: anywhere; }
@media (max-width: 640px) { .stat-grid.report-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
.report-table th, .report-table td { padding-left: 10px; padding-right: 10px; }
.report-table th:first-child, .report-table td:first-child { padding-left: 20px; }
.report-table td.num, .report-table th.num { white-space: nowrap; }
.report-table .mono { white-space: nowrap; }
.report-sub { font-size: calc(12px * var(--fs)); margin-left: 4px; }
.report-notes { padding: 10px 20px 14px; border-top: 1px solid var(--n-100); }
.report-note { margin: 0; color: var(--n-600); font-size: calc(12.5px * var(--fs)); line-height: calc(18px * var(--fs)); }
.report-chart-row > td { padding: 12px 20px 16px; background: var(--n-25); }
.report-chart-row .dash-chart { height: 252px; }
.report-gap { margin-bottom: 16px; }
.report-chart-body { border-bottom: 1px solid var(--n-100); padding-bottom: 12px; }
.report-chart-hint { margin: 6px 0 0; font-size: calc(12px * var(--fs)); }
/* 饼图卡片：同一行等高（grid 拉伸）；饼图区固定高度，图例多了在区域里滚动；没有数据时提示在同样高的区域里居中 */
.report-pies { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.report-wide { grid-column: 1 / -1; }
.report-pie-box { height: 280px; display: flex; align-items: center; gap: 20px; }
.report-pie-box .dash-empty { width: 100%; height: 100%; }
.report-pie-svg { flex: none; width: 200px; height: 200px; }
.report-pie-svg circle.slice { transition: opacity .12s; }
.report-pie-svg.dim circle.slice { opacity: .35; }
.report-pie-svg.dim circle.slice.on { opacity: 1; }
.report-pie-total { font: 650 calc(15px * var(--fs))/1 var(--font); fill: var(--n-900); font-variant-numeric: tabular-nums; }
.report-pie-unit { font: calc(8px * var(--fs))/1 var(--font); fill: var(--n-400); }
.report-pie-legend { flex: 1; min-width: 0; max-height: 100%; overflow: auto; margin: 0; padding: 0; list-style: none; }
.report-pie-legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 5px 4px; border-radius: var(--r-sm); font-size: calc(13px * var(--fs)); line-height: calc(18px * var(--fs)); }
.report-pie-legend li:hover, .report-pie-legend li.on { background: var(--n-50); }
.report-pie-legend .sw { width: 10px; height: 10px; border-radius: 2px; }
.report-pie-legend .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-pie-legend .nm small { color: var(--n-400); margin-left: 6px; }
.report-pie-legend .v { font-variant-numeric: tabular-nums; text-align: right; }
.report-pie-legend .p { min-width: 46px; text-align: right; color: var(--n-600); font-variant-numeric: tabular-nums; }
@media (max-width: 699px) {
    .report-pie-box { height: 400px; flex-direction: column; align-items: stretch; gap: 8px; }
    .report-pie-svg { align-self: center; width: 170px; height: 170px; }
    .report-pie-legend { flex: 1; min-height: 0; }
}
@media (min-width: 1000px) { .report-pies { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* 一行三张（失败原因 / 按系统 / 按客户）的那一组：宽屏并排，不够宽时表格独占一行 */
@media (min-width: 1700px) { .report-pies.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } .report-pies.three .report-wide { grid-column: auto; } }
.report-three { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.report-tall > .table-wrap { height: 560px; }
/* 两张排行并排、下面一张整宽（热门域名与 IP）：固定两列，别让 auto-fit 在宽屏多出一个空列，上下两排左右对不齐 */
.dash-cols.report-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 960px) { .dash-cols.report-pair { grid-template-columns: 1fr; } }
.box > .report-tools + .table-tools { border-bottom: 1px solid var(--n-100); }
@media (max-width: 699px) {
    .report-tools {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "presets presets" "range export";
        gap: 10px 8px; padding: 12px 14px;
    }
    /* 手机：两行——时间段等分一行；日期 + 查询 + 图标式导出一行；时段说明省掉（和日期框重复） */
    .report-label { display: none; }
    .report-export { width: 38px; padding: 0; }
    .report-export-text { display: none; }
    .report-tools .report-presets { justify-self: stretch; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(max-content, 1fr); overflow-x: auto; scrollbar-width: none; }
    .report-presets .subtab { justify-content: center; padding: 0 10px; }
    .report-range { width: 100%; }
    .report-dates { flex: 1 1 auto; }
    .report-dates input[type="date"] { flex: 1 1 0; width: auto; padding: 0 4px; font-size: calc(12.5px * var(--fs)); }  /* iPhone 上卡片只有 ~358px：日期框每个约 100px，「2026年10月18日」要放得下 */
    .report-dates-sep { padding: 0 4px; }
    .report-range { gap: 6px; }
    .report-range .btn { padding: 0 10px; }
    .report-filters { flex: 1 1 100%; flex-wrap: wrap; }
    .report-filters .search { flex-basis: 100%; max-width: none; }
    .report-filters .filter-field { flex: 1 1 0; max-width: none; }
}
/* 节点负载：中文名（链到详情）+ 下一行节点名；整行可点，展开速率曲线 */
.report-node { white-space: nowrap; }
.report-node-name { display: block; font-weight: 500; }
.report-node-tag { display: block; margin-top: 2px; color: var(--n-600); font-size: calc(12px * var(--fs)); line-height: calc(16px * var(--fs)); }
.report-node-row { cursor: pointer; }
.report-node-row:focus-visible { outline: 2px solid var(--brand-500); outline-offset: -2px; }
.report-node-row.open td { background: var(--n-25); }
input[type="date"] { width: 100%; min-height: 32px; padding: 5px 10px; border: 1px solid var(--n-300); border-radius: var(--r); background: var(--n-0); color: var(--n-800); font: calc(13.5px * var(--fs))/calc(20px * var(--fs)) var(--font); }

/* ---------- 平板竖屏：整表横滚时冻结首列，滚到右边还能看见是哪一行 ----------
   只冻结「内容够短」的首列（app.js 量过、不超过 150px 才给表格打 data-freeze）；首列文字很长的表不冻结，
   免得冻结列吃掉大半屏、后面的信息滚不出来。手机（含横屏）屏幕太窄，一律不冻结。 */
@media (max-width: 960px) {
    .table-wrap > .table[data-freeze] :is(th, td):first-child:not(.col-drag):not(.col-check):not(.num),
    .table-wrap > .table[data-freeze] :is(th, td).col-key {
        position: sticky; left: 0; z-index: 2; background: var(--surface);
        box-shadow: 1px 0 0 var(--divider);
    }
    .table-wrap > .table[data-freeze] :is(th, td).col-check { position: sticky; left: 0; z-index: 2; background: var(--n-0); }
    /* 首列前面有勾选 / 拖动列时，冻结的是「勾选 + 标识」两列（标识列左边让出勾选列的宽度） */
    .table-wrap > .table[data-freeze] :is(th, td).col-key { left: 36px; }
    .table-wrap > .table[data-freeze]:not(:has(.col-check)) :is(th, td).col-key { left: 0; }
    .table-wrap > .table[data-freeze] :is(th, td):first-child.col-key { left: 0; }
}
.table .is-open { white-space: normal !important; overflow: visible !important; max-width: none !important; overflow-wrap: anywhere; }

/* ---------- 触屏（iPhone / iPad，含 iPad 横屏）---------- */
@media (pointer: coarse) {
    /* iOS 聚焦字号 <16px 的输入框会整页放大且不还原 */
    input[type="text"], input[type="email"], input[type="number"], input[type="password"], input[type="search"],
    input[type="datetime-local"], input[type="date"], input[type="url"], input[type="tel"], select, textarea,
    .mono-input, .gsearch input, .report-dates input[type="date"] { font-size: calc(16px * var(--fs)); }
    /* 触控区 ≥40px：用 min-height / 伪元素扩展，不撑高表格行 */
    .btn { min-height: 40px; }
    .btn-sm { min-height: 36px; }
    .topnav-logout { height: 36px; }
    .nav-burger { width: 40px; height: 40px; }
    .sidenav-link { min-height: 44px; }
    .sidenav-group > summary { min-height: 40px; }
    .icon-btn { position: relative; }
    .icon-btn::after { content: ""; position: absolute; inset: -8px; }
    input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
    .tabs .tab { padding-top: 12px; padding-bottom: 12px; }
    .subtabs .subtab { padding-top: 9px; padding-bottom: 9px; }
    .choice, .seg span { min-height: 40px; }
}

/* 视口高度：iPhone Safari 的 100vh 是「地址栏收起时」的高度，底部按钮会被盖住；支持 dvh 的用 dvh */
@supports (height: 100dvh) {
    .layout { min-height: calc(100dvh - var(--topnav-h)); }
    .sidenav { height: calc(100dvh - var(--topnav-h)); }
    .params-dialog { max-height: calc(100dvh - 48px); }
    .params-dialog-body { max-height: calc(100dvh - 48px - 64px); }
    .hotkey-dialog, .edit-dialog { max-height: calc(100dvh - 64px); }
}
/* 抽屉（≤960px 是 position: fixed + bottom: 0）不需要 height */
@media (max-width: 960px) { .sidenav { height: auto; padding-bottom: env(safe-area-inset-bottom); } }
.save-bar { bottom: max(12px, env(safe-area-inset-bottom)); }

/* ---------- 手机 ---------- */
@media (max-width: 640px) {
    /* Toast：放到顶栏下面、贴两边，不盖住汉堡和退出 */
    .app-toasts { top: calc(var(--topnav-h) + 8px); right: 8px; left: 8px; width: auto; }
    /* 保存条：提示一行、按钮一行 */
    .save-bar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
    .save-bar .save-hint { flex: 1 0 100%; }
    .save-bar .btn { flex: 1 1 auto; }
}
/* 折行后的并排小表单：不留竖线和缩进 */
@media (max-width: 960px) {
    .footer-form + .footer-form { padding-left: 0; border-left: 0; }
}
/* 标签页横滚：右侧渐隐，提示还有 */
@media (max-width: 960px) {
    .tabs, .subtabs { scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .tabs::-webkit-scrollbar, .subtabs::-webkit-scrollbar { display: none; }
}
html.nav-open, html.nav-open body { overflow: hidden; }
/* 高分辨率：内容区铺满，不留左右空白；列表列间距随宽度加大，让多出来的宽度匀在列间而不是挤在某一列 */
@media (min-width: 1800px) { .table-list th, .table-list td, .table-catalog th, .table-catalog td { padding-left: 18px; padding-right: 18px; } }
@media (min-width: 2300px) { .table-list th, .table-list td, .table-catalog th, .table-catalog td { padding-left: 28px; padding-right: 28px; } }
.stat { min-width: 0; }
.stat-sub, .stat-value { overflow-wrap: anywhere; }

/* 手机顶栏：全局搜索收成一个图标，点开（聚焦）后盖满整条顶栏 */
@media (max-width: 640px) {
    .gsearch { flex: 0 0 40px; margin-left: auto; }
    .gsearch input[type="search"] { padding: 0; width: 40px; height: 36px; color: transparent; cursor: pointer; }
    .gsearch input[type="search"]::placeholder { color: transparent; }
    .gsearch > .icon { left: 12px; top: 10px; color: var(--topbar-muted); }
    .gsearch:focus-within { position: absolute; left: 8px; right: 8px; top: 6px; flex: none; z-index: 5; }
    .gsearch:focus-within input[type="search"] { width: 100%; padding: 0 12px 0 34px; color: var(--text); cursor: text; }
    .gsearch:focus-within input[type="search"]::placeholder { color: var(--text-3); }
    .gsearch:focus-within > .icon { left: 10px; top: 10px; }
}

/* ---------- 图表 ---------- */
/* 图例折行时撑高而不是被裁掉 */
.dash-chart { height: auto; min-height: 252px; overflow: visible; }
.report-chart-row .dash-chart { height: auto; min-height: 252px; }
.dash-chart .u-legend.u-inline { text-align: left; }
.dash-chart .u-legend.u-inline .u-series { padding: 2px 6px 2px 0; margin-right: 8px; }  /* uPlot 默认 16px，窄卡片放不下一行 */
/* 总览图例固定一行：悬停时数值变长也不换行（不让下面的内容跳动），放不下的部分可以横向滑动查看 */
.dash-charts .dash-chart .u-legend.u-inline { max-width: 100%; box-sizing: border-box; white-space: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.dash-charts .dash-chart .u-legend.u-inline::-webkit-scrollbar { display: none; }
.dash-charts .dash-chart .uplot { width: 100%; }  /* uPlot 自带 width: min-content，图例不换行时会被悬停的长数值撑宽 */
.dash-charts .dash-chart .u-legend .u-value { font-variant-numeric: tabular-nums; }
/* 关掉的序列（如默认隐藏的「直连」）图例里只留名字，不占冒号和数值的位置，窄卡片上图例保持一行 */
.dash-chart .u-legend.u-inline .u-series.u-off .u-value { display: none; }
.dash-chart .u-legend.u-inline.u-live .u-series.u-off th::after { content: none; }
/* 节点报表展开行：不吃 .table td 的 36em 上限；图表宽度只取可视区域，横滚时钉在左边 */
.table td.report-chart-cell, .report-chart-row > td { max-width: none; overflow: visible; white-space: normal; padding: 0; }
.report-chart-row .dash-chart { position: sticky; left: 0; padding: 8px 14px; box-sizing: border-box; }
/* 手机：日期区间上下两行，每个框铺满（16px 字号下一行放不下「2026年10月18日」） */
@media (max-width: 640px) {
    .report-dates { flex-wrap: wrap; height: auto; }
    .report-dates input[type="date"] { flex: 1 1 100%; height: var(--ctl-h); padding: 0 10px; font-size: calc(16px * var(--fs)); }
    .report-dates-sep { display: none; }
}
.table .drag-handle { touch-action: none; }
@media (pointer: coarse) { .table .col-drag, .table .drag-handle { width: 40px; font-size: calc(18px * var(--fs)); } }
/* iOS Safari 的 PDF iframe 只显示第一页且不能滚：触屏改成「打开 PDF」按钮 */
.label-open-pdf { display: none; }
@media (pointer: coarse) { .label-open-pdf { display: inline-flex; } #label-preview { display: none; } }
/* iPad（竖屏 / 横屏）：8 张 KPI 卡四列两行，紧凑版；原来每行 2 张、单卡 400px+ 又长又空 */
@media (min-width: 700px) and (max-width: 1239px) {
    .dash-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
    .dash-kpis .stat { padding: 12px 14px; }
    .dash-kpis .stat-value { font-size: calc(22px * var(--fs)); line-height: calc(28px * var(--fs)); }
    .dash-kpis .stat-value.sm { font-size: calc(15px * var(--fs)); }
    .dash-kpis .stat-sub, .dash-kpis .stat-label { font-size: calc(11.5px * var(--fs)); }
}
.stat .mono, .stat-sub .mono { overflow-wrap: anywhere; word-break: break-all; }
.q-kpi { min-width: 0; }
.q-kpi-foot { overflow-wrap: anywhere; }
.q-kpi-foot .mono { word-break: break-all; }

/* 明确要折行的单元格（设备 SN 列表、已装服务、事件列表）：一长串小项，折行显示；不吃 .table td 的不折行 / 36em 上限 */
.table td.wrap { white-space: normal; overflow: visible; max-width: none; overflow-wrap: anywhere; line-height: 1.9; }
/* 设备版本页：每个服务一张表，列宽固定一致，各段之间的列才对得齐；其余单元格顶对齐，贴着设备列表的第一行 */
.table-versions { table-layout: fixed; width: 100%; min-width: 640px; }
.table-versions td { vertical-align: top; }
.table-versions td.col-actions { vertical-align: top; }
.table-versions td { line-height: 1.9; }

/* ---------- v2 视觉补充：手机字号降一档、指标卡紧凑 ---------- */
@media (max-width: 640px) {
    .box { border-radius: 10px; margin-bottom: 16px; }
    .box-header { padding: 16px 14px 12px; }
    .box-header h1 { font-size: calc(19px * var(--fs)); line-height: calc(26px * var(--fs)); }
    .box-header h2 { font-size: calc(15.5px * var(--fs)); line-height: calc(22px * var(--fs)); }
    .box-desc { font-size: calc(12.5px * var(--fs)); line-height: calc(18px * var(--fs)); }
    .table { font-size: calc(13px * var(--fs)); }
    .table th { font-size: calc(12.5px * var(--fs)); }
    .tabs .tab { font-size: calc(13.5px * var(--fs)); padding-left: 10px; padding-right: 10px; }
    .stat { padding: 14px; }
    .stat-label { font-size: calc(12.5px * var(--fs)); }
    .stat-value { font-size: calc(21px * var(--fs)); line-height: calc(28px * var(--fs)); }
    .stat-value.sm { font-size: calc(16px * var(--fs)); line-height: calc(28px * var(--fs)); }
    .stat-sub { font-size: calc(12px * var(--fs)); }
    .q-kpi { padding: 14px; }
    .q-kpi-value { font-size: calc(21px * var(--fs)); line-height: calc(28px * var(--fs)); }
    .status { font-size: calc(13px * var(--fs)); }
    .btn { font-size: calc(13.5px * var(--fs)); }
    .dash-section { font-size: calc(14px * var(--fs)); }
    .sidenav-link { font-size: calc(15px * var(--fs)); }
}

/* ---------- 手机：列表表格变摘要卡片 ----------
   适用：四个主列表（.table-list）、设备管理各栏目（.table-catalog）和显式加了 data-cards 的列表。
   每行一张卡：第一列（或 .col-key）当标题占满一行，其余列两两并排、上面小字标列名（列名由 app.js 按表头填进 data-label）；
   勾选框放在卡片右上角，操作列、空状态占满一行。卡片里不省略、不横滚，长文本折行。 */
@media (max-width: 640px) {
    .table-wrap:has(> :is(.table-list, .table-catalog, .table[data-cards])) { overflow-x: visible; }
    :is(.table-list, .table-catalog, .table[data-cards]),
    :is(.table-list, .table-catalog, .table[data-cards]) > tbody { display: block; width: 100%; }
    :is(.table-list, .table-catalog, .table[data-cards]) > thead { display: none; }
    :is(.table-list, .table-catalog, .table[data-cards]) > tbody > tr {
        position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px;
        padding: 14px; border-bottom: 1px solid var(--divider);
    }
    :is(.table-list, .table-catalog, .table[data-cards]) > tbody > tr:last-child { border-bottom: 0; }
    :is(.table-list, .table-catalog, .table[data-cards]) > tbody > tr > td {
        display: block; min-width: 0; max-width: none; height: auto; padding: 0 !important; border: 0;
        white-space: normal; overflow: visible; overflow-wrap: anywhere; text-align: left; background: none;
    }
    :is(.table-list, .table-catalog, .table[data-cards]) > tbody > tr > td[data-label]::before {
        content: attr(data-label); display: block; margin-bottom: 2px;
        color: var(--text-3); font-size: calc(11.5px * var(--fs)); font-weight: 500; line-height: calc(16px * var(--fs));
    }
    /* 标题：第一列或 .col-key */
    :is(.table-list, .table-catalog, .table[data-cards]) > tbody > tr > td.card-title { grid-column: 1 / -1; padding-right: 36px !important; font-size: calc(14.5px * var(--fs)); }
    :is(.table-list, .table-catalog, .table[data-cards]) > tbody > tr > td.card-title::before { display: none; }
    :is(.table-list, .table-catalog, .table[data-cards]) > tbody > tr > :is(td.col-actions, td.card-wide, td[colspan]) { grid-column: 1 / -1; }
    :is(.table-list, .table-catalog, .table[data-cards]) > tbody > tr > td.col-actions::before { display: none; }
    :is(.table-list, .table-catalog, .table[data-cards]) > tbody > tr > td.col-check { position: absolute; top: 12px; right: 12px; }
    :is(.table-list, .table-catalog, .table[data-cards]) > tbody > tr > td.col-check::before { display: none; }
    :is(.table-list, .table-catalog, .table[data-cards]) > tbody > tr.empty-row { display: block; padding: 0; }
    :is(.table-list, .table-catalog, .table[data-cards]) > tbody > tr:hover > td { background: none; }
    :is(.table-list, .table-catalog, .table[data-cards]) > tbody > tr:active { background: var(--hover); }
    :is(.table-list, .table-catalog, .table[data-cards]) > tbody > tr.row-new { background: var(--ok-bg); }
    :is(.table-list, .table-catalog, .table[data-cards]) > tbody > tr.row-new > td { background: none; }
    :is(.table-list, .table-catalog, .table[data-cards]) :is(.cell-ellipsis, .cell-sub, .sc-note, .sc-customer, .sc-node, .sc-device, .sc-person,
        .device-model, .device-note, .device-customer, .cell-clip, .ident-sub, .dl-cut, .dl-clamp, .list-sub, .sc-secondary, .sc-expiry, .device-secondary, .dl-reason) { max-width: none; white-space: normal; overflow: visible; -webkit-line-clamp: unset; }
    :is(.table-list, .table-catalog, .table[data-cards]) .list-datetime { display: inline; }
    /* 筛选条：搜索框独占一行，其余两两并排（模板里有固定宽度的行内样式，这里放开） */
    .filters { width: 100%; gap: 8px; }
    .filters > * { flex: 1 1 calc(50% - 4px); min-width: 0; width: auto !important; }
    .filters > .search, .filters > :only-child { flex-basis: 100%; }
    .filters > select { width: auto; }
    .table-tools > .pagination { margin-left: auto; }
    :is(.table-list, .table-catalog, .table[data-cards]) .list-datetime span + span { margin-left: 4px; font-size: inherit; }
}

/* 小屏手机（<375px，如 iPhone SE 1 代）：顶栏只留 AF 标记，长的技术值允许断行 */
@media (max-width: 374px) {
    .brand > span:not(.brand-mark) { display: none; }
    .topnav { gap: 6px; }
    .topnav-logout { padding: 0 8px; }
    .info-readonly, .stat-sub b, .report-label b { overflow-wrap: anywhere; word-break: break-all; }
}

/* ==================== 第 5 步：详情页与弹窗 ==================== */

/* ---------- 详情页页头：去掉左侧竖条，实体标签改成标题上方的小号眉标（颜色仍区分客户 / 服务码层级） ---------- */
.page-entity { border-left: 0; padding-left: 0; }
@media (min-width: 961px) { .page-header { align-items: center; } }
.entity-badge {
    display: inline-flex; align-items: center; gap: 6px; margin: 0 0 6px; padding: 0;
    border: 0; border-radius: 0; background: none;
    color: var(--entity, var(--text-2)); font-size: calc(12.5px * var(--fs)); font-weight: 600; letter-spacing: .02em; line-height: calc(16px * var(--fs));
}
.entity-badge::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.page-header .desc a.mono, .page-header .desc .mono { font-size: .95em; }
.page-header .desc .status { vertical-align: -1px; }

/* ---------- 概览五张指标卡：≥1440 一行五张；中等宽度上三下二，铺满不留空格 ---------- */
.q-kpis-5 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.q-kpis-5 > .q-kpi { grid-column: span 2; }
.q-kpis-5 > .q-kpi:nth-child(n+4) { grid-column: span 3; }
@media (min-width: 1440px) {
    .q-kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .q-kpis-5 > .q-kpi, .q-kpis-5 > .q-kpi:nth-child(n+4) { grid-column: auto; }
}
@media (max-width: 799px) {
    .q-kpis-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .q-kpis-5 > .q-kpi, .q-kpis-5 > .q-kpi:nth-child(n+4) { grid-column: auto; }
    .q-kpis-5 > .q-kpi:last-child { grid-column: 1 / -1; }
}

/* ---------- 手机：指标卡合成一张列表卡，每项一行（名称、说明在左，数值在右），不再一张卡占半屏 ---------- */
@media (max-width: 640px) {
    .q-kpis, .q-kpis-5 {
        grid-template-columns: minmax(0, 1fr); gap: 0;
        background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg); box-shadow: var(--sh-1); overflow: hidden;
    }
    :root[data-theme="dark"] :is(.q-kpis, .q-kpis-5) { border-color: var(--border); }
    .q-kpis > .q-kpi, .q-kpis-5 > .q-kpi, .q-kpis-5 > .q-kpi:last-child {
        grid-column: auto; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 12px;
        padding: 12px 14px; border: 0; border-radius: 0; box-shadow: none; background: none;
    }
    .q-kpis > .q-kpi + .q-kpi { border-top: 1px solid var(--divider); }
    .q-kpi > .q-kpi-head { grid-column: 1; justify-content: flex-start; font-size: calc(13px * var(--fs)); }
    .q-kpi > .q-kpi-value { grid-column: 2; grid-row: 1 / span 2; text-align: right; font-size: calc(18px * var(--fs)); line-height: calc(24px * var(--fs)); }
    .q-kpi > .q-kpi-value.q-kpi-text { font-size: calc(15px * var(--fs)); }
    .q-kpi > .q-kpi-foot { grid-column: 1; margin-top: 0; }
    .q-kpi > .meter { grid-column: 1 / -1; margin-top: 6px; }
}

/* ---------- 字符图标换成 SVG 后的尺寸 ---------- */
.pagination .nav { display: inline-flex; align-items: center; justify-content: center; }
.pagination .nav .icon { width: 15px; height: 15px; }
.icon-caret { width: 14px; height: 14px; margin-left: 2px; margin-right: -4px; color: var(--text-2); }
.more-menu[open] .icon-caret { transform: rotate(180deg); }
.table .drag-handle { letter-spacing: 0; }
.table .drag-handle .icon { display: block; width: 16px; height: 16px; }
.icon-inline { width: 14px; height: 14px; vertical-align: -2px; }
.picker-chip button { display: inline-grid; place-items: center; }
.picker-chip button .icon { width: 12px; height: 12px; }
.flash-close { display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border-radius: var(--r); }
.flash-close .icon { width: 16px; height: 16px; }
.flash-close:hover { background: var(--hover); }

/* ---------- 弹窗：确认框、热键列表、双击编辑、日志参数共用一套外观 ---------- */
:is(.app-dialog, .hotkey-dialog, .edit-dialog, .params-dialog) {
    border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--text); box-shadow: var(--sh-pop);
}
:is(.app-dialog, .hotkey-dialog, .edit-dialog, .params-dialog)[open] { animation: dialog-in 180ms ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.hotkey-head, .params-dialog-head { gap: 12px; padding: 12px 12px 12px 20px; border-bottom-color: var(--divider); }
.hotkey-head h2, .params-dialog-title { font-size: calc(16px * var(--fs)); font-weight: 600; color: var(--text-strong); }
.hotkey-head .flash-close { width: 36px; height: 36px; color: var(--text-2); }
.hotkey-head .flash-close .icon { width: 18px; height: 18px; }
/* 长内容滚动时标题栏（含关闭按钮）留在顶上 */
:is(.hotkey-dialog, .edit-dialog) > .hotkey-head { position: sticky; top: 0; z-index: 2; background: var(--surface); }
.app-dialog-title { color: var(--text-strong); font-size: calc(16px * var(--fs)); }
.app-dialog-message { color: var(--text-2); font-size: calc(14px * var(--fs)); line-height: calc(22px * var(--fs)); }
.app-dialog-icon { background: var(--brand-bg); color: var(--brand-text); }
.app-dialog-actions .btn { min-width: 88px; justify-content: center; }

/* 手机：弹窗从底部弹出（Bottom Sheet），全宽、上圆角、顶部有拖动条样式的提示、避开 Home 指示条；按钮 44px 高、上下排列 */
@media (max-width: 640px) {
    :is(.app-dialog, .hotkey-dialog, .edit-dialog, .params-dialog) {
        width: 100%; max-width: none; margin: auto 0 0; max-height: calc(100vh - 24px);
        border-width: 1px 0 0; border-radius: 16px 16px 0 0;
        padding-bottom: env(safe-area-inset-bottom);
    }
    :is(.app-dialog, .hotkey-dialog, .edit-dialog, .params-dialog)[open] { animation: sheet-in 220ms cubic-bezier(.2, .8, .2, 1); }
    @keyframes sheet-in { from { transform: translateY(100%); } }
    :is(.app-dialog, .hotkey-dialog, .edit-dialog, .params-dialog)::before {
        content: ""; display: block; width: 36px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--border-strong);
    }
    :is(.hotkey-dialog, .edit-dialog) > .hotkey-head { top: 0; }
    .hotkey-head, .params-dialog-head { padding: 6px 8px 10px 16px; }
    .app-dialog-main { gap: 12px; padding: 14px 16px 4px; }
    .app-dialog-icon { width: 32px; height: 32px; }
    .app-dialog-message { max-height: 45vh; }
    .app-dialog-actions { flex-direction: column-reverse; gap: 8px; padding: 16px; }
    .app-dialog-actions .btn { width: 100%; min-height: 44px; font-size: calc(15px * var(--fs)); }
    .hotkey-grid { grid-template-columns: minmax(0, 1fr); padding: 4px 16px 16px; }
    .edit-dialog-body { padding: 12px 16px 0; }
    /* 编辑表单的保存 / 取消贴在底部，长表单不用滚到底才能提交 */
    .edit-dialog-body .form-actions {
        position: sticky; bottom: 0; z-index: 1; display: flex; flex-direction: column-reverse; gap: 8px;
        margin: 16px -16px 0; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--divider);
    }
    .edit-dialog-body .form-actions .btn { width: 100%; min-height: 44px; justify-content: center; }
    .params-dialog-body { max-height: calc(100vh - 24px - 70px); padding: 12px 16px 16px; font-size: calc(13px * var(--fs)); line-height: calc(20px * var(--fs)); }
}
@supports (height: 100dvh) {
    @media (max-width: 640px) {
        :is(.app-dialog, .hotkey-dialog, .edit-dialog, .params-dialog) { max-height: calc(100dvh - 24px); }
        .params-dialog-body { max-height: calc(100dvh - 24px - 70px); }
    }
}
@media (prefers-reduced-motion: reduce) {
    :is(.app-dialog, .hotkey-dialog, .edit-dialog, .params-dialog)[open] { animation: none; }
}

/* ==================== 第 6 步：表单、文件选择、图表图例、登录页 ==================== */

/* 表单网格：auto-fill 代替 auto-fit，只有一两个字段时保持正常列宽，不再一个输入框横贯整张卡片 */
.form-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.form-grid.tight { grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); }

/* 文件选择框：和其它输入框同一外观，按钮用次要按钮样式（浏览器默认的「Choose File」太突兀） */
input[type="file"] {
    display: block; width: 100%; max-width: 560px; min-height: 40px; padding: 4px;
    border: 1.5px dashed var(--border-strong); border-radius: var(--r-md); background: var(--surface-2, var(--surface));
    color: var(--text-2); font: inherit; font-size: calc(13.5px * var(--fs)); cursor: pointer;
}
input[type="file"]:hover { border-color: var(--brand); }
input[type="file"]:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
input[type="file"]::file-selector-button {
    margin-right: 12px; min-height: 30px; padding: 0 14px;
    border: 1.5px solid var(--border-strong); border-radius: var(--r); background: var(--surface);
    color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--hover); }

/* 图表图例：小字、色块圆角，数值等宽加粗；和坐标轴同一灰度 */
.uplot .u-legend { font-size: calc(12.5px * var(--fs)); color: var(--text-2); }
.uplot .u-legend th { font-weight: 500; }
.uplot .u-legend .u-marker { width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.uplot .u-legend .u-value { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.uplot .u-legend .u-series { padding: 2px 10px 2px 0; }

/* 登录页（运营后台、portal 共用）：卡片稍宽、上方留白按视口高度，标题更醒目，按钮 44px 便于触控 */
.login-wrap { padding-top: clamp(32px, 12vh, 120px); }
.login-box { width: min(400px, 100%); }
.login-box .box-header { padding: 28px 28px 8px; }
.login-box .box-header h1, .login-box .box-header h2 { font-size: calc(22px * var(--fs)); line-height: calc(30px * var(--fs)); }
.login-box .box-body { padding: 12px 28px 28px; }
.login-box input { min-height: 42px; }
.login-submit { width: 100%; min-height: 44px; margin-top: 4px; font-size: calc(15px * var(--fs)); justify-content: center; }
@media (max-width: 640px) {
    .login-wrap { padding: 24px 16px; }
    .login-box .box-header { padding: 22px 20px 6px; }
    .login-box .box-body { padding: 10px 20px 22px; }
}

/* ==================== 第 7 步：侧栏滚动条 ==================== */
/* 侧栏滚动条平时隐藏，鼠标移到侧栏上才出现细的一条（内容放得下时本来就没有） */
.sidenav-scroll { scrollbar-width: thin; scrollbar-color: transparent transparent; }
.sidenav-scroll:hover, .sidenav-scroll:focus-within { scrollbar-color: var(--border-strong) transparent; }
@media (min-width: 961px) {
    /* 图标栏：所有分组都展开（26 个入口），鼠标设备上每项 32px 高、分组间距收紧，1920×1080 一屏放得下；
       窄栏里不显示滚动条（64px 宽放一条滚动条会把图标挤偏），屏幕更矮时仍可滚轮滚动 */
    html.nav-rail .sidenav-scroll { scrollbar-width: none; padding-top: 12px; padding-bottom: 8px; }
    html.nav-rail .sidenav-scroll::-webkit-scrollbar { display: none; }
    html.nav-rail .sidenav-section + .sidenav-section { margin-top: 6px; padding-top: 6px; }
    html.nav-rail .sidenav-group:not([open]) { padding-bottom: 0; }
    html.nav-rail .sidenav-foot { padding-top: 4px; padding-bottom: 10px; }
    html.nav-rail .sidenav-scroll.has-more { -webkit-mask-image: linear-gradient(#000 calc(100% - 40px), transparent); mask-image: linear-gradient(#000 calc(100% - 40px), transparent); }
}
@media (min-width: 961px) and (pointer: fine) {
    html.nav-rail .sidenav-link { min-height: 32px; padding-top: 6px; padding-bottom: 6px; margin-bottom: 1px; }
    html.nav-rail .rail-toggle { min-height: 32px; }
}

/* ==================== 第 8 步：侧栏图标栏的悬停提示 ==================== */
.rail-tip {
    position: fixed; z-index: 300; left: 0; top: 0; pointer-events: none;
    padding: 6px 10px; border-radius: var(--r);
    background: #1C2530; color: #fff; font-size: calc(13px * var(--fs)); font-weight: 500; line-height: calc(18px * var(--fs)); white-space: nowrap;
    box-shadow: 0 4px 14px rgba(16, 24, 40, .18);
    opacity: 0; visibility: hidden; transform: translate(-4px, -50%);
    transition: opacity 120ms ease-out, transform 120ms ease-out, visibility 0s linear 120ms;
}
.rail-tip::before {
    content: ""; position: absolute; left: -4px; top: 50%; width: 8px; height: 8px;
    background: inherit; border-radius: 1px; transform: translateY(-50%) rotate(45deg);
}
.rail-tip.show { opacity: 1; visibility: visible; transform: translate(0, -50%); transition-delay: 0s; }
:root[data-theme="dark"] .rail-tip { background: #E8EDF3; color: #0D141E; box-shadow: 0 4px 14px rgba(0, 0, 0, .4); }

/* ==================== 出口节点详情：概览侧栏、流量分析的指标条和分栏 ==================== */
.num-text { font-variant-numeric: tabular-nums; }
.nk-aside-note { margin: 0; font-size: calc(13px * var(--fs)); }
.nk-today dd .muted { font-size: calc(12px * var(--fs)); }
.nk-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-top: 8px; }
.nk-section-head .dash-section { margin-bottom: 12px; }
.nk-link { font-size: calc(13px * var(--fs)); white-space: nowrap; }
/* 指标条：一个面板里分格，细线分隔，不做成一排独立大卡片；手机两列、平板四列、宽屏八格一行 */
.nk-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; padding: 0; overflow: hidden; background: var(--border); margin-bottom: 16px; }
.nk-metric { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 14px 16px; background: var(--surface); }
.nk-metric-label { font-size: calc(12px * var(--fs)); font-weight: 500; color: var(--text-2); }
.nk-metric-label[title] { cursor: help; text-decoration: underline dotted var(--text-3); text-underline-offset: 3px; }
.nk-metric-value { font-size: calc(20px * var(--fs)); line-height: calc(28px * var(--fs)); font-weight: 600; color: var(--text-strong); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.nk-metric-value .status { font-size: inherit; font-weight: inherit; }
.nk-metric-unit { font-size: calc(13px * var(--fs)); font-weight: 500; color: var(--text-2); }
.nk-metric-sub { margin-top: auto; font-size: calc(12px * var(--fs)); color: var(--text-2); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (min-width: 768px) { .nk-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1600px) { .nk-metrics { grid-template-columns: repeat(8, minmax(0, 1fr)); } .nk-metric-value { font-size: calc(18px * var(--fs)); } }
/* 两张并排的卡片（延迟 / 丢包、平台 / 版本、域名 / 目标 IP）：窄于 1100px 单列 */
.card-grid.nk-grid { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
@media (min-width: 1100px) { .card-grid.nk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.nk-grid .box-header h2 .badge { margin-left: 6px; vertical-align: 2px; }
/* 前 50 名的排行表在面板里滚动，表头吸顶，两张并排时一样高 */
.nk-scroll { max-height: 420px; overflow: auto; }
.nk-scroll thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); }
@media (max-width: 640px) {
    .nk-metric { padding: 12px; }
    .nk-metric-value { font-size: calc(17px * var(--fs)); line-height: calc(24px * var(--fs)); }
    .nk-scroll { max-height: 360px; }
}
/* 图表卡片的说明里有操作提示（拖选切时段），这一页不截成一行 */
.nk-traffic .dash-card .box-desc { white-space: normal; overflow: visible; }
/* 节点详情一级 tab：按时间段的分析和按配置的列表之间一条细分隔线 */
.nk-tabs { align-items: stretch; }
.nk-tabs .tab-sep { flex: none; width: 1px; margin: 10px 6px; background: var(--border); }

/* 服务码体检（.scc）：结论条在上；≥1280px 左边逐项检查、右边建议回复 + AI 排查，窄屏单列按 DOM 顺序。
   状态一律「图标 + 文字」（.status），颜色只做辅助：结论条和异常 / 注意项左边一道色条 */
.scc { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-bottom: 20px; }
.scc > .box, .scc-side > .box { margin: 0; }
.scc-side { display: grid; gap: 16px; align-content: start; min-width: 0; }
@media (min-width: 1280px) {
    .scc { grid-template-columns: minmax(0, 1.6fr) minmax(360px, 1fr); grid-template-areas: "verdict verdict" "items side"; align-items: start; }
    .scc-verdict { grid-area: verdict; }
    .scc-side { grid-area: side; }
    .scc-items { grid-area: items; }
}
/* 结论条 */
.scc-verdict { position: relative; }
.scc-verdict::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--ok-ic); }
.scc.is-warn .scc-verdict::before { background: var(--warn-ic); }
.scc.is-error .scc-verdict::before { background: var(--err-ic); }
.scc-verdict-main { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px 24px; padding: 20px 24px 18px 28px; }
.scc-verdict-text { flex: 1 1 420px; min-width: 0; }
.scc-eyebrow { margin: 0 0 8px; font-size: calc(12px * var(--fs)); line-height: calc(16px * var(--fs)); font-weight: 600; letter-spacing: .04em; color: var(--text-3); }
.scc-verdict-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0;
    font-size: calc(18px * var(--fs)); line-height: calc(26px * var(--fs)); font-weight: 600; color: var(--text-strong); }
.scc-verdict-title .status.pill { flex: none; }
.scc-headline { min-width: 0; overflow-wrap: anywhere; }
.scc-meta { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 10px 0 0; font-size: calc(12.5px * var(--fs)); line-height: calc(18px * var(--fs)); color: var(--text-2); font-variant-numeric: tabular-nums; }
.scc-verdict-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.scc-tally { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0; padding: 12px 24px 12px 28px; list-style: none; border-top: 1px solid var(--divider); background: var(--surface-2); }
.scc-tally li { display: inline-flex; align-items: center; gap: 8px; }
.scc-tally .status { font-size: calc(13px * var(--fs)); }
.scc-tally b { min-width: 1ch; font-size: calc(15px * var(--fs)); font-weight: 600; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.scc-tally li.is-zero .status, .scc-tally li.is-zero b { color: var(--text-3); }
.scc-tally li.is-zero .status::before { background-color: var(--neutral-ic); }
/* 复制按钮复制完短暂变成「已复制」 */
.scc .btn.is-done { color: var(--ok); border-color: var(--ok-bd); }
/* 建议回复客户 */
.scc-reply .box-header { align-items: center; flex-wrap: nowrap; }
.scc-reply .box-header > div:first-child { flex-basis: auto; }
.scc-reply-text { margin: 0; padding: 14px 16px; white-space: pre-line; border: 1px solid var(--divider); border-radius: var(--r-md); background: var(--surface-2);
    font-size: calc(14px * var(--fs)); line-height: calc(23px * var(--fs)); color: var(--text); }
/* AI 排查里沿用的小标题 / 结果框 */
.sc-check-sub { font-size: calc(13px * var(--fs)); font-weight: 600; margin: 0 0 8px; color: var(--text-strong); }
.sc-check-reply { white-space: pre-line; margin: 0 0 10px; padding: 12px 14px; border: 1px solid var(--divider); border-radius: var(--r-md); background: var(--surface-2); line-height: calc(22px * var(--fs)); }
/* 逐项检查：宽屏左栏是「标题 + 状态」，右栏是结论、依据（名称 / 值两栏对齐）、处理建议 */
.scc-list { list-style: none; margin: 0; padding: 0; }
.scc-item { position: relative; display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 8px 24px; padding: 18px 24px; border-top: 1px solid var(--divider); }
.scc-item.is-warn::before, .scc-item.is-error::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 3px; border-radius: 0 2px 2px 0; background: var(--warn-ic); }
.scc-item.is-error::before { background: var(--err-ic); }
.scc-item-head { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; }
.scc-item-title { margin: 0; font-size: calc(14px * var(--fs)); line-height: calc(22px * var(--fs)); font-weight: 600; color: var(--text-strong); }
.scc-item-body { min-width: 0; }
.scc-item-summary { margin: 0; font-size: calc(14px * var(--fs)); line-height: calc(22px * var(--fs)); color: var(--text-strong); }
.scc-evidence { display: grid; grid-template-columns: fit-content(14em) minmax(0, 1fr); gap: 4px 16px; margin: 10px 0 0; padding: 0; list-style: none;
    font-size: calc(13px * var(--fs)); line-height: calc(20px * var(--fs)); color: var(--text-2); font-variant-numeric: tabular-nums; }
.scc-evidence li { grid-column: 1 / -1; min-width: 0; overflow-wrap: anywhere; }
.scc-evidence li.is-kv { display: grid; grid-template-columns: subgrid; }
.scc-evidence .k { color: var(--text-3); }
.scc-evidence .v { color: var(--text); }
@supports not (grid-template-columns: subgrid) {
    .scc-evidence li.is-kv { display: flex; gap: 16px; }
    .scc-evidence .k { flex: none; min-width: 6em; }
}
.scc-advice { margin: 12px 0 0; padding: 10px 14px; border-radius: var(--r-md); background: var(--surface-2); font-size: calc(13px * var(--fs)); line-height: calc(20px * var(--fs)); color: var(--text); }
.scc-item.is-warn .scc-advice { background: var(--warn-bg); }
.scc-item.is-error .scc-advice { background: var(--err-bg); }
.scc-advice-label { display: block; margin-bottom: 2px; font-size: calc(12px * var(--fs)); font-weight: 600; color: var(--text-2); }
/* 平板 / 手机：逐项变成上下排（标题和状态一行），页边距收窄 */
@media (max-width: 767px) {
    .scc { gap: 12px; }
    .scc-side { gap: 12px; }
    .scc-verdict-main { padding: 16px 14px 14px 18px; }
    .scc-verdict-title { font-size: calc(16px * var(--fs)); line-height: calc(24px * var(--fs)); }
    .scc-verdict-actions { width: 100%; }
    .scc-verdict-actions .btn { flex: 1 1 auto; }
    .scc-tally { gap: 6px 18px; padding: 10px 14px 10px 18px; }
    .scc-item { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 14px; }
    .scc-item-head { flex-direction: row; align-items: center; justify-content: space-between; }
    .scc-item.is-warn::before, .scc-item.is-error::before { top: 14px; bottom: 14px; }
    .scc-evidence { grid-template-columns: fit-content(6.5em) minmax(0, 1fr); gap: 4px 12px; }
}
@media (pointer: coarse) { .scc-verdict-actions .btn, .scc-reply .btn, #ai-copy { min-height: 44px; } }

/* 体检页的 AI 排查：输入框撑满；手机上字号 16px，iOS 聚焦时不自动放大 */
.sc-ai-form textarea { display: block; width: 100%; min-height: 96px; margin: 0 0 10px; }
.sc-ai-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.sc-ai-result .sc-check-reply { min-height: 48px; }
@media (max-width: 640px) { .sc-ai-form textarea { font-size: calc(16px * var(--fs)); } }
/* AI 排查的截图：按钮 + 提示一行，缩略图一排（72px 方块，右上角删除）；拖图进来时表单描一圈虚线 */
.sc-ai-shots { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; }
.sc-ai-thumbs { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; margin: 0; padding: 0; list-style: none; }
.sc-ai-thumbs li { position: relative; width: 72px; height: 72px; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background: var(--hover); }
.sc-ai-thumbs img { display: block; width: 100%; height: 100%; object-fit: cover; }
.sc-ai-thumb-del { position: absolute; top: 2px; right: 2px; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%;
    background: rgba(15, 23, 42, .72); color: #fff; font-size: 16px; line-height: 24px; cursor: pointer; }
.sc-ai-thumb-del:hover, .sc-ai-thumb-del:focus-visible { background: var(--err); }
.sc-ai-thumb-del:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.sc-ai-form.is-drop { outline: 2px dashed var(--brand); outline-offset: -6px; border-radius: var(--r-md); }
/* 触屏：缩略图和删除按钮放大到好点的尺寸 */
@media (pointer: coarse) {
    .sc-ai-thumbs li { width: 96px; height: 96px; }
    .sc-ai-thumb-del { width: 44px; height: 44px; line-height: 44px; font-size: 20px; top: 0; right: 0; border-radius: 0 0 0 var(--r-md); }
    .sc-ai-shots .btn-sm { min-height: 44px; padding: 0 16px; }
}

/* ==================== 第 9 步：小 / 中 / 大字号 ==================== */
/* 顶栏各块宽度是排好的（品牌、标题、搜索框、账号、退出），字放大会挤窄搜索框、窄屏挤出屏幕：顶栏本身保持原字号，
   只放大搜索框里输入的字、搜索结果和主题 / 字号菜单（--fs-user 是用户选的倍率） */
.topnav { --fs: 1; }
.topnav .gsearch, .topnav .theme-menu-list { --fs: var(--fs-user); }
/* 原来写死高度、里面放文字的控件改成最小高度：默认档和原来一样高，字大了不被裁掉 */
.topnav-user { height: auto; min-height: 36px; }
.topnav-logout { height: auto; min-height: 32px; }
.pagination a, .pagination span { height: auto; min-height: 28px; }
@media (pointer: coarse) { .topnav-logout { min-height: 36px; } }
@media (pointer: coarse), (max-width: 960px) { .pagination a, .pagination span { min-height: 40px; } }
.status.pill { height: auto; min-height: 24px; }
.stat-value .delta { height: auto; min-height: 20px; }
/* 标签栏字大了放不下时在自己里面横向滑动，不把整页撑宽（窄屏原本就是这样） */
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs .tab { flex: none; }
/* 中 / 大字号下，型号、服务码这类没有空格的长串放不下时折行，不被卡片边缘截掉。表格里只在一行放不下时才断（break-word），
   不改变列宽的计算，宽表照旧在 .table-wrap 里横滑。默认档不加，保持原样 */
:root[data-font] .main-inner { overflow-wrap: anywhere; }
:root[data-font] .main-inner table { overflow-wrap: break-word; }
/* 手机卡片里的「日期 时间」：中 / 大字号半格放不下时，时间换到下一行 */
@media (max-width: 640px) {
    :root[data-font] :is(.table-list, .table-catalog, .table[data-cards]) .list-datetime { white-space: normal; }
    :root[data-font] :is(.table-list, .table-catalog, .table[data-cards]) .list-datetime span { display: inline-block; }
}
/* 报表的时间条（快捷时段 + 定宽的日期框 + 查询 + 导出）在平板、电脑上排成一行，日期是浏览器画的、不会折行：
   和顶栏一样保持原字号，不挤乱这一行；手机上它本来就分几行铺满，照常放大 */
@media (min-width: 641px) { .report-tools { --fs: 1; } }
/* 主题 / 字号菜单里的分组标题和分隔线 */
.theme-menu-group { padding: 6px 10px 2px; color: var(--text-3); font-size: calc(12px * var(--fs)); font-weight: 600; }
.theme-menu-sep { height: 1px; margin: 4px 0; background: var(--divider); }

/* ---------- 客户维护日志（客户详情「维护日志」tab）：编辑表单、记录列表、Markdown 正文 ---------- */
.ml-fields { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 16px; margin-bottom: 16px; }
.ml-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ml-field > label, .ml-label { font-size: calc(13px * var(--fs)); line-height: calc(20px * var(--fs)); font-weight: 600; color: var(--text-soft); }
.ml-editor textarea, .ml-editor textarea:hover, .ml-editor textarea:focus {
    min-height: 280px; white-space: pre-wrap; overflow-wrap: anywhere;
    font-family: var(--mono); font-size: calc(13px * var(--fs)); line-height: calc(20px * var(--fs));
}
.ml-mode { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--r); background: var(--hover); }
.ml-mode button {
    min-height: 26px; padding: 0 12px; border: 0; border-radius: var(--r-sm); background: transparent; cursor: pointer;
    color: var(--text-2); font: 500 calc(12.5px * var(--fs))/calc(18px * var(--fs)) var(--font);
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.ml-mode button:hover { color: var(--text); }
.ml-mode button[aria-selected="true"] { background: var(--surface); color: var(--text-strong); box-shadow: var(--sh-1); }
.ml-mode button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.ml-preview { min-height: 280px; padding: 12px 14px; }
.ml-preview .muted { color: var(--text-3); }
.ml-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.ml-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--divider); }
.ml-item { padding: 16px 24px 20px; border-bottom: 1px solid var(--divider); scroll-margin-top: calc(var(--topnav-h) + 16px); }
.ml-item:last-child { border-bottom: 0; }
.ml-item.is-highlight { background: var(--brand-bg); box-shadow: inset 3px 0 0 var(--brand); }
.ml-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ml-head-text { flex: 1; min-width: 0; }
.ml-title { margin: 0; font-size: calc(16px * var(--fs)); line-height: calc(24px * var(--fs)); font-weight: 600; color: var(--text-strong); overflow-wrap: anywhere; }
.ml-meta { display: flex; flex-wrap: wrap; gap: 0 12px; margin: 2px 0 0; color: var(--text-2); font-size: calc(12px * var(--fs)); line-height: calc(18px * var(--fs)); font-variant-numeric: tabular-nums; }
.ml-body { margin-top: 10px; }
.ml-pager { display: flex; justify-content: flex-end; padding: 14px 24px; border-top: 1px solid var(--divider); }
#maint-form { scroll-margin-top: calc(var(--topnav-h) + 16px); }

/* Markdown 正文：字号层级克制（不超过卡片标题），代码 / 表格在自己里面横滑，不撑宽页面 */
.md-body { max-width: 860px; color: var(--text); font-size: calc(14px * var(--fs)); line-height: calc(22px * var(--fs)); overflow-wrap: anywhere; }
.md-body > :first-child { margin-top: 0; }
.md-body > :last-child { margin-bottom: 0; }
.md-body p, .md-body ul, .md-body ol, .md-body pre, .md-body blockquote, .md-body table { margin: 0 0 10px; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4, .md-body h5, .md-body h6 { margin: 16px 0 6px; font-weight: 600; color: var(--text-strong); }
/* 正文里的标题比记录标题（16px）小一级，h3 起用次级颜色区分 */
.md-body h1 { font-size: calc(15px * var(--fs)); line-height: calc(22px * var(--fs)); }
.md-body h2 { font-size: calc(14px * var(--fs)); line-height: calc(22px * var(--fs)); }
.md-body h3, .md-body h4, .md-body h5, .md-body h6 { font-size: calc(14px * var(--fs)); line-height: calc(22px * var(--fs)); color: var(--text-soft); }
.md-body ul, .md-body ol { padding-left: 22px; }
.md-body ul { list-style: disc; }
.md-body ol { list-style: decimal; }
.md-body li + li { margin-top: 2px; }
.md-body li > ul, .md-body li > ol { margin: 2px 0 0; }
.md-body a { color: var(--brand-text); text-decoration: underline; text-underline-offset: 2px; }
.md-body strong { font-weight: 600; color: var(--text-strong); }
.md-body code {
    padding: 1px 5px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--divider);
    font-family: var(--mono); font-size: calc(12.5px * var(--fs));
}
.md-body pre {
    padding: 10px 12px; border: 1px solid var(--divider); border-radius: var(--r); background: var(--surface-2);
    overflow-x: auto; overflow-wrap: normal; -webkit-overflow-scrolling: touch;
}
.md-body pre code { padding: 0; border: 0; background: none; font-size: calc(12.5px * var(--fs)); line-height: calc(19px * var(--fs)); white-space: pre; }
.md-body blockquote { padding: 2px 0 2px 12px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.md-body hr { height: 1px; margin: 14px 0; border: 0; background: var(--divider); }
.md-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: calc(13px * var(--fs)); }
.md-body th, .md-body td { padding: 6px 10px; border-bottom: 1px solid var(--divider); text-align: left; vertical-align: top; }
.md-body th { font-weight: 600; color: var(--text-2); background: var(--surface-2); white-space: nowrap; }
.md-body img { max-width: 100%; height: auto; }

@media (max-width: 640px) {
    .ml-fields { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .ml-item { padding: 14px 16px 16px; }
    .ml-pager { justify-content: center; padding: 12px 16px; }
    .ml-editor textarea, .ml-editor textarea:hover, .ml-editor textarea:focus, .ml-preview { min-height: 220px; }
    .ml-actions .btn { flex: 1; justify-content: center; }
}
@media (pointer: coarse) {
    .ml-mode button { min-height: 36px; padding: 0 16px; }
    .ml-editor textarea, .ml-editor textarea:hover, .ml-editor textarea:focus { font-size: calc(16px * var(--fs)); line-height: calc(24px * var(--fs)); }
}
@media (prefers-reduced-motion: reduce) { .ml-mode button { transition: none; } }

/* ==================== 服务器状态页（system_status.html，前缀 ss-） ==================== */
.tnum { font-variant-numeric: tabular-nums; }
.ss-hint { font-size: calc(12px * var(--fs)); font-weight: 400; }
.ss-stats .stat-sub .status { font-size: calc(12.5px * var(--fs)); }
.ss-subsection { padding-top: 16px; border-top: 1px solid var(--divider); }
.ss-col-meter { width: 28%; }
.ss-holds { max-width: none; }
.meter-row .status { flex-shrink: 0; }
.meter-row > .tnum { min-width: 3.2em; text-align: right; }
/* 一行并排的小计数（进程汇总、慢查询汇总）：数值在上、标签在下，竖线隔开 */
.ss-inline-stats { display: flex; flex-wrap: wrap; gap: 12px 0; margin: 0; }
.ss-inline-stats > div { display: flex; flex-direction: column-reverse; gap: 2px; padding: 0 24px; border-left: 1px solid var(--divider); }
.ss-inline-stats > div:first-child { padding-left: 0; border-left: 0; }
.ss-inline-stats dt { color: var(--text-2); font-size: calc(12px * var(--fs)); }
.ss-inline-stats dd { margin: 0; color: var(--text-strong); font-size: calc(20px * var(--fs)); line-height: calc(28px * var(--fs)); font-weight: 600; font-variant-numeric: tabular-nums; }
.ss-inline-stats dd .status { font-size: inherit; }
.ss-proc-summary { padding-bottom: 20px; }
.ss-other-hosts { margin-top: 12px; font-size: calc(12.5px * var(--fs)); }
.ss-count { font-size: calc(13px * var(--fs)); }
.ss-table-title { margin: 8px 24px 4px; font-size: calc(14px * var(--fs)); font-weight: 600; color: var(--text); }
.ss-proc .ss-pname { max-width: 16em; overflow: hidden; text-overflow: ellipsis; }
.ss-proc .cell-flex { min-width: 240px; }
.ss-proc td.num { font-variant-numeric: tabular-nums; }
.filters .ss-kernel { min-height: 36px; }
@media (min-width: 961px) and (max-width: 1279px) {
    /* 小型电脑 / 横屏平板：内存占比、命令行让位给关键列 */
    .ss-proc .ss-mempct { display: none; }
}
@media (max-width: 960px) {
    .ss-actions { justify-content: space-between; }
    .ss-auto { min-height: 44px; }
    .ss-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .ss-stats { gap: 10px; }
    .ss-stats .stat { padding: 14px; }
    .ss-load-rest { font-size: calc(13px * var(--fs)); font-weight: 500; color: var(--text-2); }
    .ss-inline-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 0; }
    .ss-inline-stats > div { padding: 0 12px; }
    .ss-inline-stats > div:nth-child(3n + 1) { padding-left: 0; border-left: 0; }
    .ss-inline-stats dd { font-size: calc(17px * var(--fs)); line-height: calc(24px * var(--fs)); }
    .ss-col-meter { width: auto; }
    .ss-table-title { margin: 8px 16px 4px; }
    .ss-proc .ss-pname, .ss-proc .cell-flex { max-width: none; min-width: 0; }
    .ss-proc td.cell-flex { font-size: calc(12px * var(--fs)); word-break: break-all; }
    .filters .ss-kernel { flex-basis: 100%; min-height: 44px; }
    .ss-count { width: 100%; }
}
.ss-filters select { width: 180px; }
@media (max-width: 640px) { .ss-filters select { width: auto; } }
@media (max-width: 640px) { .ss-svc .status { white-space: normal; } }
@media (pointer: coarse) { .ss-svc .btn-sm { min-height: 44px; padding: 0 16px; } }

/* ---------- 服务告警（server_status.service_alerts） ---------- */
/* 每个后台页面顶部的红条：只在有服务异常（err）时出现 */
.svc-alarm {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
    margin: 0 0 16px; padding: 10px 14px;
    border: 1px solid var(--err-bd); border-radius: var(--r-md); background: var(--err-bg);
    color: var(--text-strong); font-size: calc(13.5px * var(--fs)); line-height: calc(20px * var(--fs));
}
.svc-alarm > .icon { flex: none; width: 18px; height: 18px; color: var(--err-ic); }
.svc-alarm-text { flex: 1 1 240px; min-width: 0; overflow-wrap: anywhere; }
.svc-alarm-text b { color: var(--err); }
.svc-alarm-link { flex: none; display: inline-flex; align-items: center; min-height: 32px; font-weight: 600; color: var(--err); }
/* 服务器状态页上的完整告警（err + warn，每条带说明） */
.svc-alarm-box {
    margin: 0 0 16px; padding: 12px 16px;
    border: 1px solid var(--warn-bd); border-radius: var(--r-md); background: var(--warn-bg);
    font-size: calc(13.5px * var(--fs));
}
.svc-alarm-box.err { border-color: var(--err-bd); background: var(--err-bg); }
.svc-alarm-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--text-strong); }
.svc-alarm-head .icon { width: 18px; height: 18px; color: var(--warn-ic); }
.svc-alarm-box.err .svc-alarm-head .icon { color: var(--err-ic); }
.svc-alarm-head a { margin-left: auto; font-weight: 600; }
.svc-alarm-list { margin: 8px 0 0; padding: 0; list-style: none; }
.svc-alarm-list li { padding: 4px 0 4px 26px; overflow-wrap: anywhere; color: var(--text); }
.svc-alarm-list .status { margin-right: 4px; }
.svc-alarm-detail { color: var(--text-2); }
/* 侧栏「服务器状态」角标：数字 + 屏幕阅读器文字；图标栏模式下缩成右上角小圆点 */
.nav-alarm {
    flex: none; margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 999px; background: var(--warn-ic); color: #fff;
    font-size: calc(11.5px * var(--fs)); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
.nav-alarm.err { background: var(--err-ic); }
.sidenav-link { position: relative; }
@media (min-width: 961px) {
    html.nav-rail .nav-alarm { position: absolute; top: 4px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; }
}
/* 服务表：有问题的行加浅底色（不只靠颜色：状态列有图标和文字） */
.ss-svc tr.row-err > td { background: var(--err-bg); }
.ss-svc tr.row-warn > td { background: var(--warn-bg); }
.ss-svc .ss-desc, .ss-svc .ss-detail { max-width: 32em; white-space: normal; }
@media (max-width: 640px) {
    .ss-svc > tbody > tr.row-err { background: var(--err-bg); }
    .ss-svc > tbody > tr.row-warn { background: var(--warn-bg); }
    .ss-svc > tbody > tr:is(.row-err, .row-warn) > td { background: none; }
    .svc-alarm-head a { margin-left: 0; }
    .svc-alarm-list li { padding-left: 0; }
}

/* ---------- 列表 / 图表页按 r 刷新（app.js 的 pageRefresh）：内容变暗 + 顶部居中「正在刷新…」，刷新后短暂显示「已刷新」 ---------- */
body.is-refreshing .main-inner { opacity: .5; pointer-events: none; transition: opacity .15s ease-out; }
.page-refresh-pill {
    position: fixed; top: calc(var(--topnav-h) + 12px); left: 50%; z-index: 1001; transform: translateX(-50%);
    display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface); box-shadow: var(--sh-pop);
    color: var(--text-strong); font-size: calc(13px * var(--fs)); line-height: calc(18px * var(--fs)); white-space: nowrap;
}
.page-refresh-pill[hidden] { display: none; }
/* 深色主题的 --ok-bg 是半透明的，浮在表格上会透出后面的字：底下先垫一层不透明的 --surface */
.page-refresh-pill.is-done { border-color: var(--ok-bd); background: linear-gradient(var(--ok-bg), var(--ok-bg)), var(--surface); color: var(--ok); }
.page-refresh-pill .icon { width: 16px; height: 16px; flex: none; }
.page-refresh-spin {
    flex: none; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--brand); border-radius: 50%;
    animation: page-refresh-spin .7s linear infinite;
}
@keyframes page-refresh-spin { to { transform: rotate(360deg); } }
/* 减少动效时转圈停住也看得出是加载中（文字仍写着「正在刷新」）：只把动画放慢，不靠旋转传达信息 */
@media (prefers-reduced-motion: reduce) { .page-refresh-spin { animation: page-refresh-spin 2.4s linear infinite !important; } body.is-refreshing .main-inner { transition: none; } }

/* 快捷键列表：分「跳转」「本页操作」两部分，最下面一行说明当前页能不能 r 刷新 */
.hotkey-part { margin: 0; padding: 14px 20px 0; color: var(--text-strong); font-size: calc(13px * var(--fs)); font-weight: 600; }
.hotkey-part + .hotkey-grid { padding-top: 0; }
.hotkey-foot { margin: 0; padding: 12px 20px 16px; border-top: 1px solid var(--divider); color: var(--text-2); font-size: calc(12px * var(--fs)); line-height: calc(18px * var(--fs)); }
@media (max-width: 640px) { .hotkey-part { padding: 12px 16px 0; } .hotkey-foot { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); } }
