/* ============================================================
   KCARE-CRE Design System
   Font: DM Sans (clean, medical-grade readability)
   Primary: Teal #2DBDAD | Navy: #1B3A6B | Accent: #E63946
   ============================================================ */

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

/* ── CSS Variables ───────────────────────────────────────────── */
:root {
  /* Brand */
  --teal:          #2DBDAD;
  --teal-dark:     #1F9F91;
  --teal-deeper:   #0F6E62;
  --teal-light:    #E8F7F5;
  --teal-pale:     #F2FBFA;
  --navy:          #1B3A6B;
  --navy-mid:      #2A4F8F;
  --navy-light:    #E8EDF5;
  --red:           #E63946;
  --red-light:     #FDECEA;
  --amber:         #F4A227;
  --amber-light:   #FEF6E7;
  --green:         #2A9D5C;
  --green-light:   #E8F7EE;

  /* Neutrals */
  --white:         #FFFFFF;
  --gray-50:       #F8F9FA;
  --gray-100:      #F1F3F5;
  --gray-200:      #E9ECEF;
  --gray-300:      #DEE2E6;
  --gray-400:      #CED4DA;
  --gray-500:      #ADB5BD;
  --gray-600:      #6C757D;
  --gray-700:      #495057;
  --gray-800:      #343A40;
  --gray-900:      #212529;

  /* Layout */
  --sidebar-w:     240px;
  --header-h:      60px;
  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     14px;
  --radius-xl:     20px;

  /* Shadows */
  --shadow-xs:     0 1px 3px rgba(27,58,107,.08);
  --shadow-sm:     0 2px 8px rgba(27,58,107,.10);
  --shadow:        0 4px 16px rgba(27,58,107,.12);
  --shadow-lg:     0 8px 30px rgba(27,58,107,.16);

  /* Typography */
  --font:          'DM Sans', system-ui, sans-serif;
  --font-mono:     'DM Mono', monospace;

  /* Transitions */
  --trans:         180ms ease;
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100vh;
}

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

img { max-width: 100%; display: block; }

