/* ============================================================
   FRP 管理后台 · 样式表
   暗色为默认主题，支持亮色（data-theme="light"）
   ============================================================ */

:root[data-theme="dark"] {
  --bg: #0a0d14;
  --bg-soft: #0d1119;
  --card: #121724;
  --card-hover: #171e30;
  --border: #1d2436;
  --border-strong: #2b3550;
  --text: #e9edf7;
  --text-dim: #9aa5c0;
  --text-faint: #5f6c8c;
  --primary: #4f7cff;
  --primary-strong: #6b91ff;
  --primary-soft: rgba(79, 124, 255, 0.13);
  --cyan: #22d3ee;
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.14);
  --yellow: #fbbf24;
  --yellow-soft: rgba(251, 191, 36, 0.14);
  --purple: #a78bfa;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.42);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.28);
  --chart-grid: #1c2438;
  --scrollbar: #28324a;
}

:root[data-theme="light"] {
  --bg: #f3f5fa;
  --bg-soft: #eceff7;
  --card: #ffffff;
  --card-hover: #f7f9ff;
  --border: #e3e8f2;
  --border-strong: #c9d2e4;
  --text: #1a2233;
  --text-dim: #5a6782;
  --text-faint: #96a1b8;
  --primary: #3d6bff;
  --primary-strong: #2f5df0;
  --primary-soft: rgba(61, 107, 255, 0.1);
  --cyan: #0891b2;
  --green: #059669;
  --green-soft: rgba(5, 150, 105, 0.1);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.09);
  --yellow: #b45309;
  --yellow-soft: rgba(180, 83, 9, 0.1);
  --purple: #7c3aed;
  --shadow: 0 12px 30px rgba(35, 50, 90, 0.14);
  --shadow-soft: 0 3px 12px rgba(35, 50, 90, 0.08);
  --chart-grid: #e7ecf6;
  --scrollbar: #c8d0e2;
}

/* 午夜黑：近纯黑底 + 青色主色，夜间/OLED 屏更省眼 */
:root[data-theme="midnight"] {
  --bg: #05070a;
  --bg-soft: #090c11;
  --card: #0c1016;
  --card-hover: #121821;
  --border: #161d27;
  --border-strong: #24303f;
  --text: #e6edf5;
  --text-dim: #93a1b5;
  --text-faint: #5b6878;
  --primary: #22d3ee;
  --primary-strong: #4fdff5;
  --primary-soft: rgba(34, 211, 238, 0.13);
  --cyan: #38bdf8;
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.14);
  --yellow: #fbbf24;
  --yellow-soft: rgba(251, 191, 36, 0.14);
  --purple: #a78bfa;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.55);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.4);
  --chart-grid: #16202b;
  --scrollbar: #223040;
}

/* 墨玉青：深绿底 + 翡翠主色 */
:root[data-theme="emerald"] {
  --bg: #07130f;
  --bg-soft: #0a1913;
  --card: #0d2018;
  --card-hover: #122a20;
  --border: #163024;
  --border-strong: #21452f;
  --text: #e6f4ec;
  --text-dim: #8fb3a1;
  --text-faint: #5c7a6b;
  --primary: #10b981;
  --primary-strong: #34d399;
  --primary-soft: rgba(16, 185, 129, 0.14);
  --cyan: #2dd4bf;
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.14);
  --red: #fb7185;
  --red-soft: rgba(251, 113, 133, 0.14);
  --yellow: #fbbf24;
  --yellow-soft: rgba(251, 191, 36, 0.14);
  --purple: #c084fc;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.3);
  --chart-grid: #16302a;
  --scrollbar: #1f4235;
}

/* 暗夜紫：深紫底 + 紫罗兰主色 */
:root[data-theme="violet"] {
  --bg: #0d0a1a;
  --bg-soft: #120e24;
  --card: #17122d;
  --card-hover: #1e1838;
  --border: #241c42;
  --border-strong: #362a5e;
  --text: #ece8fb;
  --text-dim: #a79ec9;
  --text-faint: #6f6694;
  --primary: #8b5cf6;
  --primary-strong: #a78bfa;
  --primary-soft: rgba(139, 92, 246, 0.15);
  --cyan: #22d3ee;
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --red: #fb7185;
  --red-soft: rgba(251, 113, 133, 0.14);
  --yellow: #fbbf24;
  --yellow-soft: rgba(251, 191, 36, 0.14);
  --purple: #c4b5fd;
  --shadow: 0 12px 34px rgba(10, 0, 30, 0.5);
  --shadow-soft: 0 4px 16px rgba(10, 0, 30, 0.35);
  --chart-grid: #241c42;
  --scrollbar: #362a5e;
}

