:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --ink: #172033;
  --muted: #687386;
  --line: #d8e0ea;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #168a4a;
  --amber: #b7791f;
  --red: #c2413a;
  --cyan: #0f766e;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Arial,
    sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 24px 0 34px;
}

.topbar,
.control-grid,
.workspace,
.detail-panel,
.resume-preview-panel,
.history-panel {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
  line-height: 1.35;
  letter-spacing: 0;
}

.top-actions,
.table-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.run-date {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(23, 32, 51, 0.04);
}

.run-date span {
  font-size: 13px;
  white-space: nowrap;
}

.run-date input {
  width: 142px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.icon-button,
.icon-only,
.drop-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  transition:
    transform 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease;
}

.icon-button {
  height: 42px;
  padding: 0 16px;
  font-weight: 700;
}

.icon-button svg,
.icon-only svg,
.drop-button svg,
.panel-title svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.icon-button.primary {
  color: #fff;
  background: var(--blue);
}

.icon-button.primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

.icon-button.secondary {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.icon-button.full {
  width: 100%;
  margin-top: 16px;
}

.icon-only {
  width: 36px;
  height: 36px;
  color: var(--muted);
  background: var(--surface-2);
}

.icon-only:hover {
  color: var(--ink);
  background: #e4ebf4;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.15fr;
  gap: 16px;
  margin-bottom: 16px;
}

.upload-panel,
.rules-panel,
.job-list,
.results-panel,
.detail-panel,
.resume-preview-panel,
.history-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.upload-panel,
.rules-panel {
  min-height: 194px;
  padding: 18px;
}

.upload-panel.drag-over {
  border-color: var(--blue);
  background: #f7fbff;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--ink);
  font-weight: 800;
}

.panel-title svg {
  color: var(--blue);
}

input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drop-button {
  width: 100%;
  height: 54px;
  border: 1px dashed #aebacf;
  color: var(--blue-dark);
  background: #f8fbff;
  font-weight: 800;
}

.drop-button:hover {
  border-color: var(--blue);
  background: #edf6ff;
}

.panel-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.panel-metrics div {
  min-height: 58px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
}

.panel-metrics strong {
  display: block;
  font-size: 22px;
  line-height: 1;
}

.panel-metrics span,
.file-note {
  color: var(--muted);
  font-size: 12px;
}

.file-note {
  margin: 10px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rules-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rules-list span {
  padding: 7px 10px;
  border-radius: 999px;
  color: #263347;
  background: #eef3f8;
  font-size: 12px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.job-list,
.results-panel {
  min-height: 540px;
  overflow: hidden;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.badge,
.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.neutral,
.status-chip.review {
  color: #4b5563;
  background: #edf1f6;
}

.status-chip.pass {
  color: #12633a;
  background: #daf5e7;
}

.status-chip.fail {
  color: #9b2c26;
  background: #fde3e0;
}

.status-chip.warn {
  color: #8a5c12;
  background: #fff2cf;
}

.list-body {
  max-height: 482px;
  overflow: auto;
  padding: 10px;
}

.list-body.empty {
  display: grid;
  place-items: center;
  height: 480px;
  color: var(--muted);
  font-size: 14px;
}

.job-item {
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f8fafc;
}

.job-item + .job-item {
  margin-top: 8px;
}

.job-item h3 {
  margin: 0 0 7px;
  font-size: 14px;
  line-height: 1.35;
  letter-spacing: 0;
}

.job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.job-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.keyword {
  padding: 4px 7px;
  border-radius: 999px;
  color: #315369;
  background: #e6f1f7;
  font-size: 11px;
  font-weight: 800;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
}

td {
  font-size: 13px;
  line-height: 1.42;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr.result-row {
  cursor: pointer;
}

tbody tr.result-row:hover {
  background: #f7fbff;
}

.candidate-name {
  display: inline;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 900;
  text-align: left;
}

.candidate-name:hover {
  color: var(--blue);
  text-decoration: underline;
}

.candidate-file {
  display: block;
  max-width: 160px;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 32px;
  border-radius: 8px;
  color: #fff;
  background: var(--cyan);
  font-weight: 900;
}

.score.low {
  background: var(--amber);
}

.score.blocked {
  background: var(--red);
}

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

.evidence {
  max-width: 280px;
}

.empty-cell {
  height: 420px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

.detail-panel {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10;
  width: 520px;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  transform: translateX(0);
}

.resume-preview-panel {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 12;
  width: min(920px, calc(100vw - 592px));
  min-width: 560px;
  max-height: calc(100vh - 48px);
  overflow: hidden;
}

.detail-panel.hidden,
.resume-preview-panel.hidden,
.history-panel.hidden {
  display: none;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-header h2 {
  font-size: 22px;
}

.detail-content {
  max-height: calc(100vh - 142px);
  overflow: auto;
  padding: 18px;
}

.resume-preview-content {
  height: calc(100vh - 142px);
  overflow: hidden;
  padding: 14px;
}

.history-panel {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 14;
  width: min(760px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: hidden;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-content {
  max-height: calc(100vh - 142px);
  overflow: auto;
  padding: 18px;
}

.history-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.history-card + .history-card {
  margin-top: 10px;
}

.history-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.history-card-head p {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.45;
}

.history-preview {
  display: grid;
  gap: 6px;
}

.history-preview div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f8fafc;
}

.history-preview span,
.history-preview strong {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.preview-actions a {
  text-decoration: none;
}

.resume-frame {
  width: 100%;
  height: calc(100% - 52px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.resume-text-preview {
  width: 100%;
  height: calc(100% - 52px);
  margin: 0;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  font-family:
    "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.preview-empty {
  padding: 18px;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
}

.detail-block {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.detail-block:first-child {
  padding-top: 0;
}

.detail-block:last-child {
  border-bottom: 0;
}

.detail-block h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.facts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.fact {
  padding: 10px;
  border-radius: 8px;
  background: #f8fafc;
}

.fact span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.fact strong {
  font-size: 13px;
}

.match-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.match-card + .match-card {
  margin-top: 8px;
}

.match-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.match-card-title strong {
  font-size: 14px;
}

.reason-line {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.error {
  color: var(--red);
}

@media (max-width: 1180px) {
  .app-shell {
    width: min(1100px, calc(100vw - 32px));
  }

  .control-grid {
    grid-template-columns: 1fr 1fr;
  }

  .rules-panel {
    grid-column: 1 / -1;
  }

  .workspace {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .resume-preview-panel {
    right: 24px;
    width: auto;
    min-width: 0;
  }
}

@media (max-width: 920px) {
  .app-shell {
    width: min(100vw - 24px, 720px);
    padding-top: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  h1 {
    font-size: 26px;
  }

  .control-grid,
  .workspace {
    grid-template-columns: 1fr;
  }

  .job-list,
  .results-panel {
    min-height: auto;
  }

  .list-body.empty {
    height: 220px;
  }

  .detail-panel,
  .resume-preview-panel,
  .history-panel {
    top: 12px;
    right: 12px;
    left: 12px;
    width: auto;
    min-width: 0;
    max-height: calc(100vh - 24px);
  }
}

@media (max-width: 560px) {
  .run-date,
  .icon-button {
    width: 100%;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .panel-metrics,
  .facts-grid,
  .history-preview div {
    grid-template-columns: 1fr;
  }
}
