:root {
  --ink: #17324d;
  --ink-2: #284963;
  --teal: #0f766e;
  --teal-dark: #0a5c56;
  --green: #18794e;
  --blue: #2563eb;
  --amber: #b45309;
  --red: #b42318;
  --paper: #f7f9fb;
  --surface: #ffffff;
  --line: #d8e0e7;
  --line-strong: #b7c3ce;
  --muted: #667785;
  --text: #182832;
  --soft-blue: #edf5fa;
  --soft-teal: #e8f5f2;
  --soft-amber: #fff5dc;
  --soft-red: #fdeeed;
  --soft-green: #eaf7ef;
  --shadow: 0 10px 30px rgba(23, 50, 77, 0.09);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: 0; color: var(--ink); }

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--ink);
}
.brand-mark.compact { width: 40px; height: 40px; }
.brand-mark svg { width: 24px; height: 24px; stroke-width: 1.8; }

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-weight: 700;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.button:active { transform: translateY(1px); }
.button svg, .icon-button svg { width: 18px; height: 18px; }
.button.primary { color: #fff; background: var(--teal); border-color: var(--teal); }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { color: var(--ink); background: #fff; border-color: var(--line-strong); }
.button.secondary:hover { background: var(--soft-blue); }
.button.danger { color: var(--red); background: #fff; border-color: #e9b8b4; }
.button.wide { width: 100%; }

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  background: #fff;
}
.icon-button:hover { background: var(--soft-blue); border-color: var(--line-strong); }

input[type="text"], input[type="password"], input[type="search"], textarea, select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--text);
  background: #fff;
  outline: none;
}
input[type="text"], input[type="password"], input[type="search"], select { height: 42px; padding: 0 12px; }
textarea { min-height: 112px; padding: 12px; line-height: 1.65; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }
.field-label { display: block; margin-bottom: 7px; color: var(--ink); font-size: 14px; font-weight: 700; }
.field-group { margin: 18px 0; }

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.status-badge.neutral { color: var(--ink-2); background: var(--soft-blue); border-color: #d7e6f0; }
.status-badge.success { color: var(--green); background: var(--soft-green); border-color: #c6e7d3; }
.status-badge.warning { color: var(--amber); background: var(--soft-amber); border-color: #f0d99d; }
.status-badge.danger { color: var(--red); background: var(--soft-red); border-color: #efc6c3; }
.status-badge.muted { color: var(--muted); background: #f1f3f5; border-color: #e2e7eb; }

.form-error {
  margin: 12px 0;
  padding: 10px 12px;
  border-left: 3px solid var(--red);
  color: var(--red);
  background: var(--soft-red);
  font-size: 14px;
}

/* Admin */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel {
  width: min(100%, 390px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
}
.login-panel .brand-mark { margin-bottom: 24px; }
.login-panel h1 { margin-bottom: 28px; font-size: 26px; }
.login-panel input { margin-bottom: 8px; }
.login-panel .button { margin-top: 14px; }

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px max(24px, calc((100vw - 1440px) / 2));
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title h1 { margin: 0; font-size: 20px; }
.toolbar { display: flex; align-items: center; gap: 8px; }
.current-user { min-width: 110px; display: grid; justify-items: end; margin-right: 4px; }
.current-user strong { color: var(--ink); font-size: 13px; }
.current-user span { color: var(--muted); font-size: 11px; }

.summary-band { border-bottom: 1px solid var(--line); background: var(--ink); color: #fff; }
.summary-inner {
  width: min(100%, 1440px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
}
.metric { min-height: 102px; padding: 22px 18px; border-right: 1px solid rgba(255,255,255,.15); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: #b9cbd7; font-size: 13px; }
.metric strong { display: block; margin-top: 8px; font-size: 30px; line-height: 1; }
.metric.warning strong { color: #ffd789; }
.metric.danger strong { color: #ffb3ad; }

.admin-main { width: min(100%, 1440px); margin: 0 auto; padding: 28px 24px 52px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 22px; }
.filter-row { display: flex; align-items: center; gap: 10px; }
.search-box { position: relative; width: 280px; }
.search-box svg { position: absolute; left: 12px; top: 12px; width: 18px; height: 18px; color: var(--muted); }
.search-box input { padding-left: 38px; }
.filter-row select { width: 140px; }
.filter-row .product-filter { width: 190px; }

.table-shell { overflow: auto; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.roster-table { width: 100%; min-width: 2070px; border-collapse: collapse; }
.roster-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px;
  text-align: left;
  color: #fff;
  background: var(--teal);
  font-size: 13px;
  white-space: nowrap;
}
.roster-table td { padding: 10px 12px; border-bottom: 1px solid #e7ecef; vertical-align: middle; }
.roster-table tr:last-child td { border-bottom: 0; }
.roster-table tr:hover td { background: #fbfcfd; }
.roster-table input[type="text"] { min-width: 110px; height: 36px; border-color: transparent; background: transparent; }
.roster-table input[type="text"]:focus { border-color: var(--teal); background: #fff; }
.roster-table .product-select { min-width: 160px; height: 36px; }
.code-cell { color: var(--ink); font-weight: 800; }
.status-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.status-time { color: var(--muted); font-size: 11px; }
.status-link { padding: 0; border: 0; background: transparent; text-align: left; }
.compact-check { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.compact-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--teal); }
.row-actions { width: 278px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.small-button {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
  white-space: nowrap;
}
.small-button:hover { background: var(--soft-blue); }
.small-button svg { width: 15px; height: 15px; }
.actions-column { width: 410px; }
.empty-state { padding: 40px; text-align: center; color: var(--muted); }
.pagination { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; }
.pagination-range { color: var(--muted); font-size: 13px; }
.pagination-controls, .pagination-pages { display: flex; align-items: center; gap: 6px; }
.pagination .icon-button, .page-button { width: 38px; height: 38px; min-width: 38px; }
.page-button { display: grid; place-items: center; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: #fff; font-weight: 700; }
.page-button:hover { background: var(--soft-blue); }
.page-button.active { color: #fff; border-color: var(--teal); background: var(--teal); }
.pagination-ellipsis { width: 24px; color: var(--muted); text-align: center; }

.drawer { position: fixed; inset: 0; z-index: 30; visibility: hidden; }
.drawer.open { visibility: visible; }
.drawer-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(17, 34, 46, .46); opacity: 0; transition: opacity 160ms ease; }
.drawer.open .drawer-backdrop { opacity: 1; }
.drawer-panel {
  position: absolute;
  inset: 0 0 0 auto;
  width: min(720px, 94vw);
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: -14px 0 38px rgba(23, 50, 77, .16);
  transform: translateX(100%);
  transition: transform 180ms ease;
}
.drawer.open .drawer-panel { transform: translateX(0); }
.drawer-header { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.drawer-header h2 { margin: 0; font-size: 20px; }
.drawer-content { flex: 1; overflow: auto; padding: 22px; }
.qc-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.detail-section { margin-top: 26px; }
.detail-section h3 { margin-bottom: 10px; font-size: 16px; }
.answer-row { padding: 15px 0; border-bottom: 1px solid #e6ebef; }
.answer-row:last-child { border-bottom: 0; }
.answer-question { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 7px; color: var(--ink); font-weight: 700; line-height: 1.5; }
.answer-id { flex: 0 0 auto; padding: 2px 5px; border-radius: 3px; color: var(--teal-dark); background: var(--soft-teal); font-size: 11px; }
.answer-value { margin: 0; color: #334a59; white-space: pre-wrap; line-height: 1.65; }
.answer-purpose { margin: 8px 0 0; padding-left: 9px; border-left: 2px solid #cfdce5; color: var(--muted); font-size: 12px; line-height: 1.5; }
.review-form { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.review-form textarea { min-height: 90px; }
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.assist-choices { display: grid; gap: 10px; }
.assist-choice { width: 100%; min-height: 76px; display: grid; grid-template-columns: 30px 1fr 22px; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: #fff; text-align: left; }
.assist-choice:hover { border-color: var(--teal); background: var(--soft-teal); }
.assist-choice > svg { width: 21px; height: 21px; }
.assist-choice span { display: grid; gap: 4px; }
.assist-choice small { color: var(--muted); line-height: 1.45; }
.assist-choice:disabled { cursor: not-allowed; opacity: .58; }
.danger-choice:not(:disabled):hover { color: var(--red); border-color: #dca8a3; background: var(--soft-red); }
.drawer-note { margin: 0 0 16px; padding: 12px 14px; border-left: 3px solid var(--amber); color: var(--muted); background: var(--soft-amber); line-height: 1.6; }
.drawer-form { display: grid; gap: 12px; max-width: 420px; }
.drawer-form input[type="number"] { width: 100%; }
.drawer-form .button { justify-self: start; margin-top: 4px; }
.field-help { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.account-create-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.account-create-grid .button { grid-column: 1 / -1; justify-self: start; }
.account-list { display: grid; gap: 12px; }
.account-item { padding: 15px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.account-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.account-heading div { display: grid; gap: 3px; }
.account-heading strong { color: var(--ink); }
.account-heading span:not(.status-badge) { color: var(--muted); font-size: 12px; }
.account-edit-grid { display: grid; grid-template-columns: 1.2fr 1.4fr auto auto; align-items: center; gap: 8px; }
.account-edit-grid .compact-check { margin: 0; white-space: nowrap; }
.password-reset-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 9px; padding-top: 9px; border-top: 1px solid #e7ecef; }
.password-reset-row input { height: 36px; }
.manual-copy { display: grid; gap: 14px; }
.manual-copy p { margin: 0; color: var(--muted); line-height: 1.6; }
.manual-copy textarea { width: 100%; min-height: 240px; resize: vertical; line-height: 1.65; }
.manual-copy .button { justify-self: start; }

/* Public form */
.form-body { background: #f4f7f9; }
.form-topbar { position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.97); }
.form-topbar-inner { width: min(100%, 860px); min-height: 68px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 22px; }
.form-identity { display: flex; align-items: center; gap: 10px; }
.form-identity strong { color: var(--ink); font-size: 16px; }
.save-state { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.save-state svg { width: 16px; height: 16px; }
.save-state.saving { color: var(--amber); }
.save-state.saved { color: var(--green); }
.progress-track { height: 4px; background: #e5ebef; }
.progress-bar { width: 0; height: 100%; background: var(--teal); transition: width 220ms ease; }

.form-main { width: min(100%, 860px); margin: 0 auto; padding: 38px 22px 80px; }
.state-view { min-height: 55vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); }
.state-view h1 { margin-bottom: 10px; }
.state-view p { max-width: 520px; line-height: 1.7; }
.spinner { width: 30px; height: 30px; border: 3px solid #dce5ea; border-top-color: var(--teal); border-radius: 50%; animation: spin 750ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.state-icon { display: grid; width: 58px; height: 58px; margin-bottom: 18px; place-items: center; border-radius: 50%; }
.state-icon svg { width: 30px; height: 30px; }
.state-icon.error { color: var(--red); background: var(--soft-red); }
.state-icon.warning { color: var(--amber); background: var(--soft-amber); }
.state-icon.success { color: var(--green); background: var(--soft-green); }

.consent-view { max-width: 680px; margin: 0 auto; padding: 34px; border: 1px solid var(--line); border-radius: 6px; background: #fff; box-shadow: var(--shadow); }
.form-heading { padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.form-heading h1 { margin: 14px 0 10px; font-size: 28px; }
.form-heading p, .section-meta p { margin: 0; color: var(--muted); line-height: 1.75; }
.mode-control { margin: 24px 0 0; padding: 0; border: 0; }
.mode-control legend { margin-bottom: 10px; color: var(--ink); font-size: 14px; font-weight: 700; }
.mode-control { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-control legend { grid-column: 1 / -1; }
.mode-control input { position: absolute; opacity: 0; pointer-events: none; }
.mode-control span { min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: 4px; background: #fff; font-weight: 700; }
.mode-control span svg { width: 18px; height: 18px; }
.mode-control input:checked + span { color: var(--teal-dark); border-color: var(--teal); background: var(--soft-teal); box-shadow: inset 0 0 0 1px var(--teal); }
.consent-check { display: grid; grid-template-columns: 20px 1fr; gap: 10px; margin: 24px 0; color: #3e5563; line-height: 1.65; }
.consent-check input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--teal); }

.section-meta { margin-bottom: 28px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.section-meta h1 { margin: 5px 0 9px; font-size: 27px; }
.question-list { background: #fff; border: 1px solid var(--line); border-radius: 5px; }
.question-block { position: relative; padding: 26px 28px; border-bottom: 1px solid #e3e9ed; }
.question-block:last-child { border-bottom: 0; }
.question-block.invalid { background: #fff9f8; box-shadow: inset 3px 0 0 var(--red); }
.question-label { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 15px; color: var(--ink); font-size: 16px; font-weight: 750; line-height: 1.6; }
.question-number { flex: 0 0 auto; min-width: 24px; color: var(--teal-dark); font-size: 13px; }
.required-mark { flex: 0 0 auto; margin-top: 3px; padding: 1px 5px; border: 1px solid #edd69b; border-radius: 3px; color: var(--amber); background: var(--soft-amber); font-size: 10px; }
.choice-list { display: grid; gap: 8px; }
.choice-list.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice-item input { position: absolute; opacity: 0; pointer-events: none; }
.choice-item span {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: #354e5c;
  background: #fff;
  line-height: 1.45;
}
.choice-item span::before { content: ""; flex: 0 0 auto; width: 16px; height: 16px; border: 1.5px solid #8ea0ad; border-radius: 50%; background: #fff; }
.choice-item.checkbox span::before { border-radius: 3px; }
.choice-item input:checked + span { color: var(--teal-dark); border-color: var(--teal); background: var(--soft-teal); }
.choice-item input:checked + span::before { border: 5px solid var(--teal); }
.choice-item.checkbox input:checked + span::before { border: 4px solid var(--teal); background: var(--teal); box-shadow: inset 0 0 0 2px #fff; }
.scale-list { display: grid; grid-template-columns: repeat(11, minmax(38px, 1fr)); gap: 5px; }
.scale-item input { position: absolute; opacity: 0; }
.scale-item span { display: grid; min-height: 42px; place-items: center; border: 1px solid var(--line); border-radius: 4px; background: #fff; font-weight: 700; }
.scale-item input:checked + span { color: #fff; border-color: var(--teal); background: var(--teal); }
.scale-hints { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 11px; }
.skip-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.skip-button { padding: 5px 9px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: #fff; font-size: 12px; }
.skip-button:hover { color: var(--ink); background: var(--soft-blue); }
.question-error { display: none; margin: 9px 0 0; color: var(--red); font-size: 12px; }
.question-block.invalid .question-error { display: block; }

.form-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; }
.section-error { margin-top: 18px; }
.missing-list { border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.missing-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 18px; border-bottom: 1px solid #e7ecef; }
.missing-item:last-child { border-bottom: 0; }
.missing-item strong { color: var(--ink); line-height: 1.55; }
.missing-item button { flex: 0 0 auto; }

.toast { position: fixed; left: 50%; bottom: 26px; z-index: 80; min-width: 210px; max-width: calc(100vw - 36px); padding: 11px 16px; border-radius: 4px; color: #fff; background: #223d50; box-shadow: var(--shadow); text-align: center; transform: translateX(-50%); }
.icp-footer { padding: 18px 16px 22px; color: var(--muted); font-size: 12px; text-align: center; }
.icp-footer a { color: inherit; text-decoration: none; }
.icp-footer a:hover { color: var(--teal-dark); text-decoration: underline; }
.icp-footer-fixed { position: fixed; right: 0; bottom: 0; left: 0; z-index: 10; pointer-events: none; }
.icp-footer-fixed a { pointer-events: auto; }

@media (max-width: 1300px) {
  .summary-inner { grid-template-columns: repeat(5, 1fr); }
  .metric { border-bottom: 1px solid rgba(255,255,255,.15); }
  .metric:nth-child(5n) { border-right: 0; }
}

@media (max-width: 900px) {
  .summary-inner { grid-template-columns: repeat(3, 1fr); }
  .metric { border-right: 1px solid rgba(255,255,255,.15); border-bottom: 1px solid rgba(255,255,255,.15); }
  .metric:nth-child(3n) { border-right: 0; }
  .metric:last-child { border-right: 0; }
}

@media (max-width: 680px) {
  .topbar { align-items: stretch; flex-direction: column; gap: 10px; padding: 12px 16px; }
  .topbar .brand-mark { display: none; }
  .topbar-title h1 { font-size: 17px; }
  .toolbar { justify-content: flex-end; }
  .toolbar .button { width: 42px; padding: 0; font-size: 0; }
  .toolbar .button svg { width: 18px; height: 18px; }
  .current-user { display: none; }
  .summary-inner { grid-template-columns: repeat(2, 1fr); }
  .metric { min-height: 86px; padding: 17px; border-right: 1px solid rgba(255,255,255,.15); border-bottom: 1px solid rgba(255,255,255,.15); }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:last-child { grid-column: 1 / -1; border-right: 0; border-bottom: 0; }
  .admin-main { padding: 22px 14px 40px; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .filter-row { align-items: stretch; flex-direction: column; }
  .search-box, .filter-row select { width: 100%; }
  .form-topbar-inner { padding: 9px 14px; }
  .form-main { padding: 24px 14px 60px; }
  .consent-view { padding: 22px 18px; }
  .form-heading h1, .section-meta h1 { font-size: 23px; }
  .question-block { padding: 22px 16px; }
  .choice-list.two-columns { grid-template-columns: 1fr; }
  .scale-list { grid-template-columns: repeat(6, 1fr); }
  .scale-item:last-child { grid-column: 3 / 4; }
  .form-nav .button { min-width: 0; flex: 1; padding-left: 10px; padding-right: 10px; }
  .review-grid { grid-template-columns: 1fr; }
  .account-create-grid, .account-edit-grid { grid-template-columns: 1fr; }
  .account-create-grid .button { grid-column: auto; }
  .pagination { align-items: flex-start; flex-direction: column; }
  .pagination-controls { width: 100%; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: 0.01ms !important; }
}
