/* Full-width clinic patient workspace — consumes website/tokens.css + portal tint vars from clinic-portal.css */

:root {
  /* Surface-local aliases on shared tokens */
  --bg: var(--bg-page);
  --blue: var(--accent);
  --red: var(--danger);
  --orange: var(--warn);
  --shadow: var(--shadow-sm);
  --radius: var(--radius-md);
  --grid: var(--line);
  --track: var(--surface-2);
  --max-w: 1440px;

  /* Chart series — light app chart.*; dark remap in clinic-theme.css (be-31). */
  --ws-chart-glucose: #4caf50;
  --ws-chart-hr: #ff5252;
  --ws-chart-bmr: #90caf9;
  --ws-chart-steps: #42a5f5;
  --ws-chart-workout: #1565c0;
  --ws-chart-eaten: #ff9800;
  --ws-chart-total: #4caf50;
  --ws-chart-balance: #37474f;
  --ws-chart-fat: #ff5252;
  --ws-chart-muscle: #4caf50;
  --ws-chart-weight: #2196f3;
  --ws-chart-visceral: #7b1fa2;
  --ws-chart-ldl: #c62828;
  --ws-chart-tg: #ff9800;
  --ws-chart-hdl: #2e7d32;
  --ws-chart-total-chol: #1565c0;
  --ws-chart-grid: #e8eaed;
  --ws-chart-muted: #6b7280;
  --ws-chart-glucose-band: #e3f2fd;
  --ws-chart-surplus-zone: #ffebee;
  --ws-chart-deficit-zone: #e8f5e9;
  --ws-chart-deficit-dot: #2e7d32;
  --ws-chart-surplus-dot: #c62828;
  --ws-chart-meal: #ff9800;
  --ws-chart-axis: #7c7c7c;
  --ws-chip-active-bg: var(--accent-light);
  --ws-chip-active-line: #90caf9;
  --ws-bubble-user: var(--accent-light);
  --ws-nudge-bg: var(--portal-warn-bg, #fffbeb);
  --ws-nudge-line: var(--portal-warn-line, #fde68a);
  --ws-nudge-ink: var(--portal-warn-ink, #854d0e);
  --ws-clinical-bg: var(--portal-ok-bg, #ecfdf3);
  --ws-clinical-line: var(--portal-ok-line, #bbf7d0);
  --ws-clinical-ink: var(--portal-ok-ink, #14532d);
  --ws-flag-ink: var(--portal-warn-ink, #854d0e);
  --ws-over-ink: var(--portal-err-ink, #991b1b);
  --ws-hover: color-mix(in srgb, var(--text) 4%, transparent);
  --ws-overlay: rgba(0, 0, 0, 0.45);
  --ws-modal-shadow: var(--shadow-lg);
  --ws-strip-title: var(--muted);
  --ws-chrome-icon: var(--muted);
}

* { box-sizing: border-box; }

body.clinic-workspace {
  margin: 0;
  font-family: var(--font-text);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3,
.ws-btn,
.ws-tab,
.badge {
  font-family: var(--font-display);
}

.ws-chrome {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
}

.ws-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--grid);
  padding: 12px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.ws-topbar a,
.ws-topbar .ws-back {
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  padding: 4px 2px;
  flex-shrink: 0;
}
/* Shared lead column — “← Clinic portal” and “My data” reserve the same
   width so the patient name starts on the same x on both pages. Sized for
   the longest locale back label; shorter labels leave trailing slack. */
.ws-topbar--case > .ws-case-lead {
  box-sizing: border-box;
  flex: 0 0 13.5rem;
  width: 13.5rem;
  max-width: 13.5rem;
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  padding: 4px 2px;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--accent-ink);
  text-decoration: none;
}
.ws-topbar h1 { margin: 0; font-size: 1.15rem; font-weight: 700; }
.ws-topbar .meta { color: var(--muted); font-size: 0.88rem; flex: 1; min-width: 200px; }
.ws-topbar .badge {
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--accent-light);
  color: var(--navy);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

/* Clinic case: back + one identity/stats strip + refresh — no second banner row. */
.ws-topbar--case {
  gap: 10px 14px;
  padding: 10px 20px;
  flex-wrap: nowrap;
}
.ws-topbar--case .ws-case-header {
  /* Do not grow — keeps Sync + Refresh tight against the body stats. */
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  max-width: none;
}
.ws-topbar--case .ws-case-header[hidden] { display: none !important; }
.ws-case-header-inner {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px 12px;
  min-width: 0;
}
.ws-topbar--case .ws-banner-name {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 14rem;
}
.ws-banner-identity {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.ws-topbar--case .chip {
  cursor: default;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill, 999px);
  flex-shrink: 0;
}
.ws-topbar--case .ws-banner-stats {
  margin-inline-start: 0;
  flex-shrink: 1;
  min-width: 0;
}
.ws-topbar--case .ws-banner-sync {
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin-inline-start: 0;
  flex-shrink: 0;
}
.ws-topbar--case #refresh-snapshot-btn,
.ws-topbar--case .sync-status-hint {
  flex-shrink: 0;
  margin-inline-start: 0;
}
.ws-topbar--case .ws-case-brand {
  /* Width/type come from .ws-case-lead — keep this for older markup. */
  flex-shrink: 0;
}
.ws-topbar--case .ws-case-readonly {
  cursor: default;
  flex-shrink: 0;
}
.ws-topbar--case .ws-case-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  margin-inline-start: auto;
  flex-shrink: 0;
}
.ws-topbar--case .ws-case-actions .portal-select {
  min-height: var(--tap-min);
}

/* Account-only overflow — keeps the case strip as dense as clinic (theme + Refresh). */
.ws-account-menu {
  position: relative;
  flex-shrink: 0;
}
.ws-account-menu > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.ws-account-menu > summary::-webkit-details-marker { display: none; }
.ws-account-menu-panel {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 6px);
  min-width: 13rem;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--grid);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  z-index: 40;
}
.ws-account-menu-item {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: start;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  min-height: var(--tap-min);
}
.ws-account-menu-item:hover {
  background: var(--surface-2, var(--bg));
}
.ws-account-menu-danger {
  color: var(--danger);
}
.ws-btn {
  border: 1px solid var(--grid);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.88rem;
  min-height: var(--tap-min);
}
.ws-btn.primary { background: var(--navy); color: var(--num-fg); border-color: var(--navy); }
.ws-btn.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--grid);
}
.ws-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.sync-status-hint { color: var(--danger); font-weight: 600; }

/* Patient banner — sticky under topbar, every tab (be-28) */
/* Account self-view: second-row banner with the same case-header markup. */
.ws-banner .ws-case-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
}
.ws-banner .ws-banner-identity { color: var(--muted); font-size: 0.82rem; }
.ws-banner .ws-banner-sync { color: var(--muted); font-size: 0.82rem; }
/* Legacy second-row banner (unused — account + clinic both use .ws-case-header). */
.ws-banner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 10px 24px 12px;
  border-bottom: 1px solid var(--grid);
  background: var(--surface);
}
.ws-banner[hidden] { display: none !important; }
.ws-banner-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
}
.ws-banner-id {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.ws-banner-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
}
.ws-banner-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: 0.82rem;
  color: var(--muted);
}
.ws-banner-sep { opacity: 0.45; }
.ws-banner-sync { font-variant-numeric: tabular-nums; }
.ws-banner .chip {
  cursor: default;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill, 999px);
}
/* Compact body stats — replaces the full-width Withings card on Dashboard */
.ws-banner-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 2px 0;
  margin-inline-start: auto;
  padding: 4px 6px;
  background: var(--surface-2);
  border: 1px solid var(--grid);
  border-radius: 10px;
}
.ws-stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 4.5rem;
  padding: 2px 12px;
  border-inline-start: 1px solid var(--grid);
}
.ws-stat:first-of-type { border-inline-start: none; }
.ws-stat-lbl {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.2;
}
.ws-stat-val {
  font-size: 0.95rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.25;
  white-space: nowrap;
}
.ws-stat-val small {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
}
.ws-stat-pct {
  margin-inline-start: 2px;
  color: var(--accent-ink) !important;
}
.ws-stat-empty .ws-stat-val {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.chip.ok {
  color: var(--ws-clinical-ink);
  background: var(--ws-clinical-bg);
  border-color: var(--ws-clinical-line);
}
.chip.soon {
  color: var(--ws-nudge-ink);
  background: var(--ws-nudge-bg);
  border-color: var(--ws-nudge-line);
}
.chip.off {
  color: var(--muted);
  background: var(--surface-2);
  border-color: var(--grid);
}

.ws-inline-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--portal-err-bg, color-mix(in srgb, var(--danger) 12%, transparent));
  color: var(--portal-err-ink, var(--danger));
  font-size: 0.85rem;
  font-weight: 600;
}
.ws-inline-error[hidden] { display: none !important; }
.ws-inline-error .ws-btn { min-height: 28px; padding: 4px 10px; font-size: 0.8rem; }

