/* 猫玖节点管理 — 主流机场风格（明亮浅色系 + 靛蓝紫渐变） */
:root {
  --c-main: #f5f6fa;
  --c-card: #ffffff;
  --c-card-hi: #f8f9fe;
  --c-sidebar: #ffffff;
  --c-border: #e7eaf3;
  --c-border-soft: #eef0f7;
  --c-accent: #6366f1;
  --c-accent-h: #818cf8;
  --c-accent-2: #a855f7;
  --c-grad: linear-gradient(135deg, #6366f1, #a855f7);
  --c-text: #1e2233;
  --c-text2: #6b7280;
  --c-text3: #9aa1af;
  --c-danger: #ef4444;
  --c-success: #10b981;
  --c-warn: #f59e0b;
  --radius: 14px;
  --shadow-card: 0 1px 2px rgba(30,34,51,0.04);
  --font: -apple-system, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Code", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--c-main); color: var(--c-text);
  font-family: var(--font); font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.role-hidden { display: none !important; }
body:not(.is-admin) .admin-only { display: none !important; }
.view { min-height: 100vh; }

code {
  font-family: var(--mono); font-size: 12.5px;
  background: #eef0fe; padding: 1px 6px; border-radius: 5px; color: #5b5fc7;
}

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d8e6; border-radius: 6px; border: 2px solid var(--c-main); }
::-webkit-scrollbar-thumb:hover { background: #bcc2d8; }

/* ==================== 登录页 ==================== */
#auth-view {
  display: flex; align-items: center; justify-content: center;
  padding: 32px 20px; min-height: 100vh;
  background:
    radial-gradient(900px 520px at 15% -5%, rgba(99,102,241,0.18), transparent 65%),
    radial-gradient(700px 420px at 95% 100%, rgba(168,85,247,0.14), transparent 65%),
    radial-gradient(600px 400px at 75% 15%, rgba(16,185,129,0.07), transparent 70%),
    linear-gradient(160deg, #f6f7fd, #eef0fa);
}

.auth-shell {
  display: grid; grid-template-columns: 1fr 400px;
  gap: 56px; align-items: center;
  width: 100%; max-width: 980px;
}

.auth-hero { padding-right: 8px; }

.hero-logo {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--c-grad);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 14px 36px rgba(99,102,241,0.35), inset 0 1px 0 rgba(255,255,255,0.35);
  margin-bottom: 26px;
}

.auth-hero h1 {
  font-size: 32px; margin: 0 0 12px; letter-spacing: -0.5px; font-weight: 800;
  background: linear-gradient(120deg, #1e2233 35%, #6366f1);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

.auth-hero > p { color: var(--c-text2); margin: 0 0 26px; font-size: 14.5px; line-height: 1.7; }

.hero-list { list-style: none; padding: 0; margin: 0 0 26px; }
.hero-list li {
  color: #4b5265; font-size: 13.5px; margin-bottom: 11px;
  display: flex; align-items: center; gap: 10px;
}
.hero-list .tick {
  width: 19px; height: 19px; border-radius: 50%; flex: 0 0 19px;
  background: rgba(16,185,129,0.13); color: var(--c-success);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}

.card {
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 20px 22px;
}
.auth-card {
  padding: 28px 28px 20px;
  border: none;
  box-shadow: 0 24px 70px rgba(99,102,241,0.14), 0 4px 16px rgba(30,34,51,0.06);
}

.tabs {
  display: flex; gap: 4px; margin-bottom: 22px;
  background: #f1f2fa; padding: 4px; border-radius: 11px;
  border: 1px solid #e8eaf6;
}
.tab {
  flex: 1; padding: 9px 8px; border: none; border-radius: 8px;
  background: transparent; color: var(--c-text2);
  cursor: pointer; font-size: 13.5px; font-family: inherit;
  transition: background 0.16s, color 0.16s, box-shadow 0.16s;
}
.tab:hover { color: var(--c-text); }
.tab.active {
  background: #fff; color: var(--c-text); font-weight: 700;
  box-shadow: 0 2px 8px rgba(30,34,51,0.08);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block; font-size: 12px; color: var(--c-text2);
  margin-bottom: 6px; letter-spacing: 0.2px; font-weight: 500;
}

input, select {
  width: 100%; padding: 10px 13px;
  background: #f7f8fd; color: var(--c-text);
  border: 1px solid var(--c-border); border-radius: 9px;
  font-size: 13.5px; font-family: inherit; outline: none;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}
input::placeholder { color: #b0b6c4; }
input:hover, select:hover { border-color: #cdd2e4; }
input:focus, select:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.14);
  background: #fff;
}
select { cursor: pointer; appearance: none; background-image: none; }
select option { background: #fff; color: var(--c-text); }

/* ==================== 按钮 ==================== */
button { font-family: inherit; }

.btn-primary, .btn-strong, .btn-ghost, .btn-small, .btn-danger, .btn-icon, .btn-mini {
  cursor: pointer; border-radius: 9px; border: 1px solid transparent;
  font-size: 13px; transition: filter 0.15s, background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s, box-shadow 0.15s, transform 0.1s;
}

.btn-primary {
  width: 100%; padding: 11px 16px; margin-top: 4px;
  background: var(--c-grad); color: #fff; font-weight: 700; font-size: 14px;
  border: none;
  box-shadow: 0 8px 20px rgba(99,102,241,0.32), inset 0 1px 0 rgba(255,255,255,0.22);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 10px 26px rgba(99,102,241,0.42); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

.btn-strong {
  padding: 9px 15px; background: #fff; color: #4b5265;
  border-color: var(--c-border);
  box-shadow: 0 1px 3px rgba(30,34,51,0.06);
}
.btn-strong:hover { background: var(--c-card-hi); border-color: #cdd2e4; color: var(--c-text); }

.btn-ghost {
  padding: 8px 14px; background: transparent; color: var(--c-text2);
  border-color: var(--c-border); width: 100%; font-size: 12.5px;
}
.btn-ghost:hover { background: #f4f5fc; color: var(--c-text); }

.btn-small {
  padding: 7px 12px; background: #fff; color: #4b5265;
  border-color: var(--c-border); font-size: 12.5px;
  box-shadow: 0 1px 2px rgba(30,34,51,0.05);
}
.btn-small:hover { background: var(--c-card-hi); border-color: #cdd2e4; color: var(--c-text); }
.btn-small.strong { background: rgba(99,102,241,0.1); color: #5b5fc7; border-color: rgba(99,102,241,0.3); }
.btn-small.strong:hover { background: rgba(99,102,241,0.18); }

.btn-danger { padding: 7px 12px; background: rgba(239,68,68,0.08); color: #dc2626; border-color: rgba(239,68,68,0.25); }
.btn-danger:hover { background: rgba(239,68,68,0.15); }

.btn-icon {
  width: 30px; height: 30px; background: #fff; color: var(--c-text2);
  border-color: var(--c-border); font-size: 15px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 2px rgba(30,34,51,0.05);
}
.btn-icon:hover { background: var(--c-card-hi); color: var(--c-text); }
.btn-icon.spin { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-mini {
  padding: 4px 10px; font-size: 12px; margin: 2px 3px 2px 0;
  background: #f4f5fc; color: #4b5265; border-color: #e3e6f2;
  white-space: nowrap;
}
.btn-mini:hover { background: #eceef9; color: var(--c-text); }
.btn-mini.danger { background: rgba(239,68,68,0.08); color: #dc2626; border-color: rgba(239,68,68,0.22); }
.btn-mini.danger:hover { background: rgba(239,68,68,0.15); }
.btn-mini.ok { background: rgba(16,185,129,0.09); color: #059669; border-color: rgba(16,185,129,0.25); }
.btn-mini.ok:hover { background: rgba(16,185,129,0.16); }

.msg { color: var(--c-danger); font-size: 12.5px; min-height: 16px; margin: 10px 0 0; line-height: 1.5; }
.msg.ok { color: var(--c-success); }
/* 免端口访问诊断结果：多行展示，保留换行 */
#pa-diag-msg { white-space: pre-line; }

/* ==================== 主框架 ==================== */
#main-view {
  display: flex; height: 100vh; overflow: hidden;
}

.sidebar {
  width: 212px; flex: 0 0 212px;
  background: var(--c-sidebar); border-right: 1px solid var(--c-border);
  display: flex; flex-direction: column; padding: 0 0 12px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px;
}
.brand-logo {
  width: 34px; height: 34px; border-radius: 11px; flex: 0 0 34px;
  background: var(--c-grad);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(99,102,241,0.32), inset 0 1px 0 rgba(255,255,255,0.25);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 15.5px; font-weight: 800; letter-spacing: 0.2px; }
.brand-text span { font-size: 11px; color: var(--c-text3); }

.nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.nav-label {
  font-size: 10.5px; color: var(--c-text3); letter-spacing: 1.6px;
  padding: 10px 10px 8px; text-transform: uppercase; font-weight: 700;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px; margin-bottom: 2px;
  background: transparent; border: none; border-radius: 10px;
  color: var(--c-text2); font-size: 13px; text-align: left;
  cursor: pointer; transition: background 0.15s, color 0.15s;
  position: relative;
}
.nav-item .ico {
  width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
  opacity: 0.7; flex: 0 0 18px; transition: opacity 0.15s, color 0.15s;
}
.nav-item .ico svg { display: block; }
.nav-item:hover { background: #f4f5fc; color: var(--c-text); }
.nav-item:hover .ico { opacity: 1; }
.nav-item.active {
  background: #edf0fa;
  color: #3b4266; font-weight: 700;
}
.nav-item.active::before {
  content: none;
}
.nav-item.active .ico { opacity: 1; color: #3b4266; }

.sidebar-foot { padding: 10px 12px 0; border-top: 1px solid var(--c-border); margin-top: 8px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 2px 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 32px;
  background: var(--c-grad);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; text-transform: uppercase;
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.user-meta { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.user-meta strong {
  font-size: 12.5px; font-weight: 700; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.user-meta span { font-size: 10.5px; color: var(--c-text3); }

.main-wrap {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
  background:
    radial-gradient(820px 380px at 88% -12%, rgba(99,102,241,0.08), transparent 65%),
    var(--c-main);
}

.topbar {
  height: 56px; flex: 0 0 56px;
  display: flex; align-items: center; padding: 0 24px;
  border-bottom: 1px solid var(--c-border);
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 15px; font-weight: 800; letter-spacing: 0.1px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-hint { font-size: 11.5px; color: var(--c-text3); }

.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--c-success);
  box-shadow: 0 0 0 0 rgba(16,185,129,0.5); animation: pulse 2.4s infinite;
}
.live-dot.bad { background: var(--c-danger); animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
  70% { box-shadow: 0 0 0 7px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

.content { flex: 1; overflow-y: auto; padding: 20px 24px 40px; }
.pane { display: none; }
.pane.active { display: block; animation: fadeUp 0.22s ease-out; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ==================== 卡片 ==================== */
.card {
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 18px 22px; margin-bottom: 14px;
  box-shadow: none;
  transition: border-color 0.18s;
}
.card:hover { border-color: #dde1ee; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.card-head h2 {
  font-size: 14px; margin: 0; font-weight: 800; letter-spacing: 0.15px;
  display: flex; align-items: center; gap: 9px;
}
.card-head h2::before {
  content: ""; width: 4px; height: 14px; border-radius: 2px;
  background: var(--c-grad); flex: 0 0 4px;
}
.head-tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.hint { font-size: 11.5px; color: var(--c-text3); }

.pill {
  margin-left: auto; font-size: 11.5px; padding: 3px 11px;
  border-radius: 20px; background: #f4f5fc; color: var(--c-text2);
  border: 1px solid #e3e6f2; white-space: nowrap;
  font-weight: 600; letter-spacing: 0.2px;
}
.pill.on { background: rgba(16,185,129,0.1); color: #059669; border-color: rgba(16,185,129,0.25); }
.pill.off { background: rgba(239,68,68,0.08); color: #dc2626; border-color: rgba(239,68,68,0.22); }
.pill.warn { background: rgba(245,158,11,0.1); color: #d97706; border-color: rgba(245,158,11,0.25); }

/* ==================== 统计卡 ==================== */
.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px; margin-bottom: 14px;
}
.stat {
  background: #ffffff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 15px 17px;
  box-shadow: var(--shadow-card);
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
  position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: var(--c-grad); opacity: 0; transition: opacity 0.18s;
}
.stat:hover { border-color: #dde1ee; transform: none; box-shadow: none; }
.stat:hover::after { opacity: 1; }
.stat .k {
  font-size: 11.5px; color: var(--c-text2); margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px; font-weight: 500;
}
.stat .v {
  font-family: var(--mono); font-size: 21px; font-weight: 800;
  letter-spacing: -0.3px; line-height: 1.15; word-break: break-all;
  color: var(--c-text);
}
.stat .v.small { font-size: 13.5px; font-weight: 700; }
.stat .s { font-size: 11px; color: var(--c-text3); margin-top: 6px; }

/* ==================== 键值网格 ==================== */
.kv-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.kv {
  background: #f8f9fd; border: 1px solid var(--c-border-soft); border-radius: 10px;
  padding: 11px 13px;
}
.kv .label { font-size: 11px; color: var(--c-text3); margin-bottom: 5px; font-weight: 500; }
.kv .value {
  font-size: 13px; font-weight: 600; word-break: break-all;
  font-family: var(--mono); line-height: 1.4; color: #2a2f42;
}
.kv .value.plain { font-family: var(--font); }
.kv .value.mono-sm { font-size: 11.5px; color: #565e73; }

.actions { display: flex; flex-wrap: wrap; gap: 9px; }

.guide { margin: 0; padding-left: 20px; color: #4b5265; font-size: 13px; line-height: 1.9; }
.guide li::marker { color: var(--c-accent); font-weight: 800; }

/* ==================== 表单 ==================== */
.inline-form { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 150px; }
.inline-form .w-90 { flex: 0 0 90px; width: 90px; }
.inline-form .w-140 { flex: 1 1 130px; max-width: 170px; }
.inline-form button { flex: 0 0 auto; width: auto; margin-top: 0; }

.topbar input, .head-tools input { width: auto; }
.w-200 { width: 200px !important; }
.w-fit { width: auto !important; padding-left: 20px; padding-right: 20px; }

.stack-form { max-width: 380px; }
.kv-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.kv-form .full { grid-column: 1 / -1; }
.kv-form button { width: auto; justify-self: start; padding: 9px 20px; margin-top: 0; }

/* ==================== 表格 ==================== */
.table-wrap { overflow-x: auto; margin: 0 -22px -18px; padding: 0 22px 4px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 10px 10px; text-align: left; border-bottom: 1px solid var(--c-border-soft); vertical-align: middle; }
th {
  color: var(--c-text3); font-weight: 700; font-size: 10.5px;
  letter-spacing: 0.8px; text-transform: uppercase;
  background: #f8f9fd; white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: #f7f8fe; }
td { color: #3c4257; }
td.mono { font-family: var(--mono); font-size: 12px; color: #5b6378; }
td.nowrap { white-space: nowrap; }
tr.row-self td { background: rgba(99,102,241,0.05); }
tr.row-off td { opacity: 0.55; }
tr.row-off:hover td { opacity: 1; }

.tag {
  display: inline-block; padding: 2px 9px; border-radius: 6px;
  font-size: 11px; font-weight: 600; white-space: nowrap; letter-spacing: 0.2px;
}
.tag.admin { background: rgba(99,102,241,0.12); color: #5b5fc7; }
.tag.user { background: #f1f2f8; color: #6b7280; }
.tag.on { background: rgba(16,185,129,0.11); color: #059669; }
.tag.off { background: rgba(239,68,68,0.09); color: #dc2626; }
.tag.wait { background: rgba(245,158,11,0.11); color: #d97706; }
.tag.live { background: rgba(16,185,129,0.11); color: #059669; }

.expired-text { color: var(--c-danger); }
.countdown { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.code-block {
  background: #f7f8fc; border: 1px solid var(--c-border-soft); border-radius: 10px;
  padding: 13px 15px; overflow: auto; font-family: var(--mono);
  font-size: 12px; line-height: 1.65; color: #3c4257;
  max-height: 380px; white-space: pre; margin: 0;
}
.code-block.tall { max-height: 60vh; }

/* ==================== 弹窗 ==================== */
.modal {
  position: fixed; inset: 0; background: rgba(30,34,51,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 200; backdrop-filter: blur(3px);
  animation: fadeIn 0.16s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  background: #fff; border: 1px solid var(--c-border);
  border-radius: 16px; width: 100%; max-width: 620px;
  max-height: 86vh; display: flex; flex-direction: column;
  box-shadow: 0 30px 80px rgba(30,34,51,0.25);
  animation: popIn 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: none; }
}
.modal-head {
  display: flex; align-items: center; padding: 16px 20px;
  border-bottom: 1px solid var(--c-border-soft); flex: 0 0 auto;
}
.modal-head h3 { margin: 0; font-size: 14px; font-weight: 800; }
.modal-close {
  margin-left: auto; width: 28px; height: 28px; border-radius: 7px;
  background: transparent; border: none; color: var(--c-text2);
  font-size: 20px; line-height: 1; cursor: pointer;
}
.modal-close:hover { background: #f1f2f8; color: var(--c-text); }
.modal-body { padding: 18px 20px 20px; overflow-y: auto; flex: 1 1 auto; }
.modal-body .hint { margin: 0 0 12px; display: block; }
.modal-body .field:last-of-type { margin-bottom: 16px; }

.qr-wrap {
  text-align: center; padding: 14px 0 6px;
  background: #fff; border: 1px solid var(--c-border-soft);
  border-radius: 12px; margin: 4px 0 14px;
}
.qr-wrap img { width: 240px; height: 240px; image-rendering: pixelated; display: block; margin: 0 auto; }

/* ==================== Toast ==================== */
.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 300;
  background: rgba(255,255,255,0.95); border: 1px solid var(--c-border); border-left: 4px solid var(--c-success);
  color: var(--c-text); padding: 12px 17px; border-radius: 12px;
  font-size: 13px; box-shadow: 0 14px 36px rgba(30,34,51,0.16);
  animation: toastIn 0.22s ease-out; max-width: 380px;
  backdrop-filter: blur(8px);
}
.toast.err { border-left-color: var(--c-danger); color: #b91c1c; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ==================== 响应式 ==================== */

/* ---- 平板：登录页单列 ---- */
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; gap: 26px; max-width: 420px; }
  .auth-hero { text-align: center; padding: 0; }
  .hero-logo { margin: 0 auto 18px; }
  .auth-hero h1 { font-size: 24px; }
  .hero-list { display: inline-block; text-align: left; }
  .kv-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ---- 手机：底部标签栏 + 卡片化表格 ---- */
@media (max-width: 760px) {
  /* 让手机使用文档滚动，避免桌面固定高度/hidden 溢出锁住整页。 */
  html, body { height: auto; min-height: 100%; overflow-x: hidden; overflow-y: auto; }
  #main-view { display: block; height: auto; min-height: 100vh; min-height: 100dvh; overflow: visible; }
  .main-wrap { display: block; height: auto; min-height: 100vh; min-height: 100dvh; overflow: visible; padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  .content { height: auto; min-height: 0; overflow: visible; padding: 12px 12px calc(30px + env(safe-area-inset-bottom, 0px)); }
  /* 侧边栏变成底部导航条 */
  #main-view { flex-direction: column; }

  .sidebar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    width: 100%; flex: 0 0 auto;
    height: auto;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-top: 1px solid var(--c-border);
    padding: 0;
    z-index: 120;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -4px 20px rgba(30,34,51,0.08);
  }

  .brand, .sidebar-foot, .nav-label { display: none !important; }

  .nav {
    display: flex;
    flex: 1;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }

  .nav-item {
    /* 关键：桌面端是 width:100%（纵向列表），移动端必须改成自动宽度，
       否则每个标签都会占满整行，底部导航只看得见第一个。 */
    width: auto;
    flex: 1 1 0;
    flex-direction: column;
    gap: 3px;
    padding: 8px 4px 7px;
    margin: 0;
    border-radius: 0;
    min-width: 0;
    font-size: 10.5px;
    justify-content: center;
    align-items: center;
    min-height: 52px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .nav-item .ico { width: 20px; height: 20px; flex-basis: 20px; }
  .nav-item .ico svg { width: 19px; height: 19px; }
  .nav-item.active { background: rgba(99, 102, 241, 0.08); }
  .nav-item.active::before {
    content: "";
    position: absolute;
    left: 20%; right: 20%; top: 0; bottom: auto;
    width: auto; height: 2.5px; border-radius: 0 0 3px 3px;
    background: var(--c-grad);
  }
  .nav-item.active .ico { color: var(--c-accent); }

  /* 主区域给底部栏留出空间 */
  .main-wrap { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  .content { padding: 12px 12px calc(30px + env(safe-area-inset-bottom, 0px)); }

  .topbar { height: 50px; flex: 0 0 50px; padding: 0 12px; }
  .topbar-title { font-size: 13.5px; }
  .topbar-hint { display: none; }

  /* 卡片与统计 */
  .card { padding: 15px 15px; border-radius: 12px; margin-bottom: 10px; }
  .card-head { margin-bottom: 12px; }
  .card-head h2 { font-size: 13px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 11px 13px; }
  .stat .v { font-size: 16px; }
  .stat .v.small { font-size: 12.5px; }
  .stat .k { font-size: 10.5px; margin-bottom: 5px; }
  .stat .s { font-size: 10px; }

  .kv-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kv { padding: 9px 11px; }
  .kv .label { font-size: 10px; }
  .kv .value { font-size: 12px; }

  /* 公网 / 接入信息块 */
  .net-hero, .access-hero { flex-direction: column; align-items: stretch; gap: 10px; }
  .net-actions, .access-actions { justify-content: flex-start; }
  .net-ip { font-size: 19px; }
  .access-endpoint { font-size: 16px; }

  /* 按钮更容易点 */
  .actions { gap: 7px; }
  .btn-primary, .btn-strong, .btn-ghost, .btn-small {
    padding: 9px 13px;
    font-size: 12.5px;
  }
  .btn-mini { padding: 6px 10px; font-size: 11.5px; }
  .actions .btn-primary, .actions .btn-strong { flex: 1 1 auto; }

  /* 表单改为单列 */
  .inline-form { flex-direction: column; align-items: stretch; gap: 8px; }
  .inline-form input, .inline-form select,
  .inline-form .w-90, .inline-form .w-140, .inline-form .w-160 {
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: none !important;
  }
  .inline-form button { width: 100%; }
  .unit-tip { display: none; }
  .head-tools { width: 100%; margin-left: 0; margin-top: 8px; }
  .head-tools input { flex: 1; width: auto !important; }
  .w-200 { width: 100% !important; }
  .stack-form { max-width: none; }
  .kv-form { grid-template-columns: 1fr; }

  /* ===== 表格卡片化：每行变成一张卡 ===== */
  .table-wrap {
    margin: 0;
    padding: 0;
    overflow: visible;
  }
  table, thead, tbody, tr, th, td { display: block; }
  table { border-collapse: separate; }

  thead { position: absolute; left: -9999px; }
  tbody tr.empty-row { display: block; }
  tbody tr.empty-row td { display: block; text-align: center; }
  tbody tr.empty-row td::before { display: none; }

  tbody tr {
    background: #f8f9fd;
    border: 1px solid var(--c-border-soft);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 9px;
  }
  tbody tr:hover { background: #f4f5fd; }
  tbody tr.row-off { opacity: 1; }
  tbody tr.row-off td { opacity: 0.55; }

  tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    border: none;
    padding: 5px 0;
    font-size: 12.5px;
    text-align: right;
    word-break: break-all;
  }
  tbody td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--c-text3);
    font-size: 11px;
    text-align: left;
    padding-top: 2px;
    white-space: nowrap;
  }
  tbody td > div, tbody td > span { text-align: right; }
  tbody td:empty { display: none; }
  tbody td[data-label="选择"] { display: block; text-align: left; padding: 0 0 5px; }
  tbody td[data-label="选择"]::before { display: none; }

  /* 操作列单独一行，按钮铺满 */
  tbody td[data-label="操作"] {
    display: block;
    text-align: left;
    padding-top: 9px;
    margin-top: 5px;
    border-top: 1px solid var(--c-border-soft);
  }
  tbody td[data-label="操作"]::before { display: none; }
  tbody td[data-label="操作"] .btn-mini {
    display: inline-block;
    margin: 3px 4px 3px 0;
    padding: 6px 11px;
  }

  /* 弹窗全屏感 */
  .modal { padding: 12px; align-items: flex-end; }
  .modal-content {
    max-width: none;
    max-height: 90vh;
    border-radius: 16px 16px 12px 12px;
  }
  .modal-body { padding: 14px 16px 18px; }
  .qr-wrap img { width: 200px; height: 200px; }

  .toast { right: 12px; left: 12px; bottom: 70px; max-width: none; }
  .guide { font-size: 12.5px; line-height: 1.85; padding-left: 18px; }
  .acc-tip { font-size: 11.5px; line-height: 1.75; }
}

/* ---- 手机上隐藏次要列 ---- */
@media (max-width: 760px) {
  tbody td[data-label="ID"] { display: none; }
  tbody td[data-label="备注"]:empty { display: none; }
  #user-filter { flex: 1 1 100%; min-width: 0; }
  #user-list-count, #selected-user-count { flex: 1 1 45%; }
}

/* ---- 超小屏 ---- */
@media (max-width: 380px) {
  .stat-row, .kv-grid { grid-template-columns: 1fr; }
  .nav-item { min-width: 54px; font-size: 9.5px; padding: 7px 4px; }
  .net-ip { font-size: 17px; }
}

/* ---- 触摸屏优化（无 hover 设备） ---- */
@media (hover: none) {
  .stat:hover, tbody tr:hover { background: inherit; transform: none; }
  .btn-primary:hover, .btn-strong:hover { filter: none; }
}

/* ==================== 套餐与流量 ==================== */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.w-160 { width: 160px !important; }
.unit-tip {
  font-size: 11px;
  color: var(--c-text3);
  margin-left: -4px;
  margin-right: 4px;
}

/* 配额进度条 */
.quota-bar-wrap {
  background: #f8f9fd;
  border: 1px solid var(--c-border-soft);
  border-radius: 10px;
  padding: 13px 15px;
}

.quota-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--c-text2);
  margin-bottom: 9px;
  font-weight: 500;
}

.quota-num {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 800;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
}

.quota-track {
  height: 8px;
  background: #e9ecf5;
  border-radius: 6px;
  overflow: hidden;
}

.quota-fill {
  height: 100%;
  width: 0;
  border-radius: 6px;
  background: linear-gradient(90deg, #10b981, #34d399);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s;
}

.quota-fill.warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.quota-fill.full { background: linear-gradient(90deg, #ef4444, #f87171); }

.quota-foot {
  font-size: 11px;
  color: var(--c-text3);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

/* 表格里的迷你进度条 */
.mini-track {
  height: 4px;
  background: #e9ecf5;
  border-radius: 3px;
  overflow: hidden;
  margin: 4px 0 2px;
  width: 100%;
  max-width: 120px;
}

.mini-fill {
  height: 100%;
  border-radius: 3px;
  background: #10b981;
  transition: width 0.4s ease;
}

.mini-fill.warn { background: #f59e0b; }
.mini-fill.full { background: #ef4444; }

/* 复选框 */
input[type="checkbox"] {
  accent-color: var(--c-accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ==================== 公网信息 ==================== */
.net-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background:
    radial-gradient(420px 130px at 15% 0%, rgba(99,102,241,0.1), transparent 70%),
    #f8f9fe;
  border: 1px solid #e4e7f5;
  border-radius: 12px;
  padding: 17px 19px;
  margin-bottom: 12px;
}

.net-ip-block { flex: 1 1 auto; min-width: 0; }

.net-label {
  font-size: 11px;
  color: var(--c-text3);
  margin-bottom: 5px;
  letter-spacing: 0.3px;
  font-weight: 500;
}

.net-ip {
  font-family: var(--mono);
  font-size: 25px;
  font-weight: 800;
  background: linear-gradient(120deg, #1e2233 35%, #6366f1);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: -0.3px;
  word-break: break-all;
  line-height: 1.25;
}

.net-loc {
  font-size: 12px;
  color: var(--c-text2);
  margin-top: 6px;
  word-break: break-all;
  line-height: 1.5;
}

.net-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
}

/* ==================== 接入信息 ==================== */
.access-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background:
    radial-gradient(440px 140px at 12% 0%, rgba(16,185,129,0.09), transparent 70%),
    linear-gradient(135deg, #f7f9ff, #f5f3ff);
  border: 1px solid #e4e7f5;
  border-radius: 12px;
  padding: 17px 19px;
  margin-bottom: 12px;
}

.access-main { flex: 1 1 auto; min-width: 0; }

.access-label {
  font-size: 11px;
  color: var(--c-text3);
  margin-bottom: 5px;
  font-weight: 500;
}

.access-endpoint {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 800;
  color: #2a2f42;
  word-break: break-all;
  line-height: 1.3;
}

.access-sub {
  font-size: 11.5px;
  color: var(--c-text3);
  margin-top: 6px;
  word-break: break-all;
}

.access-actions { display: flex; gap: 7px; flex-wrap: wrap; }

.acc-tip {
  background: #f8f9fd;
  border: 1px solid var(--c-border-soft);
  border-left: 4px solid var(--c-accent);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12px;
  color: #4b5265;
  line-height: 1.85;
}

/* ==================== 自动配置标记 ==================== */
.auto-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  color: #059669;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 20px;
  padding: 2px 10px;
  white-space: nowrap;
}
.auto-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #10b981;
  animation: pulse 2.4s infinite;
}
.net-auto-tip {
  font-size: 10.5px;
  color: var(--c-text3);
  margin-left: 4px;
  font-weight: 400;
}

/* ==================== 一键导入菜单 ==================== */
.import-wrap { position: relative; display: inline-block; }

.import-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 80;
  width: 210px;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(30,34,51,0.16);
  padding: 6px;
  animation: popIn 0.14s ease-out;
}

.import-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #3c4257;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.import-item svg { color: #8a93a8; flex: 0 0 16px; }
.import-item:hover { background: #f3f5fb; }
.import-item:hover svg { color: var(--c-accent); }

.import-tutorial {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 11px;
  border: none;
  border-radius: 8px;
  background: #2f6d6a;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: filter 0.14s;
}
.import-tutorial:hover { filter: brightness(1.1); }

@media (max-width: 760px) {
  .import-menu { right: auto; left: 0; }
}

/* ==================== 视觉打磨补充 ==================== */
::selection { background: rgba(99,102,241,0.22); }

button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid rgba(99,102,241,0.5);
  outline-offset: 2px;
}

/* 套餐卡片（plan-grid 内由 JS 生成的 stat/kv） */
.plan-grid .stat .v { font-size: 15px; }

/* Reuse the existing page language for the new VPN protocols and order flow. */
.protocol-grid, .order-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.protocol-card, .order-plan { border: 1px solid var(--c-border); border-radius: 12px; background: #f8f9fd; padding: 18px; min-width: 0; }
.protocol-card h3, .order-plan h3 { font-size: 15px; margin: 0 0 10px; overflow-wrap: anywhere; }
.protocol-card .hint { margin: 0 0 10px; }
.order-plan { display: flex; flex-direction: column; align-items: flex-start; }
.order-plan p { margin: 4px 0 10px; line-height: 1.7; }
.order-price { font-size: 23px; font-weight: 800; color: #5b5fc7; margin: 4px 0 10px; }
.order-plan .btn-primary { margin-top: auto; }
.empty-cell { padding: 26px; text-align: center; color: var(--c-text3); }
.check-field { display: flex; gap: 9px; align-items: flex-start; }
.check-field input, input[type=checkbox] { width: 16px; min-width: 16px; height: 16px; margin: 2px 4px 0 0; }
.check-field span { color: var(--c-text2); font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.head-tools { flex-wrap: wrap; }
.access-endpoint { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .protocol-grid, .order-plans { grid-template-columns: 1fr; }
  .nav-item { flex: 1 0 70px; min-width: 70px; }
  .nav { overscroll-behavior-x: contain; }
  .sidebar-foot { display: none; }
  .mobile-logout { display: inline-flex !important; }
  .card-head .head-tools { min-width: 0; }
}
.mobile-logout { display: none; }

/* Shadowrocket shares the existing connection card and modal components. */
.sr-actions, .sr-modal-actions, .sr-kind-switch { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.sr-actions a, .sr-modal-actions a { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-family: inherit; text-align: center; }
.sr-actions > *, .sr-modal-actions > *, .sr-kind-switch > * { min-height: 44px; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.sr-actions a[aria-disabled="true"] { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }
.sr-actions .sr-reset { margin-left: auto; color: #b91c1c; }
.sr-private-note { margin: 14px 0 0; color: var(--c-text3); font-size: 11.5px; line-height: 1.75; }
.sr-fallback { margin: 13px 0 0; line-height: 1.75; }
.sr-kind-switch { margin-bottom: 14px; }
.sr-modal-actions { margin: 16px 0; }
.sr-qr-content .qr-wrap { width: fit-content; max-width: 100%; min-height: 44px; margin: 0 auto 14px; }
.sr-qr-content .qr-wrap img { width: 256px; height: auto; max-width: 100%; aspect-ratio: 1; object-fit: contain; }
.sr-manual { margin-top: 14px; border-top: 1px solid var(--c-border); padding-top: 14px; min-width: 0; }
.sr-manual summary { cursor: pointer; color: var(--c-text2); min-height: 36px; line-height: 1.8; }
.sr-secret { display: block; box-sizing: border-box; width: 100%; min-width: 0; resize: vertical; min-height: 108px; max-height: 240px; padding: 12px; border: 1px solid var(--c-border); border-radius: 8px; background: #f8f9fd; color: var(--c-text2); font-family: var(--mono); font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; word-break: break-all; }
.modal-body { overscroll-behavior: contain; overflow-x: hidden; }
.sr-secret:focus-visible { outline: 2px solid rgba(99,102,241,.5); outline-offset: 2px; }
@media (max-width: 760px) {
  .sr-actions { align-items: stretch; }
  .sr-actions > * { flex: 1 1 calc(50% - 9px); }
  .sr-actions #sr-import, .sr-actions #clash-import { flex-basis: 100%; }
  .sr-actions .sr-reset { margin-left: 0; }
  .sr-kind-switch > *, .sr-modal-actions > * { flex: 1 1 calc(50% - 9px); }
  .sr-qr-content .qr-wrap img { width: 256px; }
  .sr-secret { font-size: 16px; }
}

/* 加载占位 */
.stat .v:empty::before, .kv .value:empty::before { content: "—"; color: var(--c-text3); }
