:root {
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-alt: #f0f9f8;
  --border: #dce7e7;
  --border-strong: #b8d2d0;
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --teal-light: #e6f7f5;
  --navy: #0f2933;
  --text: #162b30;
  --muted: #526a70;
  --amber: #d97706;
  --amber-bg: #fef3c7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --green: #059669;
  --green-bg: #d1fae5;
  --blue: #2563eb;
  --blue-bg: #dbeafe;
  --radius: 14px;
  --shadow: 0 4px 16px rgba(15, 41, 51, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', 'Noto Sans Devanagari', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--navy);
  color: #fff;
  padding: 10px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 3px solid var(--teal);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

.brand-title { font-weight: 800; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: #9cd3ce; }

.topbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.nav-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nav-pill {
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #cce6e4;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  cursor: pointer;
  transition: 0.15s;
}
.nav-pill:hover { background: rgba(255,255,255,0.18); color: #fff; }
.nav-pill.active { background: var(--teal); color: #fff; border-color: #2dd4bf; }

.status-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(110, 231, 183, 0.35);
}
.status-chip.offline {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
  border-color: rgba(252, 211, 77, 0.35);
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 16px 48px;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.grid-sidebar { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--navy);
  margin: 0;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.kpi-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.kpi-val { font-size: 26px; font-weight: 800; color: var(--navy); margin: 4px 0 2px; }
.kpi-sub { font-size: 12px; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  transition: 0.15s;
  font-family: inherit;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-outline { background: #fff; color: var(--teal-dark); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--teal-light); }
.btn-danger { background: var(--red); color: #fff; }
.btn-amber { background: var(--amber); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: #fff;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.badge-teal { background: var(--teal-light); color: var(--teal-dark); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-amber { background: var(--amber-bg); color: #92400e; }
.badge-green { background: var(--green-bg); color: #065f46; }
.badge-blue { background: var(--blue-bg); color: #1e40af; }
.badge-gray { background: #e2e8f0; color: #334155; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  padding: 10px 10px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:hover td { background: #f9fcfc; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.tab-btn {
  padding: 9px 15px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

.alert-banner {
  padding: 12px 14px;
  border-radius: 12px;
  border-left: 4px solid var(--amber);
  background: var(--amber-bg);
  color: #78350f;
  font-size: 13px;
  margin-bottom: 12px;
}
.alert-banner.high {
  border-left-color: var(--red);
  background: var(--red-bg);
  color: #7f1d1d;
}
.alert-banner.info {
  border-left-color: var(--teal);
  background: var(--teal-light);
  color: #134e4a;
}

.patient-list {
  max-height: 580px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.patient-item {
  padding: 10px 12px;
  border-radius: 11px;
  border: 1.5px solid var(--border);
  background: #fff;
  cursor: pointer;
  transition: 0.12s;
}
.patient-item:hover { border-color: var(--teal); background: #f5fbfb; }
.patient-item.active { border-color: var(--teal); background: var(--teal-light); }

.psr-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.psr-pill {
  min-width: 34px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
}

.ex-svg-box {
  width: 110px;
  height: 84px;
  border-radius: 10px;
  background: #f0fdfa;
  border: 1px solid #ccfbf1;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 90;
  background: var(--navy);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0,0,0,0.22);
  border-left: 4px solid var(--teal);
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 41, 51, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 16px;
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

@keyframes pulseBreath {
  0%, 100% { transform: scale(0.85); opacity: 0.7; }
  50% { transform: scale(1.12); opacity: 1; }
}
@keyframes gentleRock {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(8deg); }
}
@keyframes slideHeat {
  0%, 100% { transform: translateY(0px); opacity: 0.6; }
  50% { transform: translateY(-4px); opacity: 1; }
}
.anim-breath { transform-origin: center; animation: pulseBreath 4s ease-in-out infinite; }
.anim-rock { transform-origin: 50px 55px; animation: gentleRock 2.8s ease-in-out infinite; }
.anim-heat { animation: slideHeat 2s ease-in-out infinite; }

/* ---------- Patient portal: larger, phone-friendly UI ---------- */
.patient-ui .btn { padding: 12px 18px; font-size: 15px; min-height: 46px; }
.patient-ui .btn-sm { padding: 10px 14px; font-size: 14px; }
.patient-ui .input, .patient-ui .select, .patient-ui .textarea { font-size: 16px; padding: 12px 14px; }
.patient-ui .label { font-size: 13px; }
.patient-ui .tab-btn { font-size: 15px; padding: 12px 16px; }
.patient-ui .badge { font-size: 13px; }
.patient-ui .card-title { font-size: 18px; }
.done-check { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 15px; font-weight: 700; color: var(--teal-dark); cursor: pointer; }
.done-check input { width: 24px; height: 24px; accent-color: var(--teal); cursor: pointer; }
.problem-form { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--red-bg); border: 1px solid #fecaca; }
@media (max-width: 600px) { .ex-svg-box { width: 84px; height: 66px; } }

/* ================= Mobile-app look (welcome, login, home, patient) ================= */
.app-wrap { max-width: 520px; margin: 0 auto; padding: 16px 16px 100px; }
.app-hero { text-align: center; padding: 26px 8px 18px; }
.app-logo { width: 88px; height: 88px; border-radius: 26px; background: linear-gradient(135deg,#14b8a6,#0f766e); display: grid; place-items: center; font-size: 42px; font-weight: 800; color: #fff; margin: 0 auto 14px; box-shadow: 0 10px 24px rgba(13,148,136,.35); }
.app-hero h1 { font-size: 28px; margin: 0 0 6px; color: var(--navy); }
.app-hero p { margin: 0; color: var(--muted); font-size: 18px; }
.bigbtn { display: flex; align-items: center; gap: 14px; width: 100%; padding: 18px; border-radius: 18px; border: 1.5px solid var(--border); background: #fff; font-family: inherit; font-size: 19px; font-weight: 800; color: var(--navy); cursor: pointer; box-shadow: var(--shadow); text-align: left; margin-bottom: 12px; min-height: 64px; }
.bigbtn .ico { font-size: 30px; line-height: 1; }
.bigbtn:active { transform: scale(.98); }
.bigbtn.primary { background: var(--teal); color: #fff; border-color: var(--teal); justify-content: center; }
.bigbtn.danger { background: var(--red); color: #fff; border-color: var(--red); justify-content: center; }
.bigbtn.ghost { background: transparent; box-shadow: none; justify-content: center; color: var(--teal-dark); }
.app-input { width: 100%; padding: 16px; border-radius: 14px; border: 1.5px solid var(--border-strong); font-size: 18px; font-family: inherit; background: #fff; margin-bottom: 12px; }
.app-input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,148,136,.15); }
.screen-title { font-size: 24px; font-weight: 800; color: var(--navy); margin: 8px 0 14px; display: flex; align-items: center; gap: 10px; }
.back-btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 12px; background: #fff; border: 1.5px solid var(--border); font-weight: 800; font-size: 16px; color: var(--teal-dark); cursor: pointer; font-family: inherit; margin-bottom: 6px; }
.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 22px 10px; min-height: 150px; border-radius: 22px; background: #fff; border: 1.5px solid var(--border); box-shadow: var(--shadow); text-align: center; font-size: 18px; font-weight: 800; color: var(--navy); }
.tile .ico { font-size: 44px; line-height: 1; }
.tile:active { transform: scale(.97); }
.tile.hot { background: var(--teal); color: #fff; border-color: var(--teal); }
.tile.warn { background: var(--red-bg); border-color: #fecaca; color: #7f1d1d; }
.chip-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.chip { padding: 14px 18px; border-radius: 14px; border: 2px solid var(--border-strong); background: #fff; font-size: 18px; font-weight: 800; cursor: pointer; font-family: inherit; color: var(--navy); min-width: 56px; }
.chip.sel { background: var(--teal); border-color: var(--teal); color: #fff; }
.chip.big { flex: 1; min-width: 100px; padding: 18px 10px; font-size: 17px; }
.psr-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 14px; }
.psr-grid .chip { min-width: 0; padding: 14px 0; text-align: center; }
.ex-card { background: #fff; border: 1.5px solid var(--border); border-radius: 18px; padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow); }
.ex-card.done { background: #ecfdf5; border-color: #6ee7b7; }
.ex-top { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.ex-name { font-size: 18px; font-weight: 800; color: var(--navy); }
.ex-meta { font-size: 15px; color: var(--muted); margin-top: 2px; }
.ex-card details { margin-top: 10px; font-size: 15px; color: var(--muted); }
.ex-card summary { cursor: pointer; font-weight: 800; color: var(--teal-dark); }
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: #fff; border-top: 1.5px solid var(--border); display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; font-size: 12px; font-weight: 800; color: var(--muted); border-radius: 12px; }
.bottom-nav a .ico { font-size: 24px; line-height: 1; }
.bottom-nav a.active { color: var(--teal-dark); background: var(--teal-light); }
.review-note { text-align: center; font-size: 13px; color: var(--muted); margin: 6px 0 14px; }
.topbar .brand-sub { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
