:root {
  color-scheme: light;
  --ink: #17262b;
  --muted: #68777c;
  --line: #dbe4e4;
  --surface: #ffffff;
  --surface-soft: #f3f7f6;
  --teal: #0b615e;
  --teal-dark: #084b49;
  --navy: #113b4a;
  --navy-soft: #e9f0f2;
  --amber: #a65f00;
  --amber-soft: #fff3dc;
  --red: #a53030;
  --red-soft: #fdeaea;
  --green: #276a43;
  --green-soft: #e8f5ed;
  --shadow: 0 10px 30px rgba(24, 54, 59, 0.08);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface-soft);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  letter-spacing: 0;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
}

.eyebrow.light {
  color: #aee1dc;
}

.muted {
  color: var(--muted);
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  color: white;
  background: var(--teal);
  font-family: serif;
  font-size: 24px;
  font-weight: 700;
}

.brand-mark.large {
  width: 68px;
  height: 68px;
  margin-bottom: 30px;
  font-size: 34px;
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  font-size: 19px;
}

.button {
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 700;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.6;
  transform: none;
}

.button.primary {
  color: white;
  background: var(--teal);
}

.button.primary:hover {
  background: var(--teal-dark);
}

.button.secondary {
  border-color: #bdccce;
  color: var(--ink);
  background: white;
}

.button.text-button {
  min-height: auto;
  padding: 8px 4px;
  color: var(--muted);
  background: transparent;
}

.button.full {
  width: 100%;
}

.button.small {
  min-height: 36px;
  padding: 0 14px;
  font-size: 14px;
}

.icon-text-button {
  padding: 8px 0;
  border: 0;
  color: var(--teal);
  background: transparent;
  font-weight: 700;
}

.field {
  display: grid;
  gap: 8px;
}

.field label,
.field legend,
.note-section label {
  color: #33494f;
  font-size: 14px;
  font-weight: 700;
}

.field label span,
.field legend span {
  color: var(--red);
}

.field input,
.field select,
.field textarea,
.filter-bar input,
.filter-bar select,
.note-section textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #b9c8ca;
  border-radius: 5px;
  color: var(--ink);
  background: white;
  outline: none;
}

.field input:focus,
.field select:focus,
.filter-bar input:focus,
.filter-bar select:focus,
.note-section textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(11, 97, 94, 0.12);
}

.form-stack {
  display: grid;
  gap: 22px;
}

.form-stack.compact {
  gap: 16px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

fieldset.field {
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: grid;
  min-height: 44px;
  padding: 6px;
  place-items: center;
  border: 1px solid #bdcacc;
  border-radius: 5px;
  color: #40565c;
  background: white;
  font-size: 14px;
}

.segmented input:checked + span {
  border-color: var(--teal);
  color: var(--teal-dark);
  background: #e7f4f2;
  box-shadow: inset 0 0 0 1px var(--teal);
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #566a70;
  font-size: 13px;
  line-height: 1.65;
}

.consent-row input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--teal);
}

.notice,
.toast {
  padding: 12px 16px;
  border: 1px solid #e5ba73;
  border-radius: 5px;
  color: #704000;
  background: var(--amber-soft);
  line-height: 1.5;
}

.notice {
  margin-bottom: 18px;
}

