:root {
  --ink: #142238;
  --muted: #66758a;
  --line: #dfe5ec;
  --soft: #f4f7fa;
  --primary: #174f77;
  --primary-dark: #103a58;
  --accent: #c98b3c;
  --danger: #b33a3a;
  --success: #26724c;
  --white: #fff;
  --shadow: 0 16px 48px rgba(25, 44, 70, .08);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--soft);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { min-height: 100%; margin: 0; font-size: 15px; line-height: 1.55; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
input, select {
  width: 100%; min-height: 48px; padding: 11px 13px; color: var(--ink);
  border: 1px solid #cfd7e1; border-radius: 8px; background: var(--white); outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23, 79, 119, .1); }
input::placeholder { color: #9aa6b5; }
fieldset { border: 0; margin: 0; padding: 0; }
h1, h2, h3, p { margin-top: 0; }
h1 { letter-spacing: -.03em; }
.is-hidden, [hidden] { display: none !important; }
.eyebrow { display: block; margin-bottom: 8px; color: var(--primary); font-size: 12px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.required { color: var(--danger); }
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 43px; padding: 10px 18px;
  border: 1px solid transparent; border-radius: 8px; font-weight: 700; transition: background .15s ease, transform .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--primary); }
.button-primary:hover { background: var(--primary-dark); }
.button:disabled { cursor: wait; opacity: .72; transform: none; }
.button-secondary { color: var(--ink); border-color: var(--line); background: #fff; }
.button-ghost { color: #d6e3ed; border-color: rgba(255,255,255,.18); background: transparent; }
.button-submit { width: 100%; min-height: 54px; font-size: 16px; }
.field { min-width: 0; }
.field label, .field legend, .tag-editor legend { display: block; margin-bottom: 7px; font-size: 14px; font-weight: 700; }
.field-error { display: block; min-height: 18px; margin-top: 5px; color: var(--danger); font-size: 12px; }
.field.has-error input, .field.has-error select, fieldset.has-error label { border-color: var(--danger); }
.validation-summary { margin: 0 0 18px; padding: 12px 14px; color: #8e2d2d; border: 1px solid #ebcaca; border-radius: 8px; background: #fff4f4; }
.validation-summary:empty, .validation-summary-valid { display: none; }
.validation-summary ul { margin: 0; padding-left: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
.checkbox-row { display: flex; align-items: center; gap: 9px; margin: 16px 0; font-size: 14px; }
.checkbox-row input, .tag-editor input, .radio-field input { width: 17px; min-height: 17px; accent-color: var(--primary); }

/* Candidate flow */
.public-body { background: #f6f8fa; }
.public-header { display: flex; align-items: center; width: min(760px, calc(100% - 36px)); height: 76px; margin: auto; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--primary-dark); font-size: 17px; font-weight: 800; letter-spacing: .08em; }
.brand img { display: block; width: auto; height: 34px; object-fit: contain; }
.public-main { width: min(760px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 64px; }
.public-footer { padding: 0 16px 36px; color: #8793a3; font-size: 12px; text-align: center; }
.apply-hero { margin-bottom: 26px; }
.apply-hero h1 { margin-bottom: 8px; font-size: clamp(30px, 7vw, 44px); line-height: 1.2; }
.apply-hero p { color: var(--muted); }
.application-form { display: grid; gap: 18px; }
.form-card, .education-card, .detail-card, .table-card, .qr-card {
  border: 1px solid rgba(210, 219, 229, .9); border-radius: 14px; background: #fff; box-shadow: var(--shadow);
}
.form-card { padding: 28px; }
.section-heading { display: flex; align-items: flex-start; gap: 13px; margin-bottom: 24px; }
.section-heading h2 { margin-bottom: 3px; font-size: 19px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.section-heading-outside { margin: 12px 2px 16px; }
.step-number { display: inline-grid; flex: 0 0 auto; place-items: center; width: 34px; height: 34px; color: var(--primary); border-radius: 9px; background: #eaf2f7; font-size: 11px; font-weight: 800; }
.radio-field { display: flex; flex-wrap: wrap; gap: 12px; }
.radio-field legend { flex: 0 0 100%; }
.radio-field label { display: flex; align-items: center; gap: 8px; min-width: 112px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 8px; }
.education-section { display: grid; gap: 14px; }
.education-card { position: relative; padding: 24px 28px 6px; box-shadow: none; }
.education-title { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; }
.education-title h3 { margin: 0; font-size: 16px; }
.education-title > span:last-child { margin-left: auto; color: var(--muted); font-size: 12px; }
.degree-dot { width: 9px; height: 9px; border: 2px solid var(--primary); border-radius: 50%; }
.autocomplete { position: relative; }
.autocomplete-menu { position: absolute; z-index: 20; top: 78px; left: 0; right: 0; max-height: 260px; overflow-y: auto; padding: 6px; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: 0 18px 40px rgba(20, 34, 56, .16); }
.autocomplete-option { display: block; width: 100%; padding: 11px 12px; color: var(--ink); border: 0; border-radius: 6px; background: transparent; text-align: left; }
.autocomplete-option strong, .autocomplete-option small { display: block; }
.autocomplete-option strong { font-size: 14px; }
.autocomplete-option small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.autocomplete-option:hover, .autocomplete-option:focus { background: #eef4f8; }
.autocomplete-other { margin-top: 4px; color: var(--primary); border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; font-weight: 700; }
.autocomplete-status { padding: 12px; color: var(--muted); font-size: 13px; }
.autocomplete-status.is-loading::before { content: ""; display: inline-block; width: 11px; height: 11px; margin-right: 8px; border: 2px solid #bdd0dc; border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.confirmation-card { margin-top: 4px; }
.confirmation-card .privacy-note { margin-bottom: 18px; }
.privacy-note { display: flex; gap: 11px; padding: 15px 16px; color: var(--muted); border: 1px solid #dce7ee; border-radius: 10px; background: #f3f8fb; font-size: 13px; }
.privacy-note span { display: grid; flex: 0 0 auto; place-items: center; width: 20px; height: 20px; color: #fff; border-radius: 50%; background: var(--success); font-size: 11px; }
.privacy-note p { margin: 0; }
.success-card { max-width: 590px; margin: 80px auto; padding: 52px 42px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow); text-align: center; }
.success-card h1 { margin-bottom: 12px; font-size: 34px; }
.success-card p { max-width: 430px; margin: 0 auto 26px; color: var(--muted); }
.success-icon { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 18px; color: #fff; border-radius: 50%; background: var(--success); font-size: 26px; }

/* Login */
.login-shell { max-width: 430px; margin: 34px auto 80px; }
.login-card { padding: 34px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: var(--shadow); }
.login-card h1 { margin-bottom: 4px; font-size: 30px; }
.login-card > p { margin-bottom: 26px; color: var(--muted); }
.login-card .field { margin-bottom: 6px; }

/* Admin */
.admin-body { display: flex; min-height: 100vh; background: #f3f5f8; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; display: flex; flex-direction: column; width: 246px; padding: 25px 18px; color: #dbe6ee; background: #122a3e; }
.admin-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 26px; color: #fff; font-weight: 800; }
.admin-brand img { display: block; width: auto; height: 36px; object-fit: contain; }
.admin-brand .admin-brand-copy { display: block; color: inherit; }
.admin-brand-copy strong, .admin-brand-copy small { display: block; }
.admin-brand-copy small { margin-top: 1px; color: #93aabd; font-size: 10px; font-weight: 600; letter-spacing: .08em; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { padding: 11px 13px; border-radius: 7px; font-size: 14px; }
.sidebar nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.logout-form { margin-top: auto; }
.logout-form .button { width: 100%; }
.admin-main { width: calc(100% - 246px); min-width: 0; margin-left: 246px; }
.admin-topbar { display: flex; align-items: center; justify-content: flex-end; min-height: 72px; padding: 12px 32px; border-bottom: 1px solid var(--line); background: #fff; }
.admin-topbar .eyebrow { margin: 0; font-size: 9px; }
.admin-topbar strong { display: block; font-size: 13px; }
.menu-toggle { display: none; margin-right: auto; border: 0; background: transparent; font-size: 22px; }
.admin-content { max-width: 1500px; margin: auto; padding: 34px 32px 60px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h1 { margin-bottom: 4px; font-size: 30px; }
.page-heading p { margin: 0; color: var(--muted); }
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.filter-bar select { width: auto; min-width: 142px; min-height: 43px; }
.search-field { position: relative; flex: 1; min-width: 220px; }
.search-field span { position: absolute; top: 8px; left: 12px; color: var(--muted); font-size: 21px; }
.search-field input { min-height: 43px; padding-left: 38px; }
.table-card { overflow: hidden; border-radius: 11px; box-shadow: none; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th { padding: 12px 14px; color: #6c7a8e; background: #f8fafb; font-size: 11px; letter-spacing: .03em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 15px 14px; border-top: 1px solid #e8ecf0; font-size: 13px; vertical-align: middle; }
td strong, td span { display: block; }
td small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.empty-cell { padding: 46px; color: var(--muted); text-align: center; }
.badge, .tag-list span { display: inline-block; width: max-content; padding: 3px 8px; color: var(--primary); border-radius: 20px; background: #eaf2f7; font-size: 11px; font-weight: 700; }
.table-link, .link-button { color: var(--primary); font-weight: 700; white-space: nowrap; }
.link-button { padding: 0; border: 0; background: none; }
.actions { display: flex; gap: 10px; }
.actions form { display: inline; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 16px; color: var(--muted); font-size: 13px; }
.pagination a { padding: 7px 11px; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pagination .disabled { opacity: .4; pointer-events: none; }
.back-link { display: inline-block; margin-bottom: 18px; color: var(--primary); font-size: 13px; font-weight: 700; }
.detail-heading { align-items: center; }
.status-badge { display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.status-badge.passed { color: var(--success); background: #e7f4ec; }
.status-badge.rejected { color: var(--danger); background: #faeaea; }
.status-badge.neutral { color: #647184; background: #eef1f4; }
.detail-grid { display: grid; grid-template-columns: .85fr 1.15fr; gap: 18px; }
.detail-card { padding: 26px; box-shadow: none; }
.section-heading.compact { align-items: center; margin-bottom: 20px; }
.section-heading.compact h2 { margin: 0; }
.data-list { margin: 0; }
.data-list div { display: grid; grid-template-columns: 100px 1fr; gap: 12px; padding: 11px 0; border-bottom: 1px solid #edf0f3; }
.data-list dt { color: var(--muted); }
.data-list dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.education-timeline article { position: relative; display: grid; grid-template-columns: 20px 1fr; gap: 12px; padding-bottom: 22px; }
.education-timeline article::before { content: ""; position: absolute; top: 15px; bottom: -3px; left: 6px; width: 1px; background: var(--line); }
.education-timeline article:last-child::before { display: none; }
.education-timeline article > span { z-index: 1; width: 13px; height: 13px; margin-top: 4px; border: 3px solid #d8e7f0; border-radius: 50%; background: var(--primary); }
.education-timeline small { color: var(--primary); font-weight: 800; }
.education-timeline h3 { margin: 3px 0; font-size: 16px; }
.education-timeline p { margin: 0; color: var(--muted); }
.reasons-card { margin-top: 18px; }
.reasons-card h2 { font-size: 17px; }
.reason-list { display: flex; flex-wrap: wrap; gap: 7px; }
.reason-list > span, .reason-list code { padding: 5px 8px; color: #7c3131; border-radius: 5px; background: #fceeee; font-size: 11px; }
.compact-reasons { max-width: 300px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-list small { margin: 0; }
.school-form { max-width: 880px; }
.tag-editor { display: flex; flex-wrap: wrap; gap: 12px 22px; margin: 22px 0; padding: 18px; border: 1px solid var(--line); border-radius: 9px; }
.tag-editor legend { float: left; width: 100%; }
.tag-editor label { display: flex; align-items: center; gap: 8px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.qr-card { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 34px; max-width: 820px; padding: 34px; box-shadow: none; }
.qr-card img { max-width: 100%; border: 10px solid #f4f6f8; border-radius: 10px; }
.qr-card code { display: block; margin: 8px 0 14px; padding: 10px; overflow-wrap: anywhere; border-radius: 6px; background: var(--soft); }
.qr-card p { color: var(--muted); }
.users-grid { grid-template-columns: 1.2fr .8fr; }
.user-list { display: grid; }
.user-list article { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.user-list strong, .user-list small { display: block; }
.user-list small { margin-top: 3px; color: var(--muted); }
.user-list button { border: 0; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .menu-open .sidebar { transform: translateX(0); box-shadow: 10px 0 30px rgba(0,0,0,.2); }
  .admin-main { width: 100%; margin-left: 0; }
  .menu-toggle { display: block; }
  .admin-topbar { padding: 12px 20px; }
  .admin-content { padding: 26px 18px 50px; }
  .detail-grid, .users-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .public-header { width: min(100% - 28px, 760px); height: 66px; }
  .brand { gap: 8px; font-size: 15px; }
  .brand img { height: 30px; }
  .public-main { width: min(100% - 24px, 760px); padding-top: 20px; }
  .apply-hero { padding: 0 4px; }
  .apply-hero h1 { font-size: 32px; }
  .form-card { padding: 21px 17px; }
  .education-card { padding: 21px 17px 5px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .form-grid .full { grid-column: auto; }
  .success-card { margin: 40px auto; padding: 40px 22px; }
  .login-card { padding: 26px 20px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .filter-bar { flex-direction: column; }
  .filter-bar select { width: 100%; }
  .search-field { width: 100%; min-width: 0; }
  .qr-card { grid-template-columns: 1fr; padding: 22px; text-align: center; }
  .qr-card img { margin: auto; }
  .data-list div { grid-template-columns: 82px 1fr; }
}
