@font-face { font-family:"Tajawal CN"; src:url("/workspace/fonts/tajawal-arabic-400.woff2") format("woff2"); font-style:normal; font-weight:400; font-display:swap; unicode-range:U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF; }
@font-face { font-family:"Tajawal CN"; src:url("/workspace/fonts/tajawal-latin-400.woff2") format("woff2"); font-style:normal; font-weight:400; font-display:swap; unicode-range:U+0000-024F; }
@font-face { font-family:"Tajawal CN"; src:url("/workspace/fonts/tajawal-arabic-500.woff2") format("woff2"); font-style:normal; font-weight:500; font-display:swap; unicode-range:U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF; }
@font-face { font-family:"Tajawal CN"; src:url("/workspace/fonts/tajawal-latin-500.woff2") format("woff2"); font-style:normal; font-weight:500; font-display:swap; unicode-range:U+0000-024F; }
@font-face { font-family:"Cairo CN"; src:url("/workspace/fonts/cairo-arabic-600.woff2") format("woff2"); font-style:normal; font-weight:600; font-display:swap; unicode-range:U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF; }
@font-face { font-family:"Cairo CN"; src:url("/workspace/fonts/cairo-latin-600.woff2") format("woff2"); font-style:normal; font-weight:600; font-display:swap; unicode-range:U+0000-024F; }
@font-face { font-family:"Cairo CN"; src:url("/workspace/fonts/cairo-arabic-700.woff2") format("woff2"); font-style:normal; font-weight:700; font-display:swap; unicode-range:U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF; }
@font-face { font-family:"Cairo CN"; src:url("/workspace/fonts/cairo-latin-700.woff2") format("woff2"); font-style:normal; font-weight:700; font-display:swap; unicode-range:U+0000-024F; }

