:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #edf2fb;
  --ink: #20242c;
  --muted: #5b6573;
  --line: #d8deeb;
  --midnight: #20469c;
  --cerulean: #20469c;
  --caduceus-red: #c93d33;
  --off-white: #f5f7fb;
  --teal: var(--cerulean);
  --teal-2: #518ecf;
  --green: #2f6f4d;
  --gold: #946716;
  --red: var(--caduceus-red);
  --blue: var(--cerulean);
  --shadow: 0 16px 48px rgba(32, 70, 156, 0.13);
  --radius: 8px;
  color-scheme: light;
  font-family: "Marr Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(32, 70, 156, 0.1), rgba(245, 247, 251, 0) 300px),
    radial-gradient(circle at top right, rgba(32, 70, 156, 0.14), rgba(245, 247, 251, 0) 360px),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand img {
  width: 86px;
  height: auto;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  flex: 0 0 auto;
}

.brand strong {
  display: block;
  color: var(--midnight);
  font-size: 16px;
  line-height: 1.15;
}

.brand span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.brand-tagline {
  color: var(--caduceus-red);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
}

.desktop-tagline {
  display: block;
  max-width: 180px;
  margin-top: -14px;
  color: var(--caduceus-red);
  text-align: left;
}

.mobile-bar {
  display: none;
}

.nav {
  display: grid;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #2d3644;
  text-align: left;
}

.nav-button:hover,
.nav-button:focus-visible {
  background: var(--surface-2);
  color: var(--midnight);
  outline: none;
}

.nav-button.active {
  background: var(--midnight);
  color: #ffffff;
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--caduceus-red);
}

.icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: currentColor;
  flex: 0 0 auto;
}

.icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.account-strip {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7f9fd;
}

.account-strip strong {
  display: block;
  font-size: 14px;
}

.account-strip span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--caduceus-red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 7px;
  font-size: 30px;
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.25;
  letter-spacing: 0;
}

.lede {
  max-width: 880px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover,
.button:focus-visible {
  border-color: rgba(32, 70, 156, 0.62);
  box-shadow: 0 0 0 3px rgba(32, 70, 156, 0.16);
  outline: none;
}

.button.primary {
  border-color: var(--midnight);
  background: var(--midnight);
  color: #ffffff;
  box-shadow: inset 0 -2px 0 rgba(201, 61, 51, 0.8);
}

.button.danger {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--red);
}

.button.icon-only {
  width: 40px;
  padding: 0;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel,
.record-shell,
.message-shell,
.form-shell {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header h2,
.panel-header h3 {
  margin-bottom: 0;
}

.stat-card {
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.stat-card .label {
  color: var(--caduceus-red);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.1;
}

.stat-card span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf3fa;
  color: #245783;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.green {
  background: #eaf5ee;
  color: #255c3f;
}

.badge.gold {
  background: #fff2d4;
  color: #6e4a0e;
}

.badge.red {
  background: #fcebea;
  color: var(--red);
}

.badge.blue {
  background: #e9f2fb;
  color: #2c5f92;
}

.row-list {
  display: grid;
  gap: 10px;
}

.row-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.row-main {
  min-width: 0;
}

.row-main strong {
  display: block;
  margin-bottom: 4px;
}

.row-main span,
.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.patient-band {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
  margin-bottom: 16px;
}

.patient-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--midnight);
  color: #ffffff;
  box-shadow: inset 0 4px 0 var(--caduceus-red);
}

.patient-avatar {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--off-white);
  color: var(--midnight);
  font-weight: 900;
}

.patient-identity strong {
  display: block;
  font-size: 19px;
}

.patient-identity span {
  display: block;
  margin-top: 4px;
  color: #dbe6f1;
  font-size: 13px;
}

.quick-tile {
  padding: 17px;
  border-radius: var(--radius);
  background: #ffffff;
  border: 1px solid var(--line);
}

.quick-tile span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.quick-tile strong {
  display: block;
  margin-top: 8px;
  font-size: 17px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #334050;
  font-weight: 750;
}

.tab:hover,
.tab:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.tab.active {
  border-color: var(--midnight);
  background: var(--midnight);
  color: #ffffff;
  box-shadow: inset 0 -2px 0 var(--caduceus-red);
}

.record-content,
.message-content,
.form-content {
  padding: 18px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: var(--radius);
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.flag {
  font-weight: 850;
}

.flag.high {
  color: var(--red);
}

.flag.normal {
  color: var(--green);
}

.flag.review {
  color: var(--gold);
}

.split {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1.28fr);
  gap: 16px;
}

.thread-list,
.form-list {
  display: grid;
  gap: 8px;
}

.thread-button,
.form-button {
  width: 100%;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.thread-button:hover,
.thread-button:focus-visible,
.form-button:hover,
.form-button:focus-visible {
  border-color: rgba(32, 70, 156, 0.62);
  box-shadow: 0 0 0 3px rgba(32, 70, 156, 0.14);
  outline: none;
}

.thread-button.active,
.form-button.active {
  border-color: var(--cerulean);
  background: #edf4fb;
}

.thread-button strong,
.form-button strong {
  display: block;
  margin-bottom: 5px;
}

.conversation {
  display: grid;
  gap: 12px;
}

.bubble {
  max-width: 82%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.bubble.patient {
  justify-self: end;
  background: #edf4fb;
  border-color: #b7d1ed;
}

.bubble strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.bubble p {
  margin-bottom: 6px;
  color: #273344;
  line-height: 1.45;
}

.composer,
.form-grid {
  display: grid;
  gap: 12px;
}

.composer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: #334050;
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
}

.field textarea {
  min-height: 108px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--cerulean);
  box-shadow: 0 0 0 3px rgba(32, 70, 156, 0.16);
  outline: none;
}

.inline-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.check-row,
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.check-row:last-child,
.toggle-row:last-child {
  border-bottom: 0;
}

.check-row input,
.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--cerulean);
}

.toggle-copy strong {
  display: block;
  font-size: 14px;
}

.toggle-copy span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.timeline {
  display: grid;
  gap: 0;
}

.timeline-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  padding-bottom: 14px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  width: 11px;
  height: 11px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--cerulean);
  box-shadow: 0 0 0 5px #e4edf7;
}

.timeline-item strong {
  display: block;
  margin-bottom: 3px;
}

.empty {
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #f7f9fd;
  color: var(--muted);
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 13px 14px;
  border: 1px solid rgba(32, 70, 156, 0.62);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-weight: 750;
}

.toast.hidden {
  display: none;
}

.stack {
  display: grid;
  gap: 16px;
}

.small-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .mobile-bar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto minmax(100px, 1fr);
    align-items: center;
    gap: 12px;
  }

  .mobile-bar .brand {
    justify-self: start;
  }

  .mobile-bar .brand-tagline {
    justify-self: center;
    max-width: 360px;
  }

  .mobile-bar .badge {
    justify-self: end;
  }

  .sidebar > .brand,
  .desktop-tagline,
  .account-strip {
    display: none;
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-button {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
  }

  .main {
    padding: 20px;
  }

  .patient-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  .mobile-bar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .mobile-bar .brand-tagline {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
  }

  .topline {
    display: grid;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .grid.two,
  .grid.three,
  .grid.four,
  .patient-band,
  .split,
  .inline-fields {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 25px;
  }

  .row-item {
    grid-template-columns: 1fr;
  }

  .bubble {
    max-width: 100%;
  }

  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
