:root {
  --color-bg: #f6f7f9;
  --color-card: #ffffff;
  --color-border: #dfe3e8;
  --color-text: #1f2933;
  --color-muted: #64748b;
  --color-primary: #0d9488;
  --color-primary-hover: #0f766e;
  --color-error: #b91c1c;
  --color-error-bg: #fef2f2;
  --color-safety: #b91c1c;
  --color-safety-bg: #fef2f2;
  --color-tab-bg: #e6f4f1;
  --color-tab-bg-hover: #cfe9e3;
  --brand-teal: #1a6a5c;
  --brand-gold: #c9a24e;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 20px 80px;
}

.page-narrow {
  max-width: 420px;
}

h1 {
  font-size: 1.75rem;
  margin-bottom: 4px;
}

.subtitle {
  color: var(--color-muted);
  margin-top: 0;
}

#welcome-line {
  color: var(--color-text);
  font-weight: 700;
  font-size: 1.05rem;
}

.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 24px;
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-top: 16px;
  margin-bottom: 4px;
}

label:first-of-type {
  margin-top: 0;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.hint {
  color: var(--color-muted);
  font-size: 0.85rem;
  margin-top: 8px;
}

button {
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 24px;
}

button:hover {
  background: var(--color-primary-hover);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Secondary action button — outlined teal, paired with a filled primary
   (e.g. "Final & submit" + "Save for Later" on the intake form). */
button.btn-secondary {
  background: none;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}
button.btn-secondary:hover {
  background: var(--color-tab-bg);
  color: var(--color-primary-hover);
}

/* Quiet auto-save status line above the intake form's action buttons. */
.autosave-status {
  margin-top: 16px;
  margin-bottom: 0;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.error {
  color: var(--color-error);
  background: var(--color-error-bg);
  border: 1px solid var(--color-error);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.9rem;
  margin-top: 16px;
}

.note {
  color: var(--color-muted);
  font-size: 0.85rem;
  margin-top: 24px;
}

.auth-choice:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.choice-btn {
  width: 100%;
  background: var(--color-card);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  text-align: left;
  margin-top: 0;
}

.choice-btn:hover {
  background: var(--color-bg);
}

.choice-btn strong {
  display: block;
  font-size: 1rem;
}

.choice-btn span {
  display: block;
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-top: 2px;
}

.link-button {
  background: none;
  border: none;
  color: var(--color-primary);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0;
  margin-top: 16px;
  cursor: pointer;
}

.link-button:hover {
  background: none;
  text-decoration: underline;
}

section.section {
  margin-top: 40px;
}

section.section h2 {
  font-size: 1.25rem;
  border-bottom: 2px solid var(--color-border);
  padding-bottom: 8px;
}

section.section p.section-intro {
  color: var(--color-muted);
  font-size: 0.9rem;
}

/* Section dividers injected mid-form by GENERAL_FIELDS section_header
   entries (e.g. "Health Indicators", "Food Habits") — separate them from
   the field row above. h2 variants pick up the section.section h2
   border-bottom automatically; h3 variants (subheadings) stay lighter. */
.general-section-title {
  margin-top: 36px;
}
#general-fields h3.general-section-title {
  font-size: 1.05rem;
  margin-bottom: 4px;
}

/* Intake form: each section header sits in a soft teal band so the long
   questionnaire is easy to scan section by section. Scoped to #intake-form
   so other pages keep their plain underlined headers. */
#intake-form section.section h2,
#intake-form h2.general-section-title,
#intake-form h3.general-section-title,
#intake-form .hormone-section h3,
#intake-form .hormone-part2-group h4 {
  background: var(--color-tab-bg);
  color: var(--color-primary-hover);
  padding: 10px 14px;
  border-radius: 8px;
  border-bottom: none;
  margin-bottom: 18px;
  /* Bleed the band outward by its own horizontal padding so the header
     TEXT lines up with the field labels/content below it, while the tinted
     band keeps its inset breathing room. */
  margin-left: -14px;
  margin-right: -14px;
}

/* Intake form intro panel — a soft teal card matching the portal tint
   (and the header bands above) instead of plain white, so the opening
   note reads as part of the brand. */
#intake-form .intake-intro {
  background: var(--color-tab-bg);
  border-color: var(--color-tab-bg-hover);
}

/* Non-card intake sections (Patient Health Questionnaire, Eating habits,
   Consent) get the same horizontal inset as the carded sections, so every
   section header band — and all the content beneath it — shares one aligned
   column all the way down the form. */
