/* ============================================================
   私有 DNS 根 · 管理后台 设计系统 v5.0（现代极简 · 黑白灰）
   设计方向：留白 / 轻边框 / 纯黑白灰点缀 / 去装饰
   白侧边栏 + 浅灰画布 + 克制的炭黑，参考 Vercel / Linear 风格
   ============================================================ */

/* ---------- 设计令牌 ---------- */
:root {
  /* 品牌（炭黑白灰，仅用于关键操作与高亮） */
  --brand: #18181b;
  --brand-hover: #000000;
  --brand-active: #09090b;
  --brand-soft: #f5f5f5;
  --brand-soft-2: #e5e5e5;
  --accent: #3f3f46;

  /* 中性（极简：近黑文字 + 浅灰画布 + 轻边框） */
  --bg: #f7f8f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #eceef0;
  --border-strong: #d8dbdf;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #9ca3af;
  --on-dark: #e5e7eb;
  --on-dark-dim: #9ca3af;

  /* 语义（淡底 + 深字，≥4.5:1；仅状态反馈用色） */
  --success: #15803d;
  --success-soft: #f0fdf4;
  --success-border: #d1fae5;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --warning-border: #fde68a;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --info: #18181b;
  --info-soft: #fafafa;
  --info-border: #e4e4e7;

  /* 白侧边栏 */
  --sidebar-bg: #ffffff;
  --sidebar-bg-2: #ffffff;
  --sidebar-text: #6b7280;
  --sidebar-text-active: #18181b;
  --sidebar-border: #eceef0;

  /* 布局 */
  --sidebar-w: 236px;
  --topbar-h: 60px;
  --radius-s: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* 阴影（极淡，突出简洁） */
  --shadow-s: 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-lg: 0 8px 24px rgba(17, 24, 39, 0.08);

  /* 间距（4px 基准） */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* 排版 */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --lh: 1.6;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, monospace;

  /* 动效 */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 0.15s;
}

/* ---------- Reset / 基础 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}
.hidden { display: none !important; }
.muted { color: var(--text-3); }
.danger-text { color: var(--danger); }

/* 跳过链接 */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 9999;
  background: var(--brand); color: #fff; padding: 10px 16px;
  border-radius: 0 0 8px 0; font-size: var(--fs-sm);
}
.skip-link:focus { left: 0; }

/* ---------- 认证页（登录 / 注册） ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 400px at 85% -10%, rgba(255, 255, 255, 0.08), transparent 60%),
    linear-gradient(135deg, #0a0a0b 0%, #18181b 60%, #232326 140%);
  padding: var(--sp-6);
}
.auth-card {
  width: 100%;
  max-width: 408px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 48px rgba(6, 53, 47, 0.2);
  padding: 40px 34px;
}
.auth-brand { text-align: center; margin-bottom: var(--sp-6); }
.auth-brand .logo {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 24px; font-weight: 800; margin-bottom: 14px;
}
.auth-brand h1 { font-size: var(--fs-xl); color: var(--text); }
.auth-brand p { font-size: var(--fs-sm); color: var(--text-3); margin-top: var(--sp-1); }
.auth-switch { text-align: center; margin: var(--sp-5) 0 var(--sp-1); font-size: var(--fs-sm); }

/* ---------- 布局框架 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-border);
  position: fixed;
  top: 0; bottom: 0; left: 0;
  display: flex; flex-direction: column;
  z-index: 40;
  transition: transform var(--dur) var(--ease);
}
.sidebar .brand {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar .brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 14px;
}
.sidebar .brand span { color: var(--text); font-weight: 600; font-size: 15px; }
.sidebar nav { flex: 1; padding: var(--sp-3) var(--sp-3); overflow-y: auto; }
.sidebar .nav-group {
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.sidebar .nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: var(--fs-base);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  text-decoration: none;
}
.sidebar .nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar .nav-item:focus-visible { outline-color: var(--brand); }
.sidebar .nav-item.active,
.sidebar .nav-item[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--sidebar-text-active);
  font-weight: 600;
}
.sidebar .nav-item .icon { width: 18px; text-align: center; font-size: 14px; opacity: 0.85; display: flex; align-items: center; justify-content: center; }
.sidebar .nav-item .icon svg { display: block; }
.sidebar .sidebar-footer {
  padding: 14px var(--sp-5);
  border-top: 1px solid var(--sidebar-border);
  font-size: var(--fs-xs); color: var(--text-3);
  flex-shrink: 0;
}

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}
.topbar {
  height: var(--topbar-h);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3);
  padding: 0 var(--sp-6);
  position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.2px; }
.topbar .user-box { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-sm); color: var(--text-2); }
.topbar .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
}
.content { padding: var(--sp-6); flex: 1; }
.content:focus { outline: none; }

/* 移动端侧边栏抽屉 */
.menu-toggle {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  cursor: pointer; font-size: 17px; color: var(--text-2);
}
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(17, 24, 39, 0.45);
  z-index: 35;
}

