/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0e14;
  --bg2: #161821;
  --bg3: #1e2130;
  --border: #272b3d;
  --border-hover: #363b55;
  --accent: #6366f1;
  --accent-hover: #5254cc;
  --accent-soft: rgba(99,102,241,0.1);
  --accent-glow: rgba(99,102,241,0.25);
  --blue: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #4e5a6e;
  --radius: 12px;
  --radius-sm: 7px;
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-sm: 0 2px 12px rgba(0,0,0,0.3);
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  height: 100vh; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── 访问密码登录（全屏遮罩）────────────────────────────────── */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 80% 60% at 50% 40%, rgba(99,102,241,0.12), transparent 55%), var(--bg);
  padding: 24px;
}
.login-gate.hidden { display: none !important; }
.login-gate__card {
  width: 100%;
  max-width: 380px;
  padding: 28px 24px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login-gate__title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.login-gate__hint {
  color: var(--text2);
  font-size: 13px;
  margin-bottom: 16px;
}
.login-gate__field { margin-bottom: 18px; }
.login-gate__btn {
  width: 100%;
  justify-content: center;
  padding: 10px 16px;
  font-size: 14px;
}
.login-gate__error {
  margin-top: 12px;
  font-size: 13px;
  color: var(--red);
}

/* ── Form ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; color: var(--text2); margin-bottom: 6px;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
}
.form-group input:not([type="checkbox"]), .form-group select, .form-group textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; color: var(--text);
  font-size: 14px; font-family: inherit;
  transition: border-color .2s, box-shadow .2s; outline: none;
}
.form-group input:not([type="checkbox"]):hover,
.form-group textarea:hover { border-color: var(--border-hover); }
.form-group input:focus, .form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* 移除数字输入框的上下箭头 */
.form-group input[type="number"]::-webkit-inner-spin-button,
.form-group input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.form-group input[type="number"] {
  -moz-appearance: textfield;
}
/* 覆盖浏览器自动填充的浅色背景，保持深色主题一致 */
.form-group input:-webkit-autofill,
.form-group input:-webkit-autofill:hover,
.form-group input:-webkit-autofill:focus,
.form-group input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 50px var(--bg3) inset;
  -webkit-text-fill-color: var(--text);
}
.form-group textarea:-webkit-autofill,
.form-group textarea:-webkit-autofill:hover,
.form-group textarea:-webkit-autofill:focus,
.form-group textarea:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 50px var(--bg3) inset;
  -webkit-text-fill-color: var(--text);
}

/* ── Layout ─────────────────────────────────────────────────── */
#main-app { display: flex; height: 100vh; }

.sidebar {
  width: 200px; min-width: 200px; background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px 20px; font-weight: 700; font-size: 15px;
  border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.sidebar-nav { flex: 1; padding: 0 8px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text3); text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: background .18s, color .18s, transform .15s;
  cursor: pointer; margin-bottom: 2px;
  position: relative; user-select: none;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; transition: transform .18s; }
.nav-item:hover {
  background: var(--bg3); color: var(--text2);
  transform: translateX(2px);
}
.nav-item:hover svg { transform: scale(1.1); }
.nav-item.active {
  background: var(--accent-soft); color: var(--accent);
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  height: 60%; width: 3px;
  background: var(--accent); border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px var(--accent-glow);
}
.nav-item:active { transform: translateX(2px) scale(.97); }

.sidebar-footer {
  padding: 12px 16px 0; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.server-info { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text3); }
.server-select {
  width: 100%;
  margin-bottom: 8px;
  font-size: 11px;
  padding: 6px 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
}
.relay-label { font-size: 12px; color: var(--text2); display: inline-flex; align-items: center; gap: 6px; }
.relay-label .server-select { min-width: 160px; margin-bottom: 0; font-size: 12px; }

/* 节点加速：侧栏与整页隐藏（远端机房常无法连 ss 订阅）；恢复时去掉 nav/page 上 *-node-accel-hidden 类并改 server.js NODE_ACCEL_PERIODIC_ENABLED */
.nav-item--node-accel-hidden,
.page-node-accel-hidden {
  display: none !important;
}