#intake-form section.section:not(.card) {
  padding-left: 24px;
  padding-right: 24px;
}

fieldset.question {
  border: none;
  border-top: 1px solid var(--color-border);
  padding: 16px 0;
  margin: 0;
}

fieldset.question legend {
  font-weight: 500;
  padding: 0;
  white-space: normal;
  width: 100%;
}

.scale-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-top: 10px;
}

.scale-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  font-size: 0.9rem;
  margin: 0;
}

.scale-option input {
  margin: 0;
}

.consent-text {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 16px 20px;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--color-text);
}

.consent-text p:first-child {
  margin-top: 0;
}

.consent-text ol,
.consent-text ul {
  padding-left: 20px;
}

.consent-text li {
  margin-bottom: 6px;
}

.consent-box {
  background: #f9fafb;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 24px;
}

.consent-box label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 400;
  margin: 0;
}

.consent-box input {
  margin-top: 4px;
}

.safety-banner {
  background: var(--color-safety-bg);
  border: 1px solid var(--color-safety);
  color: var(--color-safety);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 24px;
}

.safety-banner h3 {
  margin-top: 0;
}

.results-card {
  margin-top: 24px;
}

.results-card dl:not([hidden]) {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0;
}

.results-card dt {
  color: var(--color-muted);
}

.results-card dd {
  margin: 0;
  font-weight: 600;
}

/* Brand masthead — the practice wordmark, topmost on every page, above the
   nav tabs, on a deep-teal band matching Dr Anjali Hooda's logo. When the
   real logo asset is saved to /logo.png it replaces the text wordmark.
   Placement variants (center/right) are opt-in modifier classes. */
.masthead {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--brand-teal);
  border-radius: 14px;
  padding: 16px 22px;
  margin-bottom: 18px;
}

.masthead-center { justify-content: center; }
.masthead-right { justify-content: flex-end; }

/* Background treatments — the teal band is optional; the wordmark switches to
   teal (from white) on the lighter treatments so it stays legible. */
.masthead-plain {
  background: transparent;
  border-radius: 0;
  padding: 0;
}
.masthead-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
}
.masthead-plain .brand-wordmark,
.masthead-card .brand-wordmark {
  color: var(--brand-teal);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-logo {
  height: 44px;
  width: auto;
  display: block;
}

.brand-wordmark {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.1;
}

.brand-md {
  font-size: 0.6em;
  font-weight: 600;
  color: var(--brand-gold);
  margin-left: 6px;
  letter-spacing: 0.1em;
}

.top-bar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.top-bar a {
  color: var(--color-muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.top-bar a:hover {
  text-decoration: underline;
}

.top-bar-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.top-bar .top-bar-link {
  color: var(--color-primary);
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius);
  background: var(--color-tab-bg);
  border: 1px solid var(--color-border);
}

.top-bar .top-bar-link:hover {
  background: var(--color-tab-bg-hover);
  border-color: var(--color-primary);
  text-decoration: none;
}

.banner-existing {
  background: #e6f4f1;
  border: 1px solid #b7e0d8;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.9rem;
  margin-top: 16px;
}

.hint-inline {
  color: var(--color-muted);
  font-weight: 400;
  font-size: 0.8rem;
}

.extracted-text {
  max-height: 160px;
  overflow-y: auto;
  background: #f9fafb;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
}

details summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-primary);
  margin-top: 6px;
}

code {
  background: #f1f5f9;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.85em;
}

.chat-log {
  max-height: 500px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px;
  margin-top: 12px;
}

.chat-system {
  align-self: center;
  color: var(--color-muted);
  font-size: 0.75rem;
  background: #eef2f7;
  border-radius: var(--radius);
  padding: 4px 10px;
  max-width: 80%;
  text-align: center;
}

.chat-bubble {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.chat-bubble-theirs {
  align-self: flex-start;
  background: #f1f5f9;
}

.chat-bubble-mine {
  align-self: flex-end;
  background: #d3ebe6;
}

.chat-sender {
  font-weight: 600;
  font-size: 0.75rem;
  margin-bottom: 2px;
  color: var(--color-primary);
}

.chat-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-time {
  font-size: 0.7rem;
  color: var(--color-muted);
  margin-top: 4px;
  text-align: right;
}

.report-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--color-border);
  padding: 12px 0;
}

.report-item label {
  margin: 0;
  font-weight: 400;
  flex: 1;
}

.report-item input[type="file"] {
  font-size: 0.85rem;
  max-width: 55%;
}