.mentors-note { margin-top: 12px; }
.lipid-need-more { margin-top: 12px; text-align: center; }
.meal-chips-empty { padding: 12px 0; }
.prose-col { max-width: 72ch; }

.macro-fill-p { background: var(--ws-chart-steps); }
.macro-fill-c { background: var(--orange); }
.macro-fill-f { background: var(--ws-chart-hr); }
.macro-fill-fi { background: var(--ws-chart-glucose); }
.macro-fill-kcal { background: var(--ws-chart-workout); }
.macro-fill-net { background: var(--orange); }
.macro-fill-h2o { background: var(--ws-chart-bmr); }
.macro-fill-treat { background: #8D6E63; }
.macro-fill-over { background: var(--red); }
.treat-food-hint {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.35;
}
.ws-tabs {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 12px 24px 0;
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  border-bottom: 1px solid var(--grid);
}
.ws-tabs[hidden] {
  display: none !important;
}
.ws-tab {
  border: none;
  background: transparent;
  padding: 10px 18px;
  border-radius: 8px 8px 0 0;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  flex: 0 0 auto;
  min-height: var(--tap-min);
}
.ws-tab.active {
  background: var(--surface);
  color: var(--accent-ink);
  box-shadow: var(--shadow);
}
.ws-tab-divider {
  width: 1px;
  align-self: stretch;
  margin: 4px 6px;
  background: var(--grid);
  flex: 0 0 auto;
}
.ws-tab-live {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 1px 6px;
  border-radius: var(--radius-pill, 999px);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ws-clinical-ink);
  background: var(--ws-clinical-bg);
  border: 1px solid var(--ws-clinical-line);
  vertical-align: middle;
}

