:root {
  --ink: #17231d;
  --muted: #68736d;
  --paper: #f4f2ec;
  --panel: #fffef9;
  --line: #deddd5;
  --green: #184f3b;
  --green-2: #267459;
  --accent: #d86b3c;
  --shadow: 0 18px 50px rgba(26, 43, 35, .09);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input, textarea { font: inherit; }
button { border: 0; border-radius: 10px; background: var(--green); color: white; padding: 10px 16px; cursor: pointer; transition: .18s ease; }
button:hover:not(:disabled) { background: var(--green-2); transform: translateY(-1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { color: var(--green); background: #e5ece8; }

header { height: 92px; padding: 20px 32px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(244,242,236,.92); }
h1, h2, p { margin: 0; }
h1 { font-family: Georgia, "Songti SC", serif; font-size: 27px; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .17em; margin-bottom: 5px; }
.header-actions { display: flex; gap: 10px; align-items: center; }
.badge { padding: 7px 11px; border-radius: 999px; background: #e5ece8; color: var(--green); font-size: 12px; }

main { height: calc(100vh - 92px); display: grid; grid-template-columns: minmax(360px, 42%) 1fr; gap: 18px; padding: 14px 18px 18px; }
.chat-panel, .workspace { min-height: 0; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.chat-panel { display: flex; flex-direction: column; }
.upload-card { margin: 18px; padding: 20px; border: 1px dashed #b8beb8; border-radius: 14px; background: #f8f8f3; }
.upload-card h2 { font-size: 18px; margin-bottom: 5px; }
.upload-card p { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.upload-card input { display: block; width: 100%; padding: 8px 0 14px; }
.profile { display: flex; gap: 12px; flex-wrap: wrap; padding: 12px 18px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); }
.profile strong { color: var(--ink); }
.messages { flex: 1; overflow-y: auto; padding: 18px; }
.message { width: fit-content; max-width: 88%; margin-bottom: 12px; padding: 11px 13px; line-height: 1.6; border-radius: 14px; white-space: pre-wrap; font-size: 14px; }
.message.assistant { background: #edf1ed; border-bottom-left-radius: 4px; }
.message.user { margin-left: auto; color: white; background: var(--green); border-bottom-right-radius: 4px; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 14px; border-top: 1px solid var(--line); }
textarea, input[type="password"], .dialog input { width: 100%; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: white; outline: none; }
textarea:focus, input:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(38,116,89,.1); }

.workspace { display: flex; flex-direction: column; }
.tabs { display: flex; flex: 0 0 auto; padding: 6px 12px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs .tab { white-space: nowrap; }
.tab { background: transparent; color: var(--muted); border-radius: 0; padding: 10px 15px; border-bottom: 2px solid transparent; }
.tab:hover:not(:disabled) { background: transparent; transform: none; color: var(--ink); }
.tab.active { color: var(--green); border-bottom-color: var(--green); }
.table-view { flex: 1; overflow-y: auto; padding: 10px 14px 14px; }
.empty { padding: 60px 24px; text-align: center; color: var(--muted); }
.candidate { display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; padding: 11px 10px; border-bottom: 1px solid var(--line); align-items: center; }
.candidate:hover { background: #faf9f4; }
.position { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--green); background: #e8eee9; font-weight: 800; }
.candidate h3 { margin: 0 0 3px; font-size: 15px; }
.candidate .school { color: var(--green); margin-right: 8px; }
.meta { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 7px; }
.candidate-actions { display: flex; gap: 6px; }
.candidate-actions { align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.candidate-actions button { padding: 7px 9px; font-size: 12px; }
.candidate-actions .danger { color: #9f3f2b; background: #f7e8e2; }
.position-jump { display: inline-flex; gap: 4px; align-items: center; padding-left: 4px; border-left: 1px solid var(--line); }
.position-jump input { width: 50px; height: 30px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 8px; text-align: center; }
.risk { font-weight: 700; color: var(--accent); }
.library-toolbar { position: sticky; top: -14px; z-index: 2; display: grid; grid-template-columns: 1fr auto auto; gap: 8px; padding: 12px 0; background: var(--panel); }
.library-toolbar input { min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.library-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 0 0 10px; }
.filter-group { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.filter-group > span, .filter-select { color: var(--muted); font-size: 12px; font-weight: 700; }
.filter-chip { padding: 7px 11px; color: var(--green); background: #e5ece8; border-radius: 999px; font-size: 12px; }
.filter-chip.active { color: white; background: var(--green); }
.filter-select { display: inline-flex; align-items: center; gap: 7px; }
.filter-select select { height: 32px; min-width: 108px; border: 1px solid var(--line); border-radius: 999px; padding: 0 28px 0 11px; color: var(--green); background: white; outline: none; }
.library-summary { padding: 2px 4px 10px; color: var(--muted); font-size: 12px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 14px; padding: 18px 0 8px; color: var(--muted); font-size: 13px; }
.audit-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 6px 18px; }
.audit-heading button { flex: 0 0 auto; }
.audit-overview { display: grid; grid-template-columns: 110px 1fr; gap: 20px; align-items: center; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: #faf9f4; }
.audit-score { width: 100px; height: 100px; display: grid; place-content: center; text-align: center; border-radius: 50%; background: #e5ece8; color: var(--green); }
.audit-score.medium { color: #a85a2f; background: #f7eadf; }
.audit-score.low { color: #a13e2a; background: #f7e2de; }
.audit-score strong { display: block; font-size: 36px; line-height: 1; }
.audit-score span { display: block; margin-top: 5px; font-size: 12px; }
.audit-overview h3 { margin: 0 0 6px; font-size: 19px; }
.audit-overview p { color: var(--muted); font-size: 13px; }
.audit-distribution { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.audit-distribution span { padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #ecece7; }
.audit-distribution .reach { color: #b65336; background: #f8e6df; }
.audit-distribution .match { color: #9a6a16; background: #f8efcf; }
.audit-distribution .safe { color: var(--green); background: #e3eee8; }
.audit-issues { display: grid; gap: 10px; margin-top: 16px; }
.audit-issue { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.audit-issue.critical { border-left: 4px solid #b64b35; }
.audit-issue.warning { border-left: 4px solid #d29a35; }
.audit-issue.info { border-left: 4px solid #6d8c80; }
.audit-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--muted); font-weight: 800; }
.audit-issue.critical .audit-icon { background: #b64b35; }
.audit-issue.warning .audit-icon { background: #d29a35; }
.audit-issue h3 { margin: 1px 0 5px; font-size: 15px; }
.audit-issue p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.audit-positions { display: inline-block; margin-top: 8px; color: var(--green); font-size: 12px; font-weight: 700; }
.audit-empty-good { padding: 24px; border-radius: 13px; color: var(--green); background: #e6efe9; text-align: center; font-weight: 700; }
.audit-disclaimer { margin: 16px 4px 4px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.preference-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 6px 18px; }
.preference-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.preference-form fieldset, .field-option { margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: #faf9f4; }
.preference-form legend { padding: 0 6px; color: var(--green); font-size: 13px; font-weight: 800; }
.check-option { display: flex; align-items: center; gap: 9px; margin: 8px 0; color: var(--ink); font-size: 14px; cursor: pointer; }
.check-option input { width: 18px; height: 18px; accent-color: var(--green); }
.field-option { display: block; color: var(--muted); font-size: 13px; }
.field-option input { width: 100%; margin-top: 9px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.preference-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 9px; }
.preference-note { grid-column: 1 / -1; padding: 12px 14px; color: var(--muted); background: #edf1ed; border-radius: 10px; font-size: 12px; line-height: 1.6; }

.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(20,32,26,.72); backdrop-filter: blur(12px); }
.dialog { width: min(420px, 100%); padding: 30px; border-radius: 20px; background: var(--panel); box-shadow: var(--shadow); }
.dialog p { color: var(--muted); margin: 8px 0 20px; line-height: 1.6; }
.dialog input { margin-bottom: 12px; }
.dialog button { width: 100%; }
.dialog label { display: block; color: var(--muted); font-size: 12px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; margin: 0 0 16px; border-radius: 12px; background: #e8ece8; }
.auth-tabs button { color: var(--muted); background: transparent; }
.auth-tabs button.active { color: white; background: var(--green); }
.projects-dialog { width: min(720px, 100%); max-height: min(760px, 90vh); overflow-y: auto; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-heading .icon-button { width: auto; }
.project-list { display: grid; gap: 10px; margin-top: 18px; }
.project-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: #faf9f4; }
.project-card strong, .project-card span { display: block; }
.project-card span { margin-top: 5px; color: var(--muted); font-size: 12px; }
.project-actions { display: flex; gap: 7px; flex: 0 0 auto; }
.project-actions button { width: auto; padding: 8px 12px; }
.project-actions .danger { color: #9f3f2b; background: #f7e8e2; }
.project-empty { padding: 28px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 13px; }
.error { min-height: 20px; color: #a13e2a; font-size: 13px; margin-top: 10px; }
.toast { position: fixed; right: 22px; bottom: 22px; padding: 11px 15px; color: white; background: var(--ink); border-radius: 10px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.hidden { display: none !important; }

@media (max-width: 850px) {
  header { height: auto; padding: 16px; align-items: flex-start; gap: 12px; }
  .header-actions { flex-wrap: wrap; justify-content: flex-end; }
  main { height: auto; min-height: calc(100vh - 90px); grid-template-columns: 1fr; padding: 10px; }
  .chat-panel { min-height: 620px; }
  .workspace { min-height: 540px; }
  .candidate { grid-template-columns: 36px 1fr; }
  .candidate-actions { grid-column: 2; }
  .project-card { align-items: flex-start; flex-direction: column; }
  .audit-overview { grid-template-columns: 1fr; }
  .preference-form { grid-template-columns: 1fr; }
}
