:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-soft: #f9faf7;
  --border: #d9ded5;
  --ink: #1e2520;
  --muted: #687066;
  --green: #24745a;
  --green-dark: #195740;
  --blue: #315d8b;
  --red: #a7444f;
  --amber: #9a6819;
  --shadow: 0 12px 30px rgba(33, 40, 34, 0.08);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.is-hidden { display: none !important; }

.app-shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; gap: 28px; height: 100dvh; padding: 22px 18px; background: #202820; color: #f6f8f2; }
.brand { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; overflow: hidden; border: 1px solid rgba(255,255,255,.22); border-radius: 8px; background: #f6f8f2; }
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand-copy strong, .brand-copy small { display: block; }
.brand-copy strong { font-size: 15px; }
.brand-copy small { margin-top: 3px; color: #bac4b6; font-size: 11px; }
.nav-list { display: grid; gap: 7px; }
.nav-item { display: grid; gap: 3px; width: 100%; padding: 12px; border: 0; border-radius: 7px; background: transparent; color: #dce4d8; cursor: pointer; text-align: left; }
.nav-item span { color: #bac4b6; font-size: 11px; }
.nav-item.active, .nav-item:hover, .nav-item:focus-visible { outline: none; background: rgba(255,255,255,.11); color: #fff; }
.sidebar-footer { margin-top: auto; padding: 14px; border: 1px solid rgba(255,255,255,.14); border-radius: 8px; background: rgba(255,255,255,.06); }
.sidebar-footer span, .sidebar-footer strong { display: block; }
.sidebar-footer span { color: #bac4b6; font-size: 11px; }
.sidebar-footer strong { margin-top: 5px; font-size: 12px; }

.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 100dvh; padding: 26px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.eyebrow { margin: 0 0 5px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
.topbar h1 { margin-bottom: 0; font-size: 28px; }
.account-box { display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.account-box strong, .account-box span { display: block; text-align: right; }
.account-box strong { font-size: 13px; }
.account-box span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.page-section { display: grid; gap: 16px; }

.hero-panel { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; padding: 28px; border: 1px solid #ced8ce; border-radius: 10px; background: linear-gradient(135deg, #fff 0%, #eef5ee 100%); box-shadow: var(--shadow); }
.hero-panel h2 { max-width: 680px; margin-bottom: 10px; font-size: clamp(24px, 3vw, 36px); line-height: 1.18; }
.hero-panel p:last-child { max-width: 700px; margin: 0; color: var(--muted); line-height: 1.7; }
.hero-badge { flex: 0 0 auto; padding: 9px 12px; border: 1px solid #b8cbbb; border-radius: 999px; color: var(--green-dark); background: rgba(255,255,255,.75); font-size: 12px; font-weight: 800; }
.platform-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.platform-card { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; min-height: 280px; padding: 24px; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.platform-card::after { position: absolute; right: -70px; bottom: -70px; width: 180px; height: 180px; border-radius: 50%; background: #e8f1e9; content: ""; }
.platform-card.locked { background: #f5f6f3; box-shadow: none; }
.platform-card.locked::after { background: #eceeea; }
.platform-index { position: absolute; top: 18px; right: 20px; color: #dce3da; font-size: 42px; font-weight: 900; }
.platform-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 10px; color: #fff; background: var(--green); font-size: 22px; font-weight: 900; }
.platform-card:nth-child(2) .platform-icon { background: var(--blue); }
.platform-card:nth-child(3) .platform-icon { background: var(--amber); }
.platform-card:nth-child(4) .platform-icon { background: #70528f; }
.platform-content { position: relative; z-index: 1; padding-right: 22px; }
.platform-content h2 { margin: 14px 0 9px; font-size: 24px; }
.platform-content p { color: var(--muted); line-height: 1.65; }
.availability { display: inline-block; padding: 4px 8px; border-radius: 999px; color: #727a70; background: #ecefea; font-size: 11px; font-weight: 800; }
.availability.enabled { color: var(--green-dark); background: #e2f1e8; }
.platform-button { position: absolute; z-index: 2; right: 24px; bottom: 24px; }

.flow-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; align-items: center; padding: 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.flow-step { display: flex; align-items: center; gap: 12px; min-height: 70px; padding: 12px; border-radius: 8px; background: var(--surface-soft); }
.flow-step > span { display: grid; flex: 0 0 auto; place-items: center; width: 42px; height: 42px; border: 1px solid #bfcbbf; border-radius: 50%; color: var(--green-dark); font-size: 11px; font-weight: 900; }
.flow-step strong, .flow-step small { display: block; }
.flow-step small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.flow-step.output { background: #eef3f8; }
.flow-arrow { color: #9aa59a; font-size: 24px; }

.panel { padding: 22px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.panel-heading { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.panel-heading h2 { margin-bottom: 5px; }
.panel-heading p:last-child { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: var(--surface-soft); font-size: 11px; }
td { font-size: 13px; }
td small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.table-input, select, input { min-width: 0; padding: 9px 10px; border: 1px solid #cfd6cc; border-radius: 6px; background: #fff; color: var(--ink); }
.table-input { width: 190px; }
input:focus, select:focus { border-color: var(--green); outline: 3px solid rgba(36,116,90,.12); }
.permission-check, .check-field { display: inline-flex; align-items: center; gap: 7px; }
.permission-check input, .check-field input { width: 16px; height: 16px; accent-color: var(--green); }
.switch input { position: absolute; opacity: 0; }
.switch span { position: relative; display: block; width: 38px; height: 22px; border-radius: 999px; background: #c9cec7; cursor: pointer; }
.switch span::after { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); content: ""; transition: .16s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(16px); }
.new-user-form { display: grid; grid-template-columns: 1.5fr 1fr .8fr auto auto auto; gap: 12px; align-items: end; }
.new-user-form label:not(.check-field) { display: grid; gap: 6px; }
.new-user-form label > span { color: var(--muted); font-size: 11px; font-weight: 800; }
.new-user-form .check-field { min-height: 38px; }
.system-data-form { grid-template-columns: minmax(280px, 1fr) auto; align-items: end; }
.system-data-form label:not(.check-field) { min-width: min(340px, 100%); }
.danger-panel { border-color: #efc7bd; }
.btn.danger-button { border-color: #a63a2b; background: #a63a2b; }
.btn.danger-button:hover { background: #812d22; }
.status-download { display: inline-flex; margin-left: 12px; }
.system-operation-table { min-width: 980px; }
.system-operation-table td:first-child { max-width: 290px; overflow-wrap: anywhere; }
.operation-state { display: inline-flex; padding: 4px 8px; border-radius: 999px; color: var(--blue); background: #e7eef7; font-size: 11px; font-weight: 800; }
.operation-state.state-ready, .operation-state.state-committed { color: var(--green-dark); background: #e2f1e8; }
.operation-state.state-failed, .operation-state.state-partial_failure { color: var(--red); background: #f9e9eb; }
.operation-actions { display: flex; gap: 8px; align-items: center; }
.btn.delete-operation { border-color: #efc7bd; color: var(--red); background: #fff; }
.btn.delete-operation:hover { background: #f9e9eb; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 8px 14px; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-weight: 800; text-decoration: none; }
.btn.primary { color: #fff; background: var(--green); }
.btn.primary:hover { background: var(--green-dark); }
.btn.secondary { border-color: var(--border); color: var(--ink); background: #fff; }
.btn.compact { min-height: 32px; padding: 5px 10px; font-size: 12px; }
.btn:disabled { cursor: not-allowed; opacity: .58; }
.message { padding: 11px 12px; border-radius: 7px; color: var(--muted); background: #f0f2ee; font-size: 12px; }
.message.ok { color: var(--green-dark); background: #e5f3ea; }
.message.error { color: var(--red); background: #f9e9eb; }
.site-footer { display: grid; gap: 3px; justify-items: center; margin-top: auto; padding: 30px 8px 4px; color: var(--muted); text-align: center; }
.site-footer::before { width: min(720px,100%); height: 1px; margin-bottom: 13px; background: var(--border); content: ""; }
.site-footer strong { color: var(--ink); font-size: 12px; }
.site-footer span { font-size: 10px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: 420px; padding: 12px 16px; border-radius: 7px; color: #fff; background: #26352f; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }

.questionnaire-nav-link { color: #dce4d8; text-decoration: none; }
.questionnaire-workbench { gap: 16px; }
.questionnaire-hero { align-items: center; }
.questionnaire-hero h2 { font-size: clamp(23px, 3vw, 32px); }
.questionnaire-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.questionnaire-metrics article { display: grid; gap: 7px; min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow); }
.questionnaire-metrics span { color: var(--muted); font-size: 11px; font-weight: 800; }
.questionnaire-metrics strong { overflow: hidden; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.questionnaire-heading { align-items: flex-start; }
.questionnaire-search-form { display: grid; grid-template-columns: minmax(170px, .5fr) minmax(280px, 1.5fr) auto; gap: 12px; align-items: end; margin-bottom: 14px; }
.questionnaire-search-form label { display: grid; gap: 6px; }
.questionnaire-search-form label > span { color: var(--muted); font-size: 11px; font-weight: 800; }
.questionnaire-search-form input, .questionnaire-search-form select { width: 100%; min-height: 40px; }
.questionnaire-table-wrap { margin-top: 14px; }
.sample-management-search { grid-template-columns: minmax(280px, 1fr) auto; }
.sample-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; color: var(--muted); }
.sample-pagination > div, .sample-action-group { display: flex; flex-wrap: wrap; gap: 8px; }
.portal-modal-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px; background: rgba(14, 31, 28, .56); }
.portal-modal-panel { width: min(1000px, 100%); max-height: calc(100vh - 48px); overflow: auto; padding: 22px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 24px 70px rgba(14, 31, 28, .24); }
.questionnaire-detail-description { display: grid; gap: 12px; margin-bottom: 20px; padding: 16px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-soft); }
.questionnaire-detail-description-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.questionnaire-detail-description-heading h3, .questionnaire-record-heading { margin: 0; }
.questionnaire-detail-description-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.questionnaire-detail-description pre { max-height: 460px; margin: 0; padding: 15px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--ink); font: inherit; font-size: 13px; line-height: 1.75; white-space: pre-wrap; }
.questionnaire-record-heading { margin: 0; }
.questionnaire-record-details { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-soft); }
.questionnaire-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.questionnaire-detail-grid article { display: grid; gap: 6px; min-width: 0; padding: 13px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-soft); }
.questionnaire-detail-grid span { color: var(--muted); font-size: 11px; font-weight: 800; }
.questionnaire-detail-grid strong { overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.report-action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
#comparisonPanel { margin-top: 20px; padding: 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-soft); }
#comparisonPanel h3 { margin-top: 0; }
#comparisonPanel select { min-width: 280px; margin-right: 10px; }

.review-list-heading { align-items: center; }
.review-list-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.review-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.review-pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 18px; }
.review-pagination span { min-width: 96px; color: var(--muted); font-size: 12px; font-weight: 800; text-align: center; }
.review-status { display: inline-flex; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.review-status-pending { color: #8a5710; background: #fff0d4; }
.review-status-reviewed { color: var(--green-dark); background: #e2f1e8; }
.review-status-finalized { color: #42546a; background: #e8edf3; }
.review-patient-section { margin-bottom: 22px; padding: 18px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-soft); }
.review-patient-section h3 { margin: 0 0 5px; }
.review-patient-section > p { color: var(--muted); font-size: 12px; }
.review-patient-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.review-patient-grid label { display: grid; gap: 5px; }
.review-patient-grid label > span, .review-field-card > span { color: var(--muted); font-size: 11px; font-weight: 800; }
.review-patient-grid input:disabled { color: #3d4840; background: #eef1ec; opacity: 1; }
.review-field-list { display: grid; gap: 16px; }
.review-field-card { display: grid; gap: 10px; padding: 18px; border: 1px solid var(--border); border-radius: 9px; background: #fff; }
.review-field-card h3 { margin: 0; color: var(--green-dark); font-size: 14px; }
.review-live-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.review-field-card textarea { width: 100%; min-height: 260px; padding: 12px; border: 1px solid #cfd6cc; border-radius: 7px; color: var(--ink); background: #fff; font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: vertical; }
.review-field-card textarea:focus { border-color: var(--green); outline: 3px solid rgba(36,116,90,.12); }
.review-field-card textarea:disabled { background: #eef1ec; opacity: 1; }
.review-live-preview { box-sizing: border-box; min-width: 0; min-height: 260px; max-height: 520px; overflow: auto; padding: 12px; border: 1px solid #cfd6cc; border-radius: 7px; overflow-wrap: anywhere; line-height: 1.75; background: var(--surface-soft); }
.review-live-preview > :first-child { margin-top: 0; }
.review-live-preview > :last-child { margin-bottom: 0; }
.review-save-actions { display: flex; justify-content: center; margin-top: 22px; }
.review-task-table td:first-child strong { display: block; }

.login-body {
  background-color: #f5f8f6;
  background-image: url("/login-background.png");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  background-attachment: fixed;
}
.login-shell { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(390px, .8fr); gap: clamp(40px, 8vw, 120px); align-items: center; min-height: 100dvh; width: min(1180px, calc(100% - 48px)); margin: auto; }
.login-copy { color: #183d30; }
.login-page-brand { width: fit-content; margin-bottom: 70px; }
.login-page-brand .brand-copy small { color: #587569; }
.login-copy h1 { max-width: 660px; margin-bottom: 20px; font-size: clamp(38px, 5vw, 64px); line-height: 1.08; letter-spacing: -.03em; text-shadow: 0 2px 18px rgba(255,255,255,.92); }
.login-entry { display: grid; gap: 16px; min-width: 0; }
.login-panel { display: grid; gap: 22px; padding: 30px; border-radius: 10px; background: var(--surface); box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.login-panel h2 { margin-bottom: 7px; font-size: 26px; }
.login-panel > div > p:last-child { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.login-panel form { display: grid; gap: 16px; }
.login-panel form > label { display: grid; gap: 7px; }
.login-panel label > span { color: var(--muted); font-size: 12px; font-weight: 800; }
.login-panel input { width: 100%; min-height: 44px; }
.input-action { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.login-submit { width: 100%; min-height: 44px; margin-top: 2px; }
.company-line { color: #8a9388; text-align: center; font-size: 10px; }
.login-filing { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; column-gap: 14px; row-gap: 4px; padding: 0 8px; color: #6b7f78; font-size: 10px; line-height: 16px; }
.login-filing a { display: inline-flex; align-items: center; color: inherit; text-decoration: none; white-space: nowrap; }
.login-filing a:hover { color: #255f4c; text-decoration: underline; text-underline-offset: 2px; }
.login-filing img { width: auto; height: 10px; margin-right: 3px; border: 0; }

@media (max-width: 1000px) {
  .new-user-form { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .questionnaire-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-shell { grid-template-columns: 1fr; padding: 40px 0; }
  .login-copy { display: none; }
  .login-entry { width: min(480px,100%); margin: auto; }
  .login-panel { width: 100%; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px; }
  .nav-list { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .sidebar-footer { display: none; }
  .workspace { padding: 16px; }
  .topbar, .hero-panel { align-items: stretch; flex-direction: column; }
  .account-box { justify-content: space-between; }
  .account-box strong, .account-box span { text-align: left; }
  .platform-grid { grid-template-columns: 1fr; }
  .flow-panel { grid-template-columns: 1fr; }
  .flow-arrow { transform: rotate(90deg); text-align: center; }
  .new-user-form { grid-template-columns: 1fr; }
  .questionnaire-search-form, .sample-management-search, .questionnaire-detail-grid, .questionnaire-metrics { grid-template-columns: 1fr; }
  .sample-pagination { align-items: stretch; flex-direction: column; }
  .portal-modal-backdrop { padding: 12px; }
  .portal-modal-panel { max-height: calc(100vh - 24px); padding: 16px; }
  .questionnaire-detail-description-heading { align-items: stretch; flex-direction: column; }
  .review-patient-grid { grid-template-columns: 1fr; }
  .review-live-editor { grid-template-columns: 1fr; }
}
