/* ============================================================
   短信白名单控制台 · 设计系统 v2
   tokens → components → views → responsive
   ============================================================ */

/* ---------- 1. Design tokens ---------- */
:root {
  /* 品牌色 */
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-grad: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);

  /* 语义色 */
  --green: #16a34a;   --green-bg: #dcfce7;
  --red: #dc2626;     --red-bg: #fee2e2;
  --orange: #ea580c;  --orange-bg: #ffedd5;
  --purple: #7c3aed;  --purple-bg: #ede9fe;
  --gray: #6b7280;    --gray-bg: #f3f4f6;

  /* 中性色（slate） */
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --hover: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;

  /* 层次阴影 */
  --shadow-xs: 0 1px 2px rgba(15,23,42,.05);
  --shadow-sm: 0 1px 3px rgba(15,23,42,.07), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 10px -2px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg: 0 12px 32px -8px rgba(15,23,42,.16), 0 4px 10px -6px rgba(15,23,42,.08);
  --shadow: var(--shadow-sm);
  --shadow-lg-2: var(--shadow-lg);

  /* 圆角 / 动效 / 焦点圈 */
  --radius-sm: 7px;
  --radius: 12px;
  --radius-lg: 16px;
  --t-fast: .15s ease;
  --t: .22s cubic-bezier(.33,1,.68,1);
  --ring: 0 0 0 3px rgba(37,99,235,.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scrollbar-gutter: stable; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}

::selection { background: rgba(37,99,235,.22); }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px;
  border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
*::-webkit-scrollbar-track { background: transparent; }

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* 键盘焦点圈（鼠标点击不干扰） */
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
.captcha-refresh:focus-visible, .captcha-img:focus-visible { outline: none; box-shadow: var(--ring); }
.tab:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- 2. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  padding: 8px 15px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500;
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast),
              box-shadow var(--t-fast), transform var(--t-fast);
}
/* flex 子项禁止压缩到 0 宽（防文字竖排） */
.row .btn, .toolbar > .btn { flex: 0 0 auto; }
.checklbl { white-space: nowrap; }
.btn:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }
.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--primary-grad); border-color: transparent; color: #fff;
  box-shadow: 0 1px 2px rgba(37,99,235,.4), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn-primary:hover { background: var(--primary-600); color: #fff; transform: translateY(-1px);
  box-shadow: 0 4px 12px -2px rgba(37,99,235,.45); }
.btn-primary:active { transform: translateY(0) scale(.98); }

.btn-danger { background: var(--surface); border-color: #fecaca; color: var(--red); }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.btn-danger:active { transform: scale(.98); }

.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- 3. Forms ---------- */
input, select, textarea {
  font-family: inherit; font-size: 13.5px; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px;
  background: var(--surface); outline: none; width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
select { appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; cursor: pointer; }
label { font-size: 12.5px; color: var(--text-2); font-weight: 600; letter-spacing: .2px;
  display: block; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

/* ---------- 4. Topbar ---------- */
.topbar {
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  height: 56px; display: flex; align-items: center; padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700;
  font-size: 15.5px; letter-spacing: .2px; }
.topbar .brand .logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: 0 2px 6px rgba(37,99,235,.35);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 16px;
}
.topbar .spacer { flex: 1; }
.topbar .user { display: flex; align-items: center; gap: 14px; color: var(--text-2); font-size: 13.5px; }
.avatar { width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600;
  box-shadow: 0 1px 3px rgba(37,99,235,.4); }

/* ---------- 5. Tabs（下划线导航，无全宽背景） ---------- */
.tabs {
  display: flex; gap: 4px; align-items: stretch;
  padding: 0 24px; width: 100%; max-width: 100%;
  background: transparent;
  border-bottom: 1px solid var(--border);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  padding: 13px 14px 11px; border: none; cursor: pointer; background: transparent;
  color: var(--text-2); font-weight: 500; font-size: 14px; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  transition: color var(--t-fast), background var(--t-fast);
}
.tab::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 3px;
  border-radius: 3px 3px 0 0; background: var(--primary);
  transform: scaleX(0); transform-origin: center; transition: transform .2s var(--t);
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); font-weight: 600; }
.tab.active::after { transform: scaleX(1); }

