@font-face {
  font-family: 'Space Grotesk';
  src: url('fonts/space-grotesk.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --cream: #faf8f4;
  --card: #ffffff;
  --ink: #1f2b28;
  --ink-soft: #5b6a66;
  --border: #e6e1d8;

  --teal: #1f5e56;
  --teal-dark: #163f3a;
  --sage: #e3ece7;

  --amber-bg: #fdf1dc;
  --amber-text: #9a6a12;
  --amber-dot: #d99a2b;

  --green-bg: #e4f3e8;
  --green-text: #276b3f;
  --green-dot: #2f9154;

  --red-bg: #fbe9e7;
  --red-text: #9c3a2e;
  --red-dot: #c24a38;

  --radius: 14px;
  --sidebar-w: 252px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
}

.serif, .brand-name, .screen h1, .today-greeting {
  font-family: Georgia, 'Times New Roman', serif;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--teal);
  color: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Georgia, serif;
  font-size: 17px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 19px;
  line-height: 1.2;
  color: var(--ink);
}

.brand-sub {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
  color: var(--ink-soft);
}

.nav-item:hover {
  background: var(--sage);
}

.nav-item.active {
  background: var(--sage);
  color: var(--teal-dark);
}

.nav-label { flex: 1; }

.nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--amber-bg);
  color: var(--amber-text);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 20px;
}

.staff-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
}

.staff-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--sage);
  color: var(--teal-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.staff-name { font-weight: 700; font-size: 13.5px; }
.staff-role { font-size: 12px; color: var(--ink-soft); }

/* Main */

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

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
}

.search { flex: 1; max-width: 480px; }

.search input {
  width: 100%;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 14px;
  outline: none;
}

.search input:focus {
  border-color: var(--teal);
}

.pill-btn {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.pill-btn:hover { border-color: var(--teal); }

.screen {
  padding: 32px;
  overflow-y: auto;
}

.screen h1 {
  font-size: 32px;
  margin: 0 0 6px;
}

.screen-sub {
  color: var(--ink-soft);
  margin: 0 0 24px;
  font-size: 14.5px;
}

/* Cards */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card + .card { margin-top: 16px; }

.grid {
  display: grid;
  gap: 16px;
}

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

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

.stat-tile {
  border-radius: var(--radius);
  padding: 18px;
  background: var(--sage);
}

.stat-tile .stat-label {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 10px;
}

.stat-tile .stat-number {
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 8px;
}

.stat-tile .stat-note {
  font-size: 12.5px;
  color: var(--ink-soft);
}

/* Badges / pills */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-amber { background: var(--amber-bg); color: var(--amber-text); }
.badge-amber::before { background: var(--amber-dot); }

.badge-green { background: var(--green-bg); color: var(--green-text); }
.badge-green::before { background: var(--green-dot); }

.badge-red { background: var(--red-bg); color: var(--red-text); }
.badge-red::before { background: var(--red-dot); }

.badge-neutral { background: var(--sage); color: var(--teal-dark); }
.badge-neutral::before { background: var(--teal); }

/* Lists */

.row-list .row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.row-list .row:last-child { border-bottom: none; }

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--sage);
  color: var(--teal-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; font-size: 14.5px; }
.row-sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.row-aside { flex-shrink: 0; text-align: right; }

/* Patients filter tabs */

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tab-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-soft);
}

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

/* Buttons */

.btn-primary {
  padding: 11px 18px;
  border-radius: 10px;
  border: none;
  background: var(--teal-dark);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.btn-primary:hover { background: var(--teal); }

.btn-secondary {
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

/* Patient profile */

.profile-head {
  display: flex;
  align-items: center;
  gap: 18px;
}

.profile-head .avatar { width: 64px; height: 64px; font-size: 22px; }

.profile-name {
  font-family: Georgia, serif;
  font-size: 26px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-meta {
  display: flex;
  gap: 32px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.profile-meta .meta-label {
  font-size: 11.5px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 3px;
}

.profile-meta .meta-value { font-weight: 700; font-size: 14.5px; }

.profile-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
}

.clinical-banner {
  background: var(--red-bg);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin: 16px 0;
}

@media (max-width: 1100px) {
  .clinical-banner { grid-template-columns: repeat(2, 1fr); }
}

.clinical-banner .field-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--red-text);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 4px;
}

.clinical-banner .field-value { font-size: 14px; }

.labs-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.labs-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0 0 8px;
  font-weight: 700;
}
.labs-table td { padding: 8px 0; border-top: 1px solid var(--border); }
.labs-table .flag-high, .labs-table .flag-low { color: var(--red-text); font-weight: 700; }

.protocol-list { list-style: none; margin: 0; padding: 0; }
.protocol-list li {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.protocol-list li:last-child { border-bottom: none; }
.protocol-list .item-note { color: var(--ink-soft); font-size: 12.5px; }

.notes-box {
  width: 100%;
  min-height: 90px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  outline: none;
}

.notes-box:focus { border-color: var(--teal); }

/* Inbox */

.inbox-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  height: calc(100vh - 220px);
  min-height: 420px;
}

.inbox-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  overflow-y: auto;
}

.inbox-list .row {
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.inbox-list .row.active { background: var(--sage); }
.inbox-list .row:hover { background: var(--sage); }

.inbox-detail {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inbox-detail-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
}

.inbox-detail-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.inbox-detail-head .back { font-weight: 700; color: var(--teal-dark); cursor: pointer; }

.medical-banner {
  margin: 14px 20px 0;
  padding: 12px 14px;
  background: var(--red-bg);
  color: var(--red-text);
  border-radius: 10px;
  font-size: 13.5px;
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-msg { max-width: 72%; }
.chat-msg.from-patient { align-self: flex-start; }
.chat-msg.from-assistant { align-self: flex-end; }

.chat-meta {
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  background: var(--sage);
}

.chat-msg.from-assistant .chat-bubble {
  background: var(--card);
  border: 1px solid var(--border);
}

/* Today greeting */

.today-greeting { font-size: 30px; margin: 4px 0 4px; }
.today-sub { color: var(--ink-soft); font-size: 14px; margin-bottom: 24px; }

.today-hero {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 1100px) {
  .today-hero { grid-template-columns: 1fr; }
}

.next-patient-card .badge { margin-right: 6px; margin-bottom: 6px; }
.next-patient-card .nx-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--teal-dark);
  font-weight: 700;
  margin-bottom: 6px;
}

.next-patient-card .nx-name { font-family: Georgia, serif; font-size: 20px; margin-bottom: 2px; }
.next-patient-card .nx-meta { color: var(--ink-soft); font-size: 13px; margin-bottom: 12px; }

.loading, .empty-state {
  padding: 40px 0;
  text-align: center;
  color: var(--ink-soft);
}

/* Auth */

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
}

.auth-card {
  width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 36px 28px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.auth-title {
  font-family: Georgia, serif;
  font-size: 22px;
  margin-bottom: 2px;
}

.auth-sub {
  color: var(--ink-soft);
  font-size: 13px;
  margin-bottom: 20px;
}

.auth-card input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
  margin-bottom: 10px;
  outline: none;
  font-family: inherit;
}

.auth-card input:focus { border-color: var(--teal); }

.auth-card .btn-primary {
  width: 100%;
  margin-top: 4px;
}

.auth-error {
  width: 100%;
  background: var(--red-bg);
  color: var(--red-text);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 10px;
  text-align: left;
}

.signout-link {
  margin-left: 8px;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: underline;
}