/* ── Login Page ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 420px;
}

.login-brand {
  background: var(--navy);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}

.login-brand::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: var(--teal);
  border-radius: 50%;
  opacity: .08;
  top: -200px; right: -200px;
}

.login-brand::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: var(--teal);
  border-radius: 50%;
  opacity: .06;
  bottom: -150px; left: -100px;
}

.login-brand-logo {
  width: 120px; height: 120px;
  background: var(--white);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
  position: relative; z-index: 1;
  overflow: hidden;
}

.login-brand-logo img { width: 100%; height: 100%; object-fit: cover; }

.login-brand h1 {
  color: var(--white);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -.5px;
  text-align: center;
  position: relative; z-index: 1;
}

.login-brand h1 span { color: var(--teal); }

.login-brand p {
  color: rgba(255,255,255,.6);
  font-size: .85rem;
  text-align: center;
  margin-top: .5rem;
  position: relative; z-index: 1;
  letter-spacing: .05em;
  text-transform: uppercase;
  font-weight: 500;
}

.login-brand-tagline {
  margin-top: 3rem;
  padding: 1.25rem 1.5rem;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-lg);
  max-width: 320px;
  position: relative; z-index: 1;
}

.login-brand-tagline p {
  color: rgba(255,255,255,.75);
  font-size: .8rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  line-height: 1.7;
}

.login-panel {
  background: var(--white);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 2.5rem;
  box-shadow: -4px 0 20px rgba(27,58,107,.08);
}

.login-panel h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: .35rem;
}

.login-panel > p {
  color: var(--gray-600);
  font-size: .875rem;
  margin-bottom: 2rem;
}

/* ── App Shell (Desktop) ─────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  min-height: 100vh;
}

/* Top bar */
.topbar {
  grid-column: 1 / -1;
  background: var(--navy);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.topbar-brand {
  display: flex; align-items: center; gap: .75rem;
  text-decoration: none;
  flex-shrink: 0;
}

.topbar-logo {
  width: 34px; height: 34px;
  background: var(--white);
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.topbar-logo img { width: 100%; height: 100%; object-fit: cover; }

.topbar-name {
  font-size: .95rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1.1;
}

.topbar-name small {
  display: block;
  font-size: .68rem;
  font-weight: 400;
  color: var(--teal);
  letter-spacing: .04em;
}

.topbar-divider {
  width: 1px; height: 28px;
  background: rgba(255,255,255,.15);
  margin: 0 .25rem;
}

.topbar-middle { flex: 1; }

.topbar-right {
  display: flex; align-items: center; gap: .75rem;
  flex-shrink: 0;
}

.topbar-time {
  font-size: .78rem;
  color: rgba(255,255,255,.55);
  font-family: var(--font-mono);
}

.topbar-shift {
  font-size: .72rem;
  font-weight: 600;
  padding: .25rem .65rem;
  border-radius: 99px;
  background: rgba(45,189,173,.2);
  color: var(--teal);
  border: 1px solid rgba(45,189,173,.3);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.topbar-user {
  display: flex; align-items: center; gap: .5rem;
  color: var(--white);
  font-size: .85rem;
  font-weight: 500;
}

.topbar-avatar {
  width: 32px; height: 32px;
  background: var(--teal);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: var(--white);
  flex-shrink: 0;
}

.topbar-logout {
  padding: .3rem .75rem;
  background: rgba(230,57,70,.15);
  border: 1px solid rgba(230,57,70,.3);
  border-radius: var(--radius-sm);
  color: #ff8590;
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  transition: var(--trans);
}

.topbar-logout:hover {
  background: rgba(230,57,70,.3);
  color: #ffb0b6;
  text-decoration: none;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  background: var(--navy);
  padding: 1rem 0;
  overflow-y: auto;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  border-right: 1px solid rgba(255,255,255,.07);
}

.sidebar-section {
  padding: .35rem 1rem .1rem;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  margin-top: .75rem;
}

.sidebar-section:first-child { margin-top: 0; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem 1.1rem;
  margin: .1rem .6rem;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.65);
  font-size: .85rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--trans);
  position: relative;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,.08);
  color: var(--white);
  text-decoration: none;
}

.sidebar-nav a.active {
  background: var(--teal);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(45,189,173,.35);
}

.sidebar-nav a .nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: .8;
}

.sidebar-nav a.active .nav-icon { opacity: 1; }

.sidebar-nav a .nav-badge {
  margin-left: auto;
  background: var(--red);
  color: var(--white);
  font-size: .65rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}

/* ── Main content area ───────────────────────────────────────── */
.main {
  padding: 1.5rem;
  min-width: 0;
  overflow-x: hidden;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
}

.page-subtitle {
  font-size: .82rem;
  color: var(--gray-600);
  margin-top: .2rem;
  font-weight: 400;
}

.page-actions {
  display: flex; gap: .5rem; flex-wrap: wrap; align-items: center;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--navy);
}

.card-subtitle {
  font-size: .78rem;
  color: var(--gray-600);
  margin-top: .1rem;
}

.card-body { padding: 1.25rem; }

.card-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  font-size: .8rem;
  color: var(--gray-600);
}