/* 暖阳棕：暖色深底 + 琥珀主色 */
:root[data-theme="amber"] {
  --bg: #14100a;
  --bg-soft: #1a150d;
  --card: #211a10;
  --card-hover: #2a2115;
  --border: #33281a;
  --border-strong: #4a3a25;
  --text: #f6efe2;
  --text-dim: #c0ac8d;
  --text-faint: #857252;
  --primary: #f59e0b;
  --primary-strong: #fbbf24;
  --primary-soft: rgba(245, 158, 11, 0.15);
  --cyan: #2dd4bf;
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.14);
  --yellow: #facc15;
  --yellow-soft: rgba(250, 204, 21, 0.15);
  --purple: #d8b4fe;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.34);
  --chart-grid: #33281a;
  --scrollbar: #4a3a25;
}

/* 薄荷绿：浅色 + 青绿主色 */
:root[data-theme="mint"] {
  --bg: #eff7f3;
  --bg-soft: #e6f2ec;
  --card: #ffffff;
  --card-hover: #f4fbf7;
  --border: #d7e8df;
  --border-strong: #b4d2c3;
  --text: #14231c;
  --text-dim: #4e6b5c;
  --text-faint: #8aa596;
  --primary: #0d9488;
  --primary-strong: #0f766e;
  --primary-soft: rgba(13, 148, 136, 0.1);
  --cyan: #0891b2;
  --green: #16a34a;
  --green-soft: rgba(22, 163, 74, 0.1);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.09);
  --yellow: #b45309;
  --yellow-soft: rgba(180, 83, 9, 0.1);
  --purple: #7c3aed;
  --shadow: 0 12px 30px rgba(20, 60, 45, 0.13);
  --shadow-soft: 0 3px 12px rgba(20, 60, 45, 0.08);
  --chart-grid: #d9e9e0;
  --scrollbar: #b4d2c3;
}

/* 樱花粉：浅色 + 玫红主色 */
:root[data-theme="rose"] {
  --bg: #fbf3f4;
  --bg-soft: #f7ebed;
  --card: #ffffff;
  --card-hover: #fff7f8;
  --border: #f0dcdf;
  --border-strong: #dcb9bf;
  --text: #241a1c;
  --text-dim: #6b5257;
  --text-faint: #a68b90;
  --primary: #e11d48;
  --primary-strong: #be123c;
  --primary-soft: rgba(225, 29, 72, 0.09);
  --cyan: #0891b2;
  --green: #059669;
  --green-soft: rgba(5, 150, 105, 0.1);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.09);
  --yellow: #b45309;
  --yellow-soft: rgba(180, 83, 9, 0.1);
  --purple: #7c3aed;
  --shadow: 0 12px 30px rgba(90, 40, 50, 0.13);
  --shadow-soft: 0 3px 12px rgba(90, 40, 50, 0.08);
  --chart-grid: #f0dcdf;
  --scrollbar: #dcb9bf;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

code, .mono { font-family: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace; }

.hidden { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 登录页 ---------------- */

.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(620px 420px at 12% 8%, rgba(79, 124, 255, 0.16), transparent 62%),
    radial-gradient(560px 420px at 88% 92%, rgba(34, 211, 238, 0.13), transparent 60%),
    var(--bg);
}

.login-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: 0.35;
  mask-image: radial-gradient(560px 420px at 50% 40%, #000 30%, transparent 78%);
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 34px 22px;
  box-shadow: var(--shadow);
}

.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand h1 { font-size: 21px; font-weight: 650; margin-top: 14px; letter-spacing: 0.4px; }
.login-sub { color: var(--text-dim); font-size: 13px; margin-top: 5px; }

.login-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 12.5px; color: var(--text-dim); letter-spacing: 0.3px; }

input[type="text"], input[type="password"], input[type="search"], select, textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

input::placeholder { color: var(--text-faint); }

.login-error {
  background: var(--red-soft);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: var(--red);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 13px;
}

.login-noauth { display: flex; flex-direction: column; gap: 14px; }

.login-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 12px;
}

