* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --danger: #dc2626;
}
body { font-family: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
.hidden { display: none !important; }

/* ---------- 登录页 ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.auth-card { background: #fff; border-radius: 16px; padding: 36px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.brand { text-align: center; margin-bottom: 24px; }
.brand-logo { width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff; font-size: 22px; font-weight: bold; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.brand h1 { font-size: 24px; }
.brand p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.tabs { display: flex; margin-bottom: 20px; border-bottom: 2px solid var(--border); }
.tab { flex: 1; padding: 10px; border: none; background: none; font-size: 15px; cursor: pointer; color: var(--muted); }
.tab.active { color: var(--primary); border-bottom: 2px solid var(--primary); font-weight: bold; margin-bottom: -2px; }
.auth-form label { display: block; font-size: 13px; margin: 12px 0 4px; color: var(--muted); }
.auth-form input, .modal-card input, .modal-card select, .form-row input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; }
.auth-form input:focus, .modal-card input:focus, .form-row input:focus { border-color: var(--primary); }
.auth-form .btn-primary { margin-top: 20px; width: 100%; }
.auth-note { text-align: center; font-size: 12px; color: var(--muted); margin-top: 16px; }
.msg { text-align: center; font-size: 13px; color: var(--danger); margin-top: 10px; min-height: 20px; }

/* ---------- 按钮 ---------- */
.btn-primary { background: var(--primary); color: #fff; border: none; padding: 10px 18px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); padding: 10px 18px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.btn-small { background: var(--primary); color: #fff; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.btn-danger { background: var(--danger); color: #fff; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; height: 100vh; top: 0; left: 0; z-index: 10; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px; font-weight: bold; font-size: 18px; border-bottom: 1px solid var(--border); }
.sidebar-brand .brand-logo { width: 36px; height: 36px; margin: 0; font-size: 14px; border-radius: 10px; }
.nav { flex: 1; padding: 12px; }
.nav-item { display: block; padding: 12px 14px; color: var(--text); text-decoration: none; border-radius: 8px; margin-bottom: 4px; font-size: 14px; }
.nav-item:hover, .nav-item.active { background: #eff6ff; color: var(--primary); }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.sidebar-footer .btn-ghost { width: 100%; }
.main { flex: 1; margin-left: 230px; width: calc(100% - 230px); }
.topbar { height: 60px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 12px; position: sticky; top: 0; z-index: 5; }
.menu-btn { display: none; background: none; border: none; font-size: 20px; cursor: pointer; }
.user-chip { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 14px; }
.balance-chip { background: #fef3c7; color: #92400e; padding: 4px 10px; border-radius: 20px; font-size: 12px; }
.content { padding: 24px; max-width: 1100px; margin: 0 auto; }
.page h2 { margin-bottom: 16px; font-size: 22px; }
.subtitle { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.page-head h2 { margin: 0; }

/* ---------- 卡片 / 统计 ---------- */
.card { background: var(--card); border-radius: 12px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.card h3 { font-size: 16px; margin-bottom: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat-card { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.stat-num { font-size: 26px; font-weight: bold; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }
.steps { margin-left: 20px; margin-bottom: 16px; color: var(--muted); font-size: 14px; }
.steps li { margin-bottom: 8px; }

/* ---------- 列表 ---------- */
.list-item { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.list-item:last-child { border-bottom: none; }
.item-info { flex: 1; min-width: 0; }
.item-title { font-weight: bold; font-size: 14px; }
.item-desc { color: var(--muted); font-size: 12px; word-break: break-all; }
.status-tag { font-size: 12px; padding: 2px 8px; border-radius: 12px; background: #dcfce7; color: var(--success); }
.status-tag.expired { background: #fee2e2; color: var(--danger); }
.item-actions { display: flex; gap: 6px; }

/* ---------- 套餐 ---------- */
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.plan-card { background: #fff; border: 2px solid var(--border); border-radius: 12px; padding: 20px; cursor: pointer; transition: .2s; text-align: center; }
.plan-card:hover, .plan-card.selected { border-color: var(--primary); background: #eff6ff; }
.plan-name { font-size: 16px; font-weight: bold; }
.plan-price { font-size: 28px; color: var(--primary); font-weight: bold; margin: 8px 0; }
.plan-desc { font-size: 12px; color: var(--muted); }
.form-row { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.form-row label { font-size: 14px; }
.form-row input { width: auto; flex: 1; min-width: 120px; }

/* ---------- 分销 ---------- */
.invite-box { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.invite-box code { background: #f1f5f9; padding: 8px 14px; border-radius: 8px; font-size: 18px; font-weight: bold; letter-spacing: 2px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 8px; }

/* ---------- 弹窗 / 提示 ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
.modal-card { background: #fff; border-radius: 12px; padding: 24px; width: 100%; max-width: 440px; }
.modal-card label { display: block; font-size: 13px; margin: 12px 0 4px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1e293b; color: #fff; padding: 12px 24px; border-radius: 8px; z-index: 30; font-size: 14px; }
.tutorial h3 { margin-top: 16px; color: var(--primary); }
.tutorial h3:first-child { margin-top: 0; }
.tutorial p { font-size: 14px; color: #334155; margin-bottom: 8px; }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; width: 100%; }
  .menu-btn { display: block; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-num { font-size: 21px; }
  .plans { grid-template-columns: 1fr; }
  .content { padding: 12px; }
  .list-item { flex-wrap: wrap; }
  .card { padding: 16px; }
  .page h2 { font-size: 19px; }
  .topbar { padding: 0 14px; }
  .user-chip { font-size: 12px; gap: 8px; }
  /* 手机端表单：纵向排列、字号 >=16px 避免 iOS 自动缩放、按钮足够大 */
  .form-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .form-row label { min-width: 0 !important; }
  .form-row input, .form-row select { width: 100%; }
  input, select, textarea, .btn-primary, .btn-ghost, .btn-danger, .btn-small { font-size: 16px; }
  .btn-primary, .btn-ghost, .btn-danger { padding: 12px 16px; }
  #relayStartBtn, #relayStopBtn { width: 100%; }
  .tutorial p { font-size: 13px; }
}
