:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --border: #e3e9f1;
  --text: #17243b;
  --muted: #66758b;
  --accent: #2563eb;
  --accent-soft: #eaf2ff;
  --green: #16845b;
  --amber: #b66a0b;
  --purple: #7452c8;
  --shadow: 0 10px 28px rgba(20, 35, 60, 0.055);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(180deg, #f7f9fc 0%, var(--bg) 280px);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 12px;
  left: 12px;
  transform: translateY(-160%);
  border-radius: 8px;
  padding: 10px 14px;
  background: #fff;
  color: var(--accent);
  box-shadow: var(--shadow);
  font-weight: 700;
}

.skip-link:focus {
  transform: translateY(0);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(20px, 5vw, 64px);
  background:
    radial-gradient(ellipse at 90% 10%, rgba(59, 130, 246, 0.09), transparent 34%),
    #f4f7fb;
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  width: min(100%, 1040px);
  min-height: 620px;
  overflow: hidden;
  border: 1px solid rgba(213, 222, 234, 0.8);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(20, 35, 60, 0.14), 0 4px 14px rgba(20, 35, 60, 0.04);
}

.login-aside {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  padding: clamp(30px, 5vw, 58px);
  overflow: hidden;
  background:
    radial-gradient(ellipse at 100% 0%, rgba(66, 185, 213, 0.22), transparent 42%),
    linear-gradient(145deg, #172b4a 0%, #10213a 72%, #0d1b31 100%);
  color: #f8fafc;
}

.login-aside::after {
  position: absolute;
  right: -120px;
  bottom: -170px;
  width: 380px;
  height: 380px;
  border: 1px solid rgba(191, 219, 254, 0.11);
  border-radius: 50%;
  box-shadow: 0 0 0 34px rgba(191, 219, 254, 0.025), 0 0 0 70px rgba(191, 219, 254, 0.025);
  content: "";
  pointer-events: none;
}

.login-aside .brand-block,
.login-aside-copy,
.login-aside-footer {
  position: relative;
  z-index: 1;
}

.login-brand {
  color: #f8fafc;
}

.login-brand .brand-icon {
  flex: 0 0 auto;
  color: #fff;
}

.login-brand .eyebrow {
  margin: 0 0 4px;
  color: #93c5fd;
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.2;
}

.login-aside-copy {
  max-width: 410px;
  margin: 56px 0 68px;
}

.login-aside-copy .eyebrow {
  margin: 0 0 16px;
  color: #93c5fd;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-aside-copy h2 {
  margin: 0;
  font-size: clamp(2rem, 4.2vw, 3.1rem);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1.12;
}

.login-aside-copy > p:last-child {
  max-width: 340px;
  margin: 20px 0 0;
  color: #cbd5e1;
  font-size: 1rem;
  line-height: 1.7;
}

.login-aside-footer {
  margin: 0;
  color: #a9b8cc;
  font-size: 0.82rem;
  letter-spacing: 0.015em;
}

.login-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: clamp(32px, 5vw, 68px);
}

.login-heading .eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-heading h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2rem);
  letter-spacing: -0.035em;
}

.login-intro {
  margin: 10px 0 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 10px;
  margin-top: 34px;
}

.login-form label {
  margin-top: 8px;
  font-size: 0.86rem;
  font-weight: 650;
}

.login-form input {
  width: 100%;
  min-height: 48px;
  padding: 10px 13px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.login-form .primary-btn {
  min-height: 48px;
  margin-top: 12px;
  border-radius: 10px;
  box-shadow: 0 5px 12px rgba(37, 99, 235, 0.16);
}

.login-error {
  min-height: 1.2em;
  margin: 0;
  color: #b42318;
  font-size: 0.86rem;
}

.login-card-footer {
  margin: 34px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
}

.app-shell[hidden],
.login-screen[hidden] {
  display: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #14213a 0%, #101b30 100%);
  color: #f8fafc;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid rgba(148, 163, 184, 0.14);
}

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

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #3478ee, #42b9d5);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.24);
  font-size: 24px;
  font-weight: 700;
}