/* 多机中继：默认 body.panel-relay-disabled；开启：`config.panel.relayEnabled` 或 `PANEL_RELAY_ENABLED=1` */
body.panel-relay-disabled .nav-item[data-page="relay"],
body.panel-relay-disabled #page-relay {
  display: none !important;
}

/* relay-input：中继 / 节点加速等页与深色主题统一的输入框 */
.relay-input {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color .2s, box-shadow .2s, background .2s;
  outline: none;
  min-height: 40px;
}
.relay-input:hover {
  border-color: var(--border-hover);
  background: rgba(30, 33, 48, 0.95);
}
.relay-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.relay-input::placeholder {
  color: var(--text3);
}
.relay-input[type="number"]::-webkit-inner-spin-button,
.relay-input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.relay-input[type="number"] {
  -moz-appearance: textfield;
}
.relay-input:-webkit-autofill,
.relay-input:-webkit-autofill:hover,
.relay-input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 50px var(--bg3) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
}

/* 节点加速：标签在上、输入在下 */
#page-node-accel .na-field-block {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 16px;
  max-width: 720px;
}
#page-node-accel .na-field-block > span:first-child,
#page-node-accel .na-field-block .na-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
#page-node-accel .na-field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 20px;
  align-items: flex-end;
  margin-bottom: 16px;
}
#page-node-accel .na-field-row .na-field-inline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
#page-node-accel .na-field-row .na-field-inline .na-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: 0.03em;
}
#page-node-accel .na-field-row .na-field-inline input.relay-input {
  min-width: 0;
}
#page-node-accel .na-periodic-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: border-color .2s;
}
#page-node-accel .na-periodic-wrap:hover {
  border-color: var(--border-hover);
}
#page-node-accel .na-periodic-wrap input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}
#page-node-accel .na-periodic-wrap span {
  font-size: 13px;
  color: var(--text2);
}
#page-node-accel .na-form-hint {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 14px;
  line-height: 1.55;
}
#page-node-accel .na-form-hint code {
  font-size: 11px;
  padding: 2px 7px;
  background: var(--bg3);
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--accent);
  font-family: var(--font-mono);
}
#page-node-accel .na-input-full {
  width: 100%;
  max-width: 720px;
}
#page-node-accel .na-input-num {
  width: 112px;
}
#page-node-accel .na-field-grow {
  flex: 1;
  min-width: 220px;
}
#page-node-accel .na-input-grow {
  width: 100%;
  max-width: 480px;
}
.server-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 6px var(--green);
}
.server-dot.online { animation: pulse 2.5s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--green); }
  50% { opacity: 0.4; box-shadow: 0 0 2px var(--green); }
}

.btn-icon {
  background: none; border: none; cursor: pointer; color: var(--text3);
  padding: 4px; border-radius: 4px; display: flex; align-items: center;
  transition: color .15s, background .15s, transform .15s;
}
.btn-icon:hover { color: var(--text); background: var(--bg3); transform: scale(1.1); }
.btn-icon:active { transform: scale(.9); }
.btn-icon svg { width: 16px; height: 16px; }