.hormone-section {
  padding-top: 16px;
  margin-top: 24px;
}

.hormone-section h3 {
  margin-bottom: 4px;
}

.hormone-part2-group {
  margin-top: 20px;
}

.hormone-part2-group h4 {
  margin-bottom: 4px;
}

.patient-list {
  max-height: 320px;
  overflow-y: auto;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.patient-row {
  display: block;
  width: 100%;
  text-align: left;
  background: #f9fafb;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-weight: 400;
  font-size: 0.9rem;
  padding: 10px 14px;
  margin: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

.patient-row:hover {
  background: #eef2f7;
}

.admin-subsection {
  border-top: 2px solid var(--color-border);
  padding-top: 16px;
  margin-top: 24px;
}

.admin-subsection h3 {
  margin-bottom: 4px;
}

.field-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--color-border);
  padding: 14px 0;
}

.field-row:first-child {
  border-top: none;
  padding-top: 0;
}

/* A showIf row (e.g. Menstrual Cycle when Gender != Female) is toggled via
   the hidden attribute; without this the .field-row display:flex rule would
   win over the UA [hidden] { display:none } and keep it visible. */
.field-row[hidden] {
  display: none;
}

.field-label {
  font-weight: 500;
  font-size: 0.9rem;
  flex: 0 0 42%;
  padding-top: 9px;
}

.field-control {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.field-control input[type="text"],
.field-control input[type="date"],
.field-control textarea {
  width: 100%;
  margin: 0;
}

.field-control select {
  width: auto;
  min-width: 76px;
  margin: 0;
}

.field-control textarea {
  min-height: 60px;
}

.unit-toggle {
  display: flex;
  gap: 10px;
  margin-right: 4px;
}

.unit-toggle .scale-option {
  font-size: 0.85rem;
}

@media (max-width: 600px) {
  .field-row {
    flex-direction: column;
    align-items: stretch;
  }

  .field-label {
    flex: none;
    padding-top: 0;
  }

  .field-control {
    justify-content: flex-start;
  }
}

.conditional-followup {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 2px solid var(--color-border);
}

/* Without this the display:flex above wins over the UA [hidden] rule, so a
   collapsed follow-up (e.g. Salt's amount options before "Yes") would stay
   visible. Applies to the nested third-level box too. */
.conditional-followup[hidden] {
  display: none;
}

.summary-overview {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 32px;
  padding-bottom: 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}

.summary-overview p {
  margin: 0;
  font-size: 0.95rem;
}

#summary-content h3 {
  font-size: 1.05rem;
  margin-top: 28px;
  margin-bottom: 8px;
}

#summary-content h3:first-of-type {
  margin-top: 20px;
}

.summary-list {
  margin: 0;
  padding-left: 20px;
  font-size: 0.9rem;
}

.summary-list li {
  margin-bottom: 6px;
}

.summary-table-scroll {
  overflow-x: auto;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.summary-table-scroll .summary-table {
  width: auto;
  min-width: 100%;
}

.summary-table-scroll .summary-table th,
.summary-table-scroll .summary-table td {
  white-space: nowrap;
}

.summary-table th,
.summary-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-border);
}

.summary-table th {
  color: var(--color-muted);
  font-weight: 600;
}

.next-consultation-editor {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.next-consultation-editor input[type="date"] {
  width: auto;
}

.next-consultation-editor input[type="text"] {
  width: auto;
  flex: 1;
}

.medication-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.medication-editor input,
.medication-editor select {
  width: auto;
  flex: 1 1 120px;
  margin: 0;
}

.medication-editor button {
  flex: 0 0 auto;
}

.medication-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.medication-row:first-child {
  border-top: none;
}

.clinical-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.clinical-name {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.clinical-meta {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin: 4px 0 0;
}

.clinical-right {
  text-align: right;
}

.clinical-label-sm {
  font-size: 0.75rem;
  color: var(--color-muted);
  margin: 0;
}

.clinical-value-sm {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 2px 0 0;
}

.clinical-callout {
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 18px;
}

.clinical-callout-accent {
  background: #e6f1fb;
}

.clinical-callout-danger {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error);
  display: flex;
  align-items: center;
  gap: 10px;
}

.clinical-callout-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-primary);
  margin: 0 0 2px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.clinical-callout p {
  font-size: 0.9rem;
  margin: 0;
}

.clinical-callout-link {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--color-primary);
  text-decoration: none;
  margin-top: 6px;
}