/* ---------------- 应用布局 ---------------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
  transition: margin-left 0.22s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 18px 16px;
}

.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.sidebar-brand-text strong { font-size: 15px; letter-spacing: 0.3px; }
.sidebar-brand-text span { font-size: 11.5px; color: var(--text-faint); }

.nav { flex: 1; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9.5px 12px;
  border-radius: 10px;
  color: var(--text-dim);
  text-decoration: none;
  cursor: pointer;
  font-size: 13.5px;
  transition: background 0.14s, color 0.14s;
  user-select: none;
}

.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-strong); font-weight: 600; }
.nav-ico { width: 18px; text-align: center; opacity: 0.9; font-size: 14px; }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-user { display: flex; align-items: center; gap: 9px; min-width: 0; }

.avatar {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}

.sidebar-user-name { font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 6px; }

/* 侧栏底部按钮：带文字的胶囊按钮（原先是裸图标，看不出是干什么的） */
.foot-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12.5px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.foot-btn:hover { background: var(--card-hover); color: var(--text); border-color: var(--border-strong); }
.foot-btn-danger { color: var(--red); }
.foot-btn-danger:hover { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.foot-btn-mini { height: 28px; font-size: 12px; }
.foot-ico { font-size: 13px; line-height: 1; }

/* 表单字段下方的即时校验提示（如「端口已被占用」） */
.field-msg { display: block; font-size: 12px; line-height: 1.5; min-height: 0; }
.field-msg:empty { display: none; }
.field-msg-error { color: var(--red); }
.field-msg-warn { color: var(--yellow); }
.field-msg-ok { color: var(--green); }

/* 未配置管理密码时的常驻告警（挂在侧栏导航下方） */
.auth-warn {
  margin: 10px 12px;
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid var(--red);
}
.auth-warn code { font-size: 11.5px; background: transparent; color: inherit; }

/* 主题选择浮层 */
.theme-pop {
  position: fixed;
  z-index: 220;
  width: 268px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.theme-pop-head { font-size: 12px; color: var(--text-faint); margin: 0 2px 10px; letter-spacing: 0.4px; }
.theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.theme-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 7px 4px 6px;
  border-radius: 9px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.theme-item:hover { background: var(--card-hover); border-color: var(--border); }
.theme-item.active { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
.theme-swatch {
  width: 42px;
  height: 34px;
  border-radius: 7px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  display: block;
}
.theme-swatch-bar { position: absolute; left: 0; right: 0; top: 0; height: 7px; display: block; }
.theme-swatch-dot { position: absolute; left: 6px; bottom: 6px; width: 11px; height: 11px; border-radius: 50%; display: block; }
.theme-name { white-space: nowrap; }

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}

.icon-btn:hover { background: var(--card); color: var(--text); border-color: var(--border); }

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 26px 12px;
  gap: 16px;
}

.topbar-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.topbar-title h2 { font-size: 19px; font-weight: 650; white-space: nowrap; }
.topbar-sub { color: var(--text-faint); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 14px; color: var(--text-dim); font-size: 13px; }

.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.live-dot.paused { background: var(--text-faint); box-shadow: 0 0 0 4px rgba(120, 130, 160, 0.12); }
/* 仪表盘在标签页不可见时暂停刷新，用 body 上的 page-paused 让指示灯同步变灰
   （类名要与 dashboard.js 里写的一致，否则指示灯永远不变，用户不知道数据已停更） */
body.page-paused .live-dot { background: var(--text-faint); box-shadow: 0 0 0 4px rgba(120, 130, 160, 0.12); }

.clock { font-family: "JetBrains Mono", Consolas, monospace; font-size: 12.5px; color: var(--text-faint); }

.menu-btn { display: none; }

.page { padding: 8px 26px 40px; flex: 1; }

/* ---------------- 通用组件 ---------------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.card-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13.5px; font-weight: 600; color: var(--text); margin-bottom: 14px; gap: 10px;
}

.card-title .sub { font-size: 12px; color: var(--text-faint); font-weight: 400; }

.grid { display: grid; gap: 16px; }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-32 { grid-template-columns: 3fr 2fr; }
.grid-23 { grid-template-columns: 2fr 3fr; }

@media (max-width: 1400px) {
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .grid-4, .grid-3, .grid-32, .grid-23 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .grid-5, .grid-4, .grid-3, .grid-2, .grid-32, .grid-23 { grid-template-columns: 1fr; }
  .sidebar { position: fixed; margin-left: -240px; }
  .sidebar.open { margin-left: 0; box-shadow: var(--shadow); }
  .menu-btn { display: inline-flex; }
  .page { padding: 8px 14px 40px; }
  .topbar { padding: 14px 14px 10px; }
}

/* 统计卡 */
.stat-card { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; }

/* 可点击的统计卡 / 表格行（统计报表页：点数据跳明细） */
.stat-clickable { cursor: pointer; transition: border-color 0.14s, transform 0.14s, background 0.14s; }
.stat-clickable:hover { border-color: var(--primary); background: var(--card-hover); transform: translateY(-1px); }
.row-clickable { cursor: pointer; }
.row-clickable:hover td { background: var(--card-hover); }

/* 折线图下方的日期标签（统计报表的日粒度横轴） */
.chart-x-labels {
  display: flex;
  justify-content: space-between;
  padding: 2px 12px 0 58px;
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.stat-label { font-size: 12.5px; color: var(--text-dim); display: flex; align-items: center; gap: 7px; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: 0.2px; font-variant-numeric: tabular-nums; }
.stat-unit { font-size: 13px; color: var(--text-faint); font-weight: 400; margin-left: 3px; }
.stat-extra { font-size: 12px; color: var(--text-faint); }
.stat-ico {
  width: 34px; height: 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; margin-bottom: 4px;
}
.ico-blue { background: var(--primary-soft); color: var(--primary-strong); }
.ico-green { background: var(--green-soft); color: var(--green); }
.ico-cyan { background: rgba(34, 211, 238, 0.13); color: var(--cyan); }
.ico-purple { background: rgba(167, 139, 250, 0.14); color: var(--purple); }
.ico-yellow { background: var(--yellow-soft); color: var(--yellow); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 8px 15px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.05s;
  white-space: nowrap;
}

.btn:hover { background: var(--card-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #3f66e0);
  border-color: transparent; color: #fff; font-weight: 600;
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-strong), #4a72ee); }

.btn-danger { background: var(--red-soft); border-color: rgba(248, 113, 113, 0.35); color: var(--red); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.22); }

.btn-xs { padding: 4.5px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; padding: 10.5px; font-size: 14px; }

/* 徽章 */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge-blue { background: var(--primary-soft); color: var(--primary-strong); }
.badge-gray { background: rgba(130, 142, 170, 0.13); color: var(--text-dim); }
.badge-purple { background: rgba(167, 139, 250, 0.14); color: var(--purple); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); box-shadow: 0 0 6px rgba(52, 211, 153, 0.65); }
.dot-gray { background: var(--text-faint); }
.dot-yellow { background: var(--yellow); }

/* 表格 */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); background: var(--card); }

