/* ========== Reset & Variables ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #1e293b;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --transition: 0.2s ease;
}

html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ========== Login ========== */
.login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #1e293b 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 48px 40px;
  width: 420px; max-width: 90vw; box-shadow: 0 25px 50px rgba(0,0,0,.25);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-icon { font-size: 48px; margin-bottom: 12px; }
.login-header h2 { font-size: 22px; color: var(--text); margin-bottom: 6px; }
.login-header p { color: var(--text-secondary); font-size: 14px; }
.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.login-form input {
  width: 100%; padding: 12px 16px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); font-size: 15px; transition: var(--transition);
}
.login-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.login-error { background: #fef2f2; color: var(--danger); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }
.login-hint { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.login-hint p { font-size: 12px; color: var(--text-light); line-height: 1.8; }

/* ========== App Layout ========== */
.app-container { display: flex; height: 100vh; overflow: hidden; }

/* ========== Sidebar ========== */
.sidebar {
  width: 240px; min-width: 240px;
  background: var(--bg-sidebar); color: #e2e8f0;
  display: flex; flex-direction: column;
  padding: 0; z-index: 100;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 24px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-icon { font-size: 28px; }
.brand-text { font-size: 18px; font-weight: 700; color: #fff; letter-spacing: -0.5px; }
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; margin-bottom: 2px;
  border-radius: var(--radius-sm); color: #94a3b8;
  text-decoration: none; font-size: 14px; font-weight: 500;
  transition: var(--transition); cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.sidebar-footer {
  padding: 16px 14px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: space-between;
}
.user-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.user-avatar { font-size: 24px; }
.user-name { font-size: 13px; font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: #94a3b8; }

/* ========== Main Content ========== */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; background: var(--bg-card); border-bottom: 1px solid var(--border);
  min-height: 64px;
}
.page-title { font-size: 20px; font-weight: 700; color: var(--text); }
.current-time { font-size: 13px; color: var(--text-secondary); }
.page-content { flex: 1; overflow-y: auto; padding: 24px 28px; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: var(--transition); text-decoration: none;
  line-height: 1.4; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--border-light); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== Stats Cards ========== */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 20px 24px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
}
.stat-card .stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.stat-card .stat-icon.blue { background: #eff6ff; }
.stat-card .stat-icon.green { background: #ecfdf5; }
.stat-card .stat-icon.orange { background: #fffbeb; }
.stat-card .stat-icon.purple { background: #f5f3ff; }
.stat-card .stat-icon.red { background: #fef2f2; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ========== Cards ========== */
.card {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* ========== Tables ========== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  background: var(--border-light); padding: 12px 14px;
  text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase;
  color: var(--text-secondary); letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.sortable-th { cursor: pointer; user-select: none; }
.sortable-th:hover { color: var(--primary); background: #e8ecf4; }
.sortable-th .sort-arrow { font-size: 11px; margin-left: 4px; }
tbody td {
  padding: 12px 14px; border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
tbody tr:hover { background: #f8fafc; }
tbody tr.clickable { cursor: pointer; }

/* ========== Status Badges ========== */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-blue { background: #eff6ff; color: #2563eb; }
.badge-green { background: #ecfdf5; color: #059669; }
.badge-yellow { background: #fffbeb; color: #d97706; }
.badge-purple { background: #f5f3ff; color: #7c3aed; }
.badge-red { background: #fef2f2; color: #dc2626; }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-orange { background: #fff7ed; color: #ea580c; }
.badge-teal { background: #f0fdfa; color: #0d9488; }

.status-applied { background: #eff6ff; color: #3b82f6; }
.status-screening { background: #fffbeb; color: #f59e0b; }
.status-interview { background: #f5f3ff; color: #8b5cf6; }
.status-offer { background: #fdf2f8; color: #ec4899; }
.status-hired { background: #ecfdf5; color: #10b981; }
.status-rejected { background: #fef2f2; color: #ef4444; }
.status-archived { background: #f1f5f9; color: #64748b; }

/* ========== Forms ========== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
  transition: var(--transition); background: var(--bg-card);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ========== Filters ========== */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px; padding: 14px 18px; background: var(--bg-card);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.filter-bar input, .filter-bar select {
  padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; background: var(--bg);
}
.filter-bar input:focus, .filter-bar select:focus {
  outline: none; border-color: var(--primary);
}
.filter-bar input { min-width: 200px; }

/* ========== Charts Grid ========== */
.charts-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 20px; margin-bottom: 24px;
}
.chart-container { position: relative; height: 300px; }
.chart-container canvas { width: 100% !important; height: 100% !important; }

/* ========== Pipeline Kanban ========== */
.pipeline-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding: 0 4px;
}
.pos-badge {
  font-size: 13px; font-weight: 600; color: var(--primary);
}
.pos-count { font-size: 13px; color: var(--text-secondary); }
.stage-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; border-radius: 11px;
  background: var(--bg-card); color: var(--text-secondary);
  font-size: 11px; font-weight: 600; margin-left: 6px;
}
.empty-column {
  padding: 20px; text-align: center; color: var(--text-light);
  font-size: 13px;
}
.pipeline-board {
  display: flex; gap: 16px; overflow-x: auto; padding-bottom: 12px;
}
.pipeline-column {
  min-width: 240px; flex: 1; background: var(--border-light);
  border-radius: var(--radius); padding: 12px;
}
.pipeline-column-terminal {
  background: #f9fafb; border: 2px dashed #d1d5db;
}
.pipeline-column h4 {
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px;
}
.pipeline-card {
  background: var(--bg-card); border-radius: var(--radius-sm);
  padding: 12px; margin-bottom: 8px; cursor: pointer;
  box-shadow: var(--shadow); transition: var(--transition);
}
.pipeline-card:hover { box-shadow: var(--shadow-md); }
.pipeline-card .pc-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.pipeline-card .pc-position { font-size: 12px; color: var(--text-secondary); }
.pipeline-card .pc-meta { font-size: 11px; color: var(--text-light); margin-top: 4px; }

/* ========== Position Cards (按岗位视图) ========== */
.position-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}
.position-card {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
  transition: var(--transition);
}
.position-card:hover { box-shadow: var(--shadow-md); }
.position-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 12px;
}
.position-card-header h3 {
  font-size: 16px; font-weight: 600; margin-bottom: 2px;
}
.clickable-position-title {
  cursor: pointer; color: var(--primary);
  transition: var(--transition);
}
.clickable-position-title:hover {
  color: var(--primary-dark); text-decoration: underline;
}
.clickable-position-link {
  cursor: pointer; color: var(--primary); font-weight: 500;
  text-decoration: none; transition: var(--transition);
}
.clickable-position-link:hover {
  color: var(--primary-dark); text-decoration: underline;
}
.position-card-badge {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-end;
}
.position-card-progress {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.progress-bar-mini {
  flex: 1; height: 6px; background: var(--border-light);
  border-radius: 3px; overflow: hidden;
}
.progress-fill-mini {
  height: 100%; background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 3px; transition: width 0.5s ease;
}
.mini-pipeline {
  display: flex; gap: 0; margin-bottom: 8px;
}
.mini-stage {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 8px 4px; cursor: pointer; border-radius: var(--radius-sm);
  transition: var(--transition);
}
.mini-stage:hover { background: var(--border-light); }
.mini-dot {
  width: 10px; height: 10px; border-radius: 50%; margin-bottom: 4px;
}
.mini-label {
  font-size: 11px; color: var(--text-secondary); margin-bottom: 2px;
}
.mini-count {
  font-size: 15px; font-weight: 700; color: var(--text);
}
.expanded-mini-list {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.mini-list-stage {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  margin-bottom: 6px;
}
.mini-list-label {
  font-size: 10px; color: #fff; padding: 1px 6px;
  border-radius: 3px; font-weight: 600; white-space: nowrap;
}
.mini-list-candidate {
  font-size: 12px; color: var(--text); cursor: pointer;
  padding: 2px 8px; background: var(--border-light);
  border-radius: 4px; white-space: nowrap; transition: var(--transition);
}
.mini-list-candidate:hover {
  background: var(--primary); color: #fff;
}

/* Text muted helper */
.text-muted { font-size: 12px; color: var(--text-light); }

/* ========== Tags ========== */
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  display: inline-flex; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 500;
  background: #eff6ff; color: #2563eb;
}

/* ========== Modal ========== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.4); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-card {
  background: var(--bg-card); border-radius: var(--radius);
  width: 100%; max-width: 720px; max-height: 85vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 22px;
  color: var(--text-secondary); cursor: pointer; padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--border-light); }
.modal-body { padding: 24px; }

/* ========== Detail Sections ========== */
.detail-section { margin-bottom: 20px; }
.detail-section h4 {
  font-size: 14px; font-weight: 600; color: var(--text-secondary);
  padding-bottom: 8px; margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; }
.detail-item { display: flex; flex-direction: column; }
.detail-item .dl { font-size: 11px; color: var(--text-light); text-transform: uppercase; }
.detail-item .dv { font-size: 14px; font-weight: 500; }

/* ========== Tabs ========== */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 2px solid var(--border); }
.tab-btn {
  padding: 10px 20px; border: none; background: none;
  font-size: 14px; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ========== Pagination ========== */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 20px;
}
.pagination button {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card); font-size: 13px; cursor: pointer; transition: var(--transition);
}
.pagination button:hover:not(:disabled) { background: var(--border-light); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.page-info { font-size: 13px; color: var(--text-secondary); padding: 0 8px; }

/* ========== Toast ========== */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease; min-width: 280px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--info); color: #fff; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ========== Empty State ========== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-light); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 15px; }

/* ========== Loading ========== */
.loading { text-align: center; padding: 40px; color: var(--text-secondary); }
.spinner {
  display: inline-block; width: 32px; height: 32px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Responsive ========== */
@media (max-width: 1024px) {
  .sidebar { width: 64px; min-width: 64px; }
  .brand-text, .nav-item span:not(.nav-icon), .user-name, .user-role { display: none; }
  .nav-item { justify-content: center; padding: 11px; }
  .sidebar-brand { justify-content: center; }
  .sidebar-footer { flex-direction: column; gap: 8px; align-items: center; }
  .charts-grid { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .topbar { padding: 12px 16px; }
  .page-content { padding: 16px; }
  .page-title { font-size: 17px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar input { min-width: auto; }
  .detail-grid { grid-template-columns: 1fr; }
  .pipeline-board { flex-direction: column; }
  .pipeline-column { min-width: auto; }
  .position-cards { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .modal-card { max-width: 95vw; }
}

/* ========== Advanced Search ========== */
.advanced-search-page .card { margin-bottom: 0; }
.skill-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; background: #eff6ff; color: #2563eb;
  border-radius: 20px; font-size: 12px; font-weight: 500;
}
.skill-chip-remove {
  cursor: pointer; font-size: 14px; line-height: 1;
  color: #93c5fd; transition: var(--transition);
}
.skill-chip-remove:hover { color: #ef4444; }
.skill-suggestions {
  position: absolute; z-index: 100; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); max-height: 200px; overflow-y: auto;
  min-width: 200px; margin-top: 2px;
}
.skill-suggestion-item {
  padding: 8px 14px; cursor: pointer; font-size: 13px;
  transition: var(--transition);
}
.skill-suggestion-item:hover { background: var(--primary); color: #fff; }
.nlp-term-tag {
  display: inline-flex; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
  background: #f5f3ff; color: #7c3aed;
}