/* ---------- 卡片（轻边框，无重阴影） ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
}
.card .card-title { font-size: var(--fs-md); font-weight: 600; margin-bottom: var(--sp-4); }
.card .card-title .desc { font-size: var(--fs-xs); color: var(--text-3); font-weight: 400; margin-left: var(--sp-2); }

/* ---------- 统计卡 ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-4); margin-bottom: var(--sp-4);
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  display: flex; flex-direction: column; gap: 4px;
}
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; line-height: 1.2; }
.stat-card .stat-label { font-size: var(--fs-sm); color: var(--text-3); }
.stat-card .stat-icon { font-size: 18px; color: var(--brand); margin-bottom: 2px; }

/* ---------- 表格（无斑马纹，细分隔） ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.data-table th {
  text-align: left;
  padding: 10px 12px;
  background: transparent;
  color: var(--text-3);
  font-weight: 600;
  font-size: var(--fs-xs);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.data-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table .empty { text-align: center; color: var(--text-3); padding: var(--sp-8) 0; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.6;
  border: 1px solid transparent;
}
.badge.active, .badge.enabled, .badge.online { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.badge.suspended, .badge.disabled, .badge.offline { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.badge.expired { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.badge.admin { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.badge.user { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }

/* ---------- 按钮（纯色，无渐变） ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  font-weight: 500;
  font-family: var(--font);
  line-height: 1.4;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    color var(--dur) var(--ease);
  white-space: nowrap;
  user-select: none;
}
.btn:hover { border-color: var(--text-3); background: var(--surface-2); }
.btn:active { background: var(--surface-2); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn:disabled {
  opacity: 0.45; cursor: not-allowed;
  background: var(--surface-2); color: var(--text-3); border-color: var(--border);
}
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn-primary:active { background: var(--brand-active); }
.btn-primary:disabled { background: var(--surface-2); border-color: var(--border); color: var(--text-3); }
.btn-danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.btn-success:hover { background: var(--success); border-color: var(--success); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: var(--fs-xs); }
.btn-lg { padding: 11px 22px; font-size: var(--fs-md); }
.btn-block { display: block; width: 100%; }

/* ---------- 表单 ---------- */
.form-group { margin-bottom: var(--sp-4); }
.form-group label {
  display: block; font-size: var(--fs-sm); font-weight: 500;
  color: var(--text-2); margin-bottom: 6px;
}
.form-group .hint { font-size: var(--fs-xs); color: var(--text-3); margin-top: var(--sp-1); }
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: var(--fs-base);
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.08);
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--surface-2); color: var(--text-3); cursor: not-allowed;
}
.input-error, .select-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.12) !important;
}
.textarea { min-height: 84px; resize: vertical; }
.form-row { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 160px; }
.form-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-4); }

/* 复选框 */
.row-check, #selectAll {
  width: 16px; height: 16px;
  accent-color: var(--brand);
  cursor: pointer;
}

/* ---------- 提示 ---------- */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  line-height: 1.6;
  margin: var(--sp-3) 0;
  border: 1px solid transparent;
}
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.alert-success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }

/* ---------- 对话框 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(17, 24, 39, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: var(--sp-4);
  animation: fadeIn var(--dur) var(--ease);
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 48px rgba(17, 24, 39, 0.16);
  padding: var(--sp-6);
  animation: slideUp var(--dur) var(--ease);
}
.modal .modal-title { font-size: var(--fs-lg); font-weight: 600; margin-bottom: var(--sp-4); }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-5); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: var(--sp-5); right: var(--sp-5); z-index: 200;
  padding: 11px 16px; border-radius: var(--radius);
  font-size: var(--fs-sm); font-weight: 500; color: #fff;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  animation: slideIn var(--dur) var(--ease);
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: #334155; }
.toast-leaving { opacity: 0; transition: opacity 0.3s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ---------- 三态：加载 / 空态 / 错误 ---------- */
.loading {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
  justify-content: center; padding: var(--sp-8) 0; color: var(--text-3);
  font-size: var(--fs-sm);
}
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--brand-soft-2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-2); padding: var(--sp-8) 0; color: var(--text-3); text-align: center;
  font-size: var(--fs-sm);
}
.empty-state .icon { font-size: 34px; opacity: 0.5; }
.empty-state .action { margin-top: var(--sp-3); }
.error-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-2); padding: var(--sp-8) 0; color: var(--danger); text-align: center;
}
.error-state .icon { font-size: 30px; }
.error-state .action { margin-top: var(--sp-3); }

/* ---------- 页面工具条 ---------- */
.page-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.page-toolbar .filters { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.page-toolbar .filters .input, .page-toolbar .filters .select { width: auto; min-width: 140px; }

/* ---------- 分页 ---------- */
.pagination {
  display: flex; gap: 4px; padding: var(--sp-4);
  justify-content: center; flex-wrap: wrap;
}
.page-btn {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--surface);
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-2);
  transition: all var(--dur) var(--ease);
}
.page-btn:hover { border-color: var(--brand); color: var(--brand); }
.page-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- 图表 ---------- */
.chart-wrap {
  display: flex; align-items: flex-end; gap: 4px;
  height: 180px; padding: var(--sp-4) var(--sp-2) var(--sp-2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.chart-bar-col {
  display: flex; flex-direction: column; align-items: center;
  flex: 1; min-width: 24px; height: 100%; justify-content: flex-end;
}
.chart-bar {
  width: 100%; max-width: 26px;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  background: var(--brand);
  transition: opacity var(--dur);
}
.chart-bar-col:hover .chart-bar { opacity: 0.8; }
.chart-label { font-size: 10px; color: var(--text-3); margin-top: 4px; white-space: nowrap; }

/* ---------- 代码块 / 指引 ---------- */
.code-block {
  background: #0b1e1b;
  color: #e5e7eb;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  overflow-x: auto;
  margin: var(--sp-3) 0;
}
.guide-step { display: flex; gap: 14px; margin: 14px 0; }
.guide-step .step-num {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--fs-sm); flex-shrink: 0;
}
.guide-step h4 { font-size: var(--fs-base); margin-bottom: 4px; }
.guide-step p { font-size: var(--fs-sm); color: var(--text-2); line-height: 1.7; }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .menu-toggle { display: inline-flex; }
  .sidebar { transform: translateX(-100%); box-shadow: none; border-right: 1px solid var(--border); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-backdrop.show { display: block; }
  .main { margin-left: 0; }
  .content { padding: var(--sp-4); }
  .topbar { padding: 0 var(--sp-4); }
  .topbar .user-box span:first-child { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
}
