/* ============================================================
   Meridian Chart — clinical EHR design system
   Clean, modern, calm clinical interface
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* ---- Accent / primary (teal clinical) ---- */
  --primary: #0E7C86;
  --primary-dark: #0A5C64;
  --primary-darker: #084650;
  --primary-light: #E4F2F3;
  --primary-mid: #BFE0E2;

  /* ---- Neutrals ---- */
  --bg: #EBEFF3;
  --bg-rail: #0E2A33;        /* dark teal-slate nav rail */
  --rail-active: #16424E;
  --surface: #FFFFFF;
  --surface-2: #F6F8FA;
  --surface-3: #EEF2F5;
  --border: #DCE3E9;
  --border-strong: #C4CFD8;
  --hairline: #E8ECF0;

  /* ---- Text ---- */
  --text: #15242E;
  --text-2: #43545F;
  --text-3: #6B7B86;
  --text-inv: #FFFFFF;

  /* ---- Status ---- */
  --critical: #C8392B;
  --critical-bg: #FBEAE8;
  --warn: #B9750A;
  --warn-bg: #FBF1E0;
  --good: #1E8A5C;
  --good-bg: #E6F4EC;
  --info: #2563EB;
  --info-bg: #E8EFFD;
  --purple: #6D4AA8;
  --purple-bg: #F0EAFA;

  /* lab flag colors */
  --high: #C8392B;
  --low: #2563EB;

  /* ---- Radius ---- */
  --r-xs: 3px;
  --r-sm: 5px;
  --r: 7px;
  --r-lg: 11px;
  --r-xl: 16px;

  /* ---- Shadow ---- */
  --sh-sm: 0 1px 2px rgba(21,36,46,.06), 0 1px 1px rgba(21,36,46,.04);
  --sh: 0 2px 6px rgba(21,36,46,.07), 0 1px 2px rgba(21,36,46,.05);
  --sh-md: 0 6px 18px rgba(21,36,46,.10), 0 2px 6px rgba(21,36,46,.06);
  --sh-lg: 0 16px 40px rgba(21,36,46,.16), 0 4px 12px rgba(21,36,46,.08);

  /* ---- Type ---- */
  --font: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;

  /* ---- Density (overridden by tweaks) ---- */
  --row-h: 38px;
  --pad: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { height: 100%; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: #C4CFD8; border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #A9B7C2; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.mono { font-family: var(--mono); font-feature-settings: "tnum"; }
.tnum { font-variant-numeric: tabular-nums; }

/* ============================================================
   App shell
   ============================================================ */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: 60px 1fr;
  background: var(--bg);
  overflow: hidden;
}

/* ---- Far-left nav rail ---- */
.rail {
  background: var(--bg-rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 4px;
  z-index: 40;
}
.rail-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(150deg, var(--primary) 0%, #15A0A8 100%);
  display: grid; place-items: center;
  color: #fff; margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(14,124,134,.5);
}
.rail-btn {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: #84A2AC;
  position: relative;
  transition: background .12s, color .12s;
}
.rail-btn:hover { background: var(--rail-active); color: #DCEAEC; }
.rail-btn.active { background: var(--rail-active); color: #fff; }
.rail-btn.active::before {
  content:''; position: absolute; left: -10px; top: 11px; bottom: 11px;
  width: 4px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.rail-btn .rail-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--critical); color: #fff;
  font-size: 10px; font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--bg-rail);
}
.rail-spacer { flex: 1; }
.rail-tip {
  position: absolute; left: 54px; white-space: nowrap;
  background: #15242E; color: #fff; padding: 5px 9px; border-radius: 6px;
  font-size: 12px; font-weight: 500; opacity: 0; pointer-events: none;
  transform: translateX(-4px); transition: opacity .12s, transform .12s; z-index: 60;
  box-shadow: var(--sh-md);
}
.rail-btn:hover .rail-tip { opacity: 1; transform: translateX(0); }

/* ---- Main column ---- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

/* ---- Top bar ---- */
.topbar {
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 30;
}
.topbar .brand { display: flex; align-items: baseline; gap: 8px; }
.topbar .brand b { font-size: 16px; font-weight: 700; letter-spacing: -.2px; }
.topbar .brand span { font-size: 12px; color: var(--text-3); }
.unit-pill {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface-3); border: 1px solid var(--border);
  padding: 5px 11px; border-radius: 20px; font-size: 12.5px; font-weight: 500; color: var(--text-2);
}
.unit-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }

.search {
  flex: 1; max-width: 460px; position: relative;
}
.search input {
  width: 100%; height: 36px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2);
  padding: 0 12px 0 36px; font-size: 13px; outline: none; transition: border .12s, box-shadow .12s, background .12s;
}
.search input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-light); }
.search .s-ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center;
  color: var(--text-2); position: relative; transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .ct {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--critical); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 8px; display: grid; place-items: center; border: 2px solid var(--surface);
}
.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 4px; border-radius: 22px; transition: background .12s; }
.user-chip:hover { background: var(--surface-3); }
.user-chip .uname { font-size: 12.5px; font-weight: 600; line-height: 1.1; white-space: nowrap; }
.user-chip .urole { font-size: 11px; color: var(--text-3); white-space: nowrap; }

/* ---- Patient (encounter) tabs ---- */
.enc-tabs {
  height: 36px; background: var(--surface-3); border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-end; padding: 0 8px; gap: 2px; flex-shrink: 0; overflow-x: auto;
}
.enc-tab {
  height: 30px; display: flex; align-items: center; gap: 8px; padding: 0 10px 0 12px;
  background: #E3E9EE; border: 1px solid transparent; border-bottom: none;
  border-radius: 7px 7px 0 0; font-size: 12px; color: var(--text-2); max-width: 220px;
  position: relative; top: 1px; transition: background .12s;
}
.enc-tab:hover { background: #EAEFF3; }
.enc-tab.active { background: var(--surface); border-color: var(--border); color: var(--text); font-weight: 600; }
.enc-tab .et-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.enc-tab .et-x { width: 17px; height: 17px; border-radius: 5px; display: grid; place-items: center; color: var(--text-3); flex-shrink: 0; }
.enc-tab .et-x:hover { background: rgba(0,0,0,.08); color: var(--text); }
.enc-tab .et-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* ============================================================
   Generic surfaces
   ============================================================ */
.content { flex: 1; overflow: auto; min-height: 0; }
.pad { padding: 20px 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.card-h {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--hairline);
}
.card-h h3 { font-size: 13px; font-weight: 700; letter-spacing: .01em; display: flex; align-items: center; gap: 8px; }
.card-h .ch-ic { color: var(--primary); display: grid; place-items: center; }
.card-h .spacer { flex: 1; }
.card-b { padding: 14px 16px; }
.card-b.flush { padding: 0; }

.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }

/* ---- Badges / pills ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 8px; border-radius: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
}
.badge.sq { border-radius: 5px; }
.badge-critical { background: var(--critical-bg); color: var(--critical); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-good { background: var(--good-bg); color: var(--good); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-neutral { background: var(--surface-3); color: var(--text-2); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); }

.dot-acuity { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.acuity-critical { background: var(--critical); box-shadow: 0 0 0 3px var(--critical-bg); }
.acuity-watch { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.acuity-stable { background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }

/* ---- Avatar ---- */
.avatar {
  border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; color: #fff; flex-shrink: 0; letter-spacing: .02em;
  background: var(--primary);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600; transition: background .12s, box-shadow .12s, border-color .12s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--sh-sm); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { color: var(--text-2); border: 1px solid var(--border); background: var(--surface); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-soft { background: var(--primary-light); color: var(--primary-dark); }
.btn-soft:hover { background: var(--primary-mid); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn-danger { background: var(--critical); color: #fff; }

/* ---- Tables ---- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; z-index: 2;
}
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--hairline); font-size: 13px; vertical-align: middle; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: none; }

.lab-hi { color: var(--high); font-weight: 700; }
.lab-lo { color: var(--low); font-weight: 700; }
.lab-flag { font-size: 10px; font-weight: 700; padding: 1px 4px; border-radius: 3px; margin-left: 5px; vertical-align: middle; }
.flag-H { background: var(--critical-bg); color: var(--critical); }
.flag-L { background: var(--info-bg); color: var(--info); }
.flag-HH, .flag-LL { background: var(--critical); color:#fff; }

/* ---- Chart workspace layout ---- */
.chart-wrap { display: grid; grid-template-columns: 282px 1fr; height: 100%; min-height: 0; }
.storyboard {
  background: var(--surface); border-right: 1px solid var(--border);
  overflow: auto; display: flex; flex-direction: column;
}
.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }

/* activity tab bar */
.act-tabs {
  display: flex; align-items: stretch; gap: 2px; background: var(--surface);
  border-bottom: 1px solid var(--border); padding: 0 10px; flex-shrink: 0; overflow-x: auto;
}
.act-tab {
  padding: 0 14px; height: 44px; display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-3); border-bottom: 2.5px solid transparent;
  white-space: nowrap; transition: color .12s;
}
.act-tab:hover { color: var(--text); }
.act-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.act-tab .at-ct { font-size: 11px; background: var(--surface-3); color: var(--text-2); border-radius: 9px; padding: 0 6px; height: 16px; display: grid; place-items: center; }

/* storyboard pieces */
.sb-photo-wrap { padding: 16px 16px 12px; display: flex; flex-direction: column; align-items: center; text-align: center; border-bottom: 1px solid var(--hairline); }
.sb-name { font-size: 16px; font-weight: 700; margin-top: 11px; letter-spacing: -.2px; }
.sb-sub { font-size: 12.5px; color: var(--text-2); margin-top: 1px; }
.sb-mrn { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.sb-sect { padding: 11px 16px; border-bottom: 1px solid var(--hairline); }
.sb-sect:last-child { border-bottom: none; }
.sb-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-bottom: 6px; }
.sb-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; padding: 2px 0; }
.sb-row .k { color: var(--text-3); }
.sb-row .v { font-weight: 600; text-align: right; }
.sb-alert { display: flex; align-items: flex-start; gap: 8px; padding: 7px 9px; border-radius: 7px; font-size: 12px; font-weight: 500; }

/* vital chips */
.vital-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px,1fr)); gap: 10px; }
.vital-chip { border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; background: var(--surface); }
.vital-chip .vc-lab { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); display:flex; align-items:center; gap:5px; }
.vital-chip .vc-val { font-size: 22px; font-weight: 700; line-height: 1.1; margin-top: 4px; }
.vital-chip .vc-val small { font-size: 12px; font-weight: 600; color: var(--text-3); margin-left: 2px; }
.vital-chip .vc-time { font-size: 10.5px; color: var(--text-3); margin-top: 2px; }

/* empty state */
.empty { display: grid; place-items: center; height: 100%; color: var(--text-3); text-align: center; }
.empty .ic { width: 56px; height: 56px; border-radius: 14px; background: var(--surface-3); display: grid; place-items: center; margin: 0 auto 14px; color: var(--text-3); }

/* misc */
.row { display: flex; align-items: center; }
.gap6{gap:6px}.gap8{gap:8px}.gap10{gap:10px}.gap12{gap:12px}.gap16{gap:16px}
.col { display: flex; flex-direction: column; }
.grow { flex: 1; }
.muted { color: var(--text-3); }
.t2 { color: var(--text-2); }
.fw6 { font-weight: 600; } .fw7 { font-weight: 700; }
.divider { height: 1px; background: var(--hairline); }
hr.divider { border: none; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
@media (max-width: 1280px) { .grid-3 { grid-template-columns: 1fr 1fr; } }

/* density: compact */
.density-compact { --row-h: 32px; }
.density-compact body, .density-compact { font-size: 13px; }
.density-compact .tbl td { padding: 6px 12px; }
.density-compact .card-b { padding: 11px 14px; }
.density-compact .pad { padding: 16px 18px; }
