:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(16, 24, 40, 0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* 顶部栏 */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner { display: flex; align-items: center; gap: 12px; height: 60px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.logo-badge {
  width: 32px; height: 32px; border-radius: 9px; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.topbar-spacer { flex: 1; }
.balance-chip {
  background: #eff6ff; color: var(--primary); border: 1px solid #dbeafe;
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.btn {
  border: none; border-radius: 10px; padding: 9px 16px; font-size: 14px;
  font-weight: 600; cursor: pointer; transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #f3f4f6; color: var(--text); }
.btn-ghost:hover { background: #e5e7eb; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 卡片通用 */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}

/* 筛选区 */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 20px 0 16px; }
.filter-bar select, .filter-bar input[type="text"] {
  height: 40px; border: 1px solid var(--border); border-radius: 10px; padding: 0 12px;
  font-size: 14px; background: #fff; min-width: 140px; width: 100%;
}
.filter-bar input[type="text"] { flex: 1; min-width: 180px; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  padding: 6px 14px; border-radius: 999px; font-size: 14px; background: #fff;
  border: 1px solid var(--border); cursor: pointer; color: var(--muted);
}
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 商品网格：自适应卡片栅格 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px; padding-bottom: 40px;
}
.product-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
  transition: transform .15s, box-shadow .15s;
}
.product-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16,24,40,.12); }
.card-head { display: flex; gap: 12px; align-items: center; }
.card-icon {
  width: 48px; height: 48px; border-radius: 12px; background: #f3f4f6;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  color: var(--muted); overflow: hidden; flex-shrink: 0;
}
.card-icon img { width: 100%; height: 100%; object-fit: cover; }
.card-title { font-weight: 700; font-size: 16px; }
.card-meta { font-size: 13px; color: var(--muted); }
.card-price { font-size: 16px; font-weight: 800; }
.card-price .unit { color: var(--muted); font-weight: 400; font-size: 12px; }
.stock-low { color: var(--red); }
.stock-ok { color: var(--green); }
.card-actions { margin-top: auto; display: flex; gap: 8px; }
.card-actions .btn { flex: 1; }

.empty { text-align: center; color: var(--muted); padding: 60px 0; grid-column: 1 / -1; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .45); display: none;
  align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 460px;
  padding: 22px; max-height: 85vh; overflow: auto;
}
.modal h3 { margin-bottom: 16px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.form-row select, .form-row input {
  width: 100%; height: 40px; border: 1px solid var(--border); border-radius: 10px;
  padding: 0 12px; font-size: 14px;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* 主区页面卡片（由功能 modal 渲染而来） */
.page-card {
  background: #fff; border-radius: 16px; padding: 22px; max-width: 720px;
  margin: 0 auto;
}
.page-card.wide { max-width: 960px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-head h3 { margin: 0; }

/* 下单表单双列 */
.buy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 560px) { .buy-grid { grid-template-columns: 1fr; } }

/* 面板 / 列表卡片 */
.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.panel-title { font-weight: 700; margin-bottom: 12px; }
.phone-item { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.phone-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.phone-number { font-weight: 700; font-size: 16px; }
.sms-list { margin-top: 10px; }
.sms-item { background: #f9fafb; border-left: 3px solid var(--primary); padding: 8px 10px; border-radius: 8px; margin-top: 8px; font-size: 13px; }
.sms-time { color: var(--muted); font-size: 12px; }
.sms-status { display: inline-block; background: #e8f5e9; color: #2e7d32; border-radius: 4px; padding: 1px 6px; font-size: 11px; margin-right: 6px; }
.sms-code { font-weight: 700; color: var(--primary); letter-spacing: 1px; }
.phone-item.is-expired { opacity: .6; }

/* 续费批量选择 */
.renew-list { margin-bottom: 16px; }
.renew-row { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; cursor: pointer; }
.renew-row.is-expired { opacity: .6; }
.renew-row input[type="checkbox"] { width: 18px; height: 18px; flex: none; }
.renew-row-main { flex: 1; min-width: 0; }
.renew-phone { font-weight: 700; font-size: 15px; }
.renew-price { font-weight: 700; color: var(--primary); white-space: nowrap; }
.renew-summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; background: #f9fafb; border-radius: 12px; margin-bottom: 16px; font-size: 14px; }
.renew-summary b { color: var(--primary); }
.phone-link { margin-top: 6px; font-size: 13px; color: var(--muted); word-break: break-all; }
.phone-link span { color: var(--text); }

/* 后台卡片网格：自适应屏幕宽度 */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.admin-order-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.admin-card { display: flex; flex-direction: column; gap: 10px; margin-bottom: 0; }
.admin-card-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.admin-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.price-edit-row { display: flex; gap: 12px; flex-wrap: wrap; }
.price-edit-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.price-edit-row input { width: 110px; height: 34px; border: 1px solid var(--border); border-radius: 8px; padding: 0 8px; font-size: 14px; }
.admin-note { width: 100%; height: 34px; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; font-size: 14px; }
.admin-user-bal { display: flex; gap: 24px; flex-wrap: wrap; }
.recharge-addr { margin-top: 4px; padding: 10px 12px; background: #f9fafb; border: 1px dashed var(--border); border-radius: 8px; font-size: 13px; word-break: break-all; }
.recharge-qr { margin-top: 16px; padding: 18px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; }
.recharge-qr canvas, .recharge-qr img, .recharge-qr svg { display: block; }
@media (max-width: 640px) {
  .card-grid { grid-template-columns: 1fr; }
  .phone-top { flex-direction: column; align-items: flex-start !important; gap: 10px; }
  .admin-order-actions { width: 100%; }
}

.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat .num { font-size: 24px; font-weight: 800; }
.stat .label { color: var(--muted); font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; z-index: 100; display: none; max-width: 90vw;
}
.toast.show { display: block; }

/* 汉堡按钮 */
.icon-btn {
  width: 38px; height: 38px; border: none; background: #f3f4f6; border-radius: 10px;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; cursor: pointer;
}
.icon-btn span { width: 18px; height: 2px; background: var(--text); border-radius: 2px; }

/* 抽屉 */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(17,24,39,.4); z-index: 40; display: none;
}
.drawer-mask.show { display: block; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 80vw;
  background: #fff; z-index: 50; transform: translateX(-100%); transition: transform .25s ease;
  display: flex; flex-direction: column; box-shadow: 4px 0 20px rgba(16,24,40,.15);
}
.drawer.show { transform: translateX(0); }
.drawer-head { padding: 20px 18px; border-bottom: 1px solid var(--border); }
.drawer-user { display: flex; gap: 12px; align-items: center; }
.drawer-avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.drawer-username { font-weight: 700; }
.drawer-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.drawer-group { padding: 14px 18px 6px; font-size: 12px; color: var(--muted); }
.drawer-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px; font-size: 15px; cursor: pointer; color: var(--text);
}
.drawer-item svg { width: 18px; height: 18px; flex: none; }
.drawer-item:hover { background: #f3f4f6; }
.drawer-foot { padding: 14px 18px; border-top: 1px solid var(--border); }

/* 登录/注册 居中卡片 */
.auth-wrap { min-height: calc(100vh - 60px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-tabs { display: flex; margin-bottom: 18px; background: #f3f4f6; border-radius: 10px; padding: 4px; }
.auth-tabs .tab { flex: 1; text-align: center; border: none; background: transparent; }
.auth-tabs .tab.active { background: #fff; color: var(--primary); }

/* 响应式：手机窄屏 */
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .filter-bar select, .filter-bar input[type="text"] { min-width: 100%; }
  .topbar-inner { height: 54px; }
  .btn { padding: 8px 12px; }
}