.ws-skeleton {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ws-skel-block {
  height: 88px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg) 0%, var(--surface) 45%, var(--bg) 90%);
  background-size: 200% 100%;
  animation: ws-skel-pulse 1.2s ease-in-out infinite;
}
.ws-skel-block:nth-child(2) { height: 140px; }
.ws-skel-block:nth-child(3) { height: 200px; }
@keyframes ws-skel-pulse {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ws-skel-block {
    animation: none;
    background: var(--bg);
  }
}

.ws-main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

.ws-panel {
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px 28px;
  min-height: 400px;
}

.ws-panel-fill {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0;
}

.ws-panel-fill #tab-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ws-error { color: var(--red); padding: 12px 24px; max-width: var(--max-w); margin: 0 auto; }

/* Kept for /account/ gate cards — do not delete */
.card {
  background: var(--surface-2);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card h2, .card h3 { margin: 0 0 12px; font-size: 1rem; }
.card .sub { color: var(--muted); font-size: 0.82rem; margin: -8px 0 12px; }

.chart-wrap { width: 100%; overflow: hidden; }
/* Charts use LTR coordinates (x=0 is left). Under clinicLocale he/ar the page is
   dir=rtl, and SVG inherits that — axis labels at x=4 extend leftward out of the
   viewBox so only the trailing digit shows (a column of "0"s from 60/80/100…). */
.metabolic-svg,
.trend-svg,
.energy-svg,
.lipid-chart-box svg {
  direction: ltr;
  unicode-bidi: isolate;
}
.metabolic-svg { width: 100%; display: block; }
.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.chip {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--grid);
  background: var(--surface);
  cursor: pointer;
}
.chip.active { background: var(--ws-chip-active-bg); color: var(--accent-ink); border-color: var(--ws-chip-active-line); }
.chip.disabled, .chip:disabled { opacity: 0.35; cursor: default; }

.trend-wrap { width: 100%; }
.trend-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 10px;
}
.trend-chips { justify-content: center; margin-bottom: 10px; }
.trend-chip { border-radius: 999px; padding: 6px 12px; font-size: 12px; }
.trend-svg { display: block; width: 100%; }
.trend-legend { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.trend-legend-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trend-leg {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9.5px;
  font-weight: 500;
  color: var(--muted);
  min-width: 0;
}
.trend-leg i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
  align-items: stretch;
  height: 520px;
  max-height: 520px;
  overflow: hidden;
}
.chart-half {
  min-width: 0;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}
.chart-half #trend-host,
.chart-half #energy-host {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.trend-wrap,
.energy-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}
.trend-wrap .chart-wrap,
.energy-wrap .chart-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.trend-svg,
.energy-svg {
  display: block;
  width: 100%;
  max-height: 100%;
}
@media (max-width: 1100px) {
  .charts-row { grid-template-columns: 1fr; }
  .chart-half { margin-bottom: 16px; }
  .profile-layout,
  .food-log-grid,
  .nutrition-layout {
    grid-template-columns: 1fr;
  }
  .nutrition-rail {
    flex-direction: row;
    max-height: none;
    overflow-x: auto;
  }
  .nutrition-rail .nutrition-chip {
    min-width: 140px;
    width: auto;
  }
}

.energy-wrap { width: 100%; flex: 1; display: flex; flex-direction: column; min-height: 100%; }

