:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e5e7eb;
  --text: #1f2329;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --primary: #3b6ef6;
  --primary-hover: #2f5ce0;
  --primary-soft: #eef3ff;
  --success: #16a34a;
  --success-soft: #ecfdf3;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 8px 30px rgba(16, 24, 40, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Menlo", "Consolas", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }

.hidden { display: none !important; }
.muted { color: var(--text-3); font-size: 12px; }
.mono { font-family: var(--mono); }

/* ================= 通用组件 ================= */
.btn {
  font-family: var(--font); font-size: 13px; font-weight: 600;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  padding: 8px 16px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-outline { background: var(--surface); color: var(--primary); border-color: var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-danger-ghost { background: var(--surface); color: var(--danger); border-color: var(--border); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-mini { padding: 3px 10px; font-size: 12px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
.btn-mini:hover { background: var(--border); }
.btn-lg { padding: 12px 22px; font-size: 15px; width: 100%; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
}
.badge-muted { background: #f1f2f4; color: #6b7280; }
.badge-ok { background: var(--success-soft); color: var(--success); }
.badge-info { background: var(--primary-soft); color: var(--primary); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 700; }

input, select, textarea {
  font-family: var(--font); font-size: 14px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); outline: none;
  background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
label.field-label { font-size: 12px; color: var(--text-2); display: block; margin-bottom: 5px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-2); font-weight: 600; font-size: 12px; }
tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

.empty { text-align: center; padding: 34px 16px; color: var(--text-2); }
.empty.small { padding: 20px; }
.empty-icon { font-size: 34px; margin-bottom: 10px; }
.empty p { margin: 0; font-size: 13px; }

.error { color: var(--danger); font-size: 12px; margin-top: 8px; }

/* ================= Toast ================= */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #1f2329; color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 13px; box-shadow: var(--shadow-lg); z-index: 300; max-width: 80vw;
}
.toast.error { background: var(--danger); }

/* ================= 弹窗 ================= */
.modal-mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .5);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal {
  background: var(--surface); border-radius: var(--radius); padding: 26px;
  width: 440px; max-width: calc(100vw - 40px); box-shadow: var(--shadow-lg);
}
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal-desc { margin: 0 0 16px; font-size: 13px; color: var(--text-2); }
.modal-desc code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.modal input, .modal select { width: 100%; }
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.spacer { flex: 1; }

/* ================= 后台布局 ================= */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: #141824; color: #d1d5db;
  display: flex; flex-direction: column; padding: 20px 12px; gap: 4px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.sidebar-brand .logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #3b6ef6, #7c5cff);
  display: flex; align-items: center; justify-content: center; font-size: 18px; color: #fff;
}
.sidebar-brand b { color: #fff; font-size: 15px; }
.sidebar-brand span { font-size: 11px; color: #6b7280; display: block; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 9px; cursor: pointer;
  color: #cbd5e1; font-size: 14px; font-weight: 500; border: none; background: none; text-align: left; width: 100%;
  font-family: var(--font);
}
.nav-item:hover { background: rgba(255,255,255,.06); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .ic { width: 18px; text-align: center; }
.sidebar-foot { margin-top: auto; padding: 8px; font-size: 11px; color: #6b7280; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.main-topbar h1 { margin: 0; font-size: 17px; font-weight: 700; }
.main-topbar .right { display: flex; align-items: center; gap: 12px; }
.main-content { padding: 24px 28px 60px; display: flex; flex-direction: column; gap: 20px; }

/* ================= 概览统计 ================= */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px;
}
.stat-label { font-size: 12px; color: var(--text-2); }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat-sub { font-size: 11px; color: var(--text-3); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2, .stats-grid { grid-template-columns: 1fr; } }

/* ================= 表单 ================= */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row .help { font-size: 12px; color: var(--text-3); }

/* ================= 前台布局 ================= */
.client-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.client-topbar .brand { display: flex; align-items: center; gap: 12px; }
.client-topbar .logo {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, #3b6ef6, #7c5cff); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.client-topbar h1 { margin: 0; font-size: 16px; font-weight: 700; }
.client-topbar .sub { margin: 0; font-size: 11px; color: var(--text-3); }
.client-topbar .right { display: flex; align-items: center; gap: 12px; }
.container { max-width: 900px; margin: 0 auto; padding: 24px 20px 60px; display: flex; flex-direction: column; gap: 20px; }

/* 登录页 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 400px; max-width: 100%; }
.login-card .logo-lg {
  width: 56px; height: 56px; border-radius: 15px; margin: 0 auto 14px;
  background: linear-gradient(135deg, #3b6ef6, #7c5cff); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 28px;
}
.login-card h2 { text-align: center; margin: 0 0 4px; font-size: 20px; }
.login-card .login-sub { text-align: center; color: var(--text-2); margin: 0 0 22px; font-size: 13px; }

/* 取号 / 订单 */
.phone { font-size: 26px; font-weight: 700; letter-spacing: .01em; font-family: var(--mono); }
.order-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 28px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 12px; color: var(--text-2); }
.field-value { font-size: 15px; font-weight: 500; word-break: break-all; }
.field-value-row { display: flex; align-items: center; gap: 10px; }
.order-actions { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.hint { font-size: 12px; color: var(--text-3); }

.code-hero {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--primary-soft); border: 1px solid #d6e2ff;
  border-radius: var(--radius); padding: 22px 26px; gap: 16px; flex-wrap: wrap;
}
.code-hero .code { font-family: var(--mono); font-size: 40px; font-weight: 700; letter-spacing: .12em; color: var(--primary); }
.sms-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.sms-item { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.sms-item .sms-text { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.sms-item .sms-meta { font-size: 11px; color: var(--text-3); font-family: var(--mono); }

@media (max-width: 720px) {
  .order-fields { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
