:root {
  --bg: #eef3f2;
  --bg-accent: linear-gradient(135deg, rgba(15, 118, 110, 0.18), rgba(217, 119, 6, 0.12));
  --surface: #ffffff;
  --surface-muted: #f7faf9;
  --text: #10211d;
  --text-muted: #5d706b;
  --border: #d7e4de;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --secondary: #475569;
  --success: #15803d;
  --danger: #b42318;
  --warning: #b45309;
  --info: #2563eb;
  --shadow: 0 24px 60px rgba(16, 33, 29, 0.12);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(217, 119, 6, 0.14), transparent 30%),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.16), transparent 28%),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.page-shell {
  width: min(1320px, calc(100% - 32px));
  margin: 24px auto;
  padding: 32px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.page-title h1,
.page-title h2 {
  margin: 0;
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.1;
}

.page-title p {
  margin: 10px 0 0;
  color: var(--text-muted);
}

.action-row,
.toolbar,
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.nav-tabs {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(16, 33, 29, 0.06);
}

.nav-tab {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
}

.nav-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 20px rgba(16, 33, 29, 0.08);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(16, 33, 29, 0.12);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
}

.btn-secondary,
.btn-outline-secondary,
.btn-outline-primary,
.btn-outline-danger,
.btn-outline-light {
  background: rgba(255, 255, 255, 0.76);
  color: var(--secondary);
  border-color: var(--border);
}

.btn-success {
  background: #e8f7ec;
  color: var(--success);
  border-color: #cdeed6;
}

.btn-danger {
  background: #fff0ef;
  color: var(--danger);
  border-color: #ffd3cf;
}

.btn-warning {
  background: #fff5e6;
  color: var(--warning);
  border-color: #f7ddb0;
}

.btn-info {
  background: #ebf4ff;
  color: var(--info);
  border-color: #d3e3ff;
}

.btn-outline {
  background: rgba(255, 255, 255, 0.55);
  color: var(--text);
  border-color: rgba(16, 33, 29, 0.12);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 14px;
}

.btn-lg,
.btn-login {
  padding: 14px 20px;
  font-size: 16px;
}

.section-card,
.metric-card,
.chart-card,
.table-card,
.filter-card,
.highlight-card,
.card,
.login-card,
.jd-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 36px rgba(16, 33, 29, 0.06);
}

.section-card,
.table-card,
.filter-card,
.highlight-card {
  padding: 24px;
}

.metric-grid,
.chart-grid,
.form-grid {
  display: grid;
  gap: 16px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.chart-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card {
  padding: 22px;
}

.metric-card h3,
.metric-card p {
  margin: 0;
}

.metric-card p {
  color: var(--text-muted);
  font-size: 14px;
}

.metric-value {
  display: block;
  margin-top: 10px;
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
}

.highlight-card {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.92), rgba(217, 119, 6, 0.86));
  color: #fff;
}

.highlight-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.highlight-stat {
  padding: 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.14);
}

.highlight-stat small {
  display: block;
  opacity: 0.82;
}

.highlight-stat strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.card-header,
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.card-header {
  margin-bottom: 16px;
  padding: 0;
  background: transparent;
  border-bottom: 0;
  color: inherit;
}

.card-header h3,
.card-header h4,
.card-header h5,
.chart-card h3,
.chart-card h4 {
  margin: 0;
}

.card-body,
.modal-body {
  color: inherit;
}

.chart-card {
  padding: 22px;
}

.chart-card canvas {
  width: 100%;
  height: 260px;
  display: block;
}

.table-responsive,
.result-table,
.file-list,
.jd-content-full {
  width: 100%;
  overflow-x: auto;
}

.table,
.result-table table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
}

/* 表格列宽控制 - 使用class而非nth-child，更健壮 */
.col-id {
  width: 60px;
  text-align: center;
}

.col-position {
  min-width: 120px;
}

.col-uploader {
  min-width: 100px;
}

.col-actions {
  width: 160px;
  text-align: center;
  white-space: nowrap;
}

/* 操作按钮样式：增大触摸区域与间距 */
.col-actions .btn-sm {
  padding: 10px 14px;
  font-size: 14px;
  margin: 0 4px;
}