/* ── Main Content ────────────────────────────────────────────── */
.main-content { flex: 1; overflow-y: auto; padding: 24px; background: var(--bg); }
.page { display: none; }
.page.active {
  display: block;
  animation: pageIn .22s var(--ease-out) forwards;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.page-header h2 { font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.header-actions { display: flex; gap: 8px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: none; cursor: pointer; font-size: 13px; font-weight: 500;
  transition: background .15s, box-shadow .2s, transform .12s, border-color .15s;
  text-decoration: none; position: relative; overflow: hidden;
  user-select: none;
}
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-secondary { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.btn-secondary:hover { color: var(--text); border-color: var(--border-hover); background: #242840; }
.btn-danger { background: rgba(239,68,68,0.1); color: var(--red); border: 1px solid rgba(239,68,68,0.25); }
.btn-danger:hover { background: rgba(239,68,68,0.2); box-shadow: 0 4px 16px rgba(239,68,68,0.15); }
.btn-warning { background: rgba(245,158,11,0.1); color: var(--yellow); border: 1px solid rgba(245,158,11,0.25); }
.btn-warning:hover { background: rgba(245,158,11,0.2); }
.btn-success { background: rgba(16,185,129,0.1); color: var(--green); border: 1px solid rgba(16,185,129,0.25); }
.btn-success:hover { background: rgba(16,185,129,0.2); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.float-right { float: right; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  transition: border-color .2s, box-shadow .2s;
}
.card-title {
  font-size: 11px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between;
}

/* ── Stats Grid ──────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 14px; }
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: border-color .2s, transform .2s var(--ease-out), box-shadow .2s;
}
.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.cpu  { background: rgba(99,102,241,0.12); color: var(--accent); }
.stat-icon.mem  { background: rgba(34,197,94,0.12);  color: var(--green); }
.stat-icon.disk { background: rgba(245,158,11,0.12); color: var(--yellow); }
.stat-icon.uptime { background: rgba(59,130,246,0.12); color: var(--blue); }
.stat-info { flex: 1; min-width: 0; }
.stat-label { font-size: 11px; color: var(--text3); margin-bottom: 4px; letter-spacing: .03em; }
.stat-value { font-size: 22px; font-weight: 700; margin-bottom: 8px; letter-spacing: -.5px; }
.stat-sub { font-size: 11px; color: var(--text3); }
.stat-bar { height: 3px; background: rgba(255,255,255,0.06); border-radius: 2px; overflow: hidden; }
.stat-bar-fill { height: 100%; border-radius: 2px; transition: width .9s cubic-bezier(.4,0,.2,1); }
.stat-bar-fill.cpu  { background: linear-gradient(90deg, var(--accent), #818cf8); }
.stat-bar-fill.mem  { background: linear-gradient(90deg, var(--green), #4ade80); }
.stat-bar-fill.disk { background: linear-gradient(90deg, var(--yellow), #fbbf24); }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.info-grid .card { overflow: hidden; }
.info-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.info-table tr { border-bottom: 1px solid var(--border); }
.info-table tr:last-child { border-bottom: none; }
.info-table td { padding: 8px 0; }
.info-table td:first-child { color: var(--text3); width: 100px; }
.info-table td:last-child { color: var(--text); }

/* ── Terminal ────────────────────────────────────────────────── */
.terminal-container {
  background: #080910; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; padding: 12px;
  height: calc(100vh - 140px);
}
#terminal { height: 100%; }

/* ── File Manager ────────────────────────────────────────────── */
.file-breadcrumb {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 14px;
  margin-bottom: 10px; font-size: 13px; color: var(--text2);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.breadcrumb-item { cursor: pointer; color: var(--accent); transition: opacity .15s; }
.breadcrumb-item:hover { opacity: .7; }
.breadcrumb-sep { color: var(--text3); }

.file-manager {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.file-list-header {
  display: grid; grid-template-columns: 30px 1fr 90px 150px 120px;
  padding: 8px 16px; border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .06em;
}
.file-item {
  display: grid; grid-template-columns: 30px 1fr 90px 150px 120px;
  padding: 9px 16px; align-items: center;
  border-bottom: 1px solid rgba(39,43,61,0.6);
  transition: background .12s; font-size: 13px; cursor: default;
}
.file-item:hover { background: var(--bg3); }
.file-item:last-child { border-bottom: none; }
.file-icon { display: flex; align-items: center; }
.file-icon svg { width: 16px; height: 16px; }
.file-name { cursor: pointer; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-name.dir { color: var(--accent); font-weight: 500; }
.file-name:hover { text-decoration: underline; }
.file-size { color: var(--text3); font-size: 12px; }
.file-date { color: var(--text3); font-size: 12px; }
.file-actions { display: flex; gap: 6px; justify-content: flex-end; }
.file-btn {
  background: none; border: none; cursor: pointer; color: var(--text3);
  padding: 3px; border-radius: 4px;
  transition: color .12s, background .12s, transform .12s;
}
.file-btn:hover { color: var(--text); background: var(--bg); transform: scale(1.15); }
.file-btn svg { width: 14px; height: 14px; }

/* ── Services ────────────────────────────────────────────────── */
.services-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.services-grid .loading { grid-column: 1 / -1; }
.service-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  transition: border-color .2s, transform .2s var(--ease-out), box-shadow .2s;
}
.service-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.service-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.service-name { font-weight: 600; font-size: 14px; }
.service-badge {
  padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 500;
  letter-spacing: .02em;
}
.badge-active  { background: rgba(34,197,94,0.12);  color: var(--green); }
.badge-inactive{ background: rgba(239,68,68,0.12);  color: var(--red); }
.badge-unknown { background: rgba(78,90,110,0.2);   color: var(--text3); }
.service-actions { display: flex; gap: 6px; }

/* ── VPN ──────────────────────────────────────────────────────── */
.vpn-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.vpn-user-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px;
  transition: opacity .15s;
}
.vpn-user-item:last-child { border-bottom: none; }
.vpn-user-uuid { font-family: var(--font-mono); color: var(--text3); font-size: 11px; }
.vpn-node-row {
  display: flex; justify-content: space-between; padding: 7px 0;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.vpn-node-row:last-child { border-bottom: none; }
.vpn-node-label { color: var(--text3); }
.vpn-node-val { font-family: var(--font-mono); font-size: 11px; word-break: break-all; max-width: 200px; text-align: right; }
.copy-btn {
  background: none; border: none; cursor: pointer; color: var(--text3);
  margin-left: 6px; transition: color .15s, transform .15s;
}
.copy-btn:hover { color: var(--accent); transform: scale(1.2); }

.code-editor {
  width: 100%; min-height: 280px; background: #080910;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; color: #a8d8a8; font-family: var(--font-mono);
  font-size: 12px; line-height: 1.6; resize: vertical; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.code-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ── RTunnel ─────────────────────────────────────────────────── */
.rtunnel-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
  margin-bottom: 10px;
  transition: border-color .2s, box-shadow .2s;
}
.rtunnel-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-sm); }
.rtunnel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.rtunnel-header-left { display: flex; align-items: center; gap: 10px; }
.rtunnel-name { font-weight: 600; font-size: 14px; }
.rtunnel-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: stretch;
  /* 三键等分同宽 */
  width: clamp(10.5rem, 32vw, 12.5rem);
}
.rtunnel-actions > .btn-sm {
  flex: 1 1 0;
  min-width: 0;
  justify-content: center;
  box-sizing: border-box;
}
.rtunnel-route {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 13px;
}
.rtunnel-local  { color: var(--accent); }
.rtunnel-arrow  { color: var(--text3); font-size: 16px; }
.rtunnel-remote { color: var(--green); }
.rtunnel-error {
  margin-top: 10px; font-size: 12px; color: var(--red);
  background: rgba(239,68,68,0.07); padding: 6px 10px;
  border-radius: var(--radius-sm); border-left: 2px solid var(--red);
}
.rtunnel-conflict {
  margin-top: 10px; font-size: 12px; color: var(--yellow);
  background: rgba(245,158,11,0.07); padding: 6px 10px;
  border-radius: var(--radius-sm); border-left: 2px solid var(--yellow);
}

/* ── 网络测试 ────────────────────────────────────────────────────── */
.net-combined-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.net-combined-grid {
  display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center;
}
.net-divider { width: 1px; background: var(--border); align-self: stretch; margin: 0 24px; }
.net-metric-item { display: flex; flex-direction: column; gap: 14px; }
.net-metric-head { display: flex; align-items: center; gap: 12px; }
.net-metric-icon {
  width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.net-metric-icon svg { width: 18px; height: 18px; }
.net-icon-ping { background: rgba(99,102,241,0.12); color: var(--accent); }
.net-icon-up   { background: rgba(34,197,94,0.12);  color: var(--green); }
.net-icon-down { background: rgba(59,130,246,0.12); color: var(--blue); }
.net-metric-name { font-size: 13px; font-weight: 600; color: var(--text); }
.net-metric-sub  { font-size: 11px; color: var(--text3); margin-top: 2px; }
.net-metric-val {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 26px; font-weight: 700; min-height: 32px; color: var(--text3);
}
.net-val-line { display: flex; align-items: baseline; gap: 4px; }
.net-val-line .unit { font-size: 13px; font-weight: 500; color: var(--text3); font-family: var(--font-mono); }
.net-val-tag  { font-size: 11px; color: var(--text3); margin-left: 4px; font-family: inherit; font-weight: 400; }
.net-metric-val .unit { font-size: 13px; font-weight: 500; color: var(--text3); }
.net-metric-val .sub  { font-size: 11px; font-weight: 400; color: var(--text3); margin-left: 2px; }
/* 常规测试表格 */
.net-table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.net-table thead th {
  padding: 0 16px 10px; font-size: 11px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border); text-align: right;
}
.net-th-label { text-align: left !important; width: 30%; }
.net-table tbody td { padding: 13px 16px; border-bottom: 1px solid rgba(39,43,61,0.5); vertical-align: middle; }
.net-table tbody tr:last-child td { border-bottom: none; }
.net-row-label { display: flex; align-items: center; gap: 12px; }
.net-row-name  { font-size: 13px; font-weight: 600; color: var(--text); }
.net-row-sub   { font-size: 11px; color: var(--text3); margin-top: 2px; }
.net-val-cell  { text-align: right; font-family: inherit; }
.net-num  { font-weight: 700; font-size: 20px; font-family: var(--font-mono); }
.net-unit { font-size: 11px; color: var(--text3); margin-left: 2px; font-family: var(--font-mono); }
/* 网络测试页面两栏布局 */
.net-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.net-nodes-body  { min-height: 52px; padding-top: 4px; }
.net-nodes-empty { color: var(--text3); font-size: 13px; padding: 8px 0; }
.net-nodes-grid  {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px;
}
.net-node-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg3); border-radius: var(--radius-sm); padding: 9px 13px;
  font-size: 12px; transition: background .15s;
}
.net-node-item:hover { background: #242840; }
.net-node-name { color: var(--text2); }
.net-node-ip   { font-family: var(--font-mono); font-size: 11px; color: var(--text3); margin-top: 1px; }
.net-node-ms        { font-weight: 700; font-size: 13px; font-family: var(--font-mono); }
/* 延迟档位：!important + -webkit-text-fill-color 避免被 body/card 继承色或 WebKit 覆盖成「发白」 */
#nodes-grid .net-node-ms.good,
.net-node-item .net-node-ms.good,
.net-node-ms.good {
  color: var(--green) !important;
  -webkit-text-fill-color: var(--green);
}
#nodes-grid .net-node-ms.ok,
.net-node-item .net-node-ms.ok,
.net-node-ms.ok {
  color: var(--yellow) !important;
  -webkit-text-fill-color: var(--yellow);
}
#nodes-grid .net-node-ms.bad,
.net-node-item .net-node-ms.bad,
.net-node-ms.bad {
  color: var(--red) !important;
  -webkit-text-fill-color: var(--red);
}
.net-node-ms.miss   { color: var(--text3);  font-family: inherit; font-weight: 500; -webkit-text-fill-color: var(--text3); }
.net-node-ms.idle   { color: var(--text3);  font-family: inherit; font-weight: 400; -webkit-text-fill-color: var(--text3); }
.net-node-ms.pending{ color: var(--text3);  font-family: inherit; font-weight: 400; animation: blink 1s step-end infinite; -webkit-text-fill-color: var(--text3); }
/* 独立展示页 / 静态列表上的延迟数字（与 .net-node-ms 档位一致） */
.lat-tier-good { color: var(--green) !important; -webkit-text-fill-color: var(--green); font-family: var(--font-mono); font-weight: 700; }
.lat-tier-ok   { color: var(--yellow) !important; -webkit-text-fill-color: var(--yellow); font-family: var(--font-mono); font-weight: 700; }
.lat-tier-bad  { color: var(--red) !important; -webkit-text-fill-color: var(--red); font-family: var(--font-mono); font-weight: 700; }
@keyframes blink { 50% { opacity: 0.3; } }
@media (max-width: 900px) {
  .net-combined-grid { grid-template-columns: 1fr; }
  .net-divider { width: auto; height: 1px; margin: 18px 0; }
  .net-layout { grid-template-columns: 1fr; }
}

/* ── Global Tunnel View ──────────────────────────────────────── */
.global-machine-block { margin-bottom: 18px; }
.global-machine-block:last-child { margin-bottom: 0; }
.global-machine-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.global-machine-name { font-weight: 600; font-size: 14px; }
.global-machine-time { font-size: 11px; color: var(--text3); }
.global-machine-section td { padding: 14px 10px 6px; border-bottom: none; vertical-align: top; }
.global-machine-section + tr td { border-top: 1px solid var(--border); }
.global-tunnel-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 13px; }
.global-tunnel-table thead tr { border-bottom: 1px solid var(--border); }
.global-tunnel-table th {
  text-align: left; padding: 6px 10px; font-size: 11px;
  color: var(--text3); text-transform: uppercase; letter-spacing: .06em; font-weight: 500;
}
.global-tunnel-table th:nth-child(1) { width: 10%; }   /* 状态 */
.global-tunnel-table th:nth-child(2) { width: 38%; }   /* 名称 */
.global-tunnel-table th:nth-child(3) { width: 13%; }   /* 本地端口 */
.global-tunnel-table th:nth-child(4) { width: 13%; }   /* 服务器端口 */
.global-tunnel-table th:nth-child(5) { width: 26%; }   /* 操作 */
.global-tunnel-table td { padding: 8px 10px; border-bottom: 1px solid rgba(39,43,61,0.5); }
.global-tunnel-table td:nth-child(2) { max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gt-port { font-family: var(--font-mono); font-size: 13px; }
.gt-port-local  { color: var(--accent); }
.gt-port-remote { color: var(--green); }
.global-tunnel-table tbody tr:last-child td { border-bottom: none; }
.global-tunnel-table tbody tr { transition: background .12s; }
.global-tunnel-table tbody tr:hover { background: var(--bg3); }
.global-machine-section td { padding: 12px 10px 6px; border-bottom: none; vertical-align: top; background: var(--bg2); }
.global-machine-section + tr td { border-top: 1px solid var(--border); }

/* ── Machine Name ─────────────────────────────────────────────── */
.machine-name-row {
  display: flex; align-items: center; gap: 4px;
  margin-top: 4px; font-size: 12px; color: var(--accent); font-weight: 500;
}

/* ── Checkbox 深色模式 ───────────────────────────────────────── */
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 13px; height: 13px; min-width: 13px; min-height: 13px;
  border-radius: 3px; border: 1.5px solid var(--border);
  background: var(--bg3); cursor: pointer; flex-shrink: 0;
  position: relative; transition: border-color .15s, background .15s, box-shadow .15s;
  box-sizing: border-box; vertical-align: middle;
}
input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
input[type="checkbox"]:checked::after {
  content: ''; position: absolute; left: 3px; top: 0px;
  width: 4px; height: 8px;
  border: 2px solid #fff; border-top: none; border-left: none;
  transform: rotate(45deg);
}
input[type="checkbox"]:hover { border-color: var(--accent); }

/* ── Modal ───────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; justify-content: center; align-items: flex-start;
  padding: clamp(24px, 5vh, 60px) 16px 32px;
  overflow-y: auto; z-index: 100;
  animation: modalBgIn .2s ease;
}
@keyframes modalBgIn { from { opacity: 0; } to { opacity: 1; } }
.modal.hidden { display: none !important; }
.modal-box {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; width: 440px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - clamp(56px, 10vh, 92px));
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04);
  flex-shrink: 0; margin: 0 auto;
  animation: modalIn .25s var(--ease-spring);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-box.large { width: 680px; max-width: calc(100vw - 32px); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; font-weight: 600; font-size: 15px;
}
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.btn-close {
  background: none; border: none; cursor: pointer; color: var(--text3);
  font-size: 20px; line-height: 1; padding: 2px 6px; border-radius: 4px;
  transition: color .15s, background .15s, transform .15s;
}
.btn-close:hover { color: var(--text); background: var(--bg3); transform: scale(1.1); }
.btn-close:active { transform: scale(.9); }

/* ── File Editor ─────────────────────────────────────────────── */
#file-editor-content {
  width: 100%; height: 400px; background: #080910;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; color: var(--text); font-family: var(--font-mono);
  font-size: 13px; line-height: 1.6; resize: none; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#file-editor-content:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed; top: 20px; left: 50%;
  transform: translateX(-50%) translateY(-80px) scale(.95);
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 22px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  z-index: 9999; opacity: 0; pointer-events: none;
  transition: transform .35s var(--ease-spring), opacity .2s ease;
  white-space: nowrap;
}
.toast:not(.hidden) {
  opacity: 1; pointer-events: auto;
  transform: translateX(-50%) translateY(0) scale(1);
}
.toast.success { border-color: rgba(34,197,94,0.4);  color: var(--green); background: rgba(34,197,94,0.07); }
.toast.error   { border-color: rgba(239,68,68,0.4);  color: var(--red);   background: rgba(239,68,68,0.07); }

/* 通用错误弹窗正文（可滚动、等宽） */
.panel-error-body {
  margin: 0;
  padding: 12px 14px;
  max-height: min(58vh, 520px);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ── Loading ─────────────────────────────────────────────────── */
.loading {
  color: var(--text3); padding: 32px; text-align: center; font-size: 13px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.loading::before {
  content: '';
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-hint {
  color: var(--text3); padding: 32px; text-align: center; font-size: 13px;
}

/* ── Misc ────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.error-msg { color: var(--red); font-size: 12px; margin-top: 8px; }

.qr-link-box {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
  word-break: break-all; font-family: var(--font-mono); font-size: 11px;
  color: var(--accent); margin-bottom: 10px; line-height: 1.5;
}
.info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text3); }
.info-val { font-family: var(--font-mono); font-size: 12px; }

/* ── 域名绑定表格 ──────────────────────────────────────────── */
.domain-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.domain-table th {
  text-align: left; padding: 8px 12px; color: var(--text3);
  font-weight: 500; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; border-bottom: 1px solid var(--border);
}
.domain-table td {
  padding: 10px 12px; border-bottom: 1px solid rgba(39,43,61,0.6);
  vertical-align: middle; transition: background .1s;
}
.domain-table tr:last-child td { border-bottom: none; }
.domain-table tbody tr:hover td { background: rgba(99,102,241,0.04); }
.domain-link {
  color: var(--accent); text-decoration: none; font-size: 12px;
  font-family: var(--font-mono); transition: opacity .15s;
}
.domain-link:hover { opacity: .7; }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .services-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 900px) {
  .info-grid, .vpn-layout { grid-template-columns: 1fr; }
}

/* ── 运维页 ─────────────────────────────────────────────────── */
.ops-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 1000px) {
  .ops-two-col { grid-template-columns: 1fr; }
}
.ops-pre {
  margin: 0;
  padding: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  line-height: 1.45;
  font-family: var(--font-mono);
  color: var(--text2);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 420px;
  overflow: auto;
}
.ops-pre-short { max-height: 280px; }
.ops-select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
}
.ops-filter-input {
  flex: 1;
  min-width: 120px;
  max-width: 280px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
}
.ops-backup-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.ops-backup-row:last-child { border-bottom: none; }
.ops-backup-name { font-family: var(--font-mono); font-size: 12px; }
.ops-backup-size { color: var(--text3); font-size: 12px; }

/* ── 多机中继页 ─────────────────────────────────────────────── */
.relay-flow-card .relay-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px 14px;
  margin-top: 8px;
}
.relay-flow-node {
  flex: 1 1 120px;
  min-width: 100px;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.relay-flow-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.relay-flow-ip { font-size: 13px; color: var(--text); font-weight: 500; word-break: break-all; }
.relay-flow-arrow {
  display: flex;
  align-items: center;
  color: var(--accent);
  font-size: 18px;
  font-weight: 600;
  padding: 0 2px;
}
.relay-hint {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.55;
  margin-bottom: 14px;
}
.relay-config-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}
.relay-status-panel { min-height: 48px; }
.relay-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.relay-status-col {
  padding: 14px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.relay-status-col h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}