table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }

thead th {
  text-align: left;
  padding: 11px 14px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.4px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: var(--card-hover); }

.td-actions { display: flex; gap: 6px; justify-content: flex-end; }
.th-right, .td-right { text-align: right; }
.th-center, .td-center { text-align: center; }

.table-empty { padding: 44px 20px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* 可排序列头：hover 变色 + 手型，暗示「可点击」；当前排序列用主色高亮并显示 ▲/▼ */
th.th-sortable { cursor: pointer; user-select: none; transition: color 0.12s, background 0.12s; }
th.th-sortable:hover { color: var(--text); background: var(--card-hover); }
th.th-sortable.active { color: var(--primary-strong); }
th.th-sortable .sort-ar { margin-left: 4px; font-size: 10px; }

/* 横向溢出提示：纯 CSS 渐隐阴影，不监听滚动。
   原理：两侧用 background-attachment:local 的「遮罩」随内容一起滚动 ——
   表格没有横向溢出时，遮罩完全盖住阴影（看不见）；一旦表格比容器宽，
   右侧就露出一条渐隐阴影暗示「右边还有内容」；滚到最右端时又被盖住。
   （阴影用 scroll 附着，相对滚动容器固定；遮罩用 local 附着，随内容移动。）*/
.table-scroll-hint .table-wrap {
  background-color: var(--card);
  background-image:
    linear-gradient(to right, var(--card) 30%, rgba(0, 0, 0, 0)),
    linear-gradient(to left, var(--card) 30%, rgba(0, 0, 0, 0)),
    radial-gradient(farthest-side at 0% 50%, rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0)),
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0));
  background-position: left center, right center, left center, right center;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 16px 100%, 16px 100%;
  background-attachment: local, local, scroll, scroll;
}