.lipid-tab-card { width: 100%; }
.lab-chart-details {
  margin-top: 12px;
  border: 1px solid var(--grid);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}
.lab-chart-details > summary.lab-chart-summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
}
.lab-chart-details > summary.lab-chart-summary::-webkit-details-marker { display: none; }
.lab-chart-details > summary.lab-chart-summary::after {
  content: '▾';
  float: right;
  opacity: 0.7;
}
.lab-chart-details[open] > summary.lab-chart-summary::after { content: '▴'; }
.lab-chart-details .lipid-tab-card {
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  padding: 0 10px 12px;
}
.marker-picker-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 4px 0 6px;
}
.marker-picker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.marker-filter,
.marker-pick {
  flex: 1 1 160px;
  min-width: 140px;
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--grid);
  background: var(--bg, var(--background, #fff));
  color: var(--text);
}
.marker-default-hint { margin: 0 0 8px; font-size: 0.78rem; }
.lipid-wrap {
  padding: 10px 4px 4px;
  border-top: 1px solid var(--grid);
}
.lipid-wrap.rtl .lipid-title,
.lipid-wrap.rtl .lipid-disclaimer { direction: rtl; }
.lipid-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-align: center;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.lipid-chart-box {
  width: 100%;
  max-width: 600px;
  margin-inline: auto;
  overflow: hidden;
  display: flex;
  justify-content: center;
}
.lipid-chart-box svg { display: block; max-width: 100%; width: 100%; height: auto; }
.lipid-disclaimer {
  font-size: 0.68rem;
  color: var(--muted);
  text-align: center;
  margin-top: 6px;
}
.energy-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 4px;
}
.energy-subtitle {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 10px;
}
.energy-svg { display: block; width: 100%; }

.macro-row {
  display: grid;
  grid-template-columns: 16px 1fr 72px;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.82rem;
}
.macro-row .track { height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; }
.macro-row .fill { height: 100%; border-radius: 4px; }

/* Chat */
.chat-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  min-height: 520px;
}
@media (max-width: 720px) {
  .chat-layout { grid-template-columns: 1fr; }

  .ws-banner { padding: 10px 16px 12px; }
  .ws-banner-inner,
  .ws-banner .ws-case-header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .ws-banner-stats {
    margin-inline-start: 0;
    width: 100%;
    justify-content: space-between;
  }
  .ws-stat {
    flex: 1 1 auto;
    min-width: 0;
    padding: 2px 8px;
  }

  .ws-topbar {
    padding: 12px 16px;
    gap: 10px 12px;
  }
  .ws-topbar--case {
    flex-wrap: wrap;
    padding: 10px 16px;
  }
  .ws-topbar--case .ws-case-header {
    flex: 1 1 100%;
    order: 2;
  }
  .ws-topbar--case .ws-case-header-inner {
    flex-wrap: wrap;
  }
  .ws-topbar--case .ws-banner-name {
    max-width: none;
  }
  .ws-topbar--case .ws-banner-stats {
    flex: 1 1 100%;
    width: 100%;
    justify-content: space-between;
  }
  .ws-topbar--case .ws-banner-sync {
    flex: 1 1 auto;
    margin-inline-start: 0;
  }
  .ws-topbar--case .ws-case-actions {
    order: 3;
    margin-inline-start: 0;
    width: 100%;
    justify-content: flex-end;
  }
  .ws-topbar h1 {
    flex: 1 1 100%;
    font-size: 1.05rem;
    word-break: break-word;
  }
  .ws-topbar .meta {
    flex: 1 1 100%;
    min-width: 0;
  }
  .ws-tabs {
    padding: 8px 16px 0;
  }
  .ws-main {
    padding: 0 16px 16px;
  }
  .ws-panel {
    padding: 16px;
    min-height: 280px;
  }
  .charts-row {
    height: auto;
    max-height: none;
    overflow: visible;
  }
  .chart-half {
    height: auto;
    max-height: none;
  }
}

.mentor-nav { display: flex; flex-direction: column; gap: 6px; }
.mentor-nav button {
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--grid);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
}
.mentor-nav button.active { border-color: var(--navy); background: var(--accent-light); color: var(--navy); }

.chat-thread {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 360px;
  max-height: 56vh;
}
.bubble {
  max-width: 85%;
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.bubble.user { margin-left: auto; background: var(--ws-bubble-user); border-bottom-right-radius: 4px; }
.bubble.assistant { background: var(--surface); border: 1px solid var(--grid); border-bottom-left-radius: 4px; }
.bubble .time { font-size: 0.7rem; color: var(--muted); margin-top: 6px; }

.bubble.thinking {
  opacity: 0.95;
  border-style: dashed;
}
.chat-thinking-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-style: italic;
  font-size: 0.92rem;
}
.chat-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--grid);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: chat-spin 0.75s linear infinite;
  flex-shrink: 0;
}
@keyframes chat-spin {
  to { transform: rotate(360deg); }
}

