:root {
  color-scheme: light;
  --ink: #242e31;
  --muted: #626f72;
  --teal: #176b62;
  --teal-dark: #10534c;
  --teal-soft: #edf6f3;
  --line: #dce4e1;
  --paper: #f6f8f7;
  --white: #fff;
  --danger: #a52f3f;
  --warning: #7c5a17;
  font-family: "DM Sans", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0;
  color: var(--ink);
  background: var(--white);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 90px; }
body { margin: 0; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: var(--teal); text-underline-offset: 3px; }
button, a, label, p, h1, h2, h3, dt, dd { overflow-wrap: anywhere; }
svg { width: 19px; height: 19px; flex: 0 0 auto; stroke-width: 1.7; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 26px; line-height: 1.25; font-weight: 650; }
h2 { margin-bottom: 0; font-size: 21px; line-height: 1.3; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; line-height: 1.5; }
:focus-visible { outline: 3px solid #318b80; outline-offset: 3px; }
.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; }
.skip-link { position: fixed; z-index: 20; top: 8px; left: 8px; background: white; padding: 10px 18px; transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.portal-header { height: 72px; position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px; padding: 0 36px; border-bottom: 1px solid var(--line); background: var(--white); }
.portal-brand { flex: 0 0 auto; }
.portal-brand img { width: 174px; height: 32px; object-fit: contain; }
.header-divider { height: 24px; width: 1px; background: var(--line); }
.header-title { color: var(--muted); font-size: 13px; }
.header-actions, .heading-actions { display: flex; align-items: center; gap: 12px; }
.header-actions { margin-left: auto; }
.language-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 5px; gap: 2px; }
.language-switch button { border: 0; border-radius: 3px; background: transparent; min-height: 32px; min-width: 40px; padding: 4px 8px; color: var(--muted); font-size: 12px; font-weight: 650; }
.language-switch button[aria-pressed="true"] { background: var(--teal-soft); color: var(--teal-dark); }
.icon-button { display: inline-flex; justify-content: center; align-items: center; flex: 0 0 auto; width: 38px; height: 38px; padding: 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--white); color: var(--muted); text-decoration: none; }
.icon-button:hover { background: var(--paper); color: var(--teal); }
.button { min-height: 40px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 9px 16px; border: 1px solid transparent; border-radius: 5px; font-size: 13px; line-height: 1.5; font-weight: 650; }
.button.primary { background: var(--teal); color: white; }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { background: white; color: var(--ink); border-color: #c9d6d1; }
.button.secondary:hover { background: var(--paper); }
.full-width { width: 100%; }
.text-button { border: 0; padding: 4px 0; background: none; color: var(--teal); text-decoration: underline; text-underline-offset: 3px; font-size: 13px; }
.notice { background: #f5f7f6; border-left: 3px solid #98b1a9; padding: 11px 14px; color: #445b53; font-size: 13px; }
.notice.error { color: var(--danger); background: #fff3f4; border-color: #bf5362; }
.notice.warning { background: #fcf8ed; color: var(--warning); border-color: #bf9e57; }
.global-notice { max-width: 1100px; margin: 18px auto 0; }
.boot-state { min-height: 400px; display: flex; justify-content: center; align-items: center; gap: 12px; color: var(--muted); }
.boot-state p { margin: 0; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.auth-shell { width: min(440px, calc(100% - 40px)); margin: 48px auto 64px; }
.auth-heading { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.section-symbol { width: 48px; height: 48px; border: 1px solid #c6ded4; border-radius: 6px; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; }
.section-symbol svg { width: 23px; height: 23px; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 10px; font-weight: 650; line-height: 1.5; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.auth-tabs button { border: 0; border-bottom: 2px solid transparent; padding: 10px; background: white; color: var(--muted); font-weight: 600; }
.auth-tabs button[aria-pressed="true"] { color: var(--teal); border-bottom-color: var(--teal); }
.mail-status-line { display: flex; align-items: flex-start; gap: 8px; }
.mail-status-line .notice { flex: 1; margin-bottom: 18px; }
.auth-footer { margin: 28px 0 0; padding-top: 20px; display: flex; align-items: flex-start; gap: 9px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { font-size: 14px; font-weight: 650; padding: 0; margin-bottom: 14px; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; font-weight: 600; color: #4a5859; }
.auth-shell .field { margin-bottom: 18px; }
input:not([type="checkbox"]), select, textarea { width: 100%; min-width: 0; min-height: 41px; border: 1px solid #cdd9d4; border-radius: 4px; background: white; padding: 9px 11px; color: var(--ink); line-height: 1.5; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); }
input:disabled, textarea:disabled, select:disabled { background: var(--paper); }
input[type="checkbox"] { accent-color: var(--teal); width: 17px; height: 17px; margin: 3px 0 0; flex: 0 0 auto; }
.password-row { position: relative; }
.password-row input { padding-right: 46px; }
.password-row .icon-button { position: absolute; top: 2px; right: 2px; border: 0; background: transparent; }
.code-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.field-note { font-size: 12px; color: var(--muted); margin: 0; }
.check-field { display: flex; align-items: flex-start; gap: 10px; margin: 18px 0; font-size: 12px; cursor: pointer; }
.check-field strong { display: block; font-weight: 550; }
.check-field small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.form-status { margin: 10px 0 0; color: var(--teal-dark); font-size: 12px; min-height: 0; }
.form-status:empty { display: none; }
.form-status.error { color: var(--danger); }
#forgot-password, #back-login { margin-top: 16px; }
.workspace { width: min(1360px, 100%); display: grid; grid-template-columns: 228px minmax(0,1fr); margin: 0 auto; }
.sidebar { position: sticky; top: 72px; align-self: start; height: calc(100dvh - 72px); min-height: 410px; border-right: 1px solid var(--line); padding: 28px 18px; display: flex; flex-direction: column; background: #fafbfa; }
.member-identity { display: flex; align-items: center; gap: 10px; padding: 0 2px 25px; min-width: 0; }
.member-avatar { width: 33px; height: 36px; border-radius: 5px; background: #e9eeeb; display: grid; place-items: center; color: #5e7268; flex: 0 0 auto; }
.member-identity > div { min-width: 0; }
.member-identity strong { font-size: 12px; display: block; overflow-wrap: anywhere; }
.member-identity span:not(.member-avatar) { display: block; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.workspace-nav { display: grid; gap: 5px; }
.workspace-nav a { display: flex; gap: 10px; align-items: center; min-height: 44px; padding: 10px 12px; border-radius: 4px; color: #546262; text-decoration: none; font-size: 12px; font-weight: 550; }
.workspace-nav a:hover { background: #edf1ee; }
.workspace-nav a[aria-current] { background: #e5f0eb; color: var(--teal-dark); }
.workspace-nav svg { width: 17px; height: 17px; }
.sidebar-note { padding: 24px 10px 0; margin-top: auto; color: var(--muted); }
.sidebar-note svg { color: #718a80; margin-bottom: 9px; }
.sidebar-note p { font-size: 11px; }
.sidebar-privacy { display: flex; align-items: center; gap: 8px; padding: 4px 10px; font-size: 11px; }
.sidebar-privacy svg { width: 13px; height: 13px; }
.workspace-content { min-width: 0; padding: 32px 42px 0; }
.workspace-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 25px; }
.status-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--teal-dark); background: var(--teal-soft); border: 1px solid #d3e8de; border-radius: 4px; padding: 4px 8px; line-height: 1.4; }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--teal); }
.account-summary { display: grid; grid-template-columns: 1fr .65fr 1.25fr; padding: 16px 0; margin: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); gap: 20px; }
dt { color: var(--muted); font-size: 11px; }
dd { margin: 5px 0 0; font-size: 13px; font-weight: 550; }
.workspace-section { padding: 32px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 20px; }
.workspace-section:last-child { border-bottom: 0; padding-bottom: 48px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
.section-heading > svg { color: #7c9287; width: 24px; height: 24px; }
.section-index { margin: 0 0 6px; font-size: 10px; color: #748279; font-weight: 550; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 17px 22px; }
#health-note { margin-top: 12px; }
.health-consent { max-width: 740px; margin: 20px 0; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.section-note { color: var(--muted); font-size: 12px; margin-bottom: 20px; max-width: 860px; }
.list-state { padding: 20px 0; font-size: 13px; color: var(--muted); }
.list-state:empty { display: none; }
.list-state.error { color: var(--danger); }
.message-list { max-height: 480px; overflow-y: auto; overscroll-behavior: contain; display: grid; align-content: start; gap: 16px; padding: 2px 3px; }
.message-list:not(:empty) { padding: 16px 3px 22px; }
.message { max-width: 86%; justify-self: start; min-width: 0; }
.message.patient { justify-self: end; }
.message-meta { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; font-size: 10px; margin-bottom: 5px; color: var(--muted); }
.message.patient .message-meta { justify-content: flex-end; }
.message-meta strong { color: #52645b; font-weight: 550; }
.message-body { border: 1px solid var(--line); background: var(--paper); border-radius: 5px; padding: 12px 14px; margin: 0; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.patient .message-body { border-color: #d7e8df; background: #f0f7f3; }
.message-composer { border-top: 1px solid var(--line); padding-top: 18px; }
.composer-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 10px; }
.composer-actions small { color: var(--muted); font-size: 11px; }
.privacy-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; margin: 0 0 22px; }
.privacy-row h3 { margin-bottom: 5px; }
.privacy-row p { max-width: 700px; font-size: 12px; color: var(--muted); margin: 0; }
.quiet-label { color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 3px 7px; font-size: 10px; flex: 0 0 auto; }
.switch { position: relative; display: block; flex: 0 0 auto; width: 40px; height: 24px; cursor: pointer; }
.switch input { position: absolute; margin: 0; width: 40px; height: 24px; opacity: 0; cursor: pointer; }
.switch span { display: block; height: 24px; border-radius: 20px; background: #b2bcb6; pointer-events: none; transition: background .15s; }
.switch span::before { content: ""; display: block; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: white; transition: transform .15s; }
.switch input:checked + span { background: var(--teal); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 3px solid #318b80; outline-offset: 4px; }
#preferences .section-note { margin: 20px 0 0; }
.referral-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; margin: 24px 0 16px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.referral-summary dd { font-size: 21px; font-variant-numeric: tabular-nums; }
.policy-note { color: var(--muted); font-size: 12px; margin-bottom: 28px; }
.referral-form-grid { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.referral-form-grid .field { flex: 1 1 160px; }
.referral-form-grid button { flex: 0 1 auto; }
.subheading { margin: 28px 0 12px; }
.referral-links { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.referral-link { min-width: 0; border: 1px solid var(--line); border-radius: 6px; padding: 14px; }
.link-heading { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; align-items: flex-start; }
.link-heading h4 { font-size: 13px; margin: 0; }
.link-heading p { font-size: 11px; color: var(--muted); margin: 3px 0 0; }
.link-url { display: flex; gap: 8px; align-items: center; }
.link-url input { min-height: 36px; font-size: 11px; color: #5c7168; background: #fafcfb; }
.link-url .icon-button { width: 36px; height: 36px; }
.link-metrics { display: flex; flex-wrap: wrap; gap: 16px; font-size: 11px; color: var(--muted); margin: 12px 0 0; }
.link-metrics strong { color: var(--ink); }
.empty-state { color: var(--muted); font-size: 12px; padding: 18px 0; margin: 0; }
.referral-links > .empty-state { grid-column: 1 / -1; }
.conversion-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 12px; }
.conversion-table th { text-align: left; color: var(--muted); font-size: 10px; font-weight: 550; background: var(--paper); }
.conversion-table td, .conversion-table th { padding: 12px 9px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; vertical-align: top; }
.conversion-table th:last-child, .conversion-table td:last-child { text-align: right; }
.portal-footer { padding: 20px 36px; border-top: 1px solid var(--line); color: var(--muted); display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 20px; font-size: 11px; }
@media (min-width: 1440px) {
  .workspace-content { padding-inline: 54px; }
}
@media (max-width: 1000px) {
  .portal-header { padding-inline: 22px; gap: 18px; }
  .workspace { grid-template-columns: 192px minmax(0,1fr); }
  .sidebar { padding-inline: 12px; }
  .workspace-content { padding: 28px 24px 0; }
  .workspace-nav a { padding-inline: 9px; gap: 8px; }
  .referral-summary dd { font-size: 18px; }
}
@media (max-width: 760px) {
  html { scroll-padding-top: 132px; }
  .portal-header { height: 64px; padding-inline: 18px; gap: 12px; }
  .portal-brand img { width: 142px; height: 30px; }
  .header-title, .header-divider, .home-link { display: none; }
  .header-actions { gap: 9px; }
  .workspace { display: block; }
  .sidebar { top: 64px; height: auto; min-height: 0; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 14px; z-index: 8; background: white; }
  .member-identity, .sidebar-note, .sidebar-privacy { display: none; }
  .workspace-nav { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 4px; }
  .workspace-nav a { min-height: 46px; padding: 5px 3px; flex-direction: column; gap: 3px; text-align: center; font-size: 10px; line-height: 1.3; }
  .workspace-nav svg { width: 16px; height: 16px; }
  .workspace-content { padding: 24px 20px 0; }
  .workspace-heading { gap: 12px; }
  h1 { font-size: 23px; }
  h2 { font-size: 20px; }
  .workspace-section { padding-block: 28px; }
  .section-heading { margin-bottom: 20px; }
  .global-notice { margin: 12px 18px; }
  .portal-footer { padding-inline: 20px; justify-content: flex-start; gap: 14px; }
  .auth-shell { margin-top: 32px; }
}
@media (max-width: 480px) {
  .portal-header { padding-inline: 14px; }
  .portal-brand img { width: 124px; }
  .language-switch button { min-width: 34px; padding-inline: 6px; }
  .header-actions { gap: 7px; }
  .form-grid { grid-template-columns: minmax(0,1fr); gap: 16px; }
  .account-summary { grid-template-columns: 1fr 1fr; gap: 15px; }
  .account-summary > div:last-child { grid-column: 1 / -1; }
  .workspace-heading .status-tag { font-size: 10px; padding-inline: 6px; }
  .referral-summary { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
  .referral-links { grid-template-columns: minmax(0,1fr); }
  .privacy-row { gap: 16px; }
  .message { max-width: 94%; }
  .conversion-table th, .conversion-table td { padding: 9px 4px; font-size: 10px; }
  .conversion-table .status-tag { padding: 3px; font-size: 10px; }
  input:not([type="checkbox"]), select, textarea { font-size: 16px; }
  .auth-shell { width: calc(100% - 36px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { transition: none !important; }
  .spinner { animation: none; }
}