/* 自定义 SVG 图标 */
.icon-svg {
  width: 18px;
  height: 18px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Tooltip 纯CSS实现 */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  padding: 6px 10px;
  background: var(--text);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  transform: translateX(-50%) translateY(4px);
  z-index: 100;
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Sticky 操作列：横向滚动时固定在最右侧 */
.table-resume-stats th.col-actions,
.table-resume-stats td.col-actions,
.table-resume-admin th.col-actions,
.table-resume-admin td.col-actions {
  position: sticky;
  right: 0;
  background: var(--surface);
  z-index: 2;
  box-shadow: -4px 0 12px rgba(16, 33, 29, 0.06);
}

/* Sticky 表头：纵向滚动时固定在顶部 */
.table-resume-stats thead th,
.table-resume-admin thead th {
  position: sticky;
  top: 0;
  z-index: 3;
}

/* 操作列表头需要覆盖普通表头 */
.table-resume-stats thead th.col-actions,
.table-resume-admin thead th.col-actions {
  z-index: 4;
}

/* 行hover时sticky列背景统一 */
.table-resume-stats tbody tr:hover td.col-actions,
.table-resume-admin tbody tr:hover td.col-actions {
  background: rgba(15, 118, 110, 0.04);
}

.table th,
.table td,
.result-table th,
.result-table td {
  padding: 16px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.table thead th,
.result-table th {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(16, 33, 29, 0.03);
}

.table tbody tr:hover,
.result-table tbody tr:hover,
.result-table tr:hover {
  background: rgba(15, 118, 110, 0.04);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label,
.form-label {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 600;
}

.form-input,
.form-select,
.form-control,
.input-group > .form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  box-shadow: none;
}

.form-input:focus,
.form-select:focus,
.form-control:focus,
.input-group > .form-control:focus {
  outline: 2px solid rgba(37, 99, 235, 0.18);
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: none;
}

textarea.form-control,
textarea.form-input,
#jdContentTextarea,
#createJDContent,
#editJDContent {
  min-height: 160px;
}

.badge,
.badge-score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge-success,
.bg-success {
  background: #e9f9ef !important;
  color: var(--success) !important;
}

.badge-danger,
.bg-danger {
  background: #fff1f0 !important;
  color: var(--danger) !important;
}

.badge-secondary,
.bg-secondary {
  background: #eef2f6 !important;
  color: var(--secondary) !important;
}

.badge-info,
.bg-info {
  background: #eef5ff !important;
  color: var(--info) !important;
}

.bg-primary {
  background: #e8f6f5 !important;
  color: var(--primary) !important;
}

.alert-container {
  margin-bottom: 16px;
}

.alert {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.alert-success {
  background: #edf9f0;
  border-color: #caecd2;
  color: #126832;
}

.alert-danger {
  background: #fff1f0;
  border-color: #ffd5d0;
  color: #9f2a1b;
}

.alert-warning {
  background: #fff8e6;
  border-color: #fde5a9;
  color: #9a5a10;
}

.alert-info {
  background: #eef5ff;
  border-color: #d5e3ff;
  color: #1f57c3;
}

.pagination {
  justify-content: space-between;
  margin-top: 16px;
}

.page-meta {
  color: var(--text-muted);
  font-size: 14px;
}

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(15, 118, 110, 0.14);
  border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
  margin: 0 auto;
}

.spinner-border {
  color: var(--primary) !important;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.table-empty {
  padding: 28px 0;
  text-align: center;
  color: var(--text-muted);
}

.modal-backdrop {
  background: rgba(16, 33, 29, 0.48);
}

.modal-content,
.modal-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 32px 80px rgba(16, 33, 29, 0.28);
}

.modal-header,
.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 20px;
}

.modal-header {
  border-bottom: 1px solid var(--border);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid var(--border);
}

.btn-close,
.icon-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  box-shadow: none;
}

.hidden {
  display: none !important;
}

.inline-note,
.text-muted,
.form-text {
  color: var(--text-muted) !important;
}