:root {
  font-family: "Tajawal CN", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: #253544;
  background: #f3f7fa;
  font-synthesis: none;
  --bg: #f3f7fa;
  --surface: #ffffff;
  --surface-2: #e8f3fa;
  --ink: #253544;
  --muted: #4d6071;
  --line: #cbd9e3;
  --brand: #0a5ea8;
  --brand-2: #07365f;
  --brand-deep: #052c4f;
  --accent-red: #b3202b;
  --accent-gold: #d89a24;
  --ok: #28784e;
  --warn: #9b6720;
  --danger: #a23a3a;
  --info: #315f7f;
  --shadow: 0 12px 35px rgba(7, 54, 95, .08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px clamp(16px, 3vw, 34px);
  background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: #fff; border: 1px solid var(--line); overflow: hidden; flex: 0 0 auto; }
.brand-logo { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-title { font-weight: 800; line-height: 1.05; }
.brand-subtitle { margin-top: 3px; color: var(--muted); font-size: .82rem; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.user-chip { max-width: 260px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.user-chip strong, .user-chip small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip small { color: var(--muted); margin-top: 2px; }

.main { width: min(1500px, 100%); margin: 0 auto; padding: 24px clamp(14px, 3vw, 34px) 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.35rem); letter-spacing: -.03em; }
.page-head p { margin: 6px 0 0; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.btn { border: 1px solid transparent; border-radius: 11px; padding: 10px 14px; min-height: 42px; font-weight: 700; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(10,94,168,.22); outline-offset: 2px; }
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-2); }
.btn-secondary { background: white; color: var(--ink); border-color: var(--line); }
.btn-danger { background: #fff2f1; color: var(--danger); border-color: #e9c8c5; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.field { display: grid; gap: 7px; }
.field label { font-weight: 700; font-size: .9rem; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; background: white; color: var(--ink); }
textarea { min-height: 92px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #ffffff, var(--bg) 58%); }
.auth-card { width: min(470px, 100%); padding: 26px; }
.auth-card-wide { width: min(780px, 100%); }
.auth-card h1 { margin: 14px 0 6px; }
.auth-card p { color: var(--muted); }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-foot { margin-top: 18px; font-size: .82rem; color: var(--muted); }

.search-panel { padding: 16px; display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 14px; }
.patient-list { display: grid; gap: 10px; }
.patient-row { padding: 14px; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.patient-row h3 { margin: 0 0 5px; font-size: 1rem; }
.patient-meta { display: flex; gap: 10px 16px; flex-wrap: wrap; color: var(--muted); font-size: .88rem; }

.patient-header { padding: 18px; display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; margin-bottom: 14px; }
.patient-header h1 { margin: 0; font-size: clamp(1.4rem, 3vw, 2rem); }
.patient-id { margin-top: 7px; display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); }
.patient-side { text-align: end; }
.patient-demographics { margin-bottom: 14px; padding: 18px; }
.patient-demographics-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.patient-demographics-head h2 { margin: 0; font-size: 1.08rem; color: var(--brand-2); }
.patient-demographics-head p { margin: 5px 0 0; color: var(--muted); font-size: .86rem; }
.patient-demographics-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.patient-demographic-item { min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbfdfe; }
.patient-demographic-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: .76rem; font-weight: 700; }
.patient-demographic-value { display: block; min-width: 0; color: var(--ink); font-size: .92rem; overflow-wrap: anywhere; }
.badges { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 999px; font-size: .78rem; font-weight: 800; background: var(--surface-2); color: var(--brand-2); }
.badge.ok { background: #e9f6ef; color: var(--ok); }
.badge.warn { background: #fff4df; color: var(--warn); }
.badge.danger { background: #ffeded; color: var(--danger); }
.badge.info { background: #eaf3fa; color: var(--info); }

.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.quick-card { padding: 17px; }
.quick-card h2 { margin: 0 0 12px; font-size: 1.03rem; }
.metric-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.metric-row:first-of-type { border-top: 0; }
.metric-row strong { font-size: 1.15rem; }

.tabs { display: flex; gap: 7px; overflow-x: auto; padding: 6px; margin: 0 0 14px; background: #eee5da; border-radius: 14px; scrollbar-width: thin; }
.tab { white-space: nowrap; padding: 9px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 800; }
.tab.active { background: white; color: var(--brand-2); box-shadow: 0 2px 10px rgba(64,43,31,.08); }

.section { padding: 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 1.15rem; }
.empty { padding: 26px 14px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 13px; background: #fffcf7; }
.item-list { display: grid; gap: 10px; }
.item { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.item-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.item h3 { margin: 0 0 7px; font-size: 1rem; }
.item p { margin: 6px 0; color: var(--muted); }
.item-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.kv { display: grid; grid-template-columns: minmax(110px, .35fr) 1fr; gap: 8px 14px; padding: 7px 0; border-top: 1px solid #eee7dd; }
.kv:first-child { border-top: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
pre.json { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: #f7f3ed; border: 1px solid var(--line); padding: 10px; border-radius: 10px; }

.notice { margin: 12px 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: white; }
.notice.error { border-color: #e9bdb8; background: #fff3f2; color: #7d2929; }
.notice.success { border-color: #b9dcc8; background: #eefaf3; color: #205f3e; }
.notice.info { border-color: #c8dbe8; background: #f0f7fb; color: #2d5874; }
.spinner { width: 18px; height: 18px; border: 2px solid #d4c8bb; border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
.loading { min-height: 180px; display: grid; place-items: center; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 18px; background: rgba(32,24,20,.48); }
.modal { width: min(650px, 100%); max-height: min(90vh, 820px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; box-shadow: 0 24px 70px rgba(0,0,0,.22); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-head h2 { margin: 0; }
.modal-feedback { margin-top: 0; }
.modal-feedback:focus { outline: 3px solid rgba(162,58,58,.22); outline-offset: 2px; }

.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; }
.muted { color: var(--muted); }
.no-margin { margin: 0; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }

[dir="rtl"] .patient-side { text-align: start; }
[dir="rtl"] .user-chip, [dir="rtl"] input, [dir="rtl"] textarea { text-align: right; }

/* v0.2.13 — Secure MFA enrollment and explicit password visibility */
.password-control { position: relative; min-width: 0; }
.password-control input { padding-inline-end: 54px; }
.password-toggle {
  position: absolute;
  inset-inline-end: 5px;
  top: 50%;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
}
.password-toggle:hover { background: var(--surface-2); color: var(--brand-2); }
.password-toggle:focus-visible { outline: 3px solid rgba(10,94,168,.22); outline-offset: 1px; }
.password-toggle svg { pointer-events: none; }
.mfa-enrollment-grid {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  margin: 16px 0;
}
.mfa-qr-frame {
  width: 100%;
  max-width: 280px;
  justify-self: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(63,43,31,.08);
}
.mfa-qr-svg { display: block; width: 100%; height: auto; }
.mfa-setup-field { min-width: 0; }
.mfa-setup-field input { direction: ltr; text-align: left; letter-spacing: .08em; }
.mfa-copy-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 5px; }
.mfa-copy-status { min-height: 1.4em; color: var(--ok); font-size: .86rem; font-weight: 700; }
.mfa-secret-warning { font-weight: 700; }

@media (max-width: 680px) {
  .auth-wrap { padding: 12px; }
  .auth-card { padding: 20px; }
  .mfa-enrollment-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .mfa-qr-frame { max-width: 260px; }
  .mfa-enrollment .form-actions .btn { flex: 1 1 160px; }
}

@media (max-width: 1180px) {
  .patient-demographics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .patient-header { grid-template-columns: 1fr; }
  .patient-side { text-align: start; }
  .patient-demographics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .topbar { align-items: flex-start; }
  .brand-subtitle, .user-chip { display: none; }
  .main { padding-top: 16px; }
  .page-head { align-items: start; flex-direction: column; }
  .search-panel { grid-template-columns: 1fr; }
  .patient-row { grid-template-columns: 1fr; }
  .patient-row .btn { width: 100%; }
  .patient-demographics { padding: 14px; }
  .patient-demographics-head { flex-direction: column; }
  .patient-demographics-grid { grid-template-columns: 1fr; }
  .quick-grid, .grid-2, .grid-3, .form-row { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 3px; }
  .top-actions { gap: 5px; }
  .top-actions .btn { padding-inline: 10px; }
}

/* v0.2.1 — Clinical Workspace UX refinement */
.logout-btn, .back-btn { white-space: nowrap; flex: 0 0 auto; }
.back-btn { display: inline-flex; align-items: center; gap: 6px; }
.back-icon { direction: ltr; unicode-bidi: isolate; flex: 0 0 auto; line-height: 1; }
.back-label { unicode-bidi: plaintext; }
.top-actions select { width: auto; min-width: 72px; }
.session-meta { display: flex; gap: 8px 16px; flex-wrap: wrap; margin: 7px 0; color: var(--muted); font-size: .9rem; }
.clinical-detail-card { margin-top: 10px; padding: 12px; border: 1px solid #e5dace; border-radius: 12px; background: #fbf7f1; }
.pain-flow { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 9px; margin-bottom: 8px; border-bottom: 1px solid #e7ddd2; }
.pain-flow strong { font-size: 1.1rem; color: var(--brand-2); }
.compact-badges { margin-top: 0; margin-bottom: 8px; }
.structured-grid { display: grid; gap: 0; width: 100%; }
.structured-row { display: grid; grid-template-columns: minmax(120px, .36fr) minmax(0, 1fr); gap: 10px 14px; padding: 7px 0; border-top: 1px solid #eee7dd; }
.structured-row:first-child { border-top: 0; }
.structured-key { color: var(--muted); font-size: .88rem; }
.structured-value { min-width: 0; overflow-wrap: anywhere; }
.clinical-list { margin: 3px 0; padding-inline-start: 22px; }
.clinical-list li + li { margin-top: 4px; }
.dose-box { margin-top: 10px; padding: 10px 12px; border: 1px solid #e5dace; border-radius: 11px; background: #fbf7f1; }
.dose-main { display: block; color: var(--brand-2); }
.dose-box .structured-grid { margin-top: 5px; }
.trend-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin-bottom: 14px; }
.trend-card { padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: #fbf7f1; }
.trend-card > strong { display: block; margin-bottom: 9px; }
.trend-values { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.trend-values span:not(.trend-arrow) { display: grid; gap: 2px; }
.trend-values small { color: var(--muted); }
.trend-values b { font-size: 1.1rem; }
.trend-arrow { color: var(--brand); font-weight: 900; }
.trend-foot { margin-top: 9px; font-size: .84rem; }
.document-content { margin-top: 9px; padding: 10px 12px; border: 1px solid #e5dace; border-radius: 11px; background: #fbf7f1; }
[dir="rtl"] .clinical-list { padding-inline-start: 0; padding-inline-end: 22px; }
[dir="rtl"] .structured-key, [dir="rtl"] .structured-value { text-align: right; }

@media (max-width: 680px) {
  .topbar { align-items: center; gap: 8px; }
  .top-actions { flex-wrap: nowrap; min-width: 0; }
  .top-actions select { min-width: 64px; padding-inline: 8px; }
  .logout-btn { min-height: 40px; padding-inline: 9px; font-size: .88rem; }
  .structured-row { grid-template-columns: 1fr; gap: 3px; }
  .pain-flow { align-items: center; }
}

@media (max-width: 430px) {
  .brand-title { font-size: .92rem; }
  .brand-mark { width: 36px; height: 36px; }
  .topbar { padding-inline: 10px; }
  .top-actions { gap: 4px; }
  .top-actions select { min-width: 58px; padding: 8px 6px; }
  .logout-btn { padding: 8px; }
}

/* v0.2.5 — Mobile responsive overflow hotfix
   Keep the page itself within the viewport. Horizontal scrolling is reserved
   for the tabs component only. */
html, body, .shell, .main { max-width: 100%; }
body { overflow-x: hidden; }
.topbar, .topbar > *, .main > *, .patient-header > *, .quick-grid > *, .grid > *, .quick-card, .section, .item, .item-head > *, .metric-row > * { min-width: 0; }
.patient-id span, .metric-row strong, .item h3, .item p { overflow-wrap: anywhere; }
.metric-row strong { max-width: 72%; text-align: end; line-height: 1.35; }

@media (max-width: 900px) {
  .patient-header { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 680px) {
  .search-panel,
  .patient-row,
  .quick-grid,
  .grid-2,
  .grid-3,
  .form-row { grid-template-columns: minmax(0, 1fr); }

  .brand { flex: 1 1 auto; }
  .top-actions { flex: 0 1 auto; max-width: 58%; }
  .top-actions > * { min-width: 0; }
  .patient-header h1 { overflow-wrap: anywhere; }
  .patient-id { min-width: 0; }
  .quick-card { overflow: hidden; }
  .metric-row { min-width: 0; }
  .metric-row strong { min-width: 0; max-width: 68%; overflow-wrap: anywhere; }
  .item-head { flex-wrap: wrap; }
}

@media (max-width: 430px) {
  .main { padding-inline: 10px; }
  .patient-header, .quick-card, .section { padding-inline: 14px; }
  .patient-id { gap: 6px 10px; }
  .metric-row {
    display: grid;
    grid-template-columns: minmax(0, .42fr) minmax(0, .58fr);
    align-items: start;
    gap: 8px;
  }
  .metric-row strong {
    max-width: none;
    font-size: 1rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: normal;
  }
  .topbar { width: 100%; }
  .top-actions { max-width: 62%; }
  .tabs { max-width: 100%; }
}

/* v0.2.6 — Mobile clinical-record containment & mixed-direction hotfix
   The patient list was already responsive in v0.2.5. This patch hardens the
   nested clinical workspace itself: no clinical card may establish a wider
   inline size than the viewport, and mixed Arabic/LTR fixture data may wrap
   without shifting the whole page sideways. */
html { overflow-x: clip; }
#app, .shell, .main {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
}
.patient-header,
.quick-grid,
.quick-card,
.tabs,
.section,
.section-head,
.grid,
.item-list,
.item,
.item-head,
.clinical-detail-card,
.structured-grid,
.structured-row,
.structured-value,
.dose-box,
.trend-grid,
.trend-card,
dl,
.kv,
.kv dt,
.kv dd,
.session-meta,
.badges,
.item-actions,
.pain-flow {
  min-width: 0;
  max-width: 100%;
}
.patient-header h1,
.patient-id span,
.metric-row span,
.metric-row strong,
.item h3,
.item p,
.kv dt,
.kv dd,
.structured-key,
.structured-value,
.session-meta span,
.dose-main,
.clinical-list li,
.trend-card,
.document-content {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
[dir="rtl"] [dir="auto"],
[dir="rtl"] .item p,
[dir="rtl"] .item h3,
[dir="rtl"] .dose-main {
  unicode-bidi: plaintext;
}

@media (max-width: 680px) {
  .main { width: 100%; overflow-x: clip; }
  .patient-header,
  .quick-grid,
  .section,
  .grid,
  .item-list { width: 100%; }

  /* Stack dashboard label/value pairs on phones. This is deliberately more
     conservative than the v0.2.5 split columns and survives long FR/EN data. */
  .metric-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 4px;
  }
  .metric-row strong {
    width: 100%;
    max-width: 100%;
    text-align: start;
  }
  [dir="rtl"] .metric-row strong { text-align: right; }

  .patient-id > span { flex: 1 1 100%; max-width: 100%; }
  .section-head, .pain-flow, .item-head { flex-wrap: wrap; }
  .clinical-detail-card, .dose-box, .document-content { width: 100%; }
  .structured-row, .kv { width: 100%; }
  .trend-grid { grid-template-columns: minmax(0, 1fr); }
  .trend-values { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }

  /* The tabs are the sole intentional horizontal scroller. */
  .tabs {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
  }
}

@media (max-width: 430px) {
  .main { padding-inline: 10px; }
  .patient-header, .quick-card, .section { width: 100%; max-width: 100%; }
  .patient-header h1 { font-size: clamp(1.15rem, 6vw, 1.55rem); }
  .patient-id { width: 100%; }
  .clinical-list { max-width: 100%; }
}


/* v0.2.7 — Tablet portrait clinical readability hotfix
   QA at 768×1024 showed that retaining two clinical summary columns leaves
   the nested Quick Note value column too narrow, forcing FR/EN fixture text
   into letter-by-letter wrapping. Portrait tablets now use one clinical
   content column, while 1024px landscape keeps the efficient two-column
   workspace. Dashboard label/value rows also receive a stable tablet grid so
   labels such as Focus / Precautions are not squeezed by long values. */
@media (min-width: 681px) and (max-width: 900px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .section > .grid-2,
  .grid.grid-2,
  .grid-2 > * {
    min-width: 0;
    max-width: 100%;
  }

  .clinical-detail-card,
  .clinical-detail-card .structured-grid,
  .clinical-detail-card .structured-row,
  .clinical-detail-card .structured-value {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
}

@media (min-width: 681px) and (max-width: 1100px) {
  .metric-row {
    display: grid;
    grid-template-columns: minmax(96px, .32fr) minmax(0, .68fr);
    align-items: start;
    gap: 8px 12px;
  }

  .metric-row > * { min-width: 0; }
  .metric-row strong {
    width: auto;
    max-width: none;
    text-align: end;
    overflow-wrap: anywhere;
    word-break: normal;
  }
}


/* v0.2.8 — Tablet portrait cache & summary readability hotfix
   v0.2.7 was CSS-only, so a browser retaining /workspace/app.css could keep
   the old two-column summary. v0.2.8 cache-busts workspace assets and gives
   the clinical summary a dedicated portrait rule through 1023px. */
@media (orientation: portrait) and (max-width: 1023px) {
  .summary-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
  }

  .summary-grid > .item,
  .summary-grid .clinical-detail-card,
  .summary-grid .structured-grid {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .summary-grid .kv {
    grid-template-columns: minmax(120px, .30fr) minmax(0, 1fr);
  }

  .summary-grid .clinical-detail-card .structured-row {
    grid-template-columns: minmax(105px, .30fr) minmax(0, 1fr);
  }

  .summary-grid .kv dd,
  .summary-grid .structured-value {
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
  }
}

/* v0.2.9 — Pilot Daily Operations */
.section-nav { display: inline-flex; gap: 6px; padding: 5px; margin: 0 0 18px; border: 1px solid var(--line); border-radius: 13px; background: #eee5da; }
.section-nav-btn { border: 0; border-radius: 9px; padding: 9px 14px; background: transparent; color: var(--muted); font-weight: 800; }
.section-nav-btn.active { background: white; color: var(--brand-2); box-shadow: 0 2px 10px rgba(64,43,31,.08); }
.daily-head { align-items: center; }
.day-controls { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.day-controls input[type="date"] { width: auto; min-width: 158px; }
.daily-metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.daily-metric { min-width: 0; padding: 13px; display: grid; gap: 5px; }
.daily-metric span { color: var(--muted); font-size: .78rem; font-weight: 700; }
.daily-metric strong { font-size: 1.15rem; overflow-wrap: anywhere; }
.daily-list { display: grid; gap: 10px; }
.daily-row { display: grid; grid-template-columns: 86px minmax(260px, 1fr) minmax(190px, auto) minmax(240px, auto); gap: 14px; align-items: center; padding: 14px; }
.daily-time { display: grid; gap: 3px; text-align: center; padding-inline-end: 12px; border-inline-end: 1px solid var(--line); }
.daily-time strong { font-size: 1.12rem; color: var(--brand-2); }
.daily-time small { color: var(--muted); }
.daily-info { min-width: 0; }
.daily-info h3 { margin: 0 0 7px; font-size: 1rem; overflow-wrap: anywhere; }
.daily-meta { display: flex; gap: 6px 14px; flex-wrap: wrap; color: var(--muted); font-size: .84rem; }
.daily-meta span { overflow-wrap: anywhere; }
.daily-status { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; justify-content: flex-start; }
.daily-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.daily-actions .btn { min-height: 38px; padding: 8px 11px; font-size: .86rem; }

@media (max-width: 1180px) {
  .daily-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .daily-row { grid-template-columns: 76px minmax(230px, 1fr) minmax(180px, auto); }
  .daily-actions { grid-column: 2 / -1; }
}

@media (max-width: 820px) {
  .daily-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .daily-row { grid-template-columns: 70px minmax(0, 1fr); align-items: start; }
  .daily-status, .daily-actions { grid-column: 2; justify-content: flex-start; }
}

@media (max-width: 560px) {
  .section-nav { display: flex; width: 100%; }
  .section-nav-btn { flex: 1; }
  .day-controls { width: 100%; }
  .day-controls input[type="date"] { flex: 1; min-width: 130px; }
  .daily-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .daily-row { grid-template-columns: 1fr; gap: 10px; }
  .daily-time { display: flex; gap: 8px; align-items: baseline; text-align: start; padding: 0 0 8px; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .daily-status, .daily-actions { grid-column: 1; }
  .daily-actions .btn { flex: 1 1 120px; }
}


/* v0.2.11 — Dynamic Resources & Capacities */
.resource-head { align-items: center; }
.resource-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 14px 0 20px; }
.resource-metric { padding: 14px; display: grid; gap: 5px; min-width: 0; }
.resource-metric span { color: var(--muted); font-size: .8rem; font-weight: 700; }
.resource-metric strong { font-size: 1.25rem; overflow-wrap: anywhere; }
.resource-section { margin-top: 22px; }
.resource-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.resource-section-head > div { display: flex; align-items: center; gap: 8px; min-width: 0; }
.resource-section-head h2 { margin: 0; font-size: 1.15rem; }
.resource-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(285px, 1fr)); gap: 12px; }
.resource-card { padding: 16px; min-width: 0; }
.resource-card.resource-inactive { opacity: .78; background: #fbf8f3; }
.resource-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.resource-card-head > div { min-width: 0; }
.resource-card-head h3 { margin: 0 0 4px; font-size: 1rem; overflow-wrap: anywhere; }
.resource-card-head small { color: var(--muted); overflow-wrap: anywhere; }
.resource-kv { display: grid; gap: 8px; margin: 14px 0 0; }
.resource-kv > div { display: grid; grid-template-columns: minmax(120px, .45fr) minmax(0, 1fr); gap: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.resource-kv dt { color: var(--muted); font-size: .84rem; }
.resource-kv dd { margin: 0; font-weight: 800; text-align: end; overflow-wrap: anywhere; }
.resource-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.check-field { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: white; font-weight: 700; }
.check-field input[type="checkbox"] { width: 18px; height: 18px; margin: 0; flex: 0 0 auto; }
.resource-code-hint { margin: -5px 0 6px; font-size: .82rem; }
@media (max-width: 820px) { .resource-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  .resource-head, .resource-section-head { align-items: stretch; flex-direction: column; }
  .resource-metrics { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .resource-grid { grid-template-columns: minmax(0, 1fr); }
  .resource-card-head { flex-direction: column; }
  .resource-kv > div { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .resource-kv dd { text-align: start; }
  [dir="rtl"] .resource-kv dd { text-align: right; }
  .resource-actions .btn { width: 100%; }
}

/* v0.2.12 — Team & Access Management */
.team-head { align-items: center; }
.team-head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.team-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 14px 0 20px; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.team-card { padding: 16px; min-width: 0; }
.team-card.team-inactive { opacity: .78; background: #fbf8f3; }
.team-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.team-card-head > div:first-child { min-width: 0; }
.team-card-head h3 { margin: 0 0 4px; font-size: 1rem; overflow-wrap: anywhere; }
.team-card-head small { color: var(--muted); overflow-wrap: anywhere; }
.team-card-head .badges { justify-content: flex-end; }
.team-kv { display: grid; gap: 8px; margin: 14px 0 0; }
.team-kv > div { display: grid; grid-template-columns: minmax(120px, .45fr) minmax(0, 1fr); gap: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.team-kv dt { color: var(--muted); font-size: .84rem; }
.team-kv dd { margin: 0; font-weight: 800; text-align: end; overflow-wrap: anywhere; }
.team-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.team-password-hint { margin: -4px 0 8px; font-size: .82rem; }
.team-modal { max-width: 620px; }
@media (max-width: 820px) { .team-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  .team-head, .team-card-head { align-items: stretch; flex-direction: column; }
  .team-head-actions { justify-content: stretch; }
  .team-head-actions .btn { flex: 1; }
  .team-grid { grid-template-columns: minmax(0, 1fr); }
  .team-kv > div { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .team-kv dd { text-align: start; }
  [dir="rtl"] .team-kv dd { text-align: right; }
  .team-actions .btn { flex: 1 1 140px; }
}

/* v0.2.15 — official Centre NASSER identity and local typography */
.brand-title, h1, h2, h3, .btn, strong { font-family: "Cairo CN", "Tajawal CN", sans-serif; }
html[dir="rtl"] body { font-family: "Tajawal CN", sans-serif; }

/* v0.2.17 — patient self-service and explicitly shared documents */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-top: 12px; }
.detail-grid > .item { margin: 0; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.checkbox-row input { width: auto; }
details > summary { cursor: pointer; font-weight: 700; margin: 12px 0; }
@media (max-width: 680px) {
  .detail-grid { grid-template-columns: 1fr; }
}

/* v0.2.18 pilot-readiness: reuse existing cards/metrics while keeping long guard names readable. */
.pilot-readiness-card { padding: 16px; margin: 16px 0 20px; min-width: 0; }
.pilot-readiness-card .muted { overflow-wrap: anywhere; }
.pilot-readiness-metrics { margin-bottom: 12px; }

/* v0.2.19 public booking request queue */
.booking-request-list{display:grid;gap:14px}.booking-request-card{display:grid;gap:12px}.booking-request-kv{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:8px 16px}.booking-request-kv p{margin:0}.booking-request-card .form-actions{flex-wrap:wrap}.team-head-actions select{min-width:180px}

/* v0.2.19-R2 — RDV operational parity: weekly agenda + smart waitlist */
.agenda-week-grid{display:grid;grid-template-columns:repeat(7,minmax(220px,1fr));gap:10px;overflow-x:auto;padding-bottom:8px}.agenda-day{padding:12px;min-width:220px;display:grid;align-content:start;gap:10px}.agenda-day-closed{background:#fbfaf7}.agenda-day-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px}.agenda-day-head h2{font-size:1rem;margin:0}.agenda-day-head small{display:block;margin-top:3px}.agenda-holiday,.agenda-override{display:grid;gap:3px;padding:9px 10px;border-radius:10px;background:#fff6df;border:1px solid #e5bd57}.agenda-override.ok{background:#eaf8f2;border-color:#8ac8b5}.agenda-override.danger{background:#fff0f0;border-color:#d98a8e}.agenda-appointments{display:grid;gap:7px;min-height:100px}.agenda-slot{display:grid;grid-template-columns:52px minmax(0,1fr);gap:8px;padding:9px;border:1px solid var(--line);border-radius:10px;background:white}.agenda-slot>.badge{grid-column:1/-1;justify-self:start}.agenda-slot-time{display:grid;align-content:start}.agenda-slot-time strong{color:var(--brand-2)}.agenda-slot-main{min-width:0;display:grid;gap:2px}.agenda-slot-main strong,.agenda-slot-main small{overflow-wrap:anywhere}.agenda-empty{padding:18px 8px}.agenda-day-actions{display:flex;justify-content:flex-end}.waitlist-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(380px,1fr));gap:12px}.waitlist-card{padding:16px;display:grid;gap:12px}.waitlist-kv{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px}.waitlist-kv>.item{margin:0}.waitlist-match-modal{max-width:900px}.waitlist-match-results{display:grid;gap:10px;margin-top:14px}.waitlist-match-card{padding:12px}.btn-danger{background:#fff0f0;border-color:#d98a8e;color:#8b1720}.team-head-actions input[type=search]{min-width:230px}
@media(max-width:1180px){.agenda-week-grid{grid-template-columns:repeat(7,minmax(250px,1fr))}}@media(max-width:760px){.waitlist-grid{grid-template-columns:1fr}.agenda-week-grid{grid-template-columns:repeat(7,minmax(82vw,1fr))}.team-head-actions input[type=search]{min-width:0;width:100%}}


/* v0.2.19-R2.1 — agenda/waitlist visual polish only; no API or schema changes */
.agenda-page-head{margin-bottom:14px}.agenda-week-range{font-weight:700;color:var(--brand-2)!important}.agenda-week-actions{align-items:center}.agenda-week-grid{grid-template-columns:repeat(7,minmax(200px,1fr));gap:12px}.agenda-day{position:relative;padding:13px;gap:11px;transition:border-color .16s ease,box-shadow .16s ease,transform .16s ease}.agenda-day-today{border-color:#74b9aa;box-shadow:0 0 0 2px rgba(29,137,116,.10),0 10px 24px rgba(31,61,75,.08)}.agenda-today-badge{display:inline-flex;margin-top:7px}.agenda-day-closed{background:linear-gradient(135deg,#fbfaf7 0,#fbfaf7 48%,#f4f1ec 48%,#f4f1ec 52%,#fbfaf7 52%,#fbfaf7 100%);background-size:14px 14px}.agenda-day-actions{border-top:1px solid var(--line);padding-top:9px}.agenda-manage-btn{padding:7px 12px;min-height:36px}.agenda-empty{border-style:dashed;background:rgba(255,255,255,.55)}
.waitlist-page-head{margin-bottom:12px}.waitlist-title-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.waitlist-title-row h1{margin:0}.waitlist-count-badge{font-size:.82rem;white-space:nowrap}.waitlist-toolbar{padding:12px 14px;margin-bottom:16px;display:flex;align-items:center;justify-content:space-between;gap:12px}.waitlist-filter-group,.waitlist-action-group{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.waitlist-filter-group{flex:1;min-width:0}.waitlist-filter-group input[type=search]{flex:1;min-width:240px;max-width:440px}.waitlist-filter-group select{min-width:190px}.waitlist-action-group{justify-content:flex-end}.waitlist-empty{grid-column:1/-1;min-height:170px;display:grid;place-content:center;gap:8px;padding:32px 18px}.waitlist-empty strong{font-size:1.05rem;color:var(--ink)}.waitlist-empty p{margin:0;max-width:620px;color:var(--muted)}
@media(max-width:1180px){.agenda-week-grid{grid-template-columns:repeat(7,minmax(235px,1fr))}.waitlist-toolbar{align-items:stretch;flex-direction:column}.waitlist-action-group{justify-content:flex-start}}
@media(max-width:760px){.agenda-week-grid{grid-template-columns:repeat(7,minmax(84vw,1fr))}.agenda-week-actions .btn{flex:1 1 calc(50% - 8px)}.waitlist-filter-group,.waitlist-action-group{display:grid;grid-template-columns:1fr}.waitlist-filter-group input[type=search],.waitlist-filter-group select{min-width:0;max-width:none;width:100%}.waitlist-toolbar .btn{width:100%}.waitlist-empty{min-height:150px}}

/* v0.2.20 Clinical Core — Episode of Care, structured assessment, Body Map v2, ICF, timeline and append-only addenda */
.modal-wide{max-width:1000px;width:min(1000px,calc(100vw - 32px))}
.clinical-core-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:12px}
.clinical-core-card{padding:15px;display:grid;gap:10px}
.clinical-core-card .muted{overflow-wrap:anywhere}
.body-map-compare{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:14px;align-items:start}
.body-map-panel{padding:12px;border:1px solid var(--line);border-radius:14px;background:var(--panel,#fff);display:grid;gap:9px}
.body-map-canvas{position:relative;min-height:410px;border:1px solid var(--line);border-radius:14px;background:linear-gradient(180deg,rgba(238,246,249,.6),rgba(255,255,255,.9));overflow:hidden;touch-action:manipulation;cursor:crosshair}
.body-map-canvas[aria-disabled="true"]{cursor:default}
.body-map-figure{position:absolute;inset:28px 18% 24px;opacity:.7;pointer-events:none}
.body-map-head{position:absolute;left:50%;top:0;width:54px;height:54px;transform:translateX(-50%);border:2px solid #78909c;border-radius:50%}
.body-map-torso{position:absolute;left:50%;top:58px;width:104px;height:170px;transform:translateX(-50%);border:2px solid #78909c;border-radius:38% 38% 28% 28%}
.body-map-arm{position:absolute;top:76px;width:26px;height:176px;border:2px solid #78909c;border-radius:18px}.body-map-arm.left{left:calc(50% - 84px);transform:rotate(8deg)}.body-map-arm.right{right:calc(50% - 84px);transform:rotate(-8deg)}
.body-map-leg{position:absolute;top:219px;width:36px;height:160px;border:2px solid #78909c;border-radius:18px}.body-map-leg.left{left:calc(50% - 40px)}.body-map-leg.right{right:calc(50% - 40px)}
.body-map-marker{position:absolute;width:24px;height:24px;transform:translate(-50%,-50%);border:2px solid #fff;border-radius:50%;display:grid;place-items:center;font-size:10px;font-weight:800;background:#9f2f39;color:#fff;box-shadow:0 2px 8px rgba(0,0,0,.25);z-index:3}
.body-map-marker[data-kind="NUMBNESS"],.body-map-marker[data-kind="TINGLING"]{background:#376f8e}.body-map-marker[data-kind="STIFFNESS"],.body-map-marker[data-kind="WEAKNESS"]{background:#805f9b}.body-map-marker[data-kind="SWELLING"]{background:#b37a1b}.body-map-marker[data-kind="SCAR"]{background:#5f6d73}.body-map-marker[data-kind="OTHER"]{background:#4c7770}
.body-map-marker-list{display:grid;gap:6px}.body-map-marker-row{display:flex;gap:8px;align-items:flex-start;padding:8px;border:1px solid var(--line);border-radius:10px}.body-map-marker-row strong{min-width:80px}
.body-map-controls{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:9px;margin-bottom:12px}.body-map-hint{margin:0;color:var(--muted);font-size:.9rem}
.icf-domains{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:10px}.icf-domain{padding:12px;border:1px solid var(--line);border-radius:12px;background:#fff}.icf-domain h4{margin:0 0 8px}
.clinical-timeline{position:relative;display:grid;gap:12px;padding-inline-start:26px}.clinical-timeline:before{content:"";position:absolute;inset-block:6px;inset-inline-start:9px;width:2px;background:var(--line)}
.timeline-event{position:relative;padding:13px 14px}.timeline-event:before{content:"";position:absolute;inset-inline-start:-23px;top:20px;width:12px;height:12px;border:3px solid #fff;border-radius:50%;background:var(--brand-2);box-shadow:0 0 0 1px var(--line)}
.timeline-event-head{display:flex;justify-content:space-between;gap:10px;flex-wrap:wrap}.timeline-event-head strong{overflow-wrap:anywhere}.timeline-event-meta{display:flex;gap:7px;align-items:center;flex-wrap:wrap;margin-top:7px}
.addendum-item{margin-top:9px;padding:11px 12px;border-inline-start:4px solid var(--brand-2);background:#f5f9fa;border-radius:10px;display:grid;gap:5px}.addendum-item p{margin:0;white-space:pre-wrap;overflow-wrap:anywhere}.signed-immutable{display:inline-flex;align-items:center;gap:6px}
.assessment-structured{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:9px;margin-top:10px}.assessment-structured>.item{margin:0;align-content:start}
@media(max-width:760px){.modal-wide{width:min(100%,calc(100vw - 18px));max-height:92vh}.body-map-canvas{min-height:360px}.body-map-figure{inset-inline:12%}.body-map-compare,.icf-domains,.clinical-core-grid{grid-template-columns:1fr}.clinical-timeline{padding-inline-start:22px}}
/* v0.2.20 Body Map DOM aliases used by the renderer */
.bm-head{position:absolute;left:50%;top:0;width:54px;height:54px;transform:translateX(-50%);border:2px solid #78909c;border-radius:50%}
.bm-torso{position:absolute;left:50%;top:58px;width:104px;height:170px;transform:translateX(-50%);border:2px solid #78909c;border-radius:38% 38% 28% 28%}
.bm-arm{position:absolute;top:76px;width:26px;height:176px;border:2px solid #78909c;border-radius:18px}.bm-arm-left{left:calc(50% - 84px);transform:rotate(8deg)}.bm-arm-right{right:calc(50% - 84px);transform:rotate(-8deg)}
.bm-leg{position:absolute;top:219px;width:36px;height:160px;border:2px solid #78909c;border-radius:18px}.bm-leg-left{left:calc(50% - 40px)}.bm-leg-right{right:calc(50% - 40px)}
.body-map-view-label{position:absolute;inset-block-start:9px;inset-inline-end:10px;z-index:4;padding:4px 7px;border-radius:8px;background:rgba(255,255,255,.88);border:1px solid var(--line);font-size:.78rem}
.body-map-marker.bm-pain{background:#9f2f39}.body-map-marker.bm-numbness,.body-map-marker.bm-tingling{background:#376f8e}.body-map-marker.bm-stiffness,.body-map-marker.bm-weakness{background:#805f9b}.body-map-marker.bm-swelling{background:#b37a1b}.body-map-marker.bm-scar{background:#5f6d73}.body-map-marker.bm-other{background:#4c7770}
.body-map-marker-layer{position:absolute;inset:0;width:100%;height:100%;z-index:3;pointer-events:none}.body-map-marker-svg circle{fill:#4c7770;stroke:#fff;stroke-width:.7;vector-effect:non-scaling-stroke}.body-map-marker-svg text{fill:#fff;font-size:3.2px;font-weight:800;font-family:Arial,sans-serif}.body-map-marker-svg.bm-pain circle{fill:#9f2f39}.body-map-marker-svg.bm-numbness circle,.body-map-marker-svg.bm-tingling circle{fill:#376f8e}.body-map-marker-svg.bm-stiffness circle,.body-map-marker-svg.bm-weakness circle{fill:#805f9b}.body-map-marker-svg.bm-swelling circle{fill:#b37a1b}.body-map-marker-svg.bm-scar circle{fill:#5f6d73}
.body-map-phase-section{display:grid;gap:10px;margin-bottom:16px;padding:12px;border:1px solid var(--line);border-radius:14px;background:#f8fbfc}.body-map-phase-section h3{margin:0}.body-map-phase-compare{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.body-map-phase-compare .body-map-canvas{min-height:300px}.body-map-phase-compare .body-map-figure{inset-inline:12%}@media(max-width:900px){.body-map-phase-compare{grid-template-columns:repeat(3,minmax(230px,1fr));overflow-x:auto}}@media(max-width:760px){.body-map-phase-compare{grid-template-columns:repeat(3,minmax(78vw,1fr))}}

/* v0.2.21 Outcomes & Goals — reassessment due state, trend charts and goal progress */
.outcomes-engine > .item-head { align-items: flex-start; gap: 1rem; }
.outcome-due-grid,.goal-progress-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:.85rem; margin:.75rem 0 1rem; }
.outcome-due-card,.goal-progress-card { display:flex; flex-direction:column; gap:.55rem; }
.outcome-sparkline { width:100%; height:76px; min-height:64px; margin:.4rem 0; overflow:visible; }
.outcome-sparkline polyline { stroke:currentColor; stroke-width:2.5; stroke-linecap:round; stroke-linejoin:round; opacity:.8; }
.outcome-trend-card { min-width:0; }
.goal-progress-meter { width:100%; height:.65rem; border:0; border-radius:999px; overflow:hidden; }
.goal-progress-meter::-webkit-progress-bar { background:rgba(0,0,0,.08); border-radius:999px; }
.goal-progress-meter::-webkit-progress-value { background:currentColor; opacity:.6; border-radius:999px; }
.goal-progress-meter::-moz-progress-bar { background:currentColor; opacity:.6; border-radius:999px; }
.outcome-history { margin-top:1rem; }
.outcome-history > summary { cursor:pointer; font-weight:700; }
@media (max-width:720px){.outcome-due-grid,.goal-progress-grid{grid-template-columns:1fr}.outcomes-engine>.item-head{flex-direction:column}.outcomes-engine>.item-head>.form-actions{width:100%}.outcomes-engine>.item-head>.form-actions .btn{flex:1}}


/* v0.2.22 Exercise & HEP — library, versioned builder, safe share and print */
.hep-workspace{display:grid;gap:1rem}.hep-programs .section-head,.hep-library .section-head{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem}.hep-program-card.hep-current{box-shadow:0 0 0 2px rgba(76,119,112,.18) inset}.hep-program-items{display:grid;gap:.45rem;margin:.65rem 0;padding-inline-start:1.25rem}.hep-program-items li p{margin:.25rem 0 0;color:var(--muted)}
.hep-library-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:.75rem}.hep-library-card,.hep-exercise-choice{border:1px solid var(--line);border-radius:14px;padding:.85rem;background:#fff;display:grid;gap:.45rem}.hep-library-card h3,.hep-exercise-choice p{margin:0}.hep-library-card small,.hep-precaution{color:var(--muted)}
.hep-exercise-chooser{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:.75rem;max-height:52vh;overflow:auto;padding:.25rem}.hep-choice-head{display:flex;align-items:flex-start;gap:.6rem;font-weight:700}.hep-choice-head input{margin-top:.25rem}.hep-item-fields{display:grid;grid-template-columns:1fr;gap:.5rem;border-top:1px dashed var(--line);padding-top:.55rem}.hep-builder-modal{width:min(980px,calc(100vw - 2rem))}
.hep-qr{display:grid;place-items:center;margin:1rem auto}.hep-qr .mfa-qr-svg{width:min(260px,72vw);height:auto}.hep-print-host{display:none}
@media(max-width:720px){.hep-programs .section-head,.hep-library .section-head{flex-direction:column}.hep-programs .section-head .btn,.hep-library .section-head .btn{width:100%}.hep-exercise-chooser{grid-template-columns:1fr;max-height:58vh}}
@media print{
  body.printing-hep #app{display:none!important}
  body.printing-hep .hep-print-host{display:block!important;color:#111;background:#fff;padding:12mm;font-family:Arial,sans-serif}
  body.printing-hep .hep-print-host h1{font-size:20pt;margin:0 0 6mm}
  body.printing-hep .hep-print-host h2{font-size:16pt;margin:0 0 4mm}
  body.printing-hep .hep-print-list{display:grid;gap:5mm;padding-inline-start:7mm}
  body.printing-hep .hep-print-list li{break-inside:avoid;border-bottom:1px solid #ddd;padding-bottom:4mm}
  body.printing-hep .hep-print-list h3{margin:0 0 2mm}
}

/* v0.2.23 Patient Digital Rehab */
.digital-rehab{display:grid;gap:1rem}.rehab-block{display:grid;gap:.65rem;padding:1rem;border:1px solid var(--line);border-radius:14px;background:#fbfcfc}.rehab-block h3{margin:0}.compact-form{grid-template-columns:repeat(auto-fit,minmax(180px,1fr));align-items:end}.compact-form>h3{grid-column:1/-1}.portal-message{max-width:min(82%,620px);padding:.65rem .8rem;border-radius:14px;background:#f0f4f5}.portal-message.from-patient{margin-inline-start:auto;background:#e7f2ef}.portal-message p{margin:.25rem 0 0;white-space:pre-wrap;overflow-wrap:anywhere}.digital-rehab input[type=file]{max-width:100%}@media(max-width:720px){.compact-form{grid-template-columns:1fr}.portal-message{max-width:94%}}

/* v0.2.24 Clinical Evidence & Protocol Library */
.clinical-evidence .evidence-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:14px;margin-top:14px}
.clinical-evidence .evidence-grid>.clinical-detail-card{min-width:0}
.clinical-evidence .evidence-grid .item{overflow-wrap:anywhere}
@media (max-width:720px){.clinical-evidence .evidence-grid{grid-template-columns:1fr}}


/* v0.2.27 — Advanced dashboards: aggregate-only operational/clinical/financial reporting. */
.dashboard-section { display: grid; gap: 12px; margin-block: 16px 22px; }
.dashboard-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.dashboard-metric { display: grid; gap: 6px; min-width: 0; }
.dashboard-metric span { color: var(--muted); font-size: .86rem; }
.dashboard-metric strong { font-size: clamp(1.2rem, 2vw, 1.65rem); overflow-wrap: anywhere; }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; align-items: start; }
.dashboard-panel { min-width: 0; }
.dashboard-resource-list, .dashboard-trend-list { display: grid; gap: 10px; }
.dashboard-trend-row { display: grid; grid-template-columns: minmax(120px, .25fr) minmax(0, .75fr); gap: 10px; padding-block: 7px; border-bottom: 1px solid var(--line); }
.dashboard-trend-row:last-child { border-bottom: 0; }
.dashboard-resource-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding-block: 8px; border-bottom: 1px solid var(--line); }
.dashboard-resource-row:last-child { border-bottom: 0; }
.dashboard-bar { width: 100%; height: 8px; border: 0; border-radius: 999px; overflow: hidden; accent-color: currentColor; }
@media (max-width: 680px) { .dashboard-grid, .dashboard-metrics, .dashboard-trend-row { grid-template-columns: minmax(0, 1fr); } }

/* v0.2.28 — Compliance & interoperability */
.dashboard-grid .card p { overflow-wrap:anywhere; }


/* v0.2.30 Body Map 360 — four-view anatomical atlas, normalized marker canvas, responsive clinical editor */
.body-map-workspace{gap:16px}.body-map-atlas-preview{display:grid;gap:12px;padding:14px;border:1px solid var(--line);border-radius:16px;background:linear-gradient(180deg,#f8fbfc,#fff)}
.body-map-360-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;align-items:start;direction:ltr}.body-map-360-grid.is-compact{gap:7px}
.body-map-canvas{position:relative;min-height:0!important;aspect-ratio:3/5;border:1px solid var(--line);border-radius:14px;background:linear-gradient(180deg,#fbfdfe,#f3f7f8);overflow:hidden;touch-action:manipulation;cursor:default;box-shadow:0 8px 20px rgba(38,61,73,.06)}
.body-map-canvas:not([aria-disabled="true"]){cursor:crosshair}.body-map-image-stage{position:absolute;inset:0;overflow:hidden}.body-map-image-stage[role="button"]:focus-visible{outline:3px solid rgba(55,111,142,.35);outline-offset:-4px;border-radius:12px}
.body-map-anatomy-img{position:absolute;inset:0;width:100%;height:100%;object-fit:fill;user-select:none;pointer-events:none;filter:saturate(.93) contrast(1.02)}
.body-map-view-label{inset-block-start:8px;inset-inline-end:8px;background:rgba(255,255,255,.93);box-shadow:0 2px 7px rgba(0,0,0,.05)}
.body-map-marker-layer{position:absolute;inset:0;width:100%;height:100%;z-index:3;pointer-events:none}.body-map-marker-svg .body-map-marker-halo{fill:currentColor;opacity:.16;stroke:none}.body-map-marker-svg circle:not(.body-map-marker-halo){fill:#4c7770;stroke:#fff;stroke-width:.75;vector-effect:non-scaling-stroke;filter:drop-shadow(0 1px 1px rgba(0,0,0,.35))}.body-map-marker-svg text{fill:#fff;font-size:3.15px;font-weight:800;font-family:Arial,sans-serif}.body-map-marker-svg.bm-pain{color:#9f2f39}.body-map-marker-svg.bm-pain circle:not(.body-map-marker-halo){fill:#9f2f39}.body-map-marker-svg.bm-numbness,.body-map-marker-svg.bm-tingling{color:#376f8e}.body-map-marker-svg.bm-numbness circle:not(.body-map-marker-halo),.body-map-marker-svg.bm-tingling circle:not(.body-map-marker-halo){fill:#376f8e}.body-map-marker-svg.bm-stiffness,.body-map-marker-svg.bm-weakness{color:#805f9b}.body-map-marker-svg.bm-stiffness circle:not(.body-map-marker-halo),.body-map-marker-svg.bm-weakness circle:not(.body-map-marker-halo){fill:#805f9b}.body-map-marker-svg.bm-swelling{color:#b37a1b}.body-map-marker-svg.bm-swelling circle:not(.body-map-marker-halo){fill:#b37a1b}.body-map-marker-svg.bm-scar{color:#5f6d73}.body-map-marker-svg.bm-scar circle:not(.body-map-marker-halo){fill:#5f6d73}.body-map-marker-svg.bm-other{color:#4c7770}
.body-map-editor{display:grid;gap:12px;padding:12px;border:1px solid var(--line);border-radius:16px;background:#f8fbfc}.body-map-modal{max-width:1280px;width:min(1280px,calc(100vw - 26px))}.body-map-modal .modal-head{align-items:flex-start}.body-map-modal .modal-head h2{margin-bottom:4px}
.body-map-legend{display:flex;gap:8px 12px;align-items:center;flex-wrap:wrap;padding:8px 10px;border:1px solid var(--line);border-radius:12px;background:#fff}.body-map-legend>strong{margin-inline-end:4px}.body-map-legend-item{display:inline-flex;align-items:center;gap:5px;font-size:.82rem;color:var(--muted)}.body-map-marker-swatch{display:inline-block;width:12px;height:12px;border-radius:50%;background:#4c7770;box-shadow:0 0 0 2px #fff,0 0 0 3px var(--line);flex:0 0 auto}.body-map-marker-swatch.bm-pain{background:#9f2f39}.body-map-marker-swatch.bm-numbness,.body-map-marker-swatch.bm-tingling{background:#376f8e}.body-map-marker-swatch.bm-stiffness,.body-map-marker-swatch.bm-weakness{background:#805f9b}.body-map-marker-swatch.bm-swelling{background:#b37a1b}.body-map-marker-swatch.bm-scar{background:#5f6d73}
.body-map-marker-list{display:grid;gap:7px}.body-map-marker-row{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:10px;align-items:center;padding:9px 10px;border:1px solid var(--line);border-radius:12px;background:#fff}.body-map-marker-copy{display:grid;gap:2px;min-width:0}.body-map-marker-copy strong,.body-map-marker-copy span{overflow-wrap:anywhere}.body-map-remove-marker{min-width:38px;padding-inline:10px}
.body-map-snapshot-card{display:grid;gap:10px}.body-map-phase-compare .body-map-canvas{min-height:0!important;aspect-ratio:3/5}.body-map-phase-compare .body-map-figure{display:none}
@media(max-width:1080px){.body-map-360-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.body-map-modal{width:min(100%,calc(100vw - 18px))}}
@media(max-width:620px){.body-map-360-grid{grid-template-columns:repeat(2,minmax(150px,1fr));overflow-x:auto}.body-map-legend{align-items:flex-start}.body-map-marker-row{grid-template-columns:auto minmax(0,1fr)}.body-map-remove-marker{grid-column:2;justify-self:start}.body-map-modal .form-row{grid-template-columns:1fr}}


/* v0.2.30 C5 — ICF Structured Coding v2; JSON-backed, migration-free, legacy-readable */
.icf-v2-workspace{display:grid;gap:14px}.icf-v2-workspace>.section-head{align-items:flex-start}.icf-v2-modal{max-width:1180px;width:min(1180px,calc(100vw - 28px))}
.icf-editor-domain{display:grid;gap:10px;padding:13px;border:1px solid var(--line);border-radius:14px;background:#f8fbfc;margin-top:12px}.icf-domain-head{display:flex;align-items:center;justify-content:space-between;gap:10px}.icf-domain-head h3{margin:0;font-size:1rem}.icf-editor-list{display:grid;gap:9px}.icf-editor-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:9px;align-items:end;padding:10px;border:1px solid var(--line);border-radius:12px;background:#fff}.icf-editor-fields{display:grid;grid-template-columns:repeat(auto-fit,minmax(155px,1fr));gap:9px}.icf-remove-row{align-self:end}
.icf-snapshot-card{display:grid;gap:12px}.icf-clinical-note{display:grid;gap:6px;padding:11px 12px;border-inline-start:4px solid var(--brand-2);border-radius:10px;background:#f7fafb}.icf-clinical-note p{margin:0;white-space:pre-wrap}.icf-domains{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.icf-domain-view{display:grid;gap:8px;padding:11px;border:1px solid var(--line);border-radius:12px;background:#fbfcfc;min-width:0}.icf-domain-view h4{margin:0}.icf-structured-list{display:grid;gap:8px}.icf-structured-item{display:grid;gap:6px;padding:9px;border-radius:10px;background:#fff;border:1px solid rgba(214,222,226,.85)}.icf-item-head{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap}.icf-code{direction:ltr;unicode-bidi:isolate;font-weight:800;color:var(--brand-2);background:#eef5f7;border-radius:7px;padding:2px 6px}
.icf-comparison{display:grid;gap:9px}.icf-comparison h3{margin:0}.icf-compare-table{display:grid;overflow-x:auto;border:1px solid var(--line);border-radius:12px}.icf-compare-row{display:grid;grid-template-columns:minmax(90px,.6fr) minmax(210px,1.4fr) repeat(3,minmax(150px,1fr));min-width:820px}.icf-compare-row>*{padding:9px 10px;border-inline-end:1px solid var(--line);border-bottom:1px solid var(--line);overflow-wrap:anywhere}.icf-compare-row>*:last-child{border-inline-end:0}.icf-compare-row:last-child>*{border-bottom:0}.icf-compare-head{background:#f4f8f9}.icf-compare-head strong{font-size:.82rem;color:var(--muted)}
@media(max-width:760px){.icf-domains{grid-template-columns:1fr}.icf-editor-row{grid-template-columns:1fr}.icf-remove-row{justify-self:start}.icf-v2-modal{width:min(100%,calc(100vw - 18px));max-height:92vh}.icf-editor-fields{grid-template-columns:1fr}}

.icf-compare-cols-2 .icf-compare-row{grid-template-columns:minmax(90px,.6fr) minmax(210px,1.4fr) repeat(2,minmax(150px,1fr))}.icf-compare-cols-3 .icf-compare-row{grid-template-columns:minmax(90px,.6fr) minmax(210px,1.4fr) repeat(3,minmax(150px,1fr))}

/* v0.2.30 C6 — Clinical Timeline v2: episode-first filters and clinical-stage context */
.clinical-timeline-v2{display:grid;gap:14px}.timeline-summary{display:grid;grid-template-columns:repeat(5,minmax(120px,1fr));gap:10px}.timeline-summary-card{border:1px solid var(--line);border-radius:12px;background:var(--surface-2);padding:11px 12px;display:grid;gap:4px}.timeline-summary-card strong{font-size:1.08rem}.timeline-filter-bar{display:grid;grid-template-columns:minmax(220px,1.4fr) repeat(3,minmax(150px,1fr)) auto;gap:10px;align-items:end;padding:12px;border:1px solid var(--line);border-radius:14px;background:var(--surface-2)}.timeline-filter-field{margin:0}.timeline-filter-field>span{display:block;margin-bottom:5px;font-weight:700;font-size:.84rem}.timeline-filter-field select{width:100%}.timeline-reset{min-height:42px}.timeline-event-badges{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}.timeline-event-actions{display:flex;justify-content:flex-end;margin-top:8px}.timeline-event-actions .btn-sm{padding:6px 10px;font-size:.8rem}.timeline-stage{white-space:nowrap}.timeline-milestone .timeline-dot{background:var(--brand-2)}.timeline-clinical .timeline-dot{background:var(--info)}.timeline-plan .timeline-dot{background:var(--ok)}.timeline-session .timeline-dot{background:var(--warn)}.timeline-rehab .timeline-dot{background:var(--brand-2)}.timeline-document .timeline-dot{background:var(--muted)}
@media(max-width:1000px){.timeline-summary{grid-template-columns:repeat(3,minmax(120px,1fr))}.timeline-filter-bar{grid-template-columns:repeat(2,minmax(180px,1fr))}.timeline-reset{justify-self:start}}
@media(max-width:650px){.timeline-summary{grid-template-columns:repeat(2,minmax(0,1fr))}.timeline-filter-bar{grid-template-columns:1fr}.timeline-event-head{align-items:flex-start}.timeline-event-badges{justify-content:flex-start}.timeline-event-meta{align-items:flex-start}.timeline-event-actions{justify-content:flex-start}}

/* v0.2.30 C7 — Treatment Plan v2: episode-linked structured plan and phase dosage */
.care-plan-v2{display:grid;gap:14px}.care-plan-card{display:grid;gap:10px}.care-plan-phases{display:grid;gap:8px;margin-top:6px}.care-plan-phases>.clinical-detail-card{background:var(--surface-2)}.care-plan-phases summary{cursor:pointer;font-weight:800}.care-plan-phases ul{margin:.45rem 0 0;padding-inline-start:1.25rem}.care-plan-phases li{margin:.2rem 0}.care-plan-card>.item-actions{display:flex;gap:8px;flex-wrap:wrap}.care-plan-v2 .notice.info{margin-top:10px}.team-modal textarea{resize:vertical}
@media(max-width:720px){.care-plan-card>.item-actions .btn{flex:1 1 180px}.care-plan-v2>.grid-2{grid-template-columns:1fr}}

/* C8 — Goals & Outcomes v2 */
.goal-progress-card{display:grid;gap:.55rem}.goal-progress-card>.muted{margin:0}.goal-progress-card progress{width:100%}.goal-progress-card>.btn{justify-self:start}.outcomes-engine .check-row{display:flex;align-items:center;gap:.65rem;min-height:44px;padding:.65rem .75rem;border:1px solid var(--border);border-radius:12px;background:var(--surface-2)}.outcomes-engine .check-row input{width:auto;margin:0}.goal-progress-grid+.empty{margin-top:.5rem}
@media(max-width:720px){.goal-progress-card>.btn{width:100%}.outcomes-engine .grid.grid-3{grid-template-columns:1fr}}

/* v0.2.30 C9 — Clinical Session v2 */
.clinical-session-v2 .section-head{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;flex-wrap:wrap}
.clinical-session-card{display:grid;gap:.75rem}
.session-context-card{display:grid;gap:.5rem}
.session-soap-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:.75rem}
.session-goal-picker{display:grid;gap:.4rem;max-height:180px;overflow:auto;padding:.5rem;border:1px solid var(--border,#dbe5ef);border-radius:12px}
.session-intervention-row{display:grid;gap:.25rem;padding:.55rem 0;border-bottom:1px solid var(--border,#e5ebf2)}
.session-intervention-row:last-child{border-bottom:0}
@media(max-width:720px){.session-soap-grid{grid-template-columns:1fr}.clinical-session-v2 .section-head>.btn{width:100%}}

/* C10 — Exercise / HEP v2 */
.form-grid-3{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;align-items:start}
.hep-context-card{margin:12px 0;padding:12px 14px;border:1px solid var(--line,#d9e1e8);border-radius:12px;background:rgba(248,250,252,.8);display:grid;gap:6px}
.hep-item-fields h4{margin:8px 0 4px}
.hep-program-items .dose-box{margin-top:6px}
@media (max-width:900px){.form-grid-3{grid-template-columns:1fr}}

/* V0.2.30 C11 — discharge & episode closure */
.discharge-readiness{border:1px solid var(--border,#d7e0e8);border-radius:16px;padding:16px;background:var(--surface-soft,#f8fbfd);display:grid;gap:14px}
.discharge-readiness h3{margin:0}
.discharge-metrics{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px}
.discharge-metric{border:1px solid var(--border,#d7e0e8);border-radius:12px;padding:10px;background:#fff;display:grid;gap:4px}
.discharge-metric strong{font-size:1.05rem}
.discharge-issues{display:grid;gap:8px}
.discharge-issues .notice{margin:0}
@media (max-width:720px){.discharge-metrics{grid-template-columns:1fr 1fr}}

/* C12 — Centre NASSER Clinical Architecture v1 */
.clinical-arch-editor{border:1px solid var(--line,#cfd9e3);border-radius:14px;padding:14px;margin:14px 0;background:rgba(247,250,252,.72)}
.clinical-arch-row{background:#fff}
.clinical-arch-comparison{border:1px solid var(--line,#cfd9e3);border-radius:14px;padding:14px;margin:12px 0;background:#f8fbfd}
.clinical-arch-comparison-grid{display:grid;gap:8px}
.clinical-arch-comparison-row{display:grid;grid-template-columns:minmax(180px,1.3fr) minmax(140px,1fr) minmax(140px,1fr);gap:10px;align-items:center;padding:10px;border:1px solid #dbe4ec;border-radius:10px;background:#fff}
@media (max-width:760px){.clinical-arch-comparison-row{grid-template-columns:1fr}.clinical-arch-editor .form-row{grid-template-columns:1fr}}

/* v0.2.31-H1 - RDV heritage professional shell */
.workspace-shell {
  display: block;
  min-height: 100dvh;
  padding-inline-start: 245px;
  background: var(--bg);
}
.workspace-sidebar {
  position: fixed;
  z-index: 60;
  inset-block: 0;
  inset-inline-start: 0;
  width: 245px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: #fff;
  background: linear-gradient(180deg, var(--brand-2) 0%, var(--brand-deep) 100%);
  box-shadow: 10px 0 30px rgba(5, 44, 79, .08);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.22) transparent;
}
[dir="rtl"] .workspace-sidebar { box-shadow: -10px 0 30px rgba(5, 44, 79, .08); }
.workspace-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  color: var(--brand-2);
  background: rgba(255,255,255,.97);
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(2,23,40,.18);
}
.workspace-sidebar .brand-mark {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border: 0;
  border-radius: 14px;
  background: #fff;
}
.workspace-sidebar-brand-copy { min-width: 0; display: grid; gap: 2px; }
.workspace-sidebar-brand-copy strong,
.workspace-sidebar-brand-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-sidebar-brand-copy strong { font-family: "Cairo CN", "Tajawal CN", sans-serif; font-size: 1rem; font-weight: 800; }
.workspace-sidebar-brand-copy small { color: #5b6b7f; font-size: .72rem; font-weight: 600; }
.workspace-sidebar-user {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 12px;
  background: rgba(255,255,255,.055);
}
.workspace-sidebar-user strong,
.workspace-sidebar-user small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-sidebar-user strong { font-size: .82rem; }
.workspace-sidebar-user small { color: rgba(255,255,255,.68); font-size: .68rem; }
.workspace-sidebar .section-nav {
  display: grid;
  width: 100%;
  gap: 4px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.workspace-sidebar .section-nav-btn {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: rgba(255,255,255,.74);
  text-align: start;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  font-weight: 700;
}
.workspace-sidebar .section-nav-btn:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
}
.workspace-sidebar .section-nav-btn.active {
  color: #fff;
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.06);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.025);
}
.section-nav-icon {
  width: 24px;
  flex: 0 0 24px;
  color: var(--accent-gold);
  text-align: center;
  line-height: 1;
  unicode-bidi: isolate;
}
.section-nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-sidebar-footer { margin-top: auto; display: grid; gap: 10px; }
.workspace-language-switcher {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  background: rgba(255,255,255,.055);
}
.workspace-language-btn {
  min-height: 30px;
  padding: 4px 6px;
  color: rgba(255,255,255,.64);
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: .68rem;
  font-weight: 800;
}
.workspace-language-btn.active { color: #fff; background: var(--brand); }
.workspace-logout-btn {
  min-height: 42px;
  padding: 9px 12px;
  color: #fff;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 11px;
  background: transparent;
  font-weight: 800;
}
.workspace-logout-btn:hover { background: rgba(255,255,255,.08); }
.workspace-body { min-width: 0; min-height: 100dvh; }
.workspace-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 24px clamp(14px, 3vw, 34px) 8px;
}
.workspace-header-copy { min-width: 0; }
.workspace-greeting { margin: 0 0 3px; color: var(--muted); font-size: .84rem; }
.workspace-header h1 { margin: 0; font-family: "Cairo CN", "Tajawal CN", sans-serif; font-size: clamp(1.55rem, 3vw, 2.25rem); letter-spacing: -.025em; }
.workspace-online-pill {
  flex: 0 0 auto;
  padding: 7px 11px;
  color: #0a654f;
  background: #dff4eb;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 800;
  white-space: nowrap;
}
.workspace-shell .main { width: min(1600px, 100%); padding-top: 12px; }

@media (min-width: 901px) and (max-height: 760px) {
  .workspace-sidebar { gap: 8px; padding: 10px 12px; }
  .workspace-sidebar-brand { padding: 7px 8px; }
  .workspace-sidebar .brand-mark { width: 48px; height: 48px; flex-basis: 48px; }
  .workspace-sidebar-user { padding: 7px 9px; }
  .workspace-sidebar .section-nav { gap: 2px; }
  .workspace-sidebar .section-nav-btn { min-height: 34px; padding: 6px 8px; }
  .workspace-sidebar-footer { gap: 7px; }
  .workspace-logout-btn { min-height: 36px; padding: 7px 9px; }
}

@media (max-width: 900px) {
  .workspace-shell { padding-inline-start: 0; }
  .workspace-sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
    overflow: visible;
  }
  .workspace-sidebar-brand { width: min(340px, 100%); padding: 7px 9px; }
  .workspace-sidebar .brand-mark { width: 48px; height: 48px; flex-basis: 48px; }
  .workspace-sidebar-user { display: none; }
  .workspace-sidebar .section-nav {
    grid-column: 1 / -1;
    display: flex;
    gap: 5px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .workspace-sidebar .section-nav::-webkit-scrollbar { display: none; }
  .workspace-sidebar .section-nav-btn { width: auto; min-width: max-content; flex: 0 0 auto; padding-inline: 11px; }
  .workspace-sidebar-footer { margin: 0; display: flex; align-items: center; gap: 7px; }
  .workspace-language-switcher { width: 128px; }
  .workspace-logout-btn { min-height: 38px; padding: 7px 10px; white-space: nowrap; }
  .workspace-header { padding-top: 18px; }
}

@media (max-width: 620px) {
  .workspace-sidebar { grid-template-columns: 1fr; }
  .workspace-sidebar-brand { width: 100%; }
  .workspace-sidebar-brand-copy small { display: none; }
  .workspace-sidebar-footer { justify-content: space-between; }
  .workspace-language-switcher { width: 138px; }
  .workspace-sidebar .section-nav { grid-column: 1; order: 3; }
  .workspace-header { align-items: flex-start; flex-direction: column-reverse; gap: 8px; }
  .workspace-online-pill { align-self: flex-start; }
}
/* v0.2.31-H2 - RDV heritage operational templates */
.workspace-shell {
  --ops-teal: #0d7d70;
  --ops-teal-soft: #e8f5f1;
  --ops-teal-line: #bddfd6;
  --ops-gold-soft: #fff7e8;
  --ops-panel: #fbfdfd;
  --ops-shadow: 0 8px 24px rgba(7,54,95,.055);
}

.workspace-shell .main {
  width: min(1680px, 100%);
}

.workspace-shell .page-head {
  align-items: center;
  margin-bottom: 14px;
}

.workspace-shell .page-head h1 {
  font-family: "Cairo CN", "Tajawal CN", sans-serif;
  font-size: clamp(1.42rem, 2.2vw, 2rem);
}

.workspace-shell .page-head p {
  max-width: 900px;
  line-height: 1.65;
}

/* Shared operational toolbar pattern */
.workspace-shell .search-panel,
.workspace-shell .waitlist-toolbar,
.workspace-shell .agenda-week-actions,
.workspace-shell .team-head-actions {
  border-color: var(--ops-teal-line);
  background: linear-gradient(180deg, #ffffff 0%, var(--ops-panel) 100%);
  box-shadow: none;
}

.workspace-shell input,
.workspace-shell select,
.workspace-shell textarea {
  border-color: #c8d8e1;
  background: #fff;
}

.workspace-shell input:hover,
.workspace-shell select:hover,
.workspace-shell textarea:hover {
  border-color: #9ebdca;
}

/* KPI cards: RDV-style compact operational summary */
.workspace-shell .daily-metrics,
.workspace-shell .dashboard-metrics {
  gap: 10px;
  margin-bottom: 16px;
}

.workspace-shell .daily-metric,
.workspace-shell .dashboard-metric {
  position: relative;
  min-height: 94px;
  align-content: center;
  padding: 14px 15px;
  border: 1px solid #c9dce4;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(7,54,95,.035);
  overflow: hidden;
}

.workspace-shell .daily-metric::before,
.workspace-shell .dashboard-metric::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 3px;
  background: var(--ops-teal);
  opacity: .88;
}

.workspace-shell .daily-metric span,
.workspace-shell .dashboard-metric span {
  color: #526777;
  font-size: .77rem;
  font-weight: 700;
}

.workspace-shell .daily-metric strong,
.workspace-shell .dashboard-metric strong {
  color: #102d42;
  font-family: "Cairo CN", "Tajawal CN", sans-serif;
  font-size: clamp(1.08rem, 1.55vw, 1.4rem);
  line-height: 1.25;
}

/* Daily workflow */
.workspace-shell .daily-list {
  gap: 8px;
}

.workspace-shell .daily-row {
  border: 1px solid #ccdde5;
  border-radius: 14px;
  background: #fff;
  box-shadow: none;
}

.workspace-shell .daily-row:hover {
  border-color: #9fc9bd;
  box-shadow: var(--ops-shadow);
}

.workspace-shell .daily-time strong {
  color: var(--ops-teal);
}

.workspace-shell .daily-actions .btn {
  min-height: 36px;
  border-radius: 9px;
}

/* Booking request cards */
.workspace-shell .booking-request-list {
  gap: 10px;
}

.workspace-shell .booking-request-card {
  position: relative;
  padding: 15px;
  border: 1px solid #cadde4;
  border-radius: 14px;
  background: #fff;
  box-shadow: none;
}

.workspace-shell .booking-request-card::before {
  content: "";
  position: absolute;
  inset-block: 14px;
  inset-inline-start: 0;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: var(--ops-teal);
}

[dir="rtl"] .workspace-shell .booking-request-card::before {
  border-radius: 999px 0 0 999px;
}

.workspace-shell .booking-request-kv {
  gap: 7px 14px;
}

.workspace-shell .booking-request-card .form-actions {
  padding-top: 10px;
  border-top: 1px solid #e2ebef;
}

/* Agenda */
.workspace-shell .agenda-week-grid {
  gap: 10px;
}

.workspace-shell .agenda-day {
  border-color: #cbdde5;
  border-radius: 14px;
  background: #fff;
  box-shadow: none;
}

.workspace-shell .agenda-day-today {
  border-color: var(--ops-teal);
  box-shadow: 0 0 0 2px rgba(13,125,112,.10);
}

.workspace-shell .agenda-day-head {
  padding-bottom: 9px;
  border-bottom: 1px solid #e3ecef;
}

.workspace-shell .agenda-day-head h2 {
  font-family: "Cairo CN", "Tajawal CN", sans-serif;
}

.workspace-shell .agenda-slot {
  border-color: #d5e2e8;
  border-radius: 10px;
  background: #fbfdfd;
}

.workspace-shell .agenda-slot:hover {
  border-color: #9fc9bd;
  background: #fff;
}

.workspace-shell .agenda-slot-time strong {
  color: var(--ops-teal);
}

/* Waitlist */
.workspace-shell .waitlist-grid {
  gap: 10px;
}

.workspace-shell .waitlist-card {
  position: relative;
  border: 1px solid #cadde4;
  border-radius: 14px;
  background: #fff;
  box-shadow: none;
}

.workspace-shell .waitlist-card::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  inset-block-start: 0;
  width: 4px;
  height: 42px;
  border-radius: 14px 0 8px 0;
  background: var(--accent-gold);
}

[dir="rtl"] .workspace-shell .waitlist-card::after {
  border-radius: 0 14px 0 8px;
}

.workspace-shell .waitlist-kv > .item {
  border-color: #e0e9ed;
  background: #f9fbfc;
}

/* Patient register */
.workspace-shell .search-panel {
  border: 1px solid var(--ops-teal-line);
  border-radius: 14px;
}

.workspace-shell .patient-list {
  gap: 8px;
}

.workspace-shell .patient-row {
  border: 1px solid #cfdee5;
  border-radius: 13px;
  background: #fff;
  box-shadow: none;
}

.workspace-shell .patient-row:hover {
  border-color: #9fc9bd;
  background: #fcfefe;
}

.workspace-shell .patient-row h3 {
  color: #17364d;
  font-family: "Cairo CN", "Tajawal CN", sans-serif;
}

/* Advanced dashboards */
.workspace-shell .dashboard-section {
  gap: 10px;
}

.workspace-shell .dashboard-grid {
  gap: 10px;
}

.workspace-shell .dashboard-panel {
  border-color: #ccdde5;
  box-shadow: none;
}

.workspace-shell .dashboard-trend-row,
.workspace-shell .dashboard-resource-row {
  border-color: #e2ebef;
}

.workspace-shell .dashboard-bar {
  height: 7px;
  accent-color: var(--ops-teal);
}

/* Status and empty-state harmonisation */
.workspace-shell .badge {
  border: 1px solid rgba(7,54,95,.06);
}

.workspace-shell .badge.ok {
  background: #e8f5ef;
  color: #17694b;
}

.workspace-shell .badge.warn {
  background: var(--ops-gold-soft);
  color: #8a5a12;
}

.workspace-shell .empty,
.workspace-shell .waitlist-empty,
.workspace-shell .agenda-empty {
  border-color: #c8ddd7;
  background: linear-gradient(180deg, #fbfefd 0%, #f1f8f6 100%);
  color: #58706d;
}

/* Operational action hierarchy */
.workspace-shell .daily-actions .btn-primary,
.workspace-shell .booking-request-card .btn-primary,
.workspace-shell .waitlist-card .btn-primary,
.workspace-shell .agenda-manage-btn {
  background: var(--ops-teal);
  border-color: var(--ops-teal);
  color: #fff;
}

.workspace-shell .daily-actions .btn-primary:hover,
.workspace-shell .booking-request-card .btn-primary:hover,
.workspace-shell .waitlist-card .btn-primary:hover,
.workspace-shell .agenda-manage-btn:hover {
  background: #09695f;
  border-color: #09695f;
}

/* Keep data dense but readable on smaller screens */
@media (max-width: 1180px) {
  .workspace-shell .daily-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .workspace-shell .daily-metrics,
  .workspace-shell .dashboard-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace-shell .daily-row {
    gap: 10px;
  }

  .workspace-shell .daily-metric,
  .workspace-shell .dashboard-metric {
    min-height: 82px;
    padding: 12px;
  }

  .workspace-shell .booking-request-card,
  .workspace-shell .waitlist-card {
    padding: 13px;
  }
}

@media (max-width: 430px) {
  .workspace-shell .daily-metrics,
  .workspace-shell .dashboard-metrics {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .workspace-shell .daily-metric strong,
  .workspace-shell .dashboard-metric strong {
    font-size: 1.02rem;
  }
}
/* P1-A — Derived same-day operations board (display-only queue) */
.daily-flow-summary {
  margin-bottom: 18px;
  padding: 15px 16px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px 18px;
  align-items: center;
  border-color: #b9d6df;
  box-shadow: none;
}
.daily-flow-summary-main { display: grid; gap: 2px; min-width: 0; }
.daily-flow-summary-main strong { font-family: "Cairo CN", "Tajawal CN", sans-serif; font-size: 1rem; color: var(--brand-2); }
.daily-flow-summary-main > span:last-child { font-size: 1.05rem; font-weight: 700; overflow-wrap: anywhere; }
.daily-flow-eyebrow { color: var(--muted); font-size: .76rem; font-weight: 800; }
.daily-flow-counts { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.daily-next-meta {
  grid-column: 1 / -1;
  display: flex;
  gap: 7px 16px;
  flex-wrap: wrap;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .84rem;
}
.daily-board { display: grid; gap: 18px; }
.daily-group { display: grid; gap: 8px; }
.daily-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.daily-group-head h2 { margin: 0; font-size: 1rem; color: var(--brand-2); }
.daily-group-empty {
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.56);
  color: var(--muted);
  font-size: .86rem;
}
.daily-group-waiting .daily-row { border-inline-start: 3px solid var(--ops-teal, var(--brand)); }
.daily-group-in-session .daily-row { border-inline-start: 3px solid var(--brand); }
.daily-group-closed .daily-row { background: #fbfcfd; }
.daily-flow-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.daily-flow-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #edf5f8;
  color: #315f7f;
  font-size: .78rem;
  font-weight: 700;
}
.daily-flow-chip.queue { background: #e9f6ef; color: var(--ok); }
.daily-flow-chip.active { background: #eaf3fa; color: var(--brand-2); }

@media (max-width: 760px) {
  .daily-flow-summary { grid-template-columns: 1fr; align-items: start; }
  .daily-flow-counts { justify-content: flex-start; }
  .daily-next-meta { grid-column: 1; }
}

@media (max-width: 430px) {
  .daily-flow-summary { padding: 13px; }
  .daily-flow-counts .badge { flex: 1 1 120px; justify-content: center; }
  .daily-flow-meta { display: grid; grid-template-columns: 1fr; }
  .daily-flow-chip { width: 100%; justify-content: flex-start; }
}

/* R5 session-management self-service */
.session-page-head { align-items: flex-start; gap: 16px; }
.session-page-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.session-security-hint { margin-bottom: 14px; }
.session-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.session-card { padding: 16px; min-width: 0; display: grid; gap: 12px; }
.session-card-current { border-color: #74b9aa; box-shadow: 0 0 0 2px rgba(29,137,116,.08), var(--shadow); }
.session-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; min-width: 0; }
.session-card-head > div:first-child { min-width: 0; }
.session-card-head h2 { margin: 0 0 4px; font-size: 1rem; overflow-wrap: anywhere; }
.session-card-head .badges { justify-content: flex-end; flex-wrap: wrap; }
.session-kv { margin: 0; display: grid; gap: 8px; }
.session-kv > div { display: grid; grid-template-columns: minmax(120px,.42fr) minmax(0,1fr); gap: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.session-kv dt { color: var(--muted); font-weight: 600; }
.session-kv dd { margin: 0; overflow-wrap: anywhere; }
.session-indicators { display: flex; gap: 7px; flex-wrap: wrap; }
.session-indicator { display: inline-flex; align-items: center; min-height: 30px; padding: 5px 9px; border-radius: 999px; background: #f4f1ec; border: 1px solid var(--line); color: var(--muted); font-size: .84rem; }
.session-indicator.is-match { background: #eaf8f2; border-color: #8ac8b5; color: #176653; }
.session-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: auto; }
.session-only-current { margin-top: 12px; }
[dir="rtl"] .session-kv dd { text-align: right; }
[dir="rtl"] .session-card-head .badges { justify-content: flex-start; }
[dir="rtl"] .session-actions { justify-content: flex-start; }

@media (max-width: 680px) {
  .session-page-head { display: grid; grid-template-columns: minmax(0,1fr); }
  .session-page-actions { display: grid; grid-template-columns: minmax(0,1fr); width: 100%; }
  .session-page-actions .btn { width: 100%; }
  .session-grid { grid-template-columns: minmax(0,1fr); }
  .session-card { width: 100%; max-width: 100%; padding: 14px; overflow: hidden; }
  .session-card-head { flex-direction: column; }
  .session-card-head .badges { justify-content: flex-start; }
  .session-kv > div { grid-template-columns: minmax(0,1fr); gap: 3px; }
  .session-actions { display: grid; grid-template-columns: minmax(0,1fr); }
  .session-actions .btn { width: 100%; }
}

/* R5-UI-MOBILE-NAV-01 — keep the workspace navigation fully visible on narrow screens. */
@media (max-width: 620px) {
  .workspace-sidebar .section-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    overflow-x: visible;
    overflow-y: visible;
    padding-bottom: 0;
  }
  .workspace-sidebar .section-nav-btn {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    justify-content: flex-start;
    align-items: center;
    gap: 6px;
    padding: 7px 8px;
  }
  .workspace-sidebar .section-nav-btn .section-nav-icon {
    width: 18px;
    flex-basis: 18px;
  }
  .workspace-sidebar .section-nav-btn .section-nav-label {
    min-width: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
    line-height: 1.15;
  }
}

/* CN10 P1-B — Workspace responsive layout & information density normalization.
   UI-only: make 100% browser zoom the desktop reference; no API/backend changes. */
@media (min-width: 1181px) {
  .workspace-shell .main {
    width: min(1840px, 100%);
    padding-inline: clamp(16px, 2vw, 28px);
  }

  .workspace-shell .workspace-header {
    padding-inline: clamp(16px, 2vw, 28px);
  }

  .workspace-shell .page-head,
  .workspace-shell .resource-head,
  .workspace-shell .team-head,
  .workspace-shell .session-page-head {
    align-items: center;
  }

  .workspace-shell .page-head > *,
  .workspace-shell .resource-head > *,
  .workspace-shell .team-head > *,
  .workspace-shell .session-page-head > * {
    min-width: 0;
  }

  .workspace-shell .resource-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .workspace-shell .team-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace-shell .dashboard-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace-shell .dashboard-metrics {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .workspace-shell .session-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace-shell .agenda-week-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    overflow-x: visible;
  }

  .workspace-shell .agenda-day {
    min-width: 0;
    padding: 11px;
  }

  .workspace-shell .agenda-slot {
    grid-template-columns: 46px minmax(0, 1fr);
    padding: 8px;
  }

  .workspace-shell .agenda-slot-main {
    font-size: .84rem;
  }

  .workspace-shell .agenda-day-head h2 {
    font-size: .9rem;
  }

  .workspace-shell .resource-card,
  .workspace-shell .team-card,
  .workspace-shell .session-card,
  .workspace-shell .dashboard-panel {
    min-width: 0;
  }

  .workspace-shell .resource-kv > div,
  .workspace-shell .team-kv > div,
  .workspace-shell .session-kv > div {
    grid-template-columns: minmax(98px, .38fr) minmax(0, 1fr);
  }

  .workspace-shell .resource-card,
  .workspace-shell .team-card {
    padding: 14px;
  }

  .workspace-shell .team-actions,
  .workspace-shell .resource-actions {
    gap: 6px;
  }

  .workspace-shell .team-actions .btn,
  .workspace-shell .resource-actions .btn {
    min-height: 36px;
    padding: 8px 10px;
    font-size: .82rem;
  }

  .workspace-shell .daily-metrics {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .workspace-shell .daily-row {
    grid-template-columns: 78px minmax(220px, 1fr) minmax(150px, auto) minmax(220px, auto);
    gap: 12px;
  }

  .workspace-shell .search-panel {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (min-width: 1440px) {
  .workspace-shell .resource-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .workspace-shell .team-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .workspace-shell .dashboard-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 901px) and (max-width: 1180px) {
  .workspace-shell .main {
    width: 100%;
    padding-inline: 18px;
  }

  .workspace-shell .resource-grid,
  .workspace-shell .team-grid,
  .workspace-shell .session-grid,
  .workspace-shell .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace-shell .dashboard-metrics,
  .workspace-shell .daily-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .workspace-shell .agenda-week-grid {
    grid-template-columns: repeat(7, minmax(210px, 1fr));
    overflow-x: auto;
  }
}

@media (max-width: 900px) {
  .workspace-shell .main {
    width: 100%;
    padding-inline: 14px;
  }
}

.workspace-shell .resource-grid,
.workspace-shell .team-grid,
.workspace-shell .dashboard-grid,
.workspace-shell .session-grid,
.workspace-shell .agenda-week-grid {
  align-items: start;
}

.workspace-shell .resource-card-head,
.workspace-shell .team-card-head,
.workspace-shell .session-card-head {
  min-width: 0;
}

.workspace-shell .resource-card-head h3,
.workspace-shell .team-card-head h3,
.workspace-shell .session-card-head h2,
.workspace-shell .agenda-slot-main strong,
.workspace-shell .agenda-slot-main small {
  overflow-wrap: anywhere;
}

.workspace-shell .page-head,
.workspace-shell .resource-head,
.workspace-shell .team-head,
.workspace-shell .session-page-head,
.workspace-shell .agenda-week-actions,
.workspace-shell .day-controls {
  flex-wrap: wrap;
}

.workspace-shell .resource-actions,
.workspace-shell .team-actions,
.workspace-shell .session-actions {
  flex-wrap: wrap;
}

/* CN10 P1-C — scoped responsive/RTL fixes; candidate only. */
.workspace-shell .ltr-value {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
  text-align: left;
}

@media (min-width: 1181px) {
  .workspace-shell .daily-head {
    flex-direction: row;
    flex-wrap: nowrap;
  }
  .workspace-shell .daily-head > :first-child {
    flex: 0 0 auto;
  }
  .workspace-shell .daily-head .day-controls {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-end;
    gap: 6px;
  }
  .workspace-shell .daily-head .day-controls .btn {
    flex: 0 0 auto;
    white-space: nowrap;
    padding-inline: 10px;
  }
}

@media (max-width: 900px) {
  .workspace-shell .agenda-week-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
  }
  .workspace-shell .agenda-day {
    min-width: 0;
  }
}

@media (max-width: 620px) {
  .workspace-sidebar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px 10px;
  }
  .workspace-sidebar-brand {
    width: auto;
    min-width: 0;
  }
  .workspace-sidebar-footer {
    margin: 0;
    justify-content: flex-end;
  }
  .workspace-sidebar .section-nav {
    grid-column: 1 / -1;
    order: 3;
    display: flex;
    flex-wrap: nowrap;

    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding-bottom: 1px;
  }
  .workspace-sidebar .section-nav::-webkit-scrollbar {
    display: none;
  }
  .workspace-sidebar .section-nav-btn {
    width: auto;
    min-width: max-content;
    min-height: 38px;
    flex: 0 0 auto;
    gap: 6px;
    padding: 6px 9px;
  }
  .workspace-sidebar .section-nav-btn .section-nav-label {
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: normal;
  }
  .workspace-shell .agenda-week-grid {
    grid-template-columns: minmax(0, 1fr);
    overflow-x: visible;
  }
}

@media (max-width: 420px) {
  .workspace-sidebar {
    grid-template-columns: minmax(0, 1fr);
  }
  .workspace-sidebar-footer {
    grid-column: 1;
    justify-content: space-between;
  }
}

/* CN10 P1-D R1 — P2 remediation; candidate only. */
@media (min-width: 901px) and (max-width: 1180px) {
  .workspace-shell .agenda-week-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
  }
  .workspace-shell .agenda-day {
    min-width: 0;
  }
}

[dir="rtl"] .workspace-shell .booking-requests-head {
  justify-content: flex-start;
}
[dir="rtl"] .workspace-shell .booking-requests-head .team-head-actions {
  justify-content: flex-start;
}

.workspace-shell .booking-request-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
}
[dir="rtl"] .workspace-shell .booking-request-meta {
  justify-content: flex-end;
}

/* CN10 P1-E R2 — shell/navigation/tabs/page-header harmonization; candidate only. */
.workspace-shell {
  --p1e-control-h: 42px;
  --p1e-radius: 12px;
  --p1e-border: #d7e3e9;
  --p1e-soft: #f5f9fb;
  --p1e-head-gap: 16px;
}
.workspace-shell .workspace-header {
  align-items: flex-end;
  gap: var(--p1e-head-gap);
  padding-block: 20px 10px;
}
.workspace-shell .workspace-header-copy { min-width: 0; }
.workspace-shell .workspace-greeting { margin-bottom: 4px; line-height: 1.45; }
.workspace-shell .workspace-header h1 { line-height: 1.2; }
.workspace-shell .workspace-online-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
}
.workspace-shell .workspace-sidebar .section-nav { gap: 5px; }
.workspace-shell .workspace-sidebar .section-nav-btn {
  min-height: var(--p1e-control-h);
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--p1e-radius);
}
.workspace-shell .workspace-sidebar .section-nav-btn:focus-visible {
  outline: 3px solid rgba(255,255,255,.24);
  outline-offset: 2px;
}
.workspace-shell .section-nav-icon {
  width: 20px;
  flex-basis: 20px;
  font-size: .9rem;
}
.workspace-shell .section-nav-label { line-height: 1.2; }
.workspace-shell .tabs {
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--p1e-border);
  border-radius: 14px;
  background: var(--p1e-soft);
}
.workspace-shell .tab {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
}
.workspace-shell .tab:hover {
  color: var(--brand-2);
  background: rgba(255,255,255,.7);
}
.workspace-shell .tab.active {
  color: var(--brand-2);
  background: #fff;
  border-color: #cbdde5;
  box-shadow: 0 2px 8px rgba(7,54,95,.05);
}
.workspace-shell .tab:focus-visible {
  outline: 3px solid rgba(10,94,168,.22);
  outline-offset: 2px;
}
.workspace-shell .page-head,
.workspace-shell .resource-head,
.workspace-shell .team-head,
.workspace-shell .session-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--p1e-head-gap);
  margin-bottom: 16px;
}
.workspace-shell .page-head > :first-child,
.workspace-shell .resource-head > :first-child,
.workspace-shell .team-head > :first-child,
.workspace-shell .session-page-head > :first-child {
  min-width: 0;
  flex: 1 1 auto;
}
.workspace-shell .page-head h1,
.workspace-shell .resource-head h1,
.workspace-shell .team-head h1,
.workspace-shell .session-page-head h1 {
  margin: 0;
  line-height: 1.2;
}
.workspace-shell .page-head p,
.workspace-shell .resource-head p,
.workspace-shell .team-head p,
.workspace-shell .session-page-head p {
  margin: 6px 0 0;
  max-width: 900px;
  line-height: 1.6;
}
.workspace-shell .team-head-actions,
.workspace-shell .session-page-actions,
.workspace-shell .day-controls,
.workspace-shell .agenda-week-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.workspace-shell .team-head-actions .btn,
.workspace-shell .session-page-actions .btn,
.workspace-shell .day-controls .btn,
.workspace-shell .agenda-week-actions .btn {
  min-height: var(--p1e-control-h);
}
[dir="rtl"] .workspace-shell .page-head,
[dir="rtl"] .workspace-shell .resource-head,
[dir="rtl"] .workspace-shell .team-head,
[dir="rtl"] .workspace-shell .session-page-head {
  text-align: right;
}
@media (max-width: 900px) {
  .workspace-shell .workspace-header {
    gap: 12px;
    padding-block: 16px 8px;
  }
  .workspace-shell .tabs { margin-bottom: 12px; }
}
@media (max-width: 620px) {
  .workspace-shell .workspace-sidebar .section-nav-btn {
    min-height: 40px;
    gap: 6px;
    padding: 7px 9px;
  }
  .workspace-shell .page-head,
  .workspace-shell .resource-head,
  .workspace-shell .team-head,
  .workspace-shell .session-page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .workspace-shell .team-head-actions,
  .workspace-shell .session-page-actions,
  .workspace-shell .day-controls,
  .workspace-shell .agenda-week-actions {
    width: 100%;
  }
  .workspace-shell .tabs {
    width: 100%;
    padding: 4px;
  }
  .workspace-shell .tab { min-height: 38px; }
}
@media (max-width: 620px) {
  .workspace-shell .workspace-header {
    align-items: flex-start;
    flex-direction: column-reverse;
  }
  .workspace-shell .workspace-online-pill {
    align-self: flex-start;
  }
}


/* CN10 P1-E R2 micro-fix — candidate only.
   Frozen scope: Desktop Agenda weekly-grid allocation + AR Journée bidi/header only.
   No mobile, API, schema, permissions, DB or RDV behavior changes. */
.workspace-shell .workspace-greeting-name {
  direction: ltr;
  unicode-bidi: isolate;
}

.workspace-shell .agenda-slot-main strong,
.workspace-shell .agenda-slot-main small {
  overflow-wrap: break-word;
  word-break: normal;
}

@media (min-width: 1181px) and (max-width: 1699px) {
  .workspace-shell .agenda-week-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow-x: visible;
  }

  [dir="rtl"] .workspace-shell .daily-head {
    flex-direction: column;
    align-items: stretch;
  }

  [dir="rtl"] .workspace-shell .daily-head .day-controls {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (min-width: 1700px) {
  .workspace-shell .agenda-week-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    overflow-x: visible;
  }
}