/* ── Stat cards (dashboard) ──────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: .35rem;
  position: relative;
  overflow: hidden;
  transition: var(--trans);
}

.stat-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--teal);
}

.stat-card.stat-critical::before { background: var(--red); }
.stat-card.stat-warning::before  { background: var(--amber); }
.stat-card.stat-success::before  { background: var(--green); }
.stat-card.stat-navy::before     { background: var(--navy); }

.stat-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
  font-family: var(--font-mono);
}

.stat-sub {
  font-size: .75rem;
  color: var(--gray-600);
}

.stat-icon {
  position: absolute;
  right: 1rem; top: 50%;
  transform: translateY(-50%);
  width: 40px; height: 40px;
  background: var(--teal-light);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  opacity: .8;
}

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

thead th {
  background: var(--gray-50);
  color: var(--gray-700);
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .75rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

tbody td {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-800);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--teal-pale); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  padding: .22rem .6rem;
  border-radius: 99px;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-teal    { background: var(--teal-light);  color: var(--teal-deeper); }
.badge-navy    { background: var(--navy-light);   color: var(--navy); }
.badge-red     { background: var(--red-light);    color: #9B1B26; }
.badge-amber   { background: var(--amber-light);  color: #8B5E00; }
.badge-green   { background: var(--green-light);  color: #1A5E35; }
.badge-gray    { background: var(--gray-100);     color: var(--gray-600); }

/* Condition badges */
.badge-stable    { background: var(--green-light); color: #1A5E35; }
.badge-improving { background: var(--teal-light);  color: var(--teal-deeper); }
.badge-poor      { background: var(--amber-light); color: #8B5E00; }
.badge-critical  { background: var(--red-light);   color: #9B1B26;
                   animation: pulse-badge 1.5s ease-in-out infinite; }

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50%       { opacity: .65; }
}

/* Revenue model badges */
.badge-brought { background: #EEF2FF; color: #3730A3; }
.badge-given   { background: var(--teal-light); color: var(--teal-deeper); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: var(--trans);
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary {
  background: var(--teal);
  color: var(--white);
}
.btn-primary:hover { background: var(--teal-dark); color: var(--white); text-decoration: none; }

.btn-navy {
  background: var(--navy);
  color: var(--white);
}
.btn-navy:hover { background: var(--navy-mid); color: var(--white); text-decoration: none; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gray-300);
  color: var(--gray-700);
}
.btn-outline:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-pale); text-decoration: none; }

.btn-danger {
  background: var(--red);
  color: var(--white);
}
.btn-danger:hover { background: #c1121f; color: var(--white); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  padding: .4rem .75rem;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-900); text-decoration: none; }

.btn-sm { padding: .35rem .75rem; font-size: .78rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: .95rem; }
.btn-block { width: 100%; justify-content: center; }

.btn:disabled, .btn[disabled] {
  opacity: .5; cursor: not-allowed;
  pointer-events: none;
}

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }

.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: .35rem;
}

.form-label.required::after {
  content: ' *';
  color: var(--red);
}

.form-control {
  width: 100%;
  padding: .6rem .85rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .875rem;
  color: var(--gray-900);
  background: var(--white);
  transition: var(--trans);
  appearance: none;
  -webkit-appearance: none;
  line-height: 1.5;
}

.form-control:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(45,189,173,.15);
}

.form-control:disabled {
  background: var(--gray-100);
  color: var(--gray-500);
  cursor: not-allowed;
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236C757D' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2.2rem;
}

textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint {
  font-size: .75rem;
  color: var(--gray-500);
  margin-top: .3rem;
}

.form-error {
  font-size: .75rem;
  color: var(--red);
  margin-top: .3rem;
  font-weight: 500;
}

.form-control.is-error { border-color: var(--red); }

.form-row {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Revenue model selector (big buttons) */
.model-select {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-top: .35rem;
}

.model-btn {
  padding: 1.1rem;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--trans);
  background: var(--white);
  text-align: center;
  font-family: var(--font);
}

.model-btn:hover { border-color: var(--teal); background: var(--teal-pale); }

.model-btn.selected {
  border-color: var(--teal);
  background: var(--teal-light);
}

.model-btn .model-icon {
  font-size: 1.5rem;
  margin-bottom: .4rem;
}

.model-btn .model-label {
  font-weight: 700;
  font-size: .9rem;
  color: var(--navy);
}

.model-btn .model-desc {
  font-size: .72rem;
  color: var(--gray-600);
  margin-top: .2rem;
  line-height: 1.4;
}

/* Pill buttons (vitals quick-select) */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .35rem;
}

.pill-btn {
  padding: .35rem .85rem;
  border: 1.5px solid var(--gray-300);
  border-radius: 99px;
  font-family: var(--font);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--white);
  color: var(--gray-700);
  transition: var(--trans);
}

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

.pill-btn.selected {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--white);
}