.chat-compose {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--grid);
  background: var(--surface);
}
.chat-compose textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
  border: 1px solid var(--grid);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.92rem;
}

/* Rules */
.rules-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 12px;
  overflow-y: auto;
}
.rules-intro { margin: 0; flex-shrink: 0; }
.rules-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 12px;
}
.rules-fold {
  border: 1px solid var(--grid);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.rules-fold-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: none;
  background: var(--surface-2);
  cursor: pointer;
  font: inherit;
}
.rules-fold-toggle:hover { background: var(--ws-hover); }
.rules-fold-title { font-weight: 700; flex-shrink: 0; }
.rules-fold-preview {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rules-fold-meta {
  font-size: 0.82rem;
  color: var(--muted);
  flex-shrink: 0;
}
.rules-fold-chevron {
  color: var(--muted);
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
}
.rules-fold.is-open .rules-fold-toggle { border-bottom: 1px solid var(--grid); }
.rules-fold-body { padding: 12px 14px 14px; }
.rules-fold:not(.is-open) .rules-fold-body { display: none; }
.rules-fold.is-open .rules-fold-preview { display: none; }
.rules-editor-section .rules-fold-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rules-editor-section textarea,
.rules-editor-section #rules-raw {
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--grid);
  border-radius: 10px;
  padding: 12px;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
  overflow-y: hidden;
  box-sizing: border-box;
}
.rules-actions {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  align-items: center;
}
.rules-constraints { flex-shrink: 0; }
.rules-constraints li { margin-bottom: 6px; font-size: 0.9rem; }
.rules-hint { font-size: 0.82rem; color: var(--muted); margin: 0; flex-shrink: 0; }
.rules-history-section.is-open .rules-history-panel {
  max-height: none;
  overflow: visible;
  border-top: none;
  padding-top: 0;
}
.rules-history-panel {
  flex-shrink: 0;
  max-height: min(28vh, 220px);
  overflow-y: auto;
}
.rules-history-title { margin: 0 0 10px; font-size: 1rem; }
.rules-history-list { list-style: none; margin: 0; padding: 0; }
.rules-history-item { border-bottom: 1px solid var(--grid); }
.rules-history-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 12px 0;
  cursor: pointer;
  font: inherit;
}
.rules-history-btn:hover { background: var(--ws-hover); }
.rules-history-meta { display: block; font-weight: 600; font-size: 0.88rem; }
.rules-history-preview { display: block; font-size: 0.82rem; color: var(--muted); margin-top: 4px; }
.rules-history-detail { margin: 0 0 12px; padding: 12px; background: var(--surface-2); border-radius: 8px; }
.rules-history-detail.hidden { display: none; }
.rules-history-detail .rules-raw {
  margin: 0;
  max-height: none;
  overflow: visible;
}
.rules-restore-btn { margin-top: 12px; }

/* Labs table */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th, .data-table td { border-bottom: 1px solid var(--grid); padding: 10px 8px; text-align: left; }
.lab-panel { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--grid); }

/* Verbatim PDF label under the canonical English name (prompt99 / lab i18n). */
.lab-name-original {
  font-size: 0.82em;
  color: var(--muted);
  unicode-bidi: isolate;
}

.lab-ref-range {
  font-size: 0.82em;
  color: var(--muted);
  unicode-bidi: isolate;
}

.empty { color: var(--muted); text-align: center; padding: 32px 16px; }

/* Nutrition reports — list rail + body (be-28) */
.nutrition-tab-wrap { width: 100%; }
.nutrition-card {
  background: var(--surface);
  border: 1px solid var(--grid);
  border-radius: 24px;
  padding: 14px 18px 16px;
  box-shadow: var(--shadow);
}
.nutrition-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.nutrition-rail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(70vh, 640px);
  overflow-y: auto;
}
.nutrition-rail .nutrition-chip {
  max-width: none;
  width: 100%;
}
.nutrition-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  margin: 0 0 6px;
}
.nutrition-summary-line {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin: 0 0 12px;
}
.nutrition-chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}
.nutrition-chip {
  flex: 0 0 auto;
  min-width: 100px;
  max-width: 160px;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--grid);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.nutrition-chip:hover { opacity: 0.85; border-color: var(--blue); }