.muted {
  color: var(--text-muted);
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-container {
  width: min(460px, 100%);
}

.login-card {
  padding: 32px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-header h1 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 32px;
}

.login-header p {
  margin: 0;
  color: var(--text-muted);
}

.btn-login {
  width: 100%;
}

.resume-page .main-container {
  width: min(1320px, calc(100% - 32px));
  margin: 24px auto;
  padding: 0;
}

.resume-page .main-container > .card {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.resume-page .main-container > .card > .card-header {
  margin: 0;
  padding: 32px;
  border-bottom: 1px solid var(--border);
}

.resume-page .main-container > .card > .card-body {
  padding: 32px !important;
}

.resume-page .text-white,
.resume-page .opacity-75 {
  color: inherit !important;
  opacity: 1 !important;
}

.resume-page .text-end {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.resume-page .text-end > div:first-child {
  flex-basis: 100%;
  margin-bottom: 0 !important;
}

.resume-page #statsBtn {
  order: 99;
}

.resume-page .upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  text-align: center;
  transition: all 0.2s ease;
  background: rgba(247, 250, 249, 0.9);
  cursor: pointer;
}

.resume-page .upload-area:hover,
.resume-page .upload-area.dragover {
  border-color: rgba(15, 118, 110, 0.4);
  background: #f1f7f5;
}

.resume-page .file-list {
  max-height: 300px;
}

.resume-page .file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin: 8px 0;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.resume-page .file-item.border-warning {
  background: #fff8e6;
  border-color: #f1ddb1;
}

.resume-page .file-item-actions {
  display: flex;
  gap: 8px;
}

.resume-page .result-container {
  margin-top: 32px;
}

.resume-page .result-container > .card,
.resume-page #historyList .card {
  background: var(--surface);
}

.resume-page .result-table table {
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.resume-page .result-table th {
  text-align: center;
}

.resume-page .result-table td {
  text-align: center;
  word-break: break-word;
}

.resume-page .result-table td:last-child,
.resume-page .reason-scroll-wrapper {
  text-align: left;
}

.resume-page .reason-scroll-wrapper {
  max-height: 120px;
  overflow-y: auto;
  padding-right: 4px;
  color: #374151;
  line-height: 1.6;
}

.resume-page .score-high {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #88d8b0;
}

.resume-page .score-medium {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f3d183;
}

.resume-page .score-low {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #f3b6b6;
}

.resume-page .status-completed {
  color: var(--success);
  font-weight: 600;
}

.jd-page {
  padding: 24px 0;
}

.jd-container {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
}

.jd-card {
  padding: 32px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.header-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.header-section h2 {
  margin: 0;
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.1;
}

.header-section p {
  margin: 10px 0 0;
}

.header-section > div:last-child,
.jd-page .d-flex.justify-content-between.align-items-center.mb-3 {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.jd-page .input-group {
  max-width: 420px;
}

.jd-page .table {
  min-width: 960px;
}

.jd-table td {
  vertical-align: middle;
}

.btn-action {
  margin: 0 2px;
}

.jd-content-preview {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
}

.jd-content-full {
  max-height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Courier New", monospace;
  font-size: 14px;
  background: var(--surface-muted);
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.aliases-badge {
  margin: 2px;
}

@media (max-width: 1080px) {
  .metric-grid,
  .chart-grid,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .page-shell,
  .resume-page .main-container,
  .jd-container,
  .login-container {
    width: calc(100% - 20px);
  }

  .page-shell,
  .jd-card,
  .resume-page .main-container > .card,
  .login-card {
    padding: 18px;
  }

  .resume-page .main-container > .card > .card-header,
  .resume-page .main-container > .card > .card-body {
    padding: 18px !important;
  }

  .page-header,
  .pagination,
  .header-section,
  .jd-page .d-flex.justify-content-between.align-items-center.mb-3 {
    flex-direction: column;
    align-items: stretch !important;
  }

  .metric-grid,
  .chart-grid,
  .form-grid,
  .highlight-grid {
    grid-template-columns: 1fr;
  }

  .action-row,
  .toolbar,
  .header-section > div:last-child {
    width: 100%;
  }

  .btn,
  .btn-login {
    width: 100%;
    justify-content: center;
  }

  .nav-tabs {
    width: 100%;
    justify-content: space-between;
  }

  .resume-page .upload-area {
    padding: 28px 18px;
  }

  .resume-page .text-end {
    width: 100%;
  }

  .resume-page .result-table,
  .resume-page .file-list {
    font-size: 14px;
  }

  .resume-page .result-table th,
  .resume-page .result-table td {
    padding: 10px 8px;
  }

  /* 简历表格移动端优化 */
  .table-resume-stats th,
  .table-resume-stats td,
  .table-resume-admin th,
  .table-resume-admin td {
    padding: 12px 8px;
  }

  .col-actions {
    width: 140px;
  }

  .col-actions .btn-sm {
    padding: 10px 12px;
    margin: 0 2px;
  }
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(16, 33, 29, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 32px 80px rgba(16, 33, 29, 0.28);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 24px;
  flex: 1;
  overflow: auto;
}

.filename-link {
  color: #0d9488 !important;
  text-decoration: underline !important;
  cursor: pointer;
  font-weight: 500;
}

.filename-link:hover {
  color: #0f766e !important;
  text-decoration: underline !important;
  opacity: 0.85;
}

.spinner-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}