/* ---------- 6. Layout ---------- */
.container { padding: 20px 24px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 22px; margin-bottom: 20px;
}
.card h3 { margin: 0 0 16px; font-size: 15.5px; font-weight: 700; letter-spacing: .2px;
  padding-left: 10px; border-left: 3px solid var(--primary); line-height: 1.2; }
.card .sub { color: var(--text-2); font-size: 13px; margin-top: -8px; margin-bottom: 16px; }

/* ---------- 7. Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 18px 16px; box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t), transform var(--t);
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; opacity: .85; }
.stat:nth-child(1)::before { background: var(--primary); }
.stat:nth-child(2)::before { background: var(--green); }
.stat:nth-child(3)::before { background: var(--orange); }
.stat:nth-child(4)::before { background: var(--red); }
.stat:nth-child(5)::before { background: var(--gray); }
.stat:nth-child(6)::before { background: var(--purple); }
.stat .num { font-size: 30px; font-weight: 750; line-height: 1.15;
  font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.stat .lbl { color: var(--text-2); font-size: 13px; margin-top: 6px; display: flex; align-items: center; }
.stat .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; flex: none; }

/* ---------- 8. Table ---------- */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-2); font-weight: 600; font-size: 12px; text-transform: uppercase;
  letter-spacing: .5px; background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: var(--hover); }
tbody tr:last-child td { border-bottom: none; }
td { font-variant-numeric: tabular-nums; }
td .muted { color: var(--text-3); font-size: 12.5px; }

/* ---------- 9. Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .2px; }
.badge .d { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.b-success { background: var(--green-bg); color: var(--green); }
.b-rejected { background: var(--orange-bg); color: var(--orange); }
.b-seckey { background: var(--gray-bg); color: var(--gray); }
.b-failed { background: var(--red-bg); color: var(--red); }
.b-error { background: var(--purple-bg); color: var(--purple); }

/* ---------- 10. Toggle ---------- */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: .2s; cursor: pointer; }
.slider:before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(18px); }
.switch input:focus-visible + .slider { box-shadow: var(--ring); }

/* ---------- 11. Toolbar / Pagination ---------- */
.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .field { margin-bottom: 0; }
.toolbar .grow { flex: 1; min-width: 160px; }
.pager { display: flex; align-items: center; gap: 12px; margin-top: 16px; justify-content: flex-end;
  color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.pager button { min-width: 32px; height: 32px; padding: 0 10px; }

/* ---------- 12. Toast ---------- */
.toast-wrap { position: fixed; top: 70px; right: 24px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 12px 16px; min-width: 240px;
  display: flex; align-items: center; gap: 10px; animation: slideIn .25s cubic-bezier(.21,1.02,.55,1);
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast .ic { font-size: 16px; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 13. Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(900px 480px at 15% -10%, rgba(59,130,246,.16) 0%, transparent 60%),
    radial-gradient(800px 500px at 110% 110%, rgba(96,165,250,.14) 0%, transparent 55%),
    var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 34px 32px; }
.login-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px;
  font-weight: 700; font-size: 18px; letter-spacing: .3px; }
.login-card .logo { width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: 0 4px 12px rgba(37,99,235,.4);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 20px; }
.login-card .muted { color: var(--text-2); font-size: 13px; margin-bottom: 22px; }
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row input { flex: 1; }
.captcha-img { border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); height: 42px; width: 120px;
  cursor: pointer; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.captcha-img:hover { border-color: var(--primary); box-shadow: var(--ring); }
.captcha-img img { width: 100%; height: 100%; object-fit: cover; }
.captcha-refresh { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm);
  width: 42px; height: 42px; font-size: 17px; color: var(--text-2);
  transition: color var(--t-fast), border-color var(--t-fast), transform var(--t-fast); }
.captcha-refresh:hover { color: var(--primary); border-color: var(--primary); transform: rotate(90deg); }
.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px;
  display: none; border: 1px solid transparent; }
