:root {
  --color-primary: #3157d5;
  --color-primary-hover: #2547b5;
  --color-primary-soft: #edf1ff;
  --color-bg: #f4f6fa;
  --color-surface: #ffffff;
  --color-text: #172033;
  --color-muted: #667085;
  --color-border: #dfe4ec;
  --color-danger: #b42318;
  --color-danger-soft: #fef3f2;
  --color-success: #067647;
  --color-success-soft: #ecfdf3;
  --shadow-card: 0 8px 30px rgba(20, 35, 70, 0.07);
  --radius: 14px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--color-bg); color: var(--color-text); }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.65rem, 3vw, 2.15rem); letter-spacing: -0.03em; }
h2 { font-size: 1.12rem; }
small, .muted { color: var(--color-muted); }
code { padding: 3px 7px; border-radius: 6px; background: #eef1f6; word-break: break-all; }

.topbar { position: sticky; z-index: 10; top: 0; border-bottom: 1px solid var(--color-border); background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(12px); }
.topbar-inner { display: flex; max-width: 1240px; min-height: 72px; margin: 0 auto; padding: 12px 24px; align-items: center; gap: 30px; }
.brand { display: flex; flex: 0 0 auto; align-items: center; gap: 11px; color: var(--color-text); }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; width: 40px; height: 40px; border-radius: 11px; place-items: center; color: #fff; background: linear-gradient(145deg, #3157d5, #6381e8); font-size: 0.78rem; font-weight: 800; box-shadow: 0 6px 16px rgba(49, 87, 213, 0.24); }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; font-size: 0.72rem; }
.main-nav { display: flex; min-width: 0; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.main-nav a { padding: 8px 10px; border-radius: 8px; color: #475467; font-size: 0.88rem; white-space: nowrap; }
.main-nav a:hover { color: var(--color-primary); background: var(--color-primary-soft); text-decoration: none; }

.page { width: min(1180px, calc(100% - 40px)); margin: 38px auto 72px; }
.page-header { display: flex; margin-bottom: 24px; align-items: flex-start; justify-content: space-between; gap: 20px; }
.page-header p { margin-bottom: 0; color: var(--color-muted); }
.stack { display: grid; gap: 18px; }
.card { padding: 24px; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); box-shadow: var(--shadow-card); }
.card-header { display: flex; margin-bottom: 18px; align-items: center; justify-content: space-between; gap: 12px; }
.card-header h2 { margin: 0; }
.card > :last-child { margin-bottom: 0; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.metric { padding: 22px; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); }
.metric dt { color: var(--color-muted); font-size: 0.88rem; }
.metric dd { margin: 8px 0 0; font-size: 2rem; font-weight: 750; }

form { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field { display: grid; gap: 7px; color: #344054; font-size: 0.9rem; font-weight: 650; }
.field.full { grid-column: 1 / -1; }
input, textarea, select, button { font: inherit; }
input:not([type="checkbox"]), textarea, select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cfd6e1; border-radius: 9px; color: var(--color-text); background: #fff; outline: none; transition: border-color 0.15s, box-shadow 0.15s; }
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: #6f8bea; box-shadow: 0 0 0 3px rgba(49, 87, 213, 0.12); }
.check { display: flex; align-items: flex-start; gap: 9px; color: #344054; }
.check input { margin-top: 3px; accent-color: var(--color-primary); }
.actions { display: flex; margin-top: 20px; align-items: center; flex-wrap: wrap; gap: 10px; }
button, .button { display: inline-flex; min-height: 40px; padding: 9px 15px; border: 1px solid transparent; border-radius: 9px; align-items: center; justify-content: center; color: #fff; background: var(--color-primary); cursor: pointer; font-weight: 650; transition: background 0.15s, transform 0.15s; }
button:hover, .button:hover { background: var(--color-primary-hover); text-decoration: none; }
button:active, .button:active { transform: translateY(1px); }
.button-secondary { border-color: var(--color-border); color: #344054; background: #fff; }
.button-secondary:hover { background: #f7f8fa; }
.button-danger { background: var(--color-danger); }

.table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: 11px; }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 0.9rem; }
th, td { padding: 13px 15px; border-bottom: 1px solid #e8ebf0; text-align: left; vertical-align: top; }
th { color: #475467; background: #f8f9fb; font-size: 0.78rem; letter-spacing: 0.02em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbff; }
.badge { display: inline-flex; padding: 4px 9px; border-radius: 999px; color: #344054; background: #eef1f6; font-size: 0.76rem; font-weight: 700; }
.badge-success { color: var(--color-success); background: var(--color-success-soft); }
.badge-danger { color: var(--color-danger); background: var(--color-danger-soft); }
.notice { padding: 13px 15px; border: 1px solid #fecdca; border-radius: 9px; color: var(--color-danger); background: var(--color-danger-soft); }
.empty { padding: 30px; border: 1px dashed #cfd6e1; border-radius: 11px; color: var(--color-muted); text-align: center; }
.select-list { display: grid; margin: 0; padding: 0; gap: 9px; list-style: none; }
.select-list label, .display-row { display: flex; padding: 12px; border: 1px solid var(--color-border); border-radius: 9px; align-items: center; gap: 10px; }
.select-list label { cursor: pointer; }
.select-list label:hover { border-color: #9bb0f0; background: #fafbff; }
.preview-meta { display: grid; margin: -4px 0 18px; gap: 8px 18px; color: #475467; font-size: 0.9rem; line-height: 1.5; }
.preview-table { min-width: 820px; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
.candidate-table { min-width: 1080px; table-layout: fixed; }
.candidate-table th:nth-child(2) { width: 29%; }
.candidate-table th:nth-child(3) { width: 14%; }
.candidate-table th:nth-child(4), .candidate-table th:nth-child(5) { width: 10%; }
.candidate-table th:nth-child(6) { width: 9%; }
.candidate-table th:nth-child(7) { width: 14%; }
.candidate-table th:nth-child(8) { width: 18%; }
.candidate-select { width: 58px; text-align: center; }
.candidate-check { display: inline-flex; cursor: pointer; }
.candidate-check input { accent-color: var(--color-primary); }
.candidate-title, .candidate-review-note { line-height: 1.5; overflow-wrap: anywhere; }
.candidate-record-id { white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; color: #475467; }
.candidate-rules { max-width: 820px; line-height: 1.55; }
.import-context { display: grid; margin-bottom: 18px; padding: 14px 16px; gap: 6px; border-radius: 10px; background: var(--color-primary-soft); }
.import-issues { display: grid; gap: 10px; }
.import-issue { display: grid; grid-template-columns: 1fr 220px; align-items: center; gap: 16px; padding: 14px; border: 1px solid var(--color-border); border-radius: 10px; }
.issue-index { display: inline-flex; width: 22px; height: 22px; margin-right: 6px; border-radius: 50%; align-items: center; justify-content: center; color: #475467; background: #eef1f6; font-size: 0.75rem; font-weight: 700; }
.issue-summary { margin: 6px 0 3px 28px; color: #101828; font-weight: 650; }
.import-success { padding: 18px; border-radius: 10px; background: var(--color-success-soft); }
.import-results { display: grid; margin-top: 14px; gap: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.auth-shell { display: grid; min-height: 100vh; padding: 28px; place-items: center; background: radial-gradient(circle at 15% 20%, #e4eaff 0, transparent 34%), radial-gradient(circle at 85% 80%, #e9f8f3 0, transparent 30%), #f7f8fb; }
.auth-card { width: min(440px, 100%); padding: 34px; border: 1px solid rgba(208, 214, 225, 0.9); border-radius: 18px; background: rgba(255, 255, 255, 0.96); box-shadow: 0 22px 65px rgba(29, 46, 88, 0.13); }
.auth-brand { display: flex; margin-bottom: 28px; align-items: center; gap: 12px; }
.auth-card h1 { font-size: 1.65rem; }
.auth-card .field + .field { margin-top: 16px; }
.auth-card button { width: 100%; margin-top: 22px; }
.secret-box { padding: 16px; border-radius: 10px; background: var(--color-primary-soft); }
.secret-box p:last-child { margin-bottom: 0; }
.uri { color: var(--color-muted); font-size: 0.78rem; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .topbar-inner { display: block; padding: 12px 18px; }
  .main-nav { margin-top: 10px; padding-bottom: 2px; }
  .page { width: min(100% - 28px, 1180px); margin-top: 26px; }
  .metrics, .grid, .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
}

@media (max-width: 560px) {
  .auth-shell { padding: 16px; }
  .auth-card, .card { padding: 20px; }
  .page-header { display: block; }
  .page-header .actions { margin-top: 14px; }
}