.relay-status-col h4 small { font-weight: 400; color: var(--text3); margin-left: 8px; font-size: 12px; }
.relay-check-list { list-style: none; font-size: 12px; color: var(--text2); line-height: 1.7; }
.relay-check-list li { margin-bottom: 4px; }
.relay-detail { font-size: 11px; color: var(--text3); margin-top: 10px; line-height: 1.5; }
.relay-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
}
.relay-badge-ok { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.relay-badge-bad { background: rgba(239, 68, 68, 0.12); color: var(--red); }
.relay-status-error { color: var(--red); font-size: 13px; }
.relay-pair-ok { margin-top: 12px; font-size: 12px; color: var(--green); }
.relay-pair-warn { margin-top: 12px; font-size: 12px; color: var(--yellow); }
.relay-help-card .relay-help-list {
  margin: 8px 0 0 1.1em;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.65;
}
.relay-help-list li { margin-bottom: 6px; }

/* ── 移动端顶栏 / 抽屉导航（默认隐藏，见下方 @media）────────── */
.mobile-topbar {
  display: none;
}
.mobile-nav-backdrop {
  display: none;
}

/* ── 表格横向滚动（小屏不撑破布局）──────────────────────────── */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -2px;
  padding: 0 2px;
}
.table-scroll .domain-table {
  min-width: 520px;
}
.table-scroll .global-tunnel-table {
  min-width: 560px;
}

