/* SBMCB — layout
   The shell: a fixed sidebar, a header that never scrolls away, and one
   scrolling work area. Everything else is placed inside the work area by
   the page that owns it. */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

:root[data-nav="collapsed"] .shell {
  grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr);
}

/* ---- Sidebar ---------------------------------------------------------- */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  height: var(--header-h);
  padding: 0 var(--s4);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.sidebar-mark {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  flex: none;
  background: var(--accent);
  color: var(--ink-invert);
  border-radius: var(--radius-sm);
  font-size: var(--fs-tiny);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.sidebar-name {
  min-width: 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: var(--lh-tight);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-locality {
  font-size: var(--fs-tiny);
  color: var(--ink-3);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--s3) 0;
}

.nav-group + .nav-group { margin-top: var(--s4); }

.nav-group-name {
  padding: 0 var(--s4) var(--s2);
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 34px;
  padding: 0 var(--s4);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  border-left: 2px solid transparent;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
}

.nav-item[aria-current="page"] {
  background: var(--accent-wash);
  border-left-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
}

.nav-icon { flex: none; width: 15px; height: 15px; }

.nav-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A count beside a nav item is only ever a count of things needing a
   decision. Nothing else earns a badge. */
.nav-badge {
  flex: none;
  min-width: 18px;
  padding: 0 var(--s1);
  background: var(--warn-wash);
  color: var(--warn);
  border-radius: 999px;
  font-size: var(--fs-micro);
  font-weight: 600;
  text-align: center;
  line-height: 16px;
}

.nav-badge--critical { background: var(--neg-wash); color: var(--neg); }

.sidebar-foot {
  flex: none;
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--line);
}

.practitioner {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
}

.avatar {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  flex: none;
  background: var(--surface-3);
  color: var(--ink-2);
  border-radius: 999px;
  font-size: var(--fs-tiny);
  font-weight: 600;
}

.practitioner-name {
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.practitioner-role { font-size: var(--fs-micro); color: var(--ink-3); }

:root[data-nav="collapsed"] .nav-label,
:root[data-nav="collapsed"] .nav-group-name,
:root[data-nav="collapsed"] .sidebar-name,
:root[data-nav="collapsed"] .sidebar-locality,
:root[data-nav="collapsed"] .practitioner-name,
:root[data-nav="collapsed"] .practitioner-role { display: none; }

/* ---- Main column ------------------------------------------------------ */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.header {
  display: flex;
  align-items: center;
  gap: var(--s4);
  height: var(--header-h);
  flex: none;
  padding: 0 var(--s6);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-title { min-width: 0; }

.header-crumb {
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.header-spacer { flex: 1 1 auto; }

.header-clock {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-3);
  white-space: nowrap;
}

.header-tools { display: flex; align-items: center; gap: var(--s2); }

/* The strip under the header: page lead and page-level controls. */
.subheader {
  display: flex;
  align-items: center;
  gap: var(--s4);
  min-height: var(--subheader-h);
  flex: none;
  padding: var(--s2) var(--s6);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.subheader-lead {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-xs);
  color: var(--ink-2);
}

.work {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--s6);
}

.page { max-width: 1360px; }

/* ---- Sections inside a page ------------------------------------------- */

.section + .section { margin-top: var(--s7); }

.section-head {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  margin-bottom: var(--s3);
}

.section-title { font-size: var(--fs-sm); font-weight: 600; }

.section-note {
  flex: 1 1 auto;
  font-size: var(--fs-xs);
  color: var(--ink-3);
}

.grid { display: grid; gap: var(--s4); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* ---- Narrower screens -------------------------------------------------- */

@media (max-width: 1180px) {
  .grid--main, .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
  .nav-label, .nav-group-name, .sidebar-name,
  .sidebar-locality, .practitioner-name, .practitioner-role { display: none; }
  .work { padding: var(--s4); }
  .grid--main, .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
  .header-clock { display: none; }
}

/* The patient workspace is mounted outside the shell so that opening one
   does not rebuild the page underneath it. The host itself is nothing —
   it exists to give the drawer somewhere to live. */
.drawer-host { display: contents; }

/* Page-level controls, placed into the strip under the header rather than
   inside the page body, so every page starts with content. */
.subheader-tools {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: none;
}