/* 工具栏 */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px;
}

.toolbar .spacer { flex: 1; }

.search-box { position: relative; width: 240px; max-width: 100%; }
.search-box input { padding-left: 32px; }
.search-box::before {
  content: "⌕"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); font-size: 15px; pointer-events: none;
}

select.compact { width: auto; padding: 8px 30px 8px 12px; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

/* 进度条 */
.progress { height: 7px; border-radius: 4px; background: var(--bg-soft); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--primary), var(--cyan)); transition: width 0.4s ease; }
.progress.red > i { background: linear-gradient(90deg, #f87171, #ef4444); }
.progress.yellow > i { background: linear-gradient(90deg, #fbbf24, #f59e0b); }

/* 键值列表 */
.kv { display: flex; flex-direction: column; }
.kv-row {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 8.5px 0; border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
.kv-row:last-child { border-bottom: none; }
.kv-key { color: var(--text-dim); flex-shrink: 0; }
.kv-val { text-align: right; word-break: break-all; font-variant-numeric: tabular-nums; }

/* 提示条 */
.alert {
  border-radius: 11px;
  padding: 11px 14px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1.55;
}
.alert code { background: rgba(120, 130, 160, 0.15); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.alert-warn { background: var(--yellow-soft); border: 1px solid rgba(251, 191, 36, 0.3); color: var(--yellow); }
.alert-info { background: var(--primary-soft); border: 1px solid rgba(79, 124, 255, 0.3); color: var(--primary-strong); }
.alert-danger { background: var(--red-soft); border: 1px solid rgba(248, 113, 113, 0.3); color: var(--red); }
.alert-success { background: var(--green-soft); border: 1px solid rgba(52, 211, 153, 0.3); color: var(--green); }

/* ---------------- 抽屉 ---------------- */

.drawer-mask {
  position: fixed; inset: 0; background: rgba(5, 8, 15, 0.55);
  backdrop-filter: blur(2px); z-index: 90; opacity: 0; transition: opacity 0.2s;
}
.drawer-mask.show { opacity: 1; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 94vw;
  background: var(--bg-soft); border-left: 1px solid var(--border);
  z-index: 91; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 0.24s ease;
  box-shadow: var(--shadow);
}
.drawer.show { transform: translateX(0); }

/* 宽抽屉：用于「用户详情」这类内容较宽的页面 ——
   端口表格有 6 列（含续期/编辑/删除三个按钮），520px 下操作列会被挤出可视区，
   用户必须拖横向滚动条才能点到按钮，非常难用。 */
.drawer-wide { width: 880px; }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 17px 20px; border-bottom: 1px solid var(--border); gap: 12px;
}
.drawer-head h3 { font-size: 15.5px; font-weight: 650; display: flex; align-items: center; gap: 10px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px 28px; display: flex; flex-direction: column; gap: 16px; }

/* ---------------- 弹窗 ---------------- */

.modal-mask {
  position: fixed; inset: 0; background: rgba(5, 8, 15, 0.6);
  z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; transition: opacity 0.18s;
}
.modal-mask.show { opacity: 1; }

.modal {
  width: 400px; max-width: 100%;
  background: var(--card); border: 1px solid var(--border); border-radius: 15px;
  padding: 22px; box-shadow: var(--shadow);
  transform: scale(0.96); transition: transform 0.18s;
}
.modal-mask.show .modal { transform: scale(1); }

.modal h3 { font-size: 15.5px; margin-bottom: 9px; }
.modal p { color: var(--text-dim); font-size: 13px; margin-bottom: 18px; line-height: 1.6; word-break: break-word; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------------- Toast ---------------- */

.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 120;
  display: flex; flex-direction: column; gap: 10px; max-width: 380px;
}

.toast {
  background: var(--card); border: 1px solid var(--border); border-left-width: 4px;
  border-radius: 11px; padding: 12px 16px; font-size: 13px;
  box-shadow: var(--shadow); display: flex; gap: 10px; align-items: flex-start;
  animation: toast-in 0.22s ease;
}
.toast.out { animation: toast-out 0.3s ease forwards; }
.toast-success { border-left-color: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-info { border-left-color: var(--primary); }
.toast-warn { border-left-color: var(--yellow); }
.toast-title { font-weight: 600; margin-bottom: 2px; }
.toast-msg { color: var(--text-dim); word-break: break-word; }

@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }

/* ---------------- 图表 ---------------- */

.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-dim); margin-top: 8px; flex-wrap: wrap; }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.lg-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.bar-row { display: flex; flex-direction: column; gap: 5px; padding: 7px 0; }
.bar-row .bar-head { display: flex; justify-content: space-between; font-size: 12.5px; gap: 12px; }
.bar-row .bar-head .name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-head .num { color: var(--text-faint); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.bar-track { height: 6px; background: var(--bg-soft); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--primary), var(--cyan)); }

/* 迷你资源条 */
.res-item { display: flex; flex-direction: column; gap: 6px; padding: 9px 0; }
.res-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-dim); }
.res-head b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------- 日志视图 ---------------- */