.clinical-callout-link:hover {
  text-decoration: underline;
}

.clinical-callout-danger p {
  font-size: 0.85rem;
  color: var(--color-error);
}

.clinical-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-muted);
  margin: 20px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.clinical-grid4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.clinical-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.clinical-tile {
  background: var(--color-bg);
  border-radius: var(--radius);
  padding: 8px 10px;
}

.clinical-tile-dim {
  opacity: 0.6;
}

.clinical-tile p {
  margin: 0;
}

.clinical-tile-label {
  font-size: 0.7rem;
  color: var(--color-muted);
}

.clinical-tile-value {
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 2px;
}

.clinical-tile-value-sm {
  font-size: 0.8rem;
}

.clinical-score-card {
  background: var(--color-bg);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.clinical-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.clinical-score {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}

.clinical-score span {
  font-size: 0.75rem;
  color: var(--color-muted);
  font-weight: 400;
}

.clinical-interp {
  font-size: 0.75rem;
  margin: 4px 0 0;
  color: var(--color-muted);
}

.clinical-bloodgrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 6px;
}

.clinical-bloodgrid .clinical-tile-label {
  font-size: 0.65rem;
}

.clinical-bloodgrid .clinical-tile-value {
  font-size: 0.85rem;
}

.clinical-link-line {
  display: block;
  font-size: 0.75rem;
  color: var(--color-primary);
  margin: 0 0 8px;
  text-decoration: none;
}

.clinical-link-line:hover {
  text-decoration: underline;
}

.clinical-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.clinical-tag {
  background: #faeeda;
  color: #85510b;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: var(--radius);
}

.clinical-muted-note {
  font-size: 0.75rem;
  color: var(--color-muted);
  margin: 0;
}

table.clinical-history {
  width: 100%;
  font-size: 0.85rem;
  border-collapse: collapse;
  margin-top: 4px;
}

table.clinical-history td {
  padding: 4px 0;
  vertical-align: top;
}

table.clinical-history td:first-child {
  color: var(--color-muted);
  width: 35%;
  padding-right: 12px;
}

.clinical-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
  margin-top: 20px;
}

.clinical-footer-left {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--color-muted);
}

.clinical-dot {
  color: #27500a;
}

.clinical-footer-link {
  font-size: 0.75rem;
  color: var(--color-primary);
  text-decoration: none;
}

.clinical-footer-link:hover {
  text-decoration: underline;
}

@media (max-width: 600px) {
  .clinical-grid4,
  .clinical-bloodgrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .clinical-grid2 {
    grid-template-columns: 1fr;
  }

  .clinical-header {
    flex-direction: column;
    gap: 8px;
  }

  .clinical-right {
    text-align: left;
  }
}

/* ---------- My Summary page ---------- */

.ms-page {
  background:
    radial-gradient(1200px 340px at 50% -120px, #d7f0e8 0%, rgba(215, 240, 232, 0) 70%) no-repeat,
    var(--color-bg);
}

.ms-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 700;
  margin: 30px 0 12px;
}

.ms-sec-icon {
  display: inline-flex;
  color: #0d9488;
}

.ms-sec-icon svg {
  width: 18px;
  height: 18px;
}

/* Flat header baseline on My Summary — page title, patient name, and every
   section title share one font size (starting point; differentiate later). */
.ms-page h1,
.ms-page .ms-header .ms-name,
.ms-page .ms-section-title {
  font-size: 1.15rem;
}

/* Icon chip — color + tinted background are set inline per accent. */
.ms-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.ms-icon svg {
  width: 19px;
  height: 19px;
}

/* --- Header --- */
.ms-header {
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(135deg, #0e7c6f 0%, #0d9488 52%, #17b8a6 100%);
  color: #ffffff;
  border: none;
  border-radius: 18px;
  box-shadow: 0 14px 30px -16px rgba(13, 148, 136, 0.7);
}

.ms-avatar {
  position: relative;
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.3rem;
  cursor: pointer;
}

.ms-avatar-photo {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.ms-avatar-edit {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand-gold);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px #0d9488;
}

.ms-avatar-edit svg {
  width: 13px;
  height: 13px;
}

.ms-header-body {
  min-width: 0;
}

.ms-header .ms-name {
  margin: 0;
  font-size: 1.35rem;
  color: #ffffff;
  border-bottom: none;
  padding-bottom: 0;
}

.ms-header-meta {
  margin: 3px 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.9rem;
}

.ms-member-since {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.78);
}