.pill-btn.selected-critical {
  background: var(--red);
  border-color: var(--red);
  color: var(--white);
}

.pill-btn.selected-warning {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--white);
}

/* ── Flash messages ──────────────────────────────────────────── */
.flash {
  padding: .85rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: .875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: .6rem;
  border-left: 4px solid;
  animation: slideIn .2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.flash-success { background: var(--green-light);  border-color: var(--green);  color: #1A5E35; }
.flash-error   { background: var(--red-light);    border-color: var(--red);    color: #9B1B26; }
.flash-warning { background: var(--amber-light);  border-color: var(--amber);  color: #8B5E00; }
.flash-info    { background: var(--teal-light);   border-color: var(--teal);   color: var(--teal-deeper); }

/* ── Critical alert banner ───────────────────────────────────── */
.critical-alert {
  background: var(--red);
  color: var(--white);
  padding: .75rem 1.25rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
  animation: pulse-alert 2s ease-in-out infinite;
}

@keyframes pulse-alert {
  0%, 100% { box-shadow: 0 0 0 0 rgba(230,57,70,.4); }
  50%       { box-shadow: 0 0 0 8px rgba(230,57,70,0); }
}

.critical-alert-icon { font-size: 1.1rem; flex-shrink: 0; }
.critical-alert-text { font-size: .875rem; font-weight: 600; }

/* ── Obligations checklist (nursing) ─────────────────────────── */
.obligations-board {
  display: grid;
  gap: .75rem;
}

.obligation-item {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--trans);
}

.obligation-item:hover { border-color: var(--teal); }

.obligation-item.completed {
  border-color: var(--green);
  background: var(--green-light);
  opacity: .75;
}

.obligation-item.urgent {
  border-color: var(--red);
  background: var(--red-light);
}

.obligation-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.obligation-dot.pending  { background: var(--amber); }
.obligation-dot.done     { background: var(--green); }
.obligation-dot.critical { background: var(--red); animation: pulse-badge 1.2s infinite; }

.obligation-body { flex: 1; min-width: 0; }
.obligation-title { font-weight: 600; font-size: .875rem; color: var(--navy); }
.obligation-sub   { font-size: .75rem; color: var(--gray-600); margin-top: .15rem; }

/* ── Vitals grid (monitoring form) ───────────────────────────── */
.vitals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}

.vital-input-wrap {
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: .75rem;
  transition: var(--trans);
}

.vital-input-wrap:focus-within {
  border-color: var(--teal);
  background: var(--teal-pale);
  box-shadow: 0 0 0 3px rgba(45,189,173,.1);
}

.vital-input-wrap.critical {
  border-color: var(--red);
  background: var(--red-light);
}

.vital-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
  margin-bottom: .3rem;
}

.vital-input-wrap input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--navy);
  outline: none;
}

.vital-unit {
  font-size: .7rem;
  color: var(--gray-500);
  margin-top: .2rem;
}

/* ── Patient card (ward list) ────────────────────────────────── */
.patient-card {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--trans);
  text-decoration: none;
  color: inherit;
}

.patient-card:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transform: translateY(-1px);
}

.patient-card.critical-patient {
  border-color: var(--red);
  background: #fff8f8;
}

.patient-bed {
  background: var(--navy);
  color: var(--white);
  font-size: .75rem;
  font-weight: 700;
  padding: .4rem .6rem;
  border-radius: var(--radius-sm);
  text-align: center;
  min-width: 52px;
  font-family: var(--font-mono);
}

.patient-info { flex: 1; min-width: 0; }
.patient-name { font-weight: 700; font-size: .9rem; color: var(--navy); }
.patient-meta { font-size: .75rem; color: var(--gray-600); margin-top: .15rem; }

.patient-vitals {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
}

.vital-chip {
  font-size: .72rem;
  font-weight: 600;
  padding: .25rem .55rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  background: var(--gray-100);
  color: var(--gray-700);
}