.toast {
  position: fixed;
  z-index: 100;
  top: 20px;
  left: 50%;
  min-width: 260px;
  max-width: min(500px, calc(100vw - 32px));
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.toast.success {
  border-color: #9dc8ae;
  color: var(--green);
  background: var(--green-soft);
}

/* Patient */
.patient-page {
  min-height: 100vh;
  background:
    linear-gradient(180deg, var(--navy) 0, var(--navy) 176px, var(--surface-soft) 176px);
}

.patient-header {
  display: flex;
  width: min(680px, calc(100% - 32px));
  height: 132px;
  margin: 0 auto;
  align-items: center;
  gap: 14px;
  color: white;
}

.patient-header .hospital-name {
  margin-bottom: 4px;
  color: #c8dde2;
  font-size: 13px;
}

.patient-header h1 {
  margin: 0;
  font-size: 24px;
}

.patient-shell {
  width: min(680px, calc(100% - 24px));
  min-height: 480px;
  margin: 0 auto;
  padding: 30px;
  border: 1px solid rgba(17, 59, 74, 0.08);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.intro-block {
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.intro-block h2,
.welcome-row h2,
.scale-heading h2,
.complete-screen h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.intro-block p:last-child,
.scale-heading p:last-child,
.complete-screen p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

.welcome-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.progress-pill {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--teal-dark);
  background: #e4f2f0;
  font-size: 13px;
  font-weight: 700;
}

.progress-track {
  height: 6px;
  margin: 10px 0 28px;
  overflow: hidden;
  border-radius: 3px;
  background: #e5ecec;
}

.progress-track div {
  width: 0;
  height: 100%;
  background: var(--teal);
  transition: width 250ms ease;
}

.module-list {
  display: grid;
  gap: 18px;
}

.module-block {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfc;
}

.module-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.module-title h3 {
  margin: 0;
  font-size: 17px;
}

.module-title span {
  color: var(--muted);
  font-size: 13px;
}

.scale-list {
  display: grid;
  gap: 8px;
}

.scale-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  min-height: 64px;
  padding: 10px;
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  text-align: left;
  background: white;
}

button.scale-item {
  width: 100%;
}

button.scale-item:hover {
  border-color: #aac9c6;
  background: #f5fbfa;
}

.scale-number {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 4px;
  color: var(--navy);
  background: var(--navy-soft);
  font-size: 12px;
  font-weight: 800;
}

.scale-item strong,
.scale-item small {
  display: block;
}

.scale-item small {
  margin-top: 3px;
  color: var(--muted);
}

.scale-state {
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
}

.scale-state.complete {
  color: var(--green);
}

.privacy-tip {
  margin: 22px 0 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.scale-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 13px;
}

.scale-heading {
  margin-bottom: 26px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.question-section {
  margin-bottom: 26px;
}

.question-section h3 {
  margin-bottom: 14px;
  font-size: 16px;
}

.question-block {
  margin: 0 0 12px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfc;
}

.question-block legend,
.question-label {
  width: 100%;
  margin-bottom: 12px;
  padding: 0;
  color: #263b40;
  font-weight: 700;
  line-height: 1.55;
}

.question-index {
  display: inline-grid;
  width: 24px;
  height: 24px;
  margin-right: 8px;
  place-items: center;
  border-radius: 3px;
  color: var(--teal-dark);
  background: #e5f2f0;
  font-size: 12px;
}

.choice-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.choice-list.yesno {
  grid-template-columns: repeat(2, minmax(0, 160px));
}

.choice-option {
  position: relative;
}

.choice-option input {
  position: absolute;
  opacity: 0;
}

.choice-option span {
  display: flex;
  min-height: 44px;
  padding: 8px 12px;
  align-items: center;
  border: 1px solid #c7d2d4;
  border-radius: 5px;
  color: #455c62;
  background: white;
}

.choice-option input:checked + span {
  border-color: var(--teal);
  color: var(--teal-dark);
  background: #e6f4f2;
  box-shadow: inset 0 0 0 1px var(--teal);
  font-weight: 700;
}

.inline-input {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-input input {
  width: min(240px, 100%);
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #b9c8ca;
  border-radius: 5px;
}

.inline-input span {
  color: var(--muted);
}

.sticky-submit {
  position: sticky;
  bottom: 0;
  padding: 16px 0 max(8px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
}

.complete-screen {
  padding: 48px 12px;
  text-align: center;
}

.complete-mark {
  display: grid;
  width: 64px;
  height: 64px;
  margin: 0 auto 22px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--green);
  font-size: 30px;
}

.complete-screen .button {
  margin-top: 26px;
}

.patient-footer {
  padding: 24px;
  color: #73868b;
  text-align: center;
  font-size: 12px;
}

/* Doctor */
.doctor-page {
  min-height: 100vh;
  background: #edf2f2;
}

.login-layout {
  display: grid;
  width: min(920px, calc(100% - 32px));
  min-height: 520px;
  margin: 8vh auto 0;
  grid-template-columns: 1.15fr 0.85fr;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(17, 59, 74, 0.16);
}

.login-brand {
  display: flex;
  padding: 64px;
  flex-direction: column;
  justify-content: center;
  color: white;
  background: var(--navy);
}

.login-brand h1 {
  margin-bottom: 14px;
  font-size: 36px;
}

.login-brand p:last-child {
  max-width: 380px;
  margin: 0;
  color: #c6d8dc;
  line-height: 1.8;
}

.login-panel {
  display: flex;
  padding: 56px;
  flex-direction: column;
  justify-content: center;
  background: white;
}

.login-panel h2 {
  margin-bottom: 28px;
  font-size: 28px;
}

.workspace {
  min-height: 100vh;
}

.workspace-header {
  display: flex;
  height: 68px;
  padding: 0 28px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #d2dddd;
  background: white;
}

.workspace-brand,
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.workspace-brand strong,
.workspace-brand span {
  display: block;
}

.workspace-brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.header-actions {
  font-size: 14px;
}

.workspace-main {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 34px 0 60px;
}

.page-heading,
.section-heading,
.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.page-heading h1,
.section-heading h2 {
  margin-bottom: 0;
}

.page-heading h1 {
  font-size: 28px;
}

.summary-count {
  color: var(--muted);
  font-size: 14px;
}

.filter-bar {
  display: grid;
  margin: 22px 0 16px;
  grid-template-columns: minmax(260px, 1fr) 150px 150px auto auto;
  gap: 10px;
}

.filter-bar input,
.filter-bar select {
  min-height: 40px;
}

.table-wrap {
  overflow: hidden;
  border: 1px solid #d4dfdf;
  border-radius: 7px;
  background: white;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid #e3eaea;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: #50656a;
  background: #f6f8f8;
  font-size: 12px;
  font-weight: 700;
}

tbody tr:hover {
  background: #f7fbfa;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.patient-cell strong,
.patient-cell span {
  display: block;
}

.patient-cell span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.status-badge {
  display: inline-flex;
  min-height: 26px;
  padding: 3px 8px;
  align-items: center;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge.low,
.status-badge.completed {
  color: var(--green);
  background: var(--green-soft);
}

.status-badge.medium,
.status-badge.in_progress {
  color: var(--amber);
  background: var(--amber-soft);
}

.status-badge.high {
  color: var(--red);
  background: var(--red-soft);
}

.table-action {
  border: 0;
  color: var(--teal);
  background: transparent;
  font-weight: 700;
}

.empty-state {
  padding: 70px 20px;
  color: var(--muted);
  text-align: center;
}

.detail-topbar {
  margin-bottom: 20px;
}

#report-area {
  padding: 36px;
  border: 1px solid #d4dfdf;
  border-radius: 7px;
  background: white;
}

.report-header {
  padding-bottom: 22px;
  border-bottom: 2px solid var(--navy);
  text-align: center;
}

.report-header p {
  margin-bottom: 6px;
  color: var(--navy);
  font-weight: 700;
}

.report-header h1 {
  margin-bottom: 8px;
  font-size: 26px;
}

.report-header span {
  color: var(--muted);
  font-size: 12px;
}

.patient-summary {
  display: grid;
  margin: 24px 0 30px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.summary-item {
  padding: 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.summary-item span,
.summary-item strong {
  display: block;
}

.summary-item span {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.result-grid {
  display: grid;
  margin-top: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.result-card {
  min-height: 138px;
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 4px solid #a7b7ba;
  border-radius: 5px;
}

.result-card.low {
  border-top-color: var(--green);
}

.result-card.medium {
  border-top-color: var(--amber);
}

.result-card.high {
  border-top-color: var(--red);
}

.result-card.pending {
  color: var(--muted);
  background: #f6f8f8;
}

.result-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.result-card h3 {
  margin-bottom: 3px;
  font-size: 17px;
}

.result-card small {
  color: var(--muted);
}

.score-value {
  color: var(--navy);
  font-size: 26px;
  font-weight: 800;
}

.result-card p {
  margin: 18px 0 0;
  color: #53686d;
  font-size: 13px;
  line-height: 1.5;
}

.answer-details {
  margin-top: 30px;
}

.answer-panel {
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: white;
}

.answer-panel summary {
  display: flex;
  padding: 14px 16px;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 700;
}

.answer-list {
  margin: 0;
  padding: 0 16px 12px;
  list-style: none;
}

.answer-list li {
  display: grid;
  padding: 9px 0;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 0.45fr);
  gap: 20px;
  border-top: 1px solid #edf1f1;
  font-size: 13px;
}

.answer-list span:last-child {
  color: var(--teal-dark);
  font-weight: 700;
}

.note-section {
  display: grid;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  gap: 10px;
}

.note-section textarea {
  min-height: 100px;
  resize: vertical;
}

.note-section .button {
  justify-self: start;
}

.report-disclaimer {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

dialog {
  width: min(430px, calc(100% - 32px));
  padding: 30px;
  border: 0;
  border-radius: 7px;
  box-shadow: 0 22px 70px rgba(17, 59, 74, 0.28);
}

dialog::backdrop {
  background: rgba(12, 31, 37, 0.58);
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 24px;
}

dialog h2 {
  margin-bottom: 20px;
}

#qr-dialog {
  text-align: center;
}

#qr-image {
  display: block;
  width: 260px;
  max-width: 100%;
  margin: 0 auto 16px;
}

.qr-url {
  overflow-wrap: anywhere;
  color: var(--teal);
  font-size: 13px;
}

@media (max-width: 760px) {
  .patient-page {
    background:
      linear-gradient(180deg, var(--navy) 0, var(--navy) 148px, var(--surface-soft) 148px);
  }

  .patient-header {
    height: 112px;
  }

  .patient-header h1 {
    font-size: 20px;
  }

  .patient-shell {
    padding: 22px 18px;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .segmented {
    grid-template-columns: 1fr;
  }

  .choice-list {
    grid-template-columns: 1fr;
  }

  .choice-list.yesno {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .question-block {
    padding: 14px;
  }

  .login-layout {
    display: block;
    margin-top: 18px;
  }

  .login-brand {
    min-height: 220px;
    padding: 32px;
  }

  .login-brand .brand-mark {
    margin-bottom: 18px;
  }

  .login-brand h1 {
    font-size: 28px;
  }

  .login-panel {
    padding: 34px 28px;
  }

  .workspace-header {
    height: auto;
    padding: 14px 16px;
    align-items: flex-start;
    gap: 12px;
  }

  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .workspace-main {
    width: min(100% - 24px, 1280px);
    padding-top: 24px;
  }

  .filter-bar {
    grid-template-columns: 1fr 1fr;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .table-wrap {
    overflow-x: auto;
  }

  table {
    min-width: 860px;
  }

  #report-area {
    padding: 22px 16px;
  }

  .patient-summary,
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .answer-list li {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

@media print {
  body {
    background: white;
  }

  .workspace-header,
  .detail-topbar,
  .note-section button,
  .toast {
    display: none !important;
  }

  .workspace-main {
    width: 100%;
    padding: 0;
  }

  #report-area {
    padding: 0;
    border: 0;
  }

  .answer-panel:not([open]) {
    display: none;
  }

  .result-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