.nutrition-chip-active {
  border-color: var(--ws-clinical-ink);
  background: var(--ws-clinical-bg);
}
.nutrition-chip-selected { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.nutrition-chip-date {
  display: block;
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.nutrition-chip-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-top: 1px;
  line-height: 1.3;
}
.nutrition-chip-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--ws-clinical-ink);
  margin-top: 2px;
}
.nutrition-chip-preview {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.nutrition-chip-view {
  display: block;
  font-size: 10px;
  color: var(--blue);
  margin-top: 2px;
}
.nutrition-detail-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}
.nutrition-detail-meta {
  margin: 4px 0 12px;
  font-size: 13px;
  color: var(--muted);
}
.nutrition-detail-panel {
  border-top: none;
  padding-top: 0;
}
.nutrition-detail-body {
  margin: 0;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--grid);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: none;
  overflow: visible;
}
.nutrition-rtl .nutrition-detail-body { direction: rtl; text-align: right; }
.nutrition-rtl .nutrition-detail-title { direction: rtl; text-align: right; }

/* Dashboard cards */
.snapshot-note { font-size: 0.82rem; color: var(--muted); margin: 0 0 16px; }
.snapshot-note + .chat-rules-note { margin-top: -10px; }
.nudge-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--ws-nudge-bg);
  border: 1px solid var(--ws-nudge-line);
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.88rem;
}
.nudge-count { font-weight: 800; color: var(--accent-ink); }
.nudge-text { flex: 1; color: var(--ws-nudge-ink); }

