:root {
  --ink: #1f2b26;
  --muted: #69756e;
  --quiet: #8b968f;
  --line: #dfe6e0;
  --paper: #f5f7f4;
  --surface: #ffffff;
  --surface-soft: #f8faf8;
  --green: #24634c;
  --green-soft: #e8f1eb;
  --green-faint: #f0f6f1;
  --amber: #96652c;
  --amber-soft: #fff4e3;
  --red: #a44d40;
  --red-soft: #fff0ed;
  font-family: Inter, "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 14px;
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; background: var(--paper); }

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(36, 99, 76, .22);
  outline-offset: 1px;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 245px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  font: 700 13px/1 Georgia, serif;
  letter-spacing: 0;
}
.brand strong { display: block; font-size: 14px; font-weight: 700; }
.brand small { display: block; margin-top: 3px; color: var(--quiet); font-size: 10px; }

.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.user-chip { max-width: 190px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 11px; white-space: nowrap; }
.segmented { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); }
.segment { padding: 7px 10px; border-radius: 5px; color: var(--muted); background: transparent; font-size: 12px; }
.segment.active { color: var(--green); background: var(--surface); box-shadow: 0 1px 3px rgba(31, 43, 38, .09); font-weight: 700; }
.language-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); }
.language-button { min-width: 34px; padding: 6px 7px; border-radius: 5px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 700; }
.language-button.active { color: var(--green); background: var(--surface); box-shadow: 0 1px 3px rgba(31, 43, 38, .09); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 35px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.button.primary { color: #fff; background: var(--green); }
.button.primary:hover { background: #1c543f; }
.button.secondary { border-color: var(--line); color: var(--ink); background: var(--surface); }
.button.secondary:hover { border-color: #b8c9bd; background: var(--green-faint); }

.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - 76px); }
.sidebar { min-height: calc(100vh - 76px); padding: 26px 16px 18px; border-right: 1px solid var(--line); background: #fbfcfa; }
.main { min-width: 0; max-width: 1320px; width: 100%; padding: 30px 38px 56px; }

.notice {
  min-height: 0;
  margin: 0 auto 12px;
  color: transparent;
  font-size: 12px;
}
.notice:not(:empty) { padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--green); background: var(--green-faint); }
.notice.warning { color: var(--amber); background: var(--amber-soft); border-color: #ecd2a9; }
.notice.error { color: var(--red); background: var(--red-soft); border-color: #edc0b8; }
.login-shell { display: grid; place-items: center; min-height: 58vh; }
.login-panel { width: min(440px, 100%); padding: 30px; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 12px 30px rgba(31, 43, 38, .06); }
.login-panel h1 { margin: 8px 0; font: 500 30px/1.2 Georgia, "Noto Serif SC", serif; }
.login-panel p { margin: 0 0 22px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.login-panel .button { width: 100%; margin-top: 8px; }
.submission-heading { margin-top: 24px; }
.feedback-panel, .materials-panel { margin: 0 auto 18px; padding: 18px 20px; border: 1px solid var(--line); background: var(--surface); }
.feedback-panel h2, .materials-panel h2 { margin: 5px 0 0; font: 500 18px/1.25 Georgia, "Noto Serif SC", serif; }
.feedback-panel p, .feedback-detail p { margin: 8px 0 0; white-space: pre-wrap; color: var(--muted); font-size: 12px; line-height: 1.65; }
.feedback-detail { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.feedback-detail strong { color: var(--ink); font-size: 11px; }
.attachment-list { display: grid; gap: 7px; margin: 12px 0; padding: 0; list-style: none; }
.attachment-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border: 1px solid var(--line); background: var(--surface-soft); font-size: 11px; }
.attachment-list a { color: var(--green); font-weight: 700; overflow-wrap: anywhere; }
.attachment-list small { color: var(--quiet); white-space: nowrap; }
.upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upload-row input { max-width: 100%; font-size: 11px; }
.questionnaire-view textarea { width: 100%; min-height: 520px; padding: 12px; border: 1px solid var(--line); color: var(--ink); background: var(--surface-soft); font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; }
.managed-questionnaire { margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); }
.checkbox-field { display: flex; align-items: center; gap: 9px; }
.checkbox-field input { width: 16px; height: 16px; }

.eyebrow { display: block; color: var(--quiet); font-size: 10px; font-weight: 800; letter-spacing: 1.5px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin: 8px 0 28px; }
.page-heading h1 { max-width: 820px; margin: 7px 0 7px; font: 500 31px/1.2 Georgia, "Noto Serif SC", serif; overflow-wrap: anywhere; }
.page-heading p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.heading-actions { display: flex; align-items: center; gap: 8px; padding-top: 8px; }
.status-badge { display: inline-flex; align-items: center; min-height: 28px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface); font-size: 11px; text-transform: capitalize; }
.status-badge.ready { color: var(--green); border-color: #b9d1c0; background: var(--green-soft); }

.side-heading { padding: 0 8px 18px; border-bottom: 1px solid var(--line); }
.side-heading strong { display: block; margin-top: 8px; font-size: 15px; overflow-wrap: anywhere; }
.progress-box { margin: 16px 0 20px; padding: 13px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.progress-label { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
.progress-label strong { color: var(--green); }
.progress-track { height: 5px; margin: 11px 0 9px; overflow: hidden; border-radius: 99px; background: #e5ebe6; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width .2s ease; }
.progress-box p { margin: 0; color: var(--quiet); font-size: 10px; line-height: 1.6; }
.stage-nav { display: grid; gap: 5px; }
.stage-link { display: grid; grid-template-columns: 27px 1fr; gap: 8px; width: 100%; padding: 10px 9px; border-radius: 6px; text-align: left; color: var(--muted); background: transparent; }
.stage-link:hover { background: var(--green-faint); }
.stage-link.active { color: var(--green); background: var(--green-soft); box-shadow: inset 3px 0 var(--green); }
.stage-link > span { color: var(--quiet); font-size: 10px; font-weight: 800; }
.stage-link strong, .stage-link small { display: block; }
.stage-link strong { font-size: 12px; }
.stage-link small { margin-top: 3px; color: var(--quiet); font-size: 10px; line-height: 1.45; }
.side-note { margin-top: 24px; padding: 14px 9px 0; border-top: 1px solid var(--line); }
.side-note strong { font-size: 11px; }
.side-note p { margin: 6px 0 10px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.text-button { padding: 0; color: var(--green); background: none; font-size: 11px; font-weight: 700; }
.text-button:hover { text-decoration: underline; }

.filter-row { display: grid; grid-template-columns: 1fr; gap: 7px; margin: 12px 0; }
.filter-row input, .filter-row select { width: 100%; min-height: 32px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: var(--surface); font-size: 11px; }
.proposal-list { display: grid; gap: 4px; max-height: calc(100vh - 340px); overflow: auto; }
.proposal-item { width: 100%; padding: 10px 9px; border-radius: 6px; text-align: left; background: transparent; }
.proposal-item:hover { background: var(--green-faint); }
.proposal-item.selected { background: var(--green-soft); box-shadow: inset 3px 0 var(--green); }
.proposal-item-title, .proposal-item-meta { display: block; overflow-wrap: anywhere; }
.proposal-item-title { font-size: 11px; font-weight: 700; line-height: 1.4; }
.proposal-item-meta { margin-top: 4px; color: var(--quiet); font-size: 10px; text-transform: capitalize; }
.proposal-item.ai-item { border-left: 2px solid #b77a35; }
.proposal-ai-mark { display: inline-block; margin-left: 5px; padding: 2px 4px; border: 1px solid #e3c997; border-radius: 3px; color: var(--amber); background: var(--amber-soft); font-size: 8px; font-weight: 800; vertical-align: 1px; }
.empty-state { padding: 16px 8px; color: var(--quiet); font-size: 11px; line-height: 1.6; }
.side-footer { margin-top: 18px; padding: 12px 8px 0; border-top: 1px solid var(--line); color: var(--quiet); font-size: 10px; line-height: 1.6; }

.form-section, .read-section, .review-panel { margin-bottom: 18px; padding: 21px 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.section-heading { margin-bottom: 17px; }
.section-heading p { max-width: 700px; margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.field-grid { display: grid; gap: 14px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin-bottom: 14px; }
.field-label { color: var(--ink); font-size: 11px; font-weight: 800; }
.field.required .field-label b { color: var(--red); }
.field-help { color: var(--quiet); font-size: 10px; line-height: 1.5; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #d5dfd8; border-radius: 5px; color: var(--ink); background: #fcfdfc; }
.field input, .field select { min-height: 37px; padding: 8px 10px; }
.field textarea { min-height: 74px; padding: 9px 10px; resize: vertical; line-height: 1.55; }
.field input::placeholder, .field textarea::placeholder { color: #a2ada6; }
.field select { appearance: auto; }
.field.compact { margin-bottom: 10px; }
.field.compact select { min-height: 33px; padding: 6px 8px; font-size: 11px; }

.taxonomy-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.taxonomy-card { display: flex; flex-direction: column; align-items: flex-start; min-height: 137px; padding: 12px; border: 1px solid var(--line); border-radius: 7px; text-align: left; background: var(--surface-soft); }
.taxonomy-card:hover { border-color: #a8c5b1; background: var(--green-faint); }
.taxonomy-card.selected { border-color: var(--green); background: var(--green-soft); box-shadow: 0 0 0 2px rgba(36, 99, 76, .1); }
.taxonomy-card.challenge { border-style: dashed; }
.taxonomy-id { display: grid; place-items: center; width: 22px; height: 22px; margin-bottom: 10px; border-radius: 5px; color: var(--green); background: #d9eadf; font-size: 11px; font-weight: 800; }
.taxonomy-card strong { font-size: 11px; line-height: 1.35; }
.taxonomy-card small, .taxonomy-card em { margin-top: 6px; color: var(--muted); font-size: 10px; font-style: normal; line-height: 1.45; }
.taxonomy-card em { color: var(--quiet); }
.taxonomy-challenge-panel { margin: 0 0 18px; padding: 15px; border: 1px dashed #c9a96f; border-radius: 7px; background: var(--amber-soft); }
.challenge-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 13px; }
.challenge-heading strong { display: block; max-width: 760px; margin-top: 7px; color: #68461f; font-size: 12px; line-height: 1.6; }
.challenge-mark, .proposal-challenge-mark { color: var(--amber); font-weight: 800; }
.challenge-mark { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid #d8b778; border-radius: 50%; background: #fff9ee; }
.taxonomy-review-box { margin: 0 0 16px; padding: 13px; border: 1px dashed #c9a96f; border-radius: 7px; background: var(--amber-soft); }
.taxonomy-review-box p { margin: 7px 0 13px; color: #68461f; font-size: 11px; line-height: 1.55; }
.challenge-badge { color: var(--amber); border-color: #d8b778; background: var(--amber-soft); }
.proposal-item.challenge-item { border-color: #d8b778; background: #fffaf1; }
.tag-field { margin-top: 3px; }
.tag-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-option { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface-soft); font-size: 10px; }
.tag-option.selected { border-color: #adccb7; color: var(--green); background: var(--green-soft); }
.tag-option input { accent-color: var(--green); }

.handoff-grid, .reviewer-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, .7fr); gap: 18px; align-items: start; }
.ai-review-notice { margin: 0 0 18px; padding: 12px 14px; border-left: 3px solid #b77a35; color: var(--ink); background: var(--amber-soft); }
.ai-review-notice strong { display: block; font-size: 12px; }
.ai-review-notice p { margin: 5px 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.ai-review-notice span { color: var(--quiet); font: 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.read-section { min-height: 80px; }
.read-section dl { margin: 13px 0 0; }
.read-section dl > div { display: grid; grid-template-columns: 145px minmax(0, 1fr); gap: 15px; padding: 10px 0; border-top: 1px solid #edf1ed; }
.read-section dt { color: var(--muted); font-size: 11px; }
.read-section dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); font-size: 12px; line-height: 1.65; }
.handoff-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 16px; }
.panel-header h2 { margin: 6px 0 0; font: 500 20px/1.2 Georgia, "Noto Serif SC", serif; }
.score-number { color: var(--green); font-size: 19px; }
.decision-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; padding-top: 15px; border-top: 1px solid var(--line); }

.export-popover { position: absolute; z-index: 5; top: calc(100% + 7px); right: 0; display: grid; min-width: 190px; padding: 5px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: 0 8px 28px rgba(31, 43, 38, .15); }

.board-toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(130px, 180px)); gap: 8px; margin-bottom: 14px; }
.board-toolbar input, .board-toolbar select { min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--surface); font-size: 11px; }
.score-report-warning { margin-bottom: 12px; padding: 10px 12px; border-left: 3px solid #d8b778; color: #68461f; background: var(--amber-soft); font-size: 11px; line-height: 1.5; }
.board-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; align-items: start; }
.board-table-wrap { overflow: auto; border: 1px solid var(--line); background: var(--surface); }
.board-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.board-table th { padding: 10px; border-bottom: 1px solid var(--line); color: var(--quiet); background: var(--surface-soft); font-size: 10px; font-weight: 700; text-align: left; text-transform: uppercase; letter-spacing: .04em; }
.board-table td { padding: 11px 10px; border-bottom: 1px solid #edf1ed; color: var(--muted); font-size: 11px; vertical-align: top; }
.board-table tr { cursor: pointer; }
.board-table tr:hover, .board-table tr.selected { background: var(--green-faint); }
.board-table td strong, .board-table td small { display: block; }
.board-table td strong { color: var(--ink); font-size: 11px; }
.board-table td small { max-width: 220px; margin-top: 4px; color: var(--quiet); line-height: 1.35; }
.board-pill { display: inline-block; padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-soft); font-size: 9px; white-space: nowrap; }
.board-pill.contract-invalid, .board-pill.task_contract_invalid { color: var(--red); border-color: #e6bcb5; background: var(--red-soft); }
.board-pill.delegated-evaluator, .board-pill.diagnostic-only, .board-pill.evaluation_pending { color: var(--amber); border-color: #e3c997; background: var(--amber-soft); }
.board-pill.candidate, .board-pill.resolved_success { color: var(--green); border-color: #b8d2c1; background: var(--green-soft); }
.board-detail { padding: 17px; border: 1px solid var(--line); background: var(--surface); }
.board-detail h2 { margin: 7px 0 3px; font: 500 20px/1.25 Georgia, "Noto Serif SC", serif; }
.board-task-id { margin: 0 0 14px; color: var(--quiet); font: 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.board-facts { margin: 0; }
.board-facts > div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-top: 1px solid #edf1ed; }
.board-facts dt { color: var(--quiet); font-size: 10px; }
.board-facts dd { margin: 0; overflow-wrap: anywhere; color: var(--ink); font-size: 11px; line-height: 1.45; }
.board-block { margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); }
.board-block strong { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.board-block p { margin: 6px 0 0; color: var(--ink); font-size: 11px; line-height: 1.55; }
.board-record { margin-top: 14px; border-top: 1px solid var(--line); }
.board-record summary { padding: 13px 0 9px; color: var(--ink); cursor: pointer; font-size: 11px; font-weight: 800; }
.board-record summary::marker { color: var(--green); }
.board-record dl { margin: 0 0 5px; }
.board-record dl > div { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 9px; padding: 7px 0; border-top: 1px solid #edf1ed; }
.board-record dt { color: var(--quiet); font-size: 9px; line-height: 1.45; }
.board-record dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); font-size: 10px; line-height: 1.55; }
.board-record-empty { margin: 0 0 12px; color: var(--quiet); font-size: 10px; }
.board-models { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 15px; }
.board-model { display: grid; gap: 4px; padding: 9px; border: 1px solid var(--line); background: var(--surface-soft); }
.board-model strong { font-size: 11px; }
.board-model span, .board-model small { color: var(--muted); font-size: 9px; line-height: 1.35; }
.board-model .trajectory-diagnosis { color: var(--ink); }
.trajectory-diagnosis-note { margin: 10px 0 16px; padding: 10px 12px; border-left: 3px solid #d8b778; color: var(--muted); background: var(--amber-soft); font-size: 11px; line-height: 1.55; }
@media (max-width: 1100px) { .board-layout { grid-template-columns: 1fr; } .board-detail { order: -1; } }
@media (max-width: 800px) { .board-toolbar { grid-template-columns: 1fr 1fr; } .board-toolbar input { grid-column: 1 / -1; } }
.export-popover button { padding: 9px 10px; border-radius: 4px; text-align: left; color: var(--ink); background: transparent; font-size: 11px; }
.export-popover button:hover { background: var(--green-faint); color: var(--green); }
#export-menu { position: relative; }

dialog { width: min(560px, calc(100vw - 30px)); padding: 22px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--surface); box-shadow: 0 15px 60px rgba(31, 43, 38, .2); }
dialog::backdrop { background: rgba(20, 32, 25, .3); }
.dialog-heading { display: flex; justify-content: space-between; gap: 20px; }
.dialog-heading h2 { margin: 6px 0 0; font: 500 23px/1.2 Georgia, "Noto Serif SC", serif; }
dialog p { color: var(--muted); font-size: 12px; line-height: 1.75; }
.icon-button { width: 28px; height: 28px; border-radius: 5px; color: var(--muted); background: var(--surface-soft); font-size: 19px; line-height: 1; }
.icon-button:hover { color: var(--ink); background: var(--green-soft); }

@media (max-width: 1050px) {
  .taxonomy-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .handoff-grid, .reviewer-grid { grid-template-columns: 1fr; }
  .review-panel { order: -1; }
}

@media (max-width: 800px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 18px; }
  .top-actions { width: 100%; margin-left: 0; overflow-x: auto; }
  .app-shell { display: flex; flex-direction: column; }
  .sidebar { min-height: 0; padding: 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .proposal-list { max-height: 220px; }
  .main { padding: 24px 18px 42px; }
  .page-heading { flex-direction: column; margin-bottom: 22px; }
  .heading-actions { padding-top: 0; }
}

@media (max-width: 600px) {
  .brand { min-width: 0; }
  .brand strong { font-size: 13px; }
  .top-actions { flex-wrap: wrap; }
  .top-actions .button { flex: 1 0 auto; }
  .segmented { flex: 1 0 100%; }
  .segment { flex: 1; }
  .page-heading h1 { font-size: 27px; }
  .form-section, .read-section, .review-panel { padding: 17px 15px; }
  .field-grid.two { grid-template-columns: 1fr; gap: 0; }
  .taxonomy-grid { grid-template-columns: 1fr; }
  .taxonomy-card { min-height: auto; }
  .read-section dl > div { grid-template-columns: 1fr; gap: 4px; }
  .handoff-actions .button, .decision-row .button { flex: 1 0 100%; }
}