.vital-chip.ok      { background: var(--green-light);  color: #1A5E35; }
.vital-chip.warn    { background: var(--amber-light);   color: #8B5E00; }
.vital-chip.danger  { background: var(--red-light);     color: #9B1B26; }

/* ── P&L display ─────────────────────────────────────────────── */
.pl-panel {
  background: var(--navy);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  color: var(--white);
}

.pl-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: .85rem;
}

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

.pl-label { color: rgba(255,255,255,.65); }
.pl-value { font-family: var(--font-mono); font-weight: 600; }
.pl-value.positive { color: #4ade80; }
.pl-value.negative { color: #f87171; }
.pl-value.neutral  { color: var(--teal); }

.pl-total {
  margin-top: .5rem;
  padding-top: .75rem;
  border-top: 2px solid rgba(255,255,255,.15);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pl-total-label { font-weight: 700; font-size: .9rem; }
.pl-total-value { font-family: var(--font-mono); font-size: 1.25rem; font-weight: 700; }
.pl-margin-pct  { font-size: .75rem; color: rgba(255,255,255,.55); margin-top: .15rem; text-align: right; }

/* ── Empty states ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--gray-500);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: .5;
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: .35rem;
}

.empty-state p { font-size: .85rem; }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: .3rem;
  justify-content: center;
  margin-top: 1.25rem;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 600;
  color: var(--gray-700);
  background: var(--white);
  border: 1px solid var(--gray-300);
  text-decoration: none;
  transition: var(--trans);
}

.page-btn:hover { border-color: var(--teal); color: var(--teal); text-decoration: none; }
.page-btn.active { background: var(--teal); border-color: var(--teal); color: var(--white); }
.page-btn:disabled { opacity: .4; pointer-events: none; }

/* ── Section divider ─────────────────────────────────────────── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0 1rem;
}

.section-divider-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--teal-dark);
  white-space: nowrap;
}

.section-divider-line {
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

/* ── Conditional section indicator ──────────────────────────── */
.section-tag {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem 1rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 1rem;
}

.section-tag-medical  { background: #EFF6FF; color: #1D4ED8; border: 1.5px solid #BFDBFE; }
.section-tag-surgical { background: #FFF7ED; color: #C2410C; border: 1.5px solid #FED7AA; }

/* ── Utility ─────────────────────────────────────────────────── */
.text-teal    { color: var(--teal-dark); }
.text-navy    { color: var(--navy); }
.text-muted   { color: var(--gray-500); }
.text-danger  { color: var(--red); }
.text-success { color: var(--green); }
.text-warning { color: var(--amber); }
.text-mono    { font-family: var(--font-mono); }
.text-sm      { font-size: .8rem; }
.text-xs      { font-size: .72rem; }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }

.d-flex       { display: flex; }
.align-center { align-items: center; }
.gap-sm       { gap: .5rem; }
.gap-md       { gap: 1rem; }
.ms-auto      { margin-left: auto; }
.mt-1         { margin-top: .5rem; }
.mt-2         { margin-top: 1rem; }
.mt-3         { margin-top: 1.5rem; }
.mb-1         { margin-bottom: .5rem; }
.mb-2         { margin-bottom: 1rem; }
.mb-3         { margin-bottom: 1.5rem; }

/* ── Mobile responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .login-page { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { padding: 2rem 1.5rem; min-height: 100vh; justify-content: center; }

  .app-layout { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    left: -100%; top: var(--header-h);
    height: calc(100vh - var(--header-h));
    width: var(--sidebar-w);
    z-index: 200;
    transition: left .25s ease;
  }

  .sidebar.open { left: 0; box-shadow: var(--shadow-lg); }

  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0; top: var(--header-h);
    background: rgba(0,0,0,.4);
    z-index: 199;
  }

  .sidebar-overlay.show { display: block; }

  .main { padding: 1rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row  { grid-template-columns: 1fr; }
  .model-select { grid-template-columns: 1fr; }
}

/* ── Print utility ───────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .page-actions, .btn, .flash { display: none !important; }
  .app-layout { display: block; }
  .main { padding: 0; }
  .card { border: 1px solid #ccc; box-shadow: none; }
}
