:root {
  --ink: #12262c;
  --muted: #5b7178;
  --paper: #eef4f2;
  --card: #ffffff;
  --line: #d5e2dd;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --sidebar: #11343c;
  --sidebar-2: #0c272d;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #0f766e;
  --shadow: 0 10px 30px rgba(17, 52, 60, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "Source Sans 3", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

a { color: var(--teal-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

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

.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #e7f3f0;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand strong, .brand small { display: block; }
.brand small { opacity: 0.7; font-size: 0.75rem; }

.brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.7rem;
  background: #14b8a6;
  color: #06221f;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.nav { display: flex; flex-direction: column; gap: 0.2rem; }
.nav a, .nav-soon {
  padding: 0.55rem 0.7rem;
  border-radius: 0.5rem;
  color: inherit;
}

.nav a.is-active { background: rgba(20, 184, 166, 0.22); }
.nav a:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.nav-label {
  margin: 1rem 0.7rem 0.3rem;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.55;
}
.nav-soon { opacity: 0.35; }

.workspace { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem 1.4rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.global-search {
  flex: 1;
  max-width: 42rem;
  position: relative;
}

.global-search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.65rem 2.4rem 0.65rem 1rem;
  font: inherit;
}

.global-search kbd {
  position: absolute;
  right: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  padding: 0.05rem 0.4rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.topbar-meta { display: flex; gap: 0.8rem; align-items: center; }
.practice-chip, .user-chip {
  background: #e7f3f0;
  color: var(--teal-dark);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.linkish {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.content { padding: 1.4rem; }

.page-head, .panel-head, .patient-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

h1 { margin: 0.1rem 0 0; font-size: 1.7rem; }
h2 { margin: 0 0 0.8rem; font-size: 1.05rem; }
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--teal);
}

.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 1rem 0; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.2rem;
}

.stat-card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
}

.stat-card { padding: 1rem 1.1rem; }
.stat-card span, .stat-card em { display: block; color: var(--muted); font-style: normal; }
.stat-card strong { font-size: 1.6rem; }
.stat-card.is-muted { opacity: 0.72; }

.panel { padding: 1rem 1.1rem 1.2rem; }

table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td {
  text-align: left;
  padding: 0.7rem 0.4rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}
table.data th { color: var(--muted); font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 0.7rem;
  padding: 0.55rem 0.95rem;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.btn:hover { text-decoration: none; filter: brightness(0.97); }

.filter-bar, .form-grid, .stack { display: grid; gap: 0.8rem; }
.filter-bar { grid-template-columns: 1fr auto; margin-bottom: 1rem; }

input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  padding: 0.6rem 0.7rem;
  background: #fff;
}

label { display: grid; gap: 0.35rem; font-size: 0.9rem; color: var(--muted); }

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

.form-grid .full, .form-actions { grid-column: 1 / -1; }

.patient-head {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  align-items: center;
}

.patient-meta { margin: 0.35rem 0 0; color: var(--muted); }

.tabs {
  display: flex;
  gap: 0.4rem;
  margin: 0 0 1rem;
  flex-wrap: wrap;
}

.tabs a, .tabs span {
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
}
.tabs a.is-active, .tabs .is-active { background: var(--teal); color: #fff; border-color: var(--teal); }
.tabs .is-disabled { opacity: 0.5; }

.allergy-banner {
  margin: 0.5rem 0 0;
  background: #fee2e2;
  color: var(--danger);
  padding: 0.35rem 0.65rem;
  border-radius: 0.5rem;
  font-weight: 600;
}

.pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: #e7f3f0;
}
.pill-in_progress { background: #fef3c7; color: var(--warn); }
.row-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.encounter-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 1rem; }
.patient-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 900px) {
  .encounter-grid { grid-template-columns: 1fr; }
}

.split { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 1rem; }
.facts { display: grid; gap: 0.55rem; }
.facts div { display: grid; grid-template-columns: 8rem 1fr; gap: 0.5rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.notes { background: #f7faf9; padding: 0.8rem; border-radius: 0.7rem; }

.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.7rem; }
.timeline li { display: grid; gap: 0.15rem; }
.timeline span { color: var(--muted); font-size: 0.9rem; }

.later {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--line);
  color: var(--muted);
}

.flash {
  margin: 0.8rem 1.4rem 0;
  padding: 0.7rem 0.9rem;
  border-radius: 0.7rem;
}

.flash-error { background: #fee4e2; color: var(--danger); }
.flash-success { background: #d1fae5; color: var(--ok); }
.flash-info { background: #e0f2fe; }

.pager { display: flex; gap: 0.8rem; margin-top: 0.8rem; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top left, rgba(20,184,166,0.18), transparent 32%),
    linear-gradient(160deg, #0c272d, #12343c 45%, #0f766e);
}

.auth-card {
  width: min(26rem, calc(100% - 2rem));
  background: #fff;
  border-radius: 1.2rem;
  padding: 1.6rem;
  box-shadow: var(--shadow);
}

.brand-center { margin-bottom: 1.2rem; }
.hint { color: var(--muted); font-size: 0.85rem; }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
}