/* Main concern — single line: "Main concern — Weight Management". */
.ms-concern {
  margin: 12px 0 0;
  font-size: 1.05rem;
  color: #ffffff;
}

.ms-concern-label {
  font-weight: 700;
  letter-spacing: 0.03em;
}

.ms-concern-dash {
  margin: 0 8px;
  opacity: 0.6;
}

.ms-concern-value {
  font-weight: 700;
  text-transform: capitalize;
}

/* --- Stat cards --- */
.ms-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.ms-stat {
  border: none;
  border-radius: 16px;
  padding: 18px;
}

.ms-stat-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.ms-stat-label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
}

.ms-stat-value {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--tone-strong, inherit);
}

.ms-stat-value-muted {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--color-muted);
}

.ms-stat-sub {
  margin: 5px 0 0;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.ms-visit-list {
  margin: 10px 0 0;
  padding-left: 18px;
  font-size: 0.9rem;
  color: var(--color-text);
}

.ms-visit-list li {
  margin: 4px 0;
}

/* --- Biomarker trend charts --- */
.ms-chart-grid {
  display: grid;
  gap: 12px;
}

.ms-markers-link {
  margin-top: 14px;
}
.ms-markers-link a {
  color: var(--color-primary);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
}
.ms-markers-link a:hover {
  text-decoration: underline;
}

/* Content/nav links (e.g. "Back to My Summary") in the brand teal, not the
   browser-default blue. */
.back-link {
  margin-top: 16px;
  font-size: 0.9rem;
}
.back-link a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
}
.back-link a:hover {
  text-decoration: underline;
}

.ms-chart-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 16px 18px;
}

.ms-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.ms-chart-latest {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.ms-chart {
  width: 100%;
  height: auto;
  display: block;
  margin-top: 6px;
}

.ms-grid {
  stroke: var(--color-border);
  stroke-width: 1;
}

.ms-axis {
  fill: var(--color-muted);
  font-size: 13px;
}

.ms-chart-empty {
  margin: 12px 0 4px;
  font-size: 0.85rem;
  color: var(--color-muted);
}

/* --- Medications table --- */
.ms-med-section {
  border: 1px solid #e3eaf3;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f4f8fd 100%);
}

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

.ms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.ms-table th,
.ms-table td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--color-border);
}

.ms-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  font-weight: 700;
}

.ms-table tbody tr:last-child td {
  border-bottom: none;
}

.ms-med-name {
  font-weight: 500;
}

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

.ms-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.ms-badge-blue { background: #eff6ff; color: #1e40af; }
.ms-badge-green { background: #ecfdf5; color: #047857; }
.ms-badge-violet { background: #f5f3ff; color: #6d28d9; }
.ms-badge-amber { background: #fffbeb; color: #b45309; }
.ms-badge-gray { background: #f1f5f9; color: #475569; }

/* --- Biomarker tiles --- */
.ms-biomarker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.ms-tile {
  border: none;
  border-radius: 18px;
  padding: 18px;
}

/* Per-accent pastel tones — card/tile background + its icon chip colours.
   Shared by the stat cards and the biomarker tiles. */
.ms-tone-blue { background: #e8f0ff; --tone-strong: #1d4ed8; }
.ms-tone-blue .ms-icon { background: #cfe0ff; color: #2563eb; }
.ms-tone-teal { background: #ddf5eb; --tone-strong: #0f766e; }
.ms-tone-teal .ms-icon { background: #bfeedd; color: #0d9488; }
.ms-tone-amber { background: #ffece0; --tone-strong: #c2410c; }
.ms-tone-amber .ms-icon { background: #ffd7c2; color: #ea580c; }
.ms-tone-violet { background: #efe9ff; --tone-strong: #6d28d9; }
.ms-tone-violet .ms-icon { background: #e1d7fb; color: #7c3aed; }
.ms-tone-slate { background: #eef2f7; --tone-strong: #334155; }
.ms-tone-slate .ms-icon { background: #dbe2ea; color: #475569; }

.ms-tile-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ms-tile-label {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: #5b6675;
}

.ms-tile-value {
  margin: 14px 0 6px;
  font-size: 1.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--tone-strong, inherit);
}

.ms-tile-unit {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-muted);
  margin-left: 3px;
}

.ms-tile-empty {
  margin: 16px 0 6px;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.ms-spark {
  display: block;
  width: 100%;
  height: 46px;
}

@media (max-width: 600px) {
  .ms-stat-grid,
  .ms-biomarker-grid {
    grid-template-columns: 1fr;
  }
}
