/* ==========================================================================
   域名转发控制台 — 设计系统
   色彩基调：稳重可靠的深蓝，呼应"路由 / 转发"的产品语义
   ========================================================================== */

/* @import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap'); */

:root {
  /* --- 色彩 --- */
  --ink-950: #0a1930;      /* 顶栏 / 最深文字 */
  --ink-800: #16345c;      /* 次级标题 */
  --blue-700: #1d4e89;     /* 品牌主色 / 主按钮 */
  --blue-600: #2563a6;     /* 主色悬停态 */
  --blue-500: #3b82c4;     /* 链接 / 强调 */
  --blue-100: #e8f0fa;     /* 浅色底 / 高亮行 */
  --paper-0: #f5f8fc;      /* 页面背景 */
  --paper-50: #ffffff;     /* 卡片 / 表面 */
  --slate-600: #52627a;    /* 次级文字 */
  --slate-400: #8a97ac;    /* 占位符 / 弱化文字 */
  --border: #dde5f0;
  --border-strong: #c3d1e3;
  --green-600: #1b7a4b;
  --green-50: #e7f5ec;
  --red-600: #c0362c;
  --red-50: #fbeae8;
  --amber-700: #9a5b10;
  --amber-50: #fbf1e0;

  /* --- 字体 --- */
  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  /* --- 圆角 / 阴影 / 间距节奏 --- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(10, 25, 48, 0.06);
  --shadow-md: 0 8px 24px rgba(10, 25, 48, 0.10);
  --shadow-lg: 0 16px 48px rgba(10, 25, 48, 0.16);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper-0);
  color: var(--ink-950);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--ink-950);
  margin: 0;
  letter-spacing: -0.01em;
}

a { color: var(--blue-600); }

button {
  font-family: inherit;
}

/* 可访问性：可见的键盘焦点环 */
:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ==========================================================================
   品牌标志：双节点 + 路由弧线，呼应"域名 → 转发目标"
   ========================================================================== */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  flex: none;
  display: block;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
}

/* 路由线：贯穿页面的签名分隔元素 */
.route-divider {
  height: 3px;
  width: 100%;
  background-image: repeating-linear-gradient(
    90deg,
    var(--blue-500) 0px,
    var(--blue-500) 6px,
    transparent 6px,
    transparent 14px
  );
  opacity: 0.55;
}

/* ==========================================================================
   登录页
   ========================================================================== */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--ink-950);
  padding: 24px;
}

/* 背景：低调的路由网格纹理 */
.login-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 18% 24%, rgba(59, 130, 196, 0.22), transparent 40%),
    radial-gradient(circle at 82% 76%, rgba(37, 99, 166, 0.20), transparent 42%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.035) 0px, rgba(255,255,255,0.035) 1px, transparent 1px, transparent 64px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0px, rgba(255,255,255,0.035) 1px, transparent 1px, transparent 64px);
  pointer-events: none;
}

.login-card-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.login-brand .brand-name {
  color: #fff;
  font-size: 20px;
}

.login-brand .brand-sub {
  color: rgba(232, 240, 250, 0.6);
  font-size: 13px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.login-card {
  background: var(--paper-50);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 30px 28px;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-800);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font-body);
  background: var(--paper-50);
  color: var(--ink-950);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.field input::placeholder { color: var(--slate-400); }

.field input:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 196, 0.16);
  outline: none;
}

.field input:disabled { background: var(--paper-0); color: var(--slate-400); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.15s var(--ease), transform 0.05s var(--ease), box-shadow 0.15s var(--ease);
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--blue-700);
  color: #fff;
}
.btn-primary:hover { background: var(--blue-600); }
.btn-primary:disabled {
  background: var(--slate-400);
  cursor: not-allowed;
  transform: none;
}

.btn-block { width: 100%; }

.btn-ghost {
  background: transparent;
  color: var(--ink-800);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover { background: var(--paper-0); border-color: var(--slate-400); }

.btn-danger-ghost {
  background: transparent;
  color: var(--red-600);
  border: 1px solid rgba(192, 54, 44, 0.35);
}
.btn-danger-ghost:hover { background: var(--red-50); }

.btn-danger {
  background: var(--red-600);
  color: #fff;
}
.btn-danger:hover { background: #a52d24; }

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--slate-600);
}
.btn-icon:hover { background: var(--paper-0); border-color: var(--border); color: var(--ink-950); }
.btn-icon.danger:hover { background: var(--red-50); color: var(--red-600); }
.btn-icon-label { display: none; }


.alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 18px;
}

.alert-error {
  background: var(--red-50);
  color: var(--red-600);
  border: 1px solid rgba(192, 54, 44, 0.18);
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 12px;
  color: rgba(232, 240, 250, 0.42);
  font-family: var(--font-mono);
}

/* ==========================================================================
   控制台外壳
   ========================================================================== */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--ink-950);
  color: #fff;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar .brand-mark circle,
.topbar .brand-mark path { stroke: #fff; }

.topbar .brand-name { color: #fff; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  font-family: var(--font-mono);
}

.user-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18);
}

.main {
  flex: 1;
  /* max-width: 1080px; */
  width: 100%;
  margin: 0 auto;
  padding: 32px 28px 64px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 21px;
}