.alert.err { display: block; background: var(--red-bg); color: var(--red); border-color: #fecaca; }
.alert.warn { display: block; background: var(--orange-bg); color: var(--orange); border-color: #fed7aa; }
.hint { color: var(--text-3); font-size: 12px; margin-top: 14px; text-align: center; }

/* ---------- 14. Misc ---------- */
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.mt0 { margin-top: 0; }
.text-right { text-align: right; }
.empty { text-align: center; color: var(--text-3); padding: 44px 0; font-size: 13px; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { text-align: center; padding: 30px; color: var(--text-2); }
.loading-row .spin { margin: 0 auto 10px; }
.kv { color: var(--text-3); font-size: 12px; }
code.inline { background: var(--gray-bg); border: 1px solid var(--border); padding: 2px 7px;
  border-radius: 5px; font-size: 12.5px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* ---------- 15. Modal ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 999; animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { width: min(640px, 94vw); max-height: 90vh; overflow: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 22px 24px; animation: popIn .2s cubic-bezier(.21,1.02,.55,1); }
@keyframes popIn { from { transform: translateY(10px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h3 { margin-top: 0; border-left: none; padding-left: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.checklbl { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; }

/* ---------- 16. 移动端适配 ---------- */
@media (max-width: 768px) {
  body { font-size: 13.5px; }
  input, select, textarea { font-size: 16px; }   /* 防 iOS 聚焦自动放大 */
  .btn { min-height: 38px; }

  .topbar { height: 50px; padding: 0 12px; }
  .topbar .brand { font-size: 13.5px; gap: 7px; }
  .topbar .brand .logo { width: 26px; height: 26px; font-size: 14px; }
  .topbar .user { gap: 7px; font-size: 12px; }
  .topbar .user #userLabel { display: none; }
  .avatar { width: 26px; height: 26px; font-size: 12px; }
  .topbar .btn-sm { padding: 5px 8px; font-size: 12px; }

  /* 标签栏横向滑动 */
  .tabs { padding: 0 12px; border-bottom-width: 1px; }
  .tab { flex: 0 0 auto; padding: 11px 12px 9px; font-size: 13px; }
  .tab::after { left: 12px; right: 12px; }

  .container { padding: 12px; }
  .card { padding: 14px 12px; border-radius: 10px; margin-bottom: 14px; }
  .card h3 { font-size: 14.5px; }
  .card .sub, .muted { font-size: 12.5px; }

  /* 表单行：纵向堆叠，控件占满 */
  .row { flex-direction: column; gap: 0; }
  .row > * { flex: 1 1 auto !important; align-self: stretch !important; }
  .row .field { margin-bottom: 12px; }
  .row .btn { width: 100%; justify-content: center; padding: 11px 14px; }
  .row select[style], .row input[type="date"][style], .row input[type="number"][style] { width: 100% !important; }
  .row .checklbl { font-size: 14px; }

  /* 工具栏：搜索框独占一行，其余自动换行 */
  .toolbar { gap: 8px; }
  .toolbar .grow { flex: 1 1 100%; }
  .toolbar .field { flex: 1 1 auto; min-width: 110px; }

  /* 概览统计两列 */
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 14px 14px 12px; }
  .stat .num { font-size: 22px; }
  .stat .lbl { font-size: 12px; }

  /* 表格横向滚动 */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table { min-width: 640px; }
  th, td { padding: 8px 10px; }

  /* 弹窗近全屏 */
  .modal { width: 96vw; max-height: 92vh; padding: 16px; }
  .modal-actions .btn { flex: 1; justify-content: center; }

  .login-wrap { padding: 14px; align-items: flex-start; padding-top: 12vh; }
  .login-card { padding: 26px 20px; }

  .toast-wrap { left: 12px; right: 12px; top: 58px; }
  .toast { min-width: 0; }

  .pager { flex-wrap: wrap; justify-content: center; gap: 8px; }
}
@media (max-width: 380px) {
  .topbar .user .btn { padding: 6px 8px; font-size: 12px; }
}

/* ---------- 17. 减弱动效偏好（无障碍） ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}