.dash-card {
  background: var(--surface);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.metabolic-card { padding: 14px 16px 10px; }

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.metabolic-chips {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.metabolic-chips .chip { flex-shrink: 0; }

.date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
}
.date-nav .date-label { min-width: 180px; text-align: center; color: var(--text); }
.nav-arrow {
  width: 32px;
  height: 32px;
  border: 1px solid var(--grid);
  border-radius: 8px;
  background: var(--surface);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.nav-arrow:disabled { opacity: 0.35; cursor: default; }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}
.chart-legend .leg::before {
  content: '●';
  margin-right: 4px;
}
.chart-legend .leg.glucose::before { color: var(--ws-chart-glucose); }
.chart-legend .leg.hr::before { color: var(--ws-chart-hr); }
.chart-legend .leg.bmr::before { color: var(--ws-chart-bmr); }
.chart-legend .leg.steps::before { color: var(--ws-chart-steps); }
.chart-legend .leg.workout::before { color: var(--ws-chart-workout); }

.withings-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.withings-logo { font-weight: 800; font-size: 0.95rem; color: var(--text); }
.withings-head .chip { cursor: default; }
.body-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  text-align: center;
}
.body-metrics-row .lbl { font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.body-metrics-row .val { font-size: 1.15rem; font-weight: 800; margin-top: 4px; }
.bmr-row { margin-top: 10px; font-size: 0.88rem; color: var(--muted); }

.food-log-card .food-log-title {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: center;
  margin-bottom: 8px;
}
.food-log-card .food-date-nav {
  justify-content: center;
  margin-bottom: 12px;
}
.food-log-card .energy-lines { margin: 10px 0 14px; }
.food-log-card .energy-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 0.92rem;
}
.food-log-card .energy-num {
  font-size: 1.35rem;
  font-weight: 800;
  min-width: 4.5rem;
}
.food-log-card .energy-label { color: var(--muted); font-size: 0.88rem; }
.food-log-card .energy-target { color: var(--muted); }
.food-log-card .balance-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
}
.food-log-card .balance-pill.deficit {
  background: rgba(76, 175, 80, 0.15);
  color: var(--ws-clinical-ink);
}
.food-log-card .balance-pill.surplus {
  background: rgba(255, 152, 0, 0.15);
  color: var(--ws-flag-ink);
}
.food-log-card .balance-pill .energy-num { font-size: 1.1rem; min-width: auto; }
.food-log-card .balance-pill .energy-label { font-size: 0.88rem; font-weight: 700; }
.food-log-card .macro-bars { margin: 12px 0 16px; }
.food-log-card .macro-row {
  display: grid;
  grid-template-columns: 36px 1fr minmax(88px, auto);
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.82rem;
}
.food-log-card .macro-row span:last-child {
  font-variant-numeric: tabular-nums;
  text-align: end;
  white-space: nowrap;
}
.food-log-card .macro-row .track {
  height: 8px;
  background: var(--track);
  border-radius: 4px;
  overflow: hidden;
}
.food-log-card .macro-row .fill { height: 100%; border-radius: 4px; }
.food-log-card .macro-over { color: var(--ws-over-ink); font-weight: 700; }
.food-log-panel { width: 100%; }
.food-log-grid {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.meal-chips-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  padding: 4px 2px 8px;
}
.meal-chip {
  width: 100%;
  padding: 12px 10px;
  border: 1px solid var(--grid);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.meal-chip:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.meal-chip .chip-time { display: block; font-size: 0.72rem; color: var(--muted); margin-bottom: 4px; }
.meal-chip .chip-label { display: block; font-weight: 700; font-size: 0.9rem; margin-bottom: 6px; }
.meal-chip .chip-kcal { display: block; font-size: 0.85rem; color: var(--accent-ink); font-weight: 600; margin-bottom: 8px; }
.meal-chip .chip-view { font-size: 0.78rem; color: var(--accent-ink); }
.meal-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--ws-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.meal-modal-card {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: var(--ws-modal-shadow);
}
.meal-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.meal-modal-title { font-size: 1.25rem; font-weight: 800; }
.meal-modal-time { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }
.meal-modal-close {
  border: none;
  background: var(--surface-2);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}
.meal-modal-note {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 12px;
  font-style: italic;
}
.meal-modal-plate {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  margin: 0 0 12px;
  background: var(--surface-2);
}
/* class display:block must not override the initial hidden slot before fetch */
.meal-modal-plate[hidden] {
  display: none !important;
}
.meal-items-card {
  border: 1px solid var(--grid);
  border-radius: 12px;
  overflow: hidden;
}
.meal-item-row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--grid);
}
.meal-item-row:last-child { border-bottom: none; }
.meal-item-row.flagged { background: rgba(255, 152, 0, 0.08); }
.meal-item-name { font-weight: 700; font-size: 0.95rem; }
.meal-item-rule { font-size: 0.78rem; color: var(--ws-flag-ink); margin-top: 4px; }
.meal-item-grams { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }
.meal-item-metrics { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.meal-item-kcal { font-weight: 700; color: var(--accent-ink); font-size: 0.9rem; }
.meal-item-macros { font-size: 0.78rem; color: var(--muted); }
.meal-item-total { background: var(--surface-2); }
.meal-modal-readonly {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 14px 0 0;
}
.food-log-card .muted { color: var(--muted); font-size: 0.82rem; }

.group-card .collapse-row {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--grid);
}
.group-card .collapse-row:last-child { border-bottom: none; }
.group-card .row-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  width: 1.35rem;
  height: 1.35rem;
  overflow: hidden; /* never let a multi-glyph row paint over the title */
}
.group-card .row-icon .ws-icon {
  width: 1.25rem;
  height: 1.25rem;
}
.ws-icon {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}
.ws-icon-row {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.ws-icon-row .ws-icon {
  width: 1.05rem;
  height: 1.05rem;
}
.profile-group .collapse-info .sub:empty { display: none; }
.mentor-pill .ws-icon,
.coach-mentor-title .ws-icon,
.mentor-pick .ws-icon {
  display: inline-block;
  vertical-align: -0.2em;
  width: 1rem;
  height: 1rem;
  margin-inline-end: 2px;
}
.coach-mentor-title {
  display: flex;
  align-items: center;
  gap: 6px;
}
.group-card .sub { display: block; font-size: 0.82rem; color: var(--muted); margin-top: 4px; line-height: 1.35; }
.profile-tab-card { width: 100%; }
.profile-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.profile-col {
  background: var(--surface);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.profile-group { padding: 4px 0; }
.profile-group .group-divider {
  height: 1px;
  background: var(--grid);
  margin: 0 16px;
}
.profile-group .collapse-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.profile-group .collapse-header:hover { background: var(--ws-hover); }
.profile-group .collapse-info { flex: 1; min-width: 0; }
.profile-group .collapse-title {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
}
.profile-group .collapse-chevron {
  flex-shrink: 0;
  font-size: 1.25rem;
  color: var(--muted);
  font-weight: 300;
  line-height: 1;
}
.profile-group .collapse-body {
  padding: 0 16px 16px 52px;
}
.profile-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 0;
  font-size: 0.88rem;
}
.profile-dl dt { color: var(--muted); font-weight: 600; margin: 0; }
.profile-dl dd { margin: 0; }
.reasoning-block, .rules-raw, .coach-summary, .coach-line {
  font-size: 0.88rem;
  line-height: 1.45;
  margin: 12px 0 0;
  white-space: pre-wrap;
}
.rules-summary { font-weight: 600; font-size: 0.9rem; margin: 0 0 8px; }
.rules-list { margin: 8px 0; padding-left: 1.1rem; font-size: 0.88rem; }
.rules-list li { margin-bottom: 4px; }
.mentor-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.mentor-pill {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--grid);
  font-size: 0.85rem;
  background: var(--surface-2);
}
.mentor-pill.active { border-color: var(--accent); background: var(--accent-light); }
.macro-updated { display: block; font-size: 0.75rem; color: var(--accent-ink); margin-top: 4px; font-weight: 600; }
.profile-macros { margin: 0 0 10px; }
.profile-macros .macro-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.82rem;
}
.profile-macros .macro-row .track {
  height: 6px;
  background: var(--track);
  border-radius: 3px;
  overflow: hidden;
}
.profile-macros .macro-row .fill { height: 100%; border-radius: 3px; }
.macro-kcal-row {
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
  margin: 4px 0 10px;
}
.macro-diet-label {
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  margin: 0 0 8px;
}
.clinical-profile-banner {
  background: var(--ws-clinical-bg);
  border: 1px solid var(--ws-clinical-line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 12px;
}
.clinical-profile-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ws-clinical-ink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.clinical-profile-text {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 6px;
}
.clinical-pcf-row {
  padding-top: 6px;
  margin-top: 4px;
  border-top: 1px solid var(--ws-clinical-line);
}
.clinical-pcf-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ws-clinical-ink);
  margin-bottom: 2px;
}
.clinical-pcf-short {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 2px;
}
.clinical-pcf-detail {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.35;
}
.clinical-order {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
  margin-top: 4px;
}
.coach-mentor-block { margin-top: 14px; }
.coach-mentor-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 6px; }
.coach-list-label { font-size: 0.75rem; font-weight: 700; color: var(--muted); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.coach-mentor-block ul { margin: 0; padding-left: 1.1rem; font-size: 0.88rem; }
.coach-mentor-block li { margin-bottom: 4px; }
.coach-progress, .coach-meta { font-size: 0.78rem; color: var(--muted); margin: 10px 0 0; }
.action-items { list-style: none; padding: 0; margin: 10px 0 0; font-size: 0.88rem; }
.action-items li { padding: 6px 0; border-bottom: 1px solid var(--grid); }
.action-items li.done { color: var(--muted); text-decoration: line-through; }

/* Treatment markers (be-41) */
.treat-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 18px; }
.treat-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  background: var(--surface, var(--bg));
}
.treat-row-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.treat-meta { font-size: 0.85rem; color: var(--muted); }
.treat-lab { font-size: 0.8rem; color: var(--blue); }
.treat-note { margin: 4px 0 0; font-size: 0.85rem; line-height: 1.35; }
.macro-edit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.macro-edit-row input[type='number'] {
  width: 5.5rem;
  direction: ltr;
  font-weight: 600;
}
.macro-edit-row select { max-width: 9rem; }
.macro-training { margin-top: 8px; font-size: 0.85rem; }
.macro-training summary { cursor: pointer; color: var(--muted); }
.treat-add {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  padding: 14px;
  border: 1px dashed var(--grid);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.treat-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.treat-field select,
.treat-field input {
  font: inherit;
  font-weight: 500;
  color: var(--ws-clinical-ink, inherit);
  padding: 8px 10px;
  border: 1px solid var(--grid);
  border-radius: 8px;
  background: var(--bg);
}
html[dir='rtl'] .rules-plates-section .treat-field select {
  direction: rtl;
  text-align: right;
}
.treat-field-wide { grid-column: 1 / -1; }
.treat-unit { font-weight: 600; margin-top: 4px; }
#treat-add-btn { grid-column: 1 / -1; justify-self: start; }
@media (max-width: 640px) {
  .treat-add { grid-template-columns: 1fr; }
  .treat-row { flex-direction: column; }
}

/* prompt117 — original lab PDF vs parsed table */
.lab-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 8px;
}
.lab-panel-head h3 { margin: 0; }
.lab-pdf-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.lab-pdf-btn {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
.lab-pdf-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: var(--ws-overlay, rgba(0, 0, 0, 0.45));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.lab-pdf-card {
  background: var(--surface);
  border-radius: 16px;
  width: min(1100px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--ws-modal-shadow, 0 16px 40px rgba(0,0,0,0.2));
  padding: 16px 16px 12px;
}
.lab-pdf-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.lab-pdf-title { font-size: 1.1rem; font-weight: 800; }
.lab-pdf-sub { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }
.lab-pdf-close {
  font: inherit;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--muted);
}
.lab-pdf-hint { font-size: 0.82rem; color: var(--muted); margin: 8px 0 12px; }
.lab-pdf-split {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 12px;
  min-height: 0;
  flex: 1;
}
.lab-pdf-frame {
  width: 100%;
  height: min(70vh, 640px);
  border: 1px solid var(--grid);
  border-radius: 10px;
  background: #fff;
}
.lab-pdf-table { overflow: auto; max-height: min(70vh, 640px); }
@media (max-width: 800px) {
  .lab-pdf-split { grid-template-columns: 1fr; }
  .lab-pdf-frame { height: 42vh; }
}