.page-head .meta {
  font-size: 13px;
  color: var(--slate-600);
  margin-top: 4px;
  font-family: var(--font-mono);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 260px;
  max-width: 480px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 180px;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--slate-400);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--paper-50);
  color: var(--ink-950);
}

.search-group .btn {
  flex: none;
  padding: 9px 16px;
}

.search-box input:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 196, 0.14);
  outline: none;
}

/* ==========================================================================
   表格卡片
   ========================================================================== */

.card {
  background: var(--paper-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 16px;
  background: var(--paper-0);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s var(--ease); }
tbody tr:hover { background: var(--blue-100); }

.domain-cell {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-950);
  white-space: nowrap;
}

.punycode-cell {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--slate-600);
  white-space: nowrap;
}

.punycode-cell.muted {
  color: var(--slate-400);
}

.target-cell {
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--slate-600);
  display: inline-block;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill-hidden { background: var(--blue-100); color: var(--blue-700); }
.pill-visible { background: var(--amber-50); color: var(--amber-700); }

.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.time-cell {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--slate-600);
  white-space: nowrap;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

/* 空状态 */
.empty-state {
  padding: 64px 24px;
  text-align: center;
}

.empty-state svg { color: var(--slate-400); margin-bottom: 14px; }
.empty-state h3 { font-size: 16px; color: var(--ink-800); margin-bottom: 6px; }
.empty-state p { color: var(--slate-600); font-size: 13.5px; margin: 0 0 18px; }

/* 加载骨架 */
.skeleton-row td { padding: 13px 16px; border-bottom: 1px solid var(--border); }
.skeleton-bar {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--paper-0) 25%, var(--border) 37%, var(--paper-0) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* 分页 */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--slate-600);
}

.pagination .pager-btns { display: flex; gap: 6px; }

/* ==========================================================================
   弹层 / 模态
   ========================================================================== */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 48, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s var(--ease);
}

.overlay.open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--paper-50);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  padding: 26px 26px 22px;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.16s var(--ease);
}

.overlay.open .modal { transform: translateY(0) scale(1); }

.modal h2 {
  font-size: 17px;
  margin-bottom: 4px;
}

.modal .modal-sub {
  font-size: 13px;
  color: var(--slate-600);
  margin-bottom: 20px;
  font-family: var(--font-mono);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.radio-group {
  display: flex;
  gap: 10px;
}

.radio-card {
  flex: 1;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.radio-card:hover { border-color: var(--blue-500); }

.radio-card.active {
  border-color: var(--blue-600);
  background: var(--blue-100);
}

.radio-card input { display: none; }

.radio-card .rc-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-950);
  display: flex;
  align-items: center;
  gap: 7px;
}

.radio-card .rc-desc {
  font-size: 11.5px;
  color: var(--slate-600);
  margin-top: 3px;
  line-height: 1.4;
}

.field-hint {
  font-size: 12px;
  color: var(--slate-600);
  margin-top: 5px;
  line-height: 1.4;
}

.field-error {
  font-size: 12px;
  color: var(--red-600);
  margin-top: 5px;
}

.field input.invalid { border-color: var(--red-600); }
.field input.invalid:focus { box-shadow: 0 0 0 3px rgba(192, 54, 44, 0.14); }

/* ==========================================================================
   Toast 通知
   ========================================================================== */

.toast-stack {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--ink-950);
  color: #fff;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  min-width: 240px;
  max-width: 340px;
  animation: toast-in 0.18s var(--ease);
}

.toast.success { background: #14532d; }
.toast.error { background: #7f1d1d; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   响应式
   ========================================================================== */

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .main { padding: 22px 14px 48px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-group { max-width: none; }
  .search-box { min-width: 0; }
  .modal { padding: 22px 18px 18px; }

  /* --- 表格 → 卡片列表 --- */
  .table-wrap { overflow-x: visible; }

  table { min-width: 0; }

  thead { display: none; }

  tbody, tr, td { display: block; width: 100%; }

  tbody tr {
    border-bottom: 8px solid var(--paper-0); /* 卡片间距，复用背景色当分隔 */
    padding: 4px 0;
  }
  tbody tr:hover { background: transparent; }

  tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
  }

  tbody tr:last-child td:last-child { border-bottom: none; }

  tbody td::before {
    content: attr(data-label);
    flex: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--slate-600);
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  .domain-cell,
  .punycode-cell,
  .target-cell {
    text-align: right;
    max-width: 68%;
    white-space: normal;
    word-break: break-all;
  }

  .row-actions { width: 100%; justify-content: flex-end; gap: 8px; }

  /* 触控目标放大到至少 40px，同时显示文字标签，避免只有图标不好点/看不清 */
  .btn-icon {
    width: auto;
    height: 40px;
    padding: 0 14px;
    gap: 6px;
    border: 1px solid var(--border-strong);
  }
  .btn-icon-label { display: inline; font-size: 13px; font-weight: 600; }

  .pagination { flex-direction: column; gap: 10px; align-items: stretch; text-align: center; }
  .pagination .pager-btns { justify-content: center; }
  .pagination .pager-btns .btn { flex: 1; padding: 9px 0; }
}
