:root {
  --navy: #102b4a;
  --navy-2: #183b62;
  --orange: #f7931d;
  --orange-soft: #fff3e3;
  --cream: #f7f4ee;
  --paper: #ffffff;
  --ink: #172536;
  --muted: #667386;
  --line: #dfe4ea;
  --green: #167552;
  --red: #a93838;
  --shadow: 0 18px 55px rgba(16, 43, 74, 0.1);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", Arial, sans-serif;
  color: var(--ink);
  background: var(--cream);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--cream); }
body { min-height: 100vh; margin: 0; background: linear-gradient(180deg, #f5f1e9 0, #faf9f6 36rem); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 78px;
  padding: 0 4vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: white;
  background: rgba(16, 43, 74, 0.97);
  border-bottom: 4px solid var(--orange);
  backdrop-filter: blur(18px);
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: white; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px 18px 10px 10px;
  font: 700 30px/1 Georgia, serif;
  background: linear-gradient(145deg, #ffb21c, #f27a13);
}
.brand strong { display: block; font-size: 21px; letter-spacing: .12em; }
.brand small { display: block; margin-top: 1px; font-size: 9px; letter-spacing: .18em; opacity: .82; }

.nav { display: flex; align-items: center; gap: 24px; font-size: 14px; }
.nav > a { text-decoration: none; opacity: .84; }
.nav > a:hover { opacity: 1; }
.user-chip { padding: 8px 12px; border: 1px solid rgba(255,255,255,.22); border-radius: 999px; color: #e8eef5; }
.inline-form { display: inline; margin: 0; }
.nav-button, .text-button { border: 0; padding: 0; color: inherit; background: transparent; }
.nav-button { opacity: .82; }
.text-button { color: var(--red); text-decoration: underline; }

.shell { width: min(1460px, 92vw); min-height: calc(100vh - 150px); margin: 0 auto; padding: 40px 0 64px; }
.footer { padding: 22px 4vw 32px; text-align: center; color: var(--muted); font-size: 12px; }
.eyebrow { margin-bottom: 8px; color: #d66d00; font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; color: var(--navy); font: 600 clamp(34px, 4vw, 58px)/1.05 Georgia, "Noto Serif TC", serif; }
h2 { margin-bottom: 12px; color: var(--navy); font-size: 21px; }
p { color: var(--muted); line-height: 1.65; }

.alert { margin: 0 0 22px; padding: 14px 17px; border-radius: 12px; border: 1px solid; font-weight: 650; }
.alert-success { color: #0e6948; background: #e8f6ef; border-color: #b7e3ce; }
.alert-error { color: #912c2c; background: #fff0ef; border-color: #efc7c4; }

.auth-layout { min-height: 68vh; display: grid; grid-template-columns: 1.15fr .85fr; align-items: center; gap: clamp(40px, 8vw, 120px); }
.auth-message { padding: 40px 2vw; }
.auth-message h1 { font-size: clamp(50px, 6vw, 78px); }
.auth-message p { max-width: 610px; font-size: 18px; }
.auth-card, .form-card {
  width: min(100%, 520px);
  padding: clamp(28px, 4vw, 46px);
  border: 1px solid rgba(16,43,74,.1);
  border-radius: 24px;
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow);
}
.auth-card { margin: 5vh auto; }
.auth-card.narrow { max-width: 560px; }

.stack { display: grid; gap: 17px; }
label { display: grid; gap: 7px; color: #354458; font-size: 13px; font-weight: 750; }
label small { color: var(--muted); font-weight: 500; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cdd5de;
  border-radius: 10px;
  padding: 12px 13px;
  color: var(--ink);
  background: white;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(247,147,29,.15); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 11px 18px;
  border: 1px solid var(--navy);
  border-radius: 10px;
  color: white;
  background: var(--navy);
  font-weight: 800;
  text-decoration: none;
}
.button:hover { background: var(--navy-2); }
.button-full { width: 100%; }
.button-secondary { color: var(--navy); background: white; }
.button-secondary:hover { color: white; }

.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin: 8px 0 30px; }
.page-heading p { margin: 4px 0 0; }
.metric { display: flex; align-items: baseline; gap: 8px; color: var(--muted); }
.metric strong { color: var(--navy); font: 600 44px/1 Georgia, serif; }

.filters { display: grid; grid-template-columns: minmax(230px, 1fr) 190px auto; gap: 12px; margin-bottom: 18px; }
.search-field input { padding-left: 15px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

.table-card, .history-card, .pdf-panel, .evaluation-panel, .form-card {
  border: 1px solid rgba(16,43,74,.1);
  border-radius: 18px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 10px 35px rgba(16,43,74,.06);
  overflow: hidden;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 14px 18px; color: var(--muted); background: #f4f6f8; font-size: 11px; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
td { padding: 17px 18px; border-top: 1px solid #e9edf1; vertical-align: middle; }
td strong, td small { display: block; }
td small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.row-link, .text-link { color: #ad5600; font-weight: 800; text-decoration: none; white-space: nowrap; }
.status { display: inline-flex; padding: 5px 9px; border-radius: 999px; color: #555f6d; background: #e9edf1; font-size: 12px; font-weight: 800; white-space: nowrap; }
.status-pending { color: #9b5200; background: #fff0db; }
.status-done { color: var(--green); background: #e4f4ec; }
.empty-list { padding: 70px 24px; text-align: center; }
.empty-list.compact { padding: 30px 10px; }
.empty-list p { margin-bottom: 0; }

.breadcrumb { display: flex; gap: 8px; margin-bottom: 28px; color: var(--muted); font-size: 13px; }
.breadcrumb a { color: #ad5600; font-weight: 750; text-decoration: none; }
.candidate-hero { display: flex; align-items: end; justify-content: space-between; gap: 40px; margin-bottom: 24px; }
.candidate-hero h1 { margin-bottom: 6px; }
.candidate-hero p { margin-bottom: 0; font-size: 17px; }
.candidate-meta { display: flex; gap: 14px; }
.candidate-meta span { min-width: 126px; padding: 12px 14px; border-left: 2px solid var(--orange); color: var(--muted); font-size: 11px; }
.candidate-meta strong { display: block; margin-top: 4px; color: var(--navy); font-size: 14px; }
.assignment { display: flex; align-items: end; gap: 12px; padding: 15px 18px; margin-bottom: 18px; border: 1px solid #e5d2b5; border-radius: 14px; background: var(--orange-soft); }
.assignment label { flex: 1; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(330px, .65fr); gap: 18px; align-items: start; }
.panel-heading { min-height: 72px; padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.panel-heading .eyebrow { margin-bottom: 3px; }
.panel-heading h2 { margin: 0; }
.panel-heading > h2 { margin: 0; }
.panel-heading > span { color: var(--muted); font-size: 13px; }
.pdf-panel iframe { display: block; width: 100%; height: min(72vh, 920px); border: 0; background: #d8dde2; }
.evaluation-panel { position: sticky; top: 100px; }
.evaluation-panel > form, .evaluation-panel > .review-summary, .evaluation-panel > .empty-list { margin: 0; padding: 22px; }
.review-summary strong { color: var(--navy); }
.history-card { margin-top: 18px; }
.history-item { min-height: 82px; padding: 15px 22px; display: grid; grid-template-columns: 1fr 1.2fr auto; align-items: center; gap: 20px; border-top: 1px solid var(--line); }
.history-item strong, .history-item small { display: block; }
.history-item small { margin-top: 5px; color: var(--muted); }
.history-review small { max-width: 540px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.admin-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, .5fr); gap: 18px; align-items: start; }
.form-card { position: sticky; top: 100px; width: auto; padding: 26px; }
.credential-card {
  display: grid;
  grid-template-columns: minmax(220px, .65fr) minmax(0, 1.35fr);
  gap: 24px;
  padding: 24px 26px;
  margin-bottom: 18px;
  border: 1px solid #e9b76f;
  border-radius: 18px;
  background: var(--orange-soft);
}
.credential-card h2 { margin-bottom: 0; }
.credential-card dl { margin: 0; }
.credential-card dl > div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(16,43,74,.1); }
.credential-card dt { color: var(--muted); font-size: 12px; font-weight: 800; }
.credential-card dd { margin: 0; overflow-wrap: anywhere; color: var(--navy); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 800; }
.credential-card p { grid-column: 1 / -1; margin: 0; color: #7b4a0d; font-size: 13px; }
fieldset { display: grid; gap: 9px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
legend { padding: 0 6px; color: var(--muted); font-size: 12px; font-weight: 800; }
.check-label { display: flex; align-items: center; gap: 9px; color: var(--ink); font-size: 14px; font-weight: 650; }
.check-label input { width: 18px; height: 18px; margin: 0; accent-color: var(--orange); }
code { color: var(--navy); font-size: 12px; }
.empty-state { min-height: 62vh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.empty-state .button { margin-top: 12px; }
.empty-code { color: var(--orange); font: 700 72px/1 Georgia, serif; }

@media (max-width: 1040px) {
  .nav > a, .user-chip { display: none; }
  .auth-layout { grid-template-columns: 1fr; gap: 0; }
  .auth-message { padding-bottom: 0; text-align: center; }
  .auth-message p { margin-inline: auto; }
  .auth-card { margin-top: 20px; }
  .candidate-hero { align-items: start; flex-direction: column; }
  .workspace-grid { grid-template-columns: 1fr; }
  .evaluation-panel { position: static; }
  .admin-grid { grid-template-columns: 1fr; }
  .form-card { position: static; }
  .credential-card { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar { min-height: 70px; padding-inline: 18px; }
  .brand strong { font-size: 17px; }
  .brand small { display: none; }
  .shell { width: min(94vw, 1460px); padding-top: 26px; }
  .auth-message { display: none; }
  .auth-card { padding: 26px 22px; }
  .page-heading { align-items: start; }
  .filters { grid-template-columns: 1fr; }
  .candidate-meta { width: 100%; overflow-x: auto; }
  .candidate-meta span { min-width: 120px; }
  .assignment { align-items: stretch; flex-direction: column; }
  .history-item { grid-template-columns: 1fr; gap: 10px; }
  .history-item .row-link { justify-self: start; }
  .pdf-panel iframe { height: 66vh; }
}

@media print {
  .topbar, .footer, .filters, .assignment, .evaluation-panel { display: none; }
  .shell { width: 100%; }
  .workspace-grid { display: block; }
}