/* ── 手机 / 窄屏适配（抽屉侧栏 + 触控与安全区）──────────────── */
@media (max-width: 768px) {
  html { -webkit-text-size-adjust: 100%; }
  body {
    min-height: 100dvh;
    min-height: 100svh;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    min-height: 48px;
    padding: 8px 12px;
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
  }
  .mobile-menu-btn {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .mobile-menu-btn:active {
    transform: scale(0.96);
    background: var(--bg2);
  }
  .mobile-topbar-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.02em;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.26s ease;
  }
  .mobile-nav-backdrop.mobile-backdrop--visible {
    opacity: 1;
    pointer-events: auto;
  }

  #main-app {
    flex-direction: column;
    height: 100%;
    min-height: 100dvh;
    min-height: 100svh;
    max-height: 100dvh;
    max-height: 100svh;
    overflow: hidden;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(288px, 86vw);
    z-index: 210;
    padding-top: max(12px, env(safe-area-inset-top, 0px));
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    transform: translateX(-105%);
    transition: transform 0.3s var(--ease-out);
    box-shadow: none;
    border-right: 1px solid var(--border);
  }
  .sidebar.sidebar--open {
    transform: translateX(0);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.55);
  }

  .sidebar-brand {
    padding-top: 4px;
  }
  .nav-item {
    padding: 12px 12px;
    min-height: 44px;
    font-size: 14px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .nav-item svg {
    width: 18px;
    height: 18px;
  }
  .nav-item:hover {
    transform: none;
  }

  .sidebar-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  }
  .sidebar-footer .btn-icon {
    align-self: flex-end;
    min-width: 44px;
    min-height: 44px;
  }
  .server-select {
    font-size: 13px;
    padding: 10px 10px;
  }

  .main-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px max(12px, env(safe-area-inset-right, 0px)) max(14px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  }

  .page-header {
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
  }
  .page-header h2 {
    font-size: 17px;
  }
  .header-actions {
    flex-wrap: wrap;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .stat-card {
    padding: 14px;
  }
  .stat-value {
    font-size: 20px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .services-grid {
    grid-template-columns: 1fr;
  }

  .terminal-container {
    height: calc(100dvh - 52px - 120px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    min-height: 220px;
    max-height: 72dvh;
    padding: 10px;
  }

  .file-manager {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
  }
  .file-list-header,
  .file-item {
    min-width: 520px;
  }

  .toast {
    left: max(16px, env(safe-area-inset-left, 0px));
    right: max(16px, env(safe-area-inset-right, 0px));
    transform: translateY(-80px) scale(0.95);
    max-width: none;
    width: auto;
    white-space: normal;
    text-align: center;
    line-height: 1.45;
  }
  .toast:not(.hidden) {
    transform: translateY(0) scale(1);
  }

  .modal {
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
    align-items: flex-end;
  }
  .modal-box {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    margin-top: auto;
    max-height: min(92dvh, 100%);
  }
  .modal-box.large {
    width: 100%;
  }

  .login-gate {
    padding: max(20px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  }
  .login-gate__card {
    max-width: 100%;
  }

  .btn {
    min-height: 40px;
    touch-action: manipulation;
  }
  .btn-sm {
    min-height: 36px;
  }

  .relay-status-grid {
    grid-template-columns: 1fr;
  }
  .relay-flow-card .relay-flow {
    flex-direction: column;
  }
  .relay-flow-arrow {
    transform: rotate(90deg);
    align-self: center;
    padding: 4px 0;
  }

  body.mobile-sidebar-open {
    overflow: hidden;
    touch-action: none;
  }
}