.log-view {
  background: #07090f;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  font-size: 12.2px;
  line-height: 1.7;
  padding: 14px 16px;
  overflow: auto;
  height: calc(100vh - 240px);
  min-height: 320px;
}

:root[data-theme="light"] .log-view { background: #0e1320; }

.log-line { white-space: pre-wrap; word-break: break-all; color: #b6c2dc; display: flex; gap: 10px; padding: 1px 0; }
.log-line:hover { background: rgba(120, 140, 200, 0.07); }
.log-line .ln-no { color: #48536e; user-select: none; flex-shrink: 0; min-width: 44px; text-align: right; }
.log-line .ln-txt { flex: 1; }
.log-line.level-error .ln-txt { color: #ff8d8d; }
.log-line.level-warn .ln-txt { color: #ffd479; }
.log-line.level-debug .ln-txt, .log-line.level-trace .ln-txt { color: #7d89a8; }
.log-line.level-info .ln-txt { color: #b6c2dc; }

.log-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text-dim); user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong);
  position: relative; transition: background 0.16s; flex-shrink: 0;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: left 0.16s;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { left: 18px; }

/* ---------------- 其他 ---------------- */

.section-title { font-size: 14px; font-weight: 650; margin: 26px 0 12px; display: flex; align-items: center; gap: 10px; }
.section-title:first-child { margin-top: 4px; }
.section-title .sub { font-size: 12px; color: var(--text-faint); font-weight: 400; }

.skeleton {
  border-radius: 10px;
  background: linear-gradient(100deg, var(--card) 40%, var(--card-hover) 50%, var(--card) 60%);
  background-size: 200% 100%;
  animation: sk 1.2s infinite;
}
@keyframes sk { to { background-position: -200% 0; } }

.text-dim { color: var(--text-dim); }
.text-faint { color: var(--text-faint); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-sm { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }

/* ============================================================
   用户库（商用多用户）
   ============================================================ */

/* 通用弹窗：带标题栏与可滚动内容区 */
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.modal-head h3 { font-size: 16px; margin: 0; }
.modal-body { max-height: 66vh; overflow-y: auto; }
.modal-body .field { margin-bottom: 11px; }
.modal-body .modal-note { font-size: 12.5px; color: var(--text-faint); line-height: 1.6; }

/* 端口标签 */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; margin: 2px 4px 2px 0;
  border-radius: 7px; font-size: 12px; line-height: 1.6;
  background: var(--primary-soft); color: var(--text);
  border: 1px solid transparent; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tag b { color: var(--primary-strong); font-weight: 650; }
.tag-arrow { color: var(--text-faint); }
.tag-off { background: rgba(130, 142, 170, 0.12); color: var(--text-faint); }
.tag-off b { color: var(--text-faint); }
.tag-online { box-shadow: inset 0 0 0 1px var(--green-soft); }

/* 详情里的键值对两列排布（宽抽屉下用）：同样的信息只占一半高度 */
.kv-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 26px; }
.kv-2col .kv-row { min-width: 0; }
.kv-2col .kv-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 端口标签 + 下方一行「隧道备注」：隧道名只能是英文/数字，中文含义写在备注里，
   列表上把它带出来，省得每次点进详情看 */
.tag-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  margin: 0 5px 5px 0;
  vertical-align: top;
  max-width: 100%;
}
.tag-note {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-dim);
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 访问地区限制的标记（用主色区分于普通备注） */
.tag-note-geo { color: var(--primary-strong); }

/* 授权码展示 */
.token-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 9px; border-radius: 7px;
  background: rgba(130, 142, 170, 0.12);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; letter-spacing: 0.4px; color: var(--text-dim);
  cursor: pointer; border: 1px solid transparent; transition: all 0.14s;
}
.token-chip:hover { color: var(--text); border-color: var(--border-strong); background: var(--card-hover); }
.token-chip .eye { font-size: 11px; opacity: 0.7; }

/* 用户单元格 */
.user-cell { display: flex; flex-direction: column; gap: 2px; }
.user-cell .name { font-weight: 600; }
.user-cell .meta { font-size: 12px; color: var(--text-faint); }

/* 有效期展示 */
.expire-cell { display: flex; flex-direction: column; gap: 3px; min-width: 108px; }
.expire-days { font-weight: 600; font-variant-numeric: tabular-nums; }
.expire-date { font-size: 12px; color: var(--text-faint); }
.expire-bar { height: 4px; border-radius: 999px; background: var(--border); overflow: hidden; }
.expire-bar > i { display: block; height: 100%; border-radius: 999px; }

/* 快捷天数选择 */
.quick-days { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-days button {
  padding: 4px 11px; border-radius: 7px; font-size: 12.5px; cursor: pointer;
  background: var(--card-hover); border: 1px solid var(--border);
  color: var(--text-dim); transition: all 0.14s;
}
.quick-days button:hover { border-color: var(--primary); color: var(--primary-strong); }
.quick-days button.active {
  background: var(--primary-soft); border-color: var(--primary);
  color: var(--primary-strong); font-weight: 600;
}

/* 配置预览 */
.cfg-view {
  width: 100%; min-height: 260px; max-height: 46vh; overflow: auto;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 13px 15px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.65; color: var(--text);
  white-space: pre; resize: vertical;
}

/* 统计卡中的小图标行 */
.stat-row { display: flex; align-items: center; gap: 12px; }
.mini-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.mini-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 13px 15px; display: flex; flex-direction: column; gap: 3px;
}
.mini-card .v { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mini-card .k { font-size: 12.5px; color: var(--text-dim); }

/* 到期提醒列表 */
.notice-list { display: flex; flex-direction: column; gap: 7px; margin-top: 9px; }
.notice-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 11px; border-radius: 9px; background: var(--card-hover);
  font-size: 12.5px;
}
.notice-item .left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.notice-item .nm { font-weight: 600; }
.notice-item .sub { color: var(--text-faint); }

/* 抽屉内的隧道表 */
.drawer .table-wrap { border-radius: 11px; }
.drawer-body { padding-bottom: 8px; }

.cell-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------------- 部署指引 · 文档阅读（迷你 Markdown） ---------------- */

.md-body {
  max-height: 66vh;
  overflow: auto;
  padding-right: 6px;
  font-size: 13.2px;
  line-height: 1.75;
  color: var(--text);
}
.md-body .md-h {
  margin: 18px 0 8px;
  font-weight: 650;
  line-height: 1.4;
  color: var(--text);
}
.md-body .md-h:first-child { margin-top: 0; }
.md-body h2.md-h { font-size: 16.5px; border-bottom: 1px solid var(--border); padding-bottom: 7px; }
.md-body h3.md-h { font-size: 15px; }
.md-body h4.md-h { font-size: 14px; color: var(--text-dim); }
.md-body h5.md-h, .md-body h6.md-h { font-size: 13.2px; color: var(--text-dim); }
.md-body p { margin: 8px 0; }
.md-body .md-list { margin: 8px 0; padding-left: 20px; list-style: disc; }
.md-body .md-list li { margin: 3px 0; }
.md-body .md-pre {
  margin: 10px 0;
  max-height: 340px;
  overflow: auto;
  font-size: 12.4px;
  line-height: 1.6;
  white-space: pre;
}
.md-body .md-quote {
  margin: 10px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  background: var(--primary-soft);
  color: var(--text-dim);
}
.md-body .md-hr { margin: 16px 0; border: none; border-top: 1px solid var(--border); }
.md-body .md-table { margin: 12px 0; }
.md-body .md-table table { font-size: 12.6px; }
.md-body code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(130, 142, 170, 0.16);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}
.md-body a { color: var(--primary-strong); }

/* 平台卡片内的文件标签：限制高度、避免撑破卡片 */
#gd-platforms .tag { font-size: 11.5px; padding: 1px 7px; }