.brand-block h1 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.brand-block p {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.9rem;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.nav-group {
  display: grid;
  gap: 3px;
}

.nav-group-title {
  margin: 0 0 4px;
  padding: 0 12px;
  color: #94a3b8;
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-link {
  border: 0;
  text-align: left;
  padding: 10px 12px;
  border-radius: 9px;
  min-height: 42px;
  color: #cbd5e1;
  background: transparent;
  cursor: pointer;
  font-size: 0.92rem;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.nav-link.active {
  box-shadow: inset 3px 0 0 #60a5fa;
  background: rgba(59, 130, 246, 0.16);
  color: #fff;
}

.nav-link:hover {
  background: rgba(148, 163, 184, 0.15);
  color: white;
}

.hidden-section {
  display: none;
}

.view-section.hidden-section {
  display: none !important;
}

.sidebar-card {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  padding: 14px;
}

.quick-action-card .eyebrow {
  color: #93c5fd;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
}

.sidebar-card p {
  color: #cbd5e1;
  line-height: 1.45;
}

.role-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.role-card h3 {
  margin: 0;
  font-size: 0.95rem;
}

.role-card > p {
  margin: 0;
  color: #f8fafc;
  font-weight: 650;
}

.role-help {
  color: #cbd5e1;
  font-size: 0.88rem;
  line-height: 1.5;
}

.role-label {
  color: #e2e8f0;
  font-size: 0.85rem;
  font-weight: 600;
}

.role-card select {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.55);
  color: #f8fafc;
}

.role-card select option {
  color: var(--text);
}

.sign-out-btn {
  align-self: flex-start;
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: #bfdbfe;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sign-out-btn:hover {
  color: #fff;
}

.primary-btn,
.ghost-btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 650;
  transition: background 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.primary-btn {
  background: linear-gradient(135deg, #2864d7, #3184df);
  color: white;
}

.primary-btn:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
  transform: translateY(-1px);
}

.primary-btn:disabled,
.ghost-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ghost-btn {
  background: var(--accent-soft);
  color: var(--accent);
}

.ghost-btn:hover:not(:disabled) {
  background: #bfdbfe;
}

.main-panel {
  min-width: 0;
  padding: clamp(20px, 3vw, 36px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px 24px;
  min-height: 62px;
  padding-bottom: 2px;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-weight: 700;
}

.topbar h2 {
  margin: 0;
  font-size: clamp(1.3rem, 2vw, 1.7rem);
  letter-spacing: -0.035em;
  line-height: 1.2;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 360px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.search-box {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  min-width: 220px;
  max-width: 340px;
  min-height: 42px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.search-box:focus-within {
  border-color: #8bb4f4;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-box input {
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
  min-width: 0;
  padding: 8px 0;
  box-shadow: none;
}

.demo-badge {
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 7px 10px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  gap: 12px;
}

.stat-card {
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 14px;
  padding: 17px 18px;
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.025);
  transition: box-shadow 140ms ease, transform 140ms ease;
}

button.stat-card {
  font: inherit;
  text-align: left;
  cursor: pointer;
  width: 100%;
}

.stat-card.selected {
  box-shadow: 0 0 0 2px #4d84e8;
}

.stat-card:focus-visible {
  outline: 2px solid #4d84e8;
  outline-offset: 2px;
}

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  font-weight: 600;
}

.filter-bar.hidden-section {
  display: none;
}

.patient-card .filter-detail {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
}

.stat-card:hover {
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}

.stat-card p,
.stat-card span {
  margin: 0;
}

.stat-card p {
  font-size: 0.88rem;
  font-weight: 600;
}

.stat-card span {
  color: #475569;
  font-size: 0.8rem;
}

.stat-card strong {
  display: block;
  font-size: 1.8rem;
  margin: 6px 0 3px;
}

.accent-blue { border-left: 3px solid #4d84e8; background: #f0f5ff; }
.accent-green { border-left: 3px solid #3a9b74; background: #f0f8f4; }
.accent-amber { border-left: 3px solid #cf8b2d; background: #fbf6ed; }
.accent-purple { border-left: 3px solid #826ac7; background: #f5f2fb; }

.content-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.4fr;
  gap: 18px;
}

.lower-grid {
  grid-template-columns: 1fr 1fr;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.035);
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.panel-header h3 {
  margin: 0;
}

.pill {
  background: #f1f5f9;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.patient-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 440px;
  overflow-y: auto;
  padding-right: 4px;
}

.patient-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.patient-card:hover {
  border-color: #b7c8e2;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.045);
}

.patient-card.active {
  border-color: #7da7ec;
  background: #f5f8ff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.patient-card strong {
  display: block;
  margin-bottom: 4px;
}

.patient-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.detail-panel {
  min-height: 320px;
}

.patient-status-dashboard {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.status-overview,
.clinical-dashboard-card,
.patient-timeline {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.status-overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px 18px;
  padding: 16px;
  border-left: 4px solid var(--accent);
}

.status-overview h4,
.clinical-dashboard-heading h4,
.timeline-heading h4 {
  margin: 0;
  color: var(--text);
}

.status-overview > div:first-child > p:last-child {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.status-overview-tags {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.status-overview-tags .status-pill {
  background: #f1f5f9;
  color: #334155;
}

.status-overview-tags .status-urgent {
  background: #fee2e2;
  color: #991b1b;
}

.allergy-alert {
  grid-column: 1 / -1;
  margin: 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 0.88rem;
}

.clinical-dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 12px;
}

.clinical-dashboard-card {
  min-width: 0;
  padding: 15px;
  background: #fbfdff;
}

.clinical-dashboard-heading,
.timeline-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.clinical-dashboard-heading .eyebrow,
.timeline-heading .eyebrow,
.status-overview .eyebrow {
  margin-bottom: 4px;
  font-size: 0.66rem;
}

.dashboard-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
}

.vital-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.vital-metric {
  min-width: 0;
  border: 1px solid #e8edf5;
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.vital-metric span,
.vital-metric strong {
  display: block;
}

.vital-metric span {
  color: var(--muted);
  font-size: 0.75rem;
}

.vital-metric strong {
  margin-top: 4px;
  color: var(--text);
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.dashboard-footnote {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.vital-history {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 9px;
}

.vital-history summary {
  color: var(--accent);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 650;
}

.vital-history-list {
  display: grid;
  gap: 7px;
  margin-top: 9px;
}

.vital-history-row {
  display: grid;
  grid-template-columns: minmax(110px, auto) minmax(0, 1fr);
  gap: 8px;
  color: #475569;
  font-size: 0.76rem;
}

.vital-history-row time {
  color: var(--muted);
}

.vital-history-row span {
  overflow-wrap: anywhere;
}

.imaging-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.imaging-metric-grid > div {
  display: grid;
  justify-items: center;
  gap: 3px;
  border-radius: 9px;
  padding: 9px 4px;
  background: #f1f5f9;
}

.imaging-metric-grid strong {
  color: var(--text);
  font-size: 1.1rem;
}

.imaging-metric-grid span {
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
}

.latest-imaging {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.latest-imaging-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
}

.latest-imaging-heading > strong {
  min-width: 0;
}

.latest-imaging > p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.latest-imaging .latest-imaging-report {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: #334155;
}

.compact-empty {
  margin-top: 10px;
  padding: 10px;
  font-size: 0.8rem;
}

.patient-timeline {
  margin: 0 0 18px;
  padding: 15px;
}

.timeline-heading {
  margin-bottom: 8px;
}

.timeline-list {
  position: relative;
  display: grid;
  gap: 0;
  margin: 0;
  padding: 4px 0 0;
  list-style: none;
}

.timeline-list::before {
  position: absolute;
  top: 11px;
  bottom: 14px;
  left: 7px;
  width: 2px;
  background: #e2e8f0;
  content: "";
}

.timeline-item {
  position: relative;
  padding: 0;
}

.timeline-entry {
  min-width: 0;
}

.timeline-summary {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 10px;
  padding: 7px 0 9px;
  list-style: none;
  cursor: pointer;
}

.timeline-summary::-webkit-details-marker {
  display: none;
}

.timeline-summary:focus-visible {
  border-radius: 6px;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.timeline-marker {
  z-index: 1;
  width: 14px;
  height: 14px;
  margin-top: 3px;
  border: 3px solid #dbeafe;
  border-radius: 50%;
  background: #2563eb;
}

.timeline-imaging { border-color: #ede9fe; background: #7c3aed; }
.timeline-medication,
.timeline-laboratory,
.timeline-vitals { border-color: #dcfce7; background: #16a34a; }
.timeline-appointment { border-color: #fef3c7; background: #d97706; }
.timeline-document { border-color: #e2e8f0; background: #64748b; }

.timeline-content {
  min-width: 0;
}

.timeline-content > time {
  display: block;
  margin-top: 3px;
}

.timeline-event-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 9px;
}

.timeline-event-heading > strong {
  color: #1e293b;
  font-size: 0.88rem;
}

.timeline-type {
  border-radius: 999px;
  padding: 2px 7px;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.68rem;
  font-weight: 650;
}

.timeline-content > p {
  margin: 3px 0;
  color: #475569;
  font-size: 0.8rem;
  line-height: 1.4;
}

.timeline-content time {
  color: var(--muted);
  font-size: 0.72rem;
}

.timeline-expanded {
  margin: 0 0 10px 26px;
  border-left: 2px solid #dbeafe;
  padding: 2px 0 2px 12px;
}

.timeline-description {
  margin: 0 0 7px;
  color: #475569;
  font-size: 0.8rem;
  line-height: 1.45;
}

.timeline-detail-list {
  display: grid;
  gap: 6px;
  margin: 0;
}

.timeline-detail-list > div {
  display: grid;
  grid-template-columns: minmax(80px, 110px) minmax(0, 1fr);
  gap: 8px;
  font-size: 0.77rem;
  line-height: 1.4;
}

.timeline-detail-list dt {
  color: var(--muted);
  font-weight: 650;
}

.timeline-detail-list dd {
  min-width: 0;
  margin: 0;
  color: #334155;
  overflow-wrap: anywhere;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.detail-header h3 {
  margin: 0 0 6px;
  font-size: 1.3rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.mini-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: #fbfdff;
}

.mini-card h4 {
  margin: 0 0 10px;
}

.detail-notes {
  margin-top: 12px;
}

.mini-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fbfdff;
}

.appointment-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.appointment-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 8px 12px;
}

.appointment-item.completed {
  background: #f0fdf4;
}

.appointment-item.cancelled {
  background: #fff7ed;
}

.list-item strong {
  display: block;
  margin-bottom: 4px;
}

.snapshot-panel {
  display: grid;
  gap: 12px;
}

.snapshot-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: #f8fbff;
  border-radius: 14px;
}

.audit-panel {
  margin-top: 2px;
}

.audit-trail-list {
  display: grid;
  gap: 10px;
}

.audit-entry {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: #fbfdff;
}

.audit-entry strong,
.audit-entry span,
.audit-entry p {
  display: block;
}

.audit-entry span,
.audit-entry p {
  color: var(--muted);
}

.audit-entry span {
  margin-top: 4px;
  font-size: 0.9rem;
}

.audit-entry p {
  margin: 8px 0 0;
  line-height: 1.5;
}

.encounter-panel {
  margin-top: 2px;
}

.encounter-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  color: #334155;
}

input,
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fcfdff;
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

textarea {
  resize: vertical;
}

.status-message {
  margin: 12px 0 0;
  color: var(--green);
  font-weight: 600;
}

.demo-notice {
  margin-bottom: 0;
  color: #bfdbfe !important;
  font-size: 0.72rem;
  line-height: 1.4;
}

.clinical-workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.clinical-workspace.hidden-section {
  display: none;
}

.clinical-banner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  border-top: 4px solid var(--accent);
}

.clinical-banner h3 {
  margin: 0;
  font-size: 1.35rem;
}

.muted-copy,
.document-meta {
  color: var(--muted);
}

.workflow-summary {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.workflow-chip,
.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.82rem;
  font-weight: 700;
}

.clinical-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.structured-fields {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: #fbfdff;
}

.structured-fields-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.structured-fields-heading strong {
  color: #1e293b;
  font-size: 0.92rem;
}

.structured-fields-heading span {
  color: var(--muted);
  font-size: 0.82rem;
}

.structured-fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.structured-fields label span {
  color: #dc2626;
}

.structured-fields select,
.structured-fields input,
.structured-fields textarea {
  width: 100%;
}

.structured-field-wide {
  grid-column: 1 / -1;
}

.document-fields .structured-fields-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.structured-record-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin: 14px 0 0;
}

.structured-record-fields > div {
  min-width: 0;
  border-left: 2px solid #dbeafe;
  padding-left: 10px;
}

.structured-record-fields dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.structured-record-fields dd {
  margin: 3px 0 0;
  color: #334155;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.clinical-form > button {
  align-self: flex-start;
}

.vitals-fieldset {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}

.vitals-fieldset legend {
  padding: 0 6px;
  color: #334155;
  font-weight: 700;
}

.vitals-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.form-caution {
  margin: 0;
  color: #92400e;
  font-size: 0.88rem;
  line-height: 1.5;
}

.record-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.record-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: #fbfdff;
}

.imaging-record {
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 14px;
}

.imaging-record:first-of-type {
  border-top: 0;
  margin-top: 0;
}

.imaging-record > p {
  margin: 8px 0 0;
  color: #475569;
  line-height: 1.55;
}

.imaging-preview {
  width: min(100%, 320px);
  margin: 12px 0 0;
}

.imaging-preview img {
  display: block;
  width: 100%;
  max-height: 300px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #0f172a;
  object-fit: contain;
}

.imaging-preview figcaption {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.72rem;
}

.record-card-header,
.record-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.record-card h4 {
  margin: 5px 0 0;
}

.record-card p {
  margin: 10px 0 0;
  color: #475569;
  line-height: 1.55;
  white-space: pre-wrap;
}

.record-category {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.record-card-footer {
  align-items: center;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.86rem;
}

.record-card-footer button {
  margin-left: 6px;
}

.text-btn {
  border: 0;
  background: transparent;
  color: #b91c1c;
  cursor: pointer;
  padding: 8px;
}

.status-completed {
  background: #dcfce7;
  color: #166534;
}

.status-cancelled {
  background: #f1f5f9;
  color: #475569;
}

.status-acknowledged {
  background: #fef3c7;
  color: #92400e;
}

.document-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.document-sections > div {
  border-left: 3px solid #dbeafe;
  padding-left: 10px;
}

.document-sections strong {
  color: #334155;
  font-size: 0.9rem;
}

.empty-state {
  margin: 0;
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.nav-link:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 1080px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid,
  .lower-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .login-screen {
    padding: 18px;
  }

  .login-layout {
    grid-template-columns: minmax(0, 1fr);
    width: min(100%, 520px);
    min-height: 0;
  }

  .login-aside {
    min-height: 230px;
    padding: 26px;
  }

  .login-aside-copy {
    margin: 34px 0 0;
  }

  .login-aside-copy h2 {
    max-width: 390px;
    font-size: clamp(1.75rem, 7vw, 2.4rem);
  }

  .login-aside-copy > p:last-child,
  .login-aside-footer {
    display: none;
  }

  .login-card {
    padding: clamp(26px, 7vw, 40px);
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    min-width: 0;
    position: static;
    height: auto;
    overflow: visible;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .nav-links {
    width: 100%;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-group {
    display: contents;
  }

  .nav-group-title {
    display: none;
  }

  .nav-link {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .quick-action-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
  }

  .quick-action-card .eyebrow,
  .quick-action-card .demo-notice {
    display: none;
  }

  .role-card {
    margin-top: 0;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    column-gap: 12px;
  }

  .role-card h3,
  .role-help {
    display: none;
  }

  .role-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
  }

  .role-card select {
    min-width: 125px;
  }

  .topbar,
  .row {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    width: 100%;
  }

  .search-box {
    flex: 1 1 auto;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .status-overview {
    grid-template-columns: minmax(0, 1fr);
  }

  .status-overview-tags {
    justify-content: flex-start;
  }

  .vitals-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .clinical-banner {
    flex-direction: column;
  }

  .workflow-summary {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .main-panel {
    min-width: 0;
    padding: 16px 12px 24px;
    gap: 14px;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .search-box {
    min-width: 100%;
    max-width: none;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-card strong {
    font-size: 1.5rem;
  }

  .panel {
    padding: 14px;
    border-radius: 14px;
  }

  .vitals-grid,
  .document-sections {
    grid-template-columns: 1fr;
  }

  .vital-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .imaging-metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .vital-history-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .record-card-header,
  .record-card-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .structured-fields-grid,
  .structured-record-fields,
  .document-fields .structured-fields-grid {
    grid-template-columns: 1fr;
  }
}

.collapse-toggle {
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}

.collapse-toggle:hover {
  background: #f1f5f9;
}

.collapse-toggle:focus-visible {
  outline: 2px solid #4d84e8;
  outline-offset: 2px;
}

.collapsible.collapsed > .collapse-head .collapse-toggle {
  transform: rotate(-90deg);
}

.collapse-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.collapse-head > :first-child:not(.collapse-toggle) {
  margin-right: auto;
}

h4.collapse-head .collapse-toggle {
  margin-left: auto;
}

.collapsible.collapsed > .collapse-head {
  margin-bottom: 0;
}

.section-summary {
  margin: -6px 0 12px;
  color: var(--muted);
  font-size: 0.84rem;
}

.collapsible.collapsed > .section-summary {
  margin: 6px 0 0;
}

.collapsible.collapsed > :not(.collapse-head):not(.section-summary) {
  display: none;
}

.data-exchange {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.data-exchange .ghost-btn {
  min-height: 36px;
}

.data-exchange select {
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line, #d7dee8);
  border-radius: 8px;
  background: #fff;
  font: inherit;
}

@media (max-width: 760px) {
  html {
    scroll-padding-top: 190px;
  }

  .login-screen {
    min-height: 100vh;
    min-height: 100svh;
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  }

  .app-shell {
    min-height: 100vh;
    min-height: 100svh;
  }

  .sidebar {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    align-items: center;
    column-gap: 10px;
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px max(14px, env(safe-area-inset-left)) 10px;
    background: #14213a;
    box-shadow: 0 5px 14px rgba(15, 23, 42, 0.15);
  }

  .sidebar > .brand-block,
  .sidebar > .nav-links {
    grid-column: 1 / -1;
  }

  .sidebar > .brand-block {
    gap: 10px;
  }

  .sidebar > .brand-block .brand-icon {
    width: 42px;
    height: 42px;
  }

  .sidebar > .brand-block p {
    font-size: 0.82rem;
  }

  .nav-links {
    gap: 6px;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .nav-link {
    min-height: 44px;
    scroll-snap-align: start;
  }

  .quick-action-card {
    grid-column: 1;
    min-width: 0;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .quick-action-card .primary-btn {
    width: 100%;
    min-height: 44px;
    padding: 10px 8px;
    font-size: 0.86rem;
    white-space: nowrap;
  }

  .role-card {
    grid-column: 2;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .role-card > p {
    display: none;
  }

  .role-card select {
    flex: 1 1 auto;
    min-height: 44px;
    min-width: 0;
    padding: 8px;
  }

  .role-card .sign-out-btn {
    flex: 0 0 auto;
  }

  .sign-out-btn {
    min-height: 44px;
    padding: 8px 0;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    flex: 0 1 auto;
    justify-content: stretch;
    align-content: flex-start;
    width: 100%;
  }

  .search-box {
    min-height: 46px;
  }

  .search-box input,
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .data-exchange {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .data-exchange select,
  .data-exchange .ghost-btn {
    width: 100%;
    min-width: 0;
    min-height: 44px;
  }

  .data-exchange select {
    padding: 0 8px;
  }
}

@media (max-width: 520px) {
  .main-panel {
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .topbar {
    gap: 12px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .demo-badge {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
  }

  .panel-header {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }

  .panel-header > :first-child {
    min-width: 0;
  }

  .imaging-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .patient-list {
    max-height: min(440px, 55vh);
  }

  .clinical-dashboard-heading,
  .timeline-heading {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .collapse-toggle {
    width: 36px;
    height: 36px;
  }
}

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

  .quick-action-card,
  .role-card {
    grid-column: 1 / -1;
  }

  .quick-action-card {
    justify-content: flex-start;
  }

  .quick-action-card .primary-btn {
    width: auto;
    padding: 8px 5px;
    font-size: 0.78rem;
  }
}
