/* Hypr Mobile — concept-art sim-hospital theme
   Cream sky, mint panels, chunky candy cards, bouncy shadows. */

:root {
  --cream:   #fdf4e4;
  --cream-2: #f7ead2;
  --mint:    #cfeede;
  --mint-2:  #a9dccb;
  --mint-3:  #7cc7ac;
  --teal:    #2f9d80;
  --teal-dk: #1f6f5c;
  --ink:     #22423a;
  --ink-soft:#5b7a72;
  --card:    #ffffff;
  --orange:  #f5821f;
  --orange-d:#d86a0e;
  --green:   #43b079;
  --green-bg:#e3f8ec;
  --red:     #ef6a6a;
  --red-bg:  #ffe3e3;
  --amber:   #f4b942;
  --amber-bg:#fff4d8;
  --line:    #d9ece4;
  --shadow:  0 6px 0 rgba(47, 157, 128, .16), 0 14px 30px rgba(31, 111, 92, .14);
  --shadow-sm: 0 3px 0 rgba(47, 157, 128, .14);
  --r-lg: 26px;
  --r-md: 18px;
  --font: 'Baloo 2', 'Mali', 'Comic Sans MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  /* the sim-hospital lobby is the background for the whole app */
  background:
    linear-gradient(170deg, rgba(253, 244, 228, .90) 0%, rgba(253, 244, 228, .94) 45%, rgba(253, 238, 211, .97) 100%),
    url('images/bg.jpeg') center 22% / cover fixed no-repeat,
    var(--cream);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

/* ── phone column ──────────────────────────────────────────── */
.phone {
  position: relative; z-index: 1;
  width: min(100%, 440px);
  margin: 0 auto;
  padding: 14px 14px calc(28px + env(safe-area-inset-bottom));
}

/* ── character cutouts (PNG sprites from images/) ──────────── */
.char {
  position: absolute;
  pointer-events: none;
  z-index: 3;
  filter: drop-shadow(0 8px 8px rgba(31, 111, 92, .3)) drop-shadow(0 1px 2px rgba(0,0,0,.15));
}
.with-char { position: relative; overflow: visible; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(var(--tilt, 0deg)); }
  50%      { transform: translateY(-7px) rotate(var(--tilt, 0deg)); }
}
/* the cast lining up in the lobby (search screen) */
.cast { display: flex; align-items: flex-end; justify-content: center; gap: 4px;
  margin: 20px auto 4px; padding: 0 4px; }
.cast .char { position: static; }
.cast img { height: 78px;
  filter: drop-shadow(0 8px 8px rgba(31, 111, 92, .3)) drop-shadow(0 1px 2px rgba(0,0,0,.15)); }
.cast img:nth-child(odd)  { animation: bob 3.6s ease-in-out infinite; }
.cast img:nth-child(even) { animation: bob 4.3s ease-in-out .6s infinite; }
.cast img:nth-child(3) { height: 84px; }
.cast img:nth-child(1) { transform: scaleX(1); --tilt: 2deg; }
.cast img:nth-child(5) { --tilt: -3deg; }
/* menu */
.menu-boy    { right: 10px;  top: -14px; height: 88px;  --tilt: 4deg; animation: bob 3.8s ease-in-out infinite; }
.menu-doctor { right: 14px;  bottom: 8px; height: 96px; --tilt: -3deg; animation: bob 4.6s ease-in-out .8s infinite; opacity: .92; }
/* stations page: nurse keeps watch by the journey card */
.stations-nurse { right: -4px; bottom: -26px; height: 110px; --tilt: 5deg; animation: bob 4.2s ease-in-out infinite; }
/* expenses page */
.expenses-woman { right: 12px; bottom: 14px; height: 104px; --tilt: -4deg; animation: bob 4.8s ease-in-out .4s infinite; opacity: .9; }
/* meds waiting-room scene */
.meds-scene { position: relative; height: 190px; margin: 4px 12px 8px; }
.meds-girl  { left: 38%;  bottom: 0;   height: 168px; transform: translateX(-50%); }
.meds-nurse { right: 4%;  bottom: 4px; height: 150px; --tilt: -3deg; animation: bob 3.6s ease-in-out infinite; }
.meds-boy   { left: 6%;   bottom: 0;   height: 158px; --tilt: 2deg; animation: bob 4.4s ease-in-out .6s infinite; }

.screen { animation: pop-in .35s cubic-bezier(.34, 1.4, .5, 1); }
.hidden { display: none !important; }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

h1, h2, h3 { font-weight: 700; margin: 0 0 8px; }
h2 { font-size: 17px; }
.tag {
  display: inline-block; font-size: 12px; padding: 2px 10px; margin-left: 6px;
  border-radius: 999px; background: var(--mint); color: var(--teal-dk);
  border: 2px solid var(--mint-3); vertical-align: 2px;
}

/* ── BRAND (search screen — the lobby photo shows behind) ──── */
.brand {
  text-align: center;
  padding: 18px 10px 10px;
  margin: 0 auto 12px;
  max-width: 340px;
  border-radius: 24px;
}
.brand h1 { font-size: 26px; margin: 0; color: var(--teal-dk); line-height: 1.15;
  text-shadow: 0 2px 0 #fff, 0 4px 14px rgba(31,111,92,.18); }
.brand h1 span { color: var(--orange); font-size: 20px; display: block; }
.lead { margin: 6px 0 0; font-size: 13.5px; color: var(--ink-soft); font-weight: 500;
  text-shadow: 0 1px 0 #fff; }

/* ── SEARCH card ───────────────────────────────────────────── */
.search-card {
  margin-top: 14px;
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 3px solid #fff;
}
.field { position: relative; display: flex; align-items: center; }
.field-icon { position: absolute; left: 12px; font-size: 22px; }
.field input {
  width: 100%;
  font: 600 24px/1 var(--font);
  letter-spacing: 2px;
  color: var(--teal-dk);
  background: #f4fbf8;
  border: 3px solid var(--mint-2);
  border-radius: var(--r-md);
  padding: 15px 84px 15px 46px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(47,157,128,.15); }
.idcheck { position: absolute; right: 12px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.idcheck.ok  { color: var(--green); }
.idcheck.bad { color: var(--red); }

.btn {
  font: 700 16px var(--font);
  border: none; border-radius: 999px;
  padding: 13px 22px;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, filter .12s;
}
#btn-scan {
  margin-top: 20px;
}
.btn:active { transform: translateY(2px) scale(.98); }
.btn.primary {
  width: 100%; margin-top: 12px;
  color: #fff;
  background: linear-gradient(180deg, #ff9d3c, var(--orange) 60%, var(--orange-d));
  box-shadow: 0 5px 0 #b85c0c, 0 10px 20px rgba(245,130,31,.35);
}
.btn.primary:active { box-shadow: 0 2px 0 #b85c0c; }
.btn.ghost {
  background: #fff; color: var(--teal-dk);
  border: 3px solid var(--mint-2);
  box-shadow: var(--shadow-sm);
}
.btn.ghost:active { border-color: var(--teal); }
.btn.ghost.dark { background: rgba(31,111,92,.85); color: #fff; border-color: transparent; }
.btn.wide { width: 100%; display: block; }
.btn:disabled { filter: grayscale(.5) opacity(.6); cursor: default; }
.btn-row { display: flex; gap: 10px; margin-top: 10px; }
.btn-row .btn { flex: 1; font-size: 14px; padding: 11px 12px; }

.status { min-height: 20px; margin: 10px 4px 0; font-size: 13.5px; font-weight: 600; }
.status.error { color: var(--red); }
.status.warn  { color: #b7791f; }
.hint { margin: 10px 4px 0; font-size: 12px; color: var(--ink-soft); text-align: center; }

/* step strip under search */
.step-strip {
  display: flex; align-items: center; gap: 2px;
  margin-top: 16px; padding: 0 6px;
}
.mini-step {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; color: var(--teal-dk);
}
.mini-step span:last-child {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.step-ico {
  width: 36px; height: 36px; display: grid; place-items: center;
  font-size: 16px; background: #fff;
  border: 3px solid var(--mint-2); border-radius: 50%;
  box-shadow: var(--shadow-sm);
}
.step-arrow { flex: none; color: var(--mint-3); font-size: 11px; margin: 0 1px 12px; }

/* ── VISIT HEAD (sticky candy header) ──────────────────────── */
.visit-head {
  position: sticky; top: 8px; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(8px);
  border: 3px solid #fff;
  border-radius: 999px;
  padding: 8px 16px 8px 8px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.head-back {
  border: none; background: var(--cream-2); color: var(--teal-dk);
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 17px; cursor: pointer; box-shadow: var(--shadow-sm);
}
.head-avatar-wrap {
  width: 46px; height: 46px; border-radius: 50%;
  padding: 3px; background: conic-gradient(var(--amber), var(--green), var(--orange), var(--amber));
  animation: ring-spin 6s linear infinite;
}
@keyframes ring-spin { to { transform: rotate(360deg); } }
.head-avatar { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: #eee; }
.head-id { flex: 1; min-width: 0; }
.head-name { font-weight: 700; font-size: 15px; line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-sub { display: flex; align-items: center; gap: 6px; margin-top: 2px;
  font-size: 12.5px; color: var(--ink-soft); }
.lv-badge {
  font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  background: var(--amber-bg); color: #976500; border: 2px solid var(--amber);
}
.head-meter { width: 92px; }
.meter-bar { height: 9px; border-radius: 99px; background: var(--cream-2); overflow: hidden;
  border: 2px solid #fff; box-shadow: inset 0 1px 3px rgba(0,0,0,.08); }
.meter-fill {
  height: 100%; width: 0%;
  background: repeating-linear-gradient(45deg, var(--amber) 0 8px, #ffd75e 8px 16px);
  border-radius: 99px; transition: width .6s cubic-bezier(.34,1.4,.5,1);
}
.meter-steps { display: flex; justify-content: space-between; font-size: 11px; margin-top: 2px; }
.head-ring { width: 10px; } /* spacer for ring anim width */

/* ── banners ───────────────────────────────────────────────── */
.banner {
  border-radius: var(--r-md);
  padding: 11px 16px;
  font-weight: 700; font-size: 14.5px;
  margin-bottom: 12px;
  border: 3px solid;
  box-shadow: var(--shadow-sm);
}
.banner.active { background: var(--green-bg); color: #177a4c; border-color: var(--green); }
.banner.done   { background: var(--amber-bg); color: #8a6008; border-color: var(--amber); }

/* ── generic cards ─────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 3px solid #fff;
}
.card:empty { display: none; }
.card h2 { display: flex; align-items: center; }

/* room for the character peeking into the kv columns */
.card.with-char .kv { padding-right: 92px; }
.card h3 { font-size: 14px; color: var(--teal-dk); margin: 10px 0 6px; }
.card p { margin: 4px 0; font-size: 14px; }

/* patient card */
.patient-card { display: flex; gap: 14px; align-items: center; }
.avatar {
  width: 66px; height: 66px; border-radius: 22px; object-fit: cover;
  border: 3px solid var(--mint-2); box-shadow: var(--shadow-sm);
  background: #e7f6f0;
}
.name-th { font-size: 19px; font-weight: 700; line-height: 1.1; }
.name-en { font-size: 13px; color: var(--ink-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: var(--red-bg); color: #b3362f; border: 2px solid #ffc2c2;
}
.chip.none { background: var(--green-bg); color: #177a4c; border-color: #b9e8cf; }

.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 8px 0 0; }
.kv > div { min-width: 0; }
.kv dt { font-size: 11.5px; color: var(--ink-soft); }
.kv dd { margin: 1px 0 0; font-size: 14.5px; font-weight: 600; word-break: break-word; }

.privileges:empty { display: none; }
.priv { display: flex; justify-content: space-between; align-items: center;
  padding: 7px 10px; border-radius: 12px; background: #f4fbf8; margin: 4px 0; font-size: 14px; }
.ptype { font-size: 11px; font-weight: 700; color: var(--teal-dk);
  background: var(--mint); border: 2px solid var(--mint-2); border-radius: 999px; padding: 1px 8px; }

.sub { margin-top: 10px; border-top: 2px dashed var(--line); padding-top: 8px; }

/* ── journey list (menu card — text-only, scales to many stations) ── */
.journey-list { margin: 10px 0 4px; max-height: 220px; overflow-y: auto;
  overscroll-behavior: contain; scrollbar-width: thin; }
.jrow { display: flex; align-items: center; gap: 10px;
  padding: 7px 4px 7px 2px; border-bottom: 2px dotted var(--line); }
.jrow:last-child { border-bottom: none; }
.jrow .dot { width: 13px; height: 13px; border-radius: 50%; flex: none;
  border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(124,199,172,.5); }
.jrow.done .dot { background: var(--green); }
.jrow.done { color: #177a4c; }
.jrow.now .dot { background: var(--orange); animation: pulse 1.4s ease-in-out infinite; }
.jrow.now { color: var(--orange-d); }
.jrow.wait { color: var(--ink-soft); }
.jrow.wait .dot { background: #d5e2de; box-shadow: 0 0 0 2px rgba(180,200,195,.6); }
.jrow .jname { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jrow .jtime { font-size: 12px; color: var(--ink-soft); flex: none; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(245, 130, 31, .55); }
  50%      { box-shadow: 0 0 0 6px rgba(245, 130, 31, .15); }
}
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ── menu cards ────────────────────────────────────────────── */
.menu-list { display: flex; flex-direction: column; gap: 11px; margin: 4px 0 12px; }
.menu-card {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left; cursor: pointer;
  font-family: var(--font);
  background: #fff;
  border: 3px solid #fff;
  border-radius: var(--r-lg);
  padding: 13px 18px 13px 13px;
  box-shadow: var(--shadow);
  transition: transform .14s cubic-bezier(.34,1.4,.5,1), box-shadow .14s, border-color .14s;
}
.menu-card:hover { transform: translateY(-3px); border-color: var(--mint-2); box-shadow: 0 10px 0 rgba(47,157,128,.16), 0 18px 34px rgba(31,111,92,.18); }
.menu-card:active { transform: translateY(1px) scale(.99); }
.menu-ico {
  width: 52px; height: 52px; border-radius: 18px;
  display: grid; place-items: center; font-size: 26px; flex: none;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.08);
}
.menu-card.station .menu-ico { background: linear-gradient(160deg,#d7f0ff,#aee0f9); }
.menu-card.expense .menu-ico { background: linear-gradient(160deg,#fff2cf,#ffe08a); }
.menu-card.med     .menu-ico { background: linear-gradient(160deg,#ffd9e8,#ffb4cf); }
.menu-card.qr      .menu-ico { background: linear-gradient(160deg,#e2f6d9,#c2ecb0); }
.menu-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.menu-t { font-size: 17px; font-weight: 700; color: var(--ink); }
.menu-s { font-size: 12.5px; color: var(--ink-soft); }
.menu-count {
  font-size: 13px; font-weight: 700; color: var(--teal-dk);
  background: var(--mint); border-radius: 999px; padding: 4px 12px; border: 2px solid var(--mint-2);
}
.menu-count.soon { background: var(--cream-2); border-color: #e5d5b5; color: #8a6008; }
.menu-cta { font-size: 12.5px; font-weight: 700; color: #fff; background: var(--orange);
  padding: 5px 12px; border-radius: 999px; box-shadow: 0 3px 0 #b85c0c; }
.chev { font-size: 26px; color: var(--mint-3); font-weight: 700; margin-left: 2px; }

/* ── page titles (sub screens) + back-home button ──────────── */
.page-title { display: flex; align-items: center; gap: 12px; padding: 6px 6px 12px; }
.page-title h2 { font-size: 21px; color: var(--teal-dk); }
.page-title p { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); }
.page-back {
  flex: none;
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid #fff;
  background: linear-gradient(180deg, #fff, #eef9f5);
  color: var(--teal-dk);
  font: 700 26px/1 var(--font);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, border-color .15s;
}
.page-back:hover { transform: translateX(-2px); border-color: var(--mint-2); }
.page-back:active { transform: translateX(-2px) scale(.94); }

/* ── stations ──────────────────────────────────────────────── */
.station-row {
  position: relative;
  padding: 11px 12px 11px 16px;
  margin: 9px 0;
  background: #f7fcfa;
  border: 2.5px solid var(--line);
  border-left: 7px solid var(--mint-3);
  border-radius: 16px;
  transition: border-color .15s, transform .15s;
}
.station-row:hover { transform: translateX(2px); border-color: var(--mint-2); }
.station-row .st-top { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.st-name { font-weight: 700; font-size: 15px; flex: 1 1 120px; }
.st-time { font-size: 12px; color: var(--ink-soft); background: #fff;
  border: 2px solid var(--line); border-radius: 999px; padding: 2px 9px; }
.st-badge { font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 2px 9px; border: 2px solid; }
.st-pass    { background: var(--green-bg); color: #177a4c; border-color: var(--green); }
.st-create  { background: var(--amber-bg); color: #8a6008; border-color: var(--amber); }
.st-forward { background: #e8f3ff; color: #1a66b8; border-color: #93c6f5; }
.btn.checkin {
  font-size: 12.5px; font-weight: 700; padding: 5px 12px;
  background: #fff; color: var(--teal-dk);
  border: 2.5px solid var(--mint-2); border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.btn.checkin.checked { background: var(--green-bg); border-color: var(--green); color: #177a4c; }
.btn.checkin.is-readonly { cursor: default; opacity: .85; }
.btn.checkin.busy { opacity: .5; }
.st-sub { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }

.checkin-status-line {
  font-size: 13px; font-weight: 600; padding: 4px 2px;
  border-bottom: 2px dotted var(--line);
}
.checkin-status-line:last-child { border-bottom: none; }

/* ── expenses ──────────────────────────────────────────────── */
.expense-summary { display: flex; gap: 10px; margin-bottom: 12px; }
.sum-card {
  flex: 1; border-radius: var(--r-md); padding: 12px 14px;
  display: flex; flex-direction: column;
  border: 3px solid #fff; box-shadow: var(--shadow);
}
.sum-card.pay  { background: linear-gradient(160deg, #fff6e4, #ffe7c2); }
.sum-card.priv { background: linear-gradient(160deg, #eefbf5, #d7f3e6); }
.sum-label { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.sum-val { font-size: 26px; font-weight: 700; line-height: 1.2; }
.sum-card.pay .sum-val { color: var(--orange-d); }
.sum-card.priv .sum-val { color: var(--teal); }
.sum-note { font-size: 11px; color: var(--ink-soft); }

.inv-row {
  padding: 11px 13px; margin: 9px 0;
  background: #f7fcfa; border: 2.5px solid var(--line); border-radius: 16px;
}
.inv-row:hover { border-color: var(--mint-2); }
.inv-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inv-badge { font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 2px 10px; border: 2px solid; }
.inv-paid     { background: var(--green-bg); color: #177a4c; border-color: var(--green); }
.inv-waiting  { background: var(--amber-bg); color: #8a6008; border-color: var(--amber); }
.inv-create   { background: #eef1f5; color: #4a5568; border-color: #cbd5e0; }
.inv-cancelled{ background: var(--red-bg); color: #b3362f; border-color: #ffc2c2; }
.inv-ref { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; flex: 1; }
.inv-total { font-size: 16.5px; font-weight: 700; color: var(--teal-dk); }
.inv-info { margin-top: 5px; font-size: 13px; }
.inv-owe-label { color: var(--ink-soft); }
.inv-owe { font-weight: 700; color: var(--orange-d); }
.inv-priv { font-size: 12px; color: var(--teal); }
.inv-items { margin-top: 7px; border-top: 2px dashed var(--line); padding-top: 6px; }
.inv-item { font-size: 12.5px; padding: 2px 0; color: var(--ink); }
.btn.qr-btn {
  margin-top: 8px; font-size: 13px; padding: 7px 16px;
  background: linear-gradient(180deg, #ff9d3c, var(--orange));
  color: #fff; border: none; border-radius: 999px;
  box-shadow: 0 3px 0 #b85c0c;
}
.btn.qr-btn.done { background: var(--green-bg); color: #177a4c; box-shadow: none; border: 2px solid var(--green); }

.empty { text-align: center; padding: 30px 10px; color: var(--ink-soft); }
.empty-ico { font-size: 44px; margin-bottom: 6px; animation: bounce 2s infinite; }

/* meds hero (loading / not-yet-prescribed state) */
.meds-hero {
  background: linear-gradient(180deg, #fff, #f2fbf7);
  border: 3px solid #fff; border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 18px 18px 26px; text-align: center;
}

/* ── medication list ───────────────────────────────────────── */
.med-row {
  padding: 11px 13px; margin: 9px 0;
  background: #fff8fb; border: 2.5px solid #f4d3e3; border-left: 7px solid #e58bb4;
  border-radius: 16px;
  transition: border-color .15s, transform .15s;
}
.med-row:hover { border-color: #eebad2; transform: translateX(2px); }
.med-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.med-name { font-weight: 700; font-size: 15px; flex: 1 1 120px; min-width: 0; word-break: break-word; }
.med-date { font-size: 11.5px; color: var(--ink-soft); background: #fff;
  border: 2px solid var(--line); border-radius: 999px; padding: 2px 9px; flex: none; }
.med-trade { font-size: 12.5px; color: var(--ink-soft); margin-top: 1px; }
.med-use { font-size: 13px; margin-top: 6px; padding: 5px 10px;
  background: #fdf2f8; border: 1.5px dashed #f0c9dc; border-radius: 10px; }
.med-foot { display: flex; align-items: baseline; gap: 8px; margin-top: 7px; flex-wrap: wrap; }
.med-qty { font-weight: 700; font-size: 14.5px; }
.med-unit { font-size: 12.5px; color: var(--ink-soft); }
.med-packs { font-size: 12px; font-weight: 600; color: var(--teal-dk);
  background: var(--mint); border: 2px solid var(--mint-2); border-radius: 999px; padding: 1px 8px; }
.med-badge { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 9px; border: 2px solid; }
.med-badge.stat { background: var(--red-bg); color: #b3362f; border-color: var(--red); }
.med-badge.prn  { background: var(--amber-bg); color: #8a6008; border-color: var(--amber); }
.med-badge.had  { background: #f3e8ff; color: #7c3aed; border-color: #d3b5f5; }
.med-badge.paid { background: var(--green-bg); color: #177a4c; border-color: var(--green); }
.med-badge.manual { background: var(--mint); color: var(--teal-dk); border-color: var(--mint-3); }
.med-row.manual { background: #f7fcfa; border-left-color: var(--mint-3); }
.soon-title { font-size: 18px; font-weight: 700; color: var(--teal-dk); }
.soon-sub { font-size: 13px; color: var(--ink-soft); }

/* ── overlays ──────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  background: rgba(15, 40, 33, .55);
  backdrop-filter: blur(3px);
  animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }
.overlay video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.guide {
  position: relative; z-index: 1;
  width: min(76vw, 300px); aspect-ratio: 1.6;
  border-radius: 24px;
  border: 4px dashed #fff;
  box-shadow: 0 0 0 200vmax rgba(15,40,33,.35);
  display: grid; place-items: center;
}
.guide span {
  position: absolute; bottom: -44px; width: max-content;
  background: rgba(255,255,255,.92); color: var(--teal-dk);
  font-size: 13px; font-weight: 700; padding: 6px 14px; border-radius: 999px;
}
.scan-live {
  position: absolute; z-index: 1; top: calc(20px + env(safe-area-inset-top)); left: 0; right: 0;
  text-align: center; color: #fff; font-weight: 700; font-size: 14px;
  text-shadow: 0 2px 8px rgba(0,0,0,.5);
  word-break: break-all; padding: 0 20px;
}
.scan-actions { position: absolute; z-index: 1; bottom: calc(34px + env(safe-area-inset-bottom));
  left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.scan-tip { color: #fff; font-size: 13px; text-shadow: 0 2px 8px rgba(0,0,0,.6); }

/* QR pay box */
.qr-box {
  width: min(90vw, 360px);
  background: linear-gradient(180deg, #ffffff, #f4fbf8);
  border: 4px solid #fff;
  border-radius: 30px;
  padding: 22px 20px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  animation: pop-in .3s cubic-bezier(.34,1.4,.5,1);
}
.qr-amount { font-size: 40px; font-weight: 700; color: var(--orange-d); line-height: 1.1; }
.qr-label { font-size: 13px; color: var(--ink-soft); margin-bottom: 12px; }
.qr-img-wrap { display: grid; place-items: center; margin: 6px 0 10px; padding: 12px;
  background: #fff; border-radius: 20px; border: 3px solid var(--mint-2); box-shadow: var(--shadow-sm); }
.qr-img-wrap canvas, .qr-img-wrap img { border-radius: 10px; }
.qr-img { max-width: 220px; }
.qr-ref { font-size: 12px; color: var(--ink-soft); font-weight: 600; word-break: break-all; }
.qr-patient { font-size: 14px; font-weight: 700; margin-top: 2px; }
.qr-status { margin-top: 10px; font-size: 13.5px; font-weight: 700; border-radius: 12px; padding: 8px 10px; }
.qr-status.loading { background: var(--amber-bg); color: #8a6008; }
.qr-status.ok { background: var(--green-bg); color: #177a4c; }
.qr-status.err { background: var(--red-bg); color: #b3362f; }
.btn.qr-pay { width: 100%; margin-top: 12px; color: #fff;
  background: linear-gradient(180deg, #ff9d3c, var(--orange));
  box-shadow: 0 4px 0 #b85c0c; }
#qr-close { margin-top: 8px; width: 100%; }
.qr-fallback { font-size: 11px; word-break: break-all; color: var(--ink-soft); }

/* ── VISITS LIST (patient's visit history) ─────────────── */
.visits-hn { font-size: 12px; color: var(--ink-soft); font-weight: 600; margin-top: 4px; }
.visits-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.visit-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--r-md);
  padding: 12px 14px; cursor: pointer;
  border: 2px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
  animation: pop-in .25s cubic-bezier(.34,1.4,.5,1);
}
.visit-item:active { transform: scale(.97); }
.visit-item.active-visit { border-color: var(--green); }
.visit-item:last-child { animation-delay: .04s; }
.visit-item:nth-child(2) { animation-delay: .06s; }
.visit-item:nth-child(3) { animation-delay: .08s; }
.visit-item:nth-child(4) { animation-delay: .1s; }
.visit-ico {
  font-size: 22px; width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--mint); border-radius: 12px;
  flex-shrink: 0;
}
.visit-info { flex: 1; min-width: 0; }
.visit-vn { font-weight: 700; font-size: 14px; color: var(--ink); }
.visit-meta { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.visit-status-badge {
  font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 999px; flex-shrink: 0;
}
.visit-status-badge.ongoing { background: var(--green-bg); color: #177a4c; }
.visit-status-badge.discharge { background: var(--amber-bg); color: #8a6008; }
.visit-status-badge.other { background: #eee; color: #666; }

.visits-show-all { margin-top: 4px; border: 2px dashed var(--line); }

/* ── LAST VISIT CARD (prominent, on patient dashboard) ───── */
.last-visit-card {
  margin-top: 12px; cursor: pointer;
  border: 3px solid var(--teal);
  box-shadow: 0 4px 0 rgba(47,157,128,.2), var(--shadow);
  padding: 16px;
  animation: pop-in .3s cubic-bezier(.34,1.4,.5,1);
  transition: transform .15s;
}
.last-visit-card:active { transform: scale(.97); }
.last-visit-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.last-visit-badge {
  font-size: 11px; font-weight: 700; padding: 3px 12px;
  border-radius: 999px; background: var(--green-bg); color: #177a4c;
}
.last-visit-date { font-size: 12px; color: var(--ink-soft); }
.last-visit-vn { font-size: 16px; font-weight: 700; color: var(--ink); }
.last-visit-meta { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.last-visit-cta {
  margin-top: 10px; font-size: 12px; font-weight: 600;
  color: var(--teal); text-align: right;
}

/* ── Section headings on the dashboard ─────────────────── */
.section-heading {
  font-size: 14px; font-weight: 700; color: var(--teal-dk);
  margin: 18px 0 8px; padding-left: 4px;
}

/* ── Appointment list ───────────────────────────────────── */
.appt-list { display: flex; flex-direction: column; gap: 8px; }
.appt-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--r-md);
  padding: 12px 14px;
  border: 2px solid var(--line); box-shadow: var(--shadow-sm);
}
.appt-ico {
  font-size: 20px; width: 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--amber-bg); border-radius: 10px;
  flex-shrink: 0;
}
.appt-info { flex: 1; min-width: 0; }
.appt-date { font-weight: 700; font-size: 13px; color: var(--ink); }
.appt-meta { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.appt-ics-btn {
  flex-shrink: 0;
  font-size: 14px;
  padding: 6px 10px;
  background: var(--mint);
  border: 2px solid var(--mint-2);
  border-radius: 12px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.appt-ics-btn:active { transform: scale(.92); }

.appt-type {
  font-size: 10px; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; background: var(--mint); color: var(--teal-dk);
  flex-shrink: 0;
}
.appt-empty {
  text-align: center; padding: 16px; font-size: 13px; color: var(--ink-soft);
}

/* ── VISIT QR OVERLAY ──────────────────────────────────── */
.visit-qr-box {
  width: min(92vw, 400px);
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #ffffff, #f4fbf8);
  border: 4px solid #fff;
  border-radius: 30px;
  padding: 18px 16px 20px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  animation: pop-in .3s cubic-bezier(.34,1.4,.5,1);
}
.visit-qr-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.visit-qr-title {
  font-size: 17px; font-weight: 700; color: var(--teal-dk);
}
.visit-qr-close {
  padding: 4px 10px; font-size: 14px; line-height: 1;
}
.visit-qr-body {
  display: flex; gap: 14px; align-items: flex-start;
  justify-content: center;
}
.visit-qr-col { flex: 0 0 48%; }
.qr-col { display: flex; flex-direction: column; align-items: center; }
.visit-qr-code-wrap {
  padding: 12px; border-radius: 14px; background: #fff;
  border: 2px solid var(--mint-2); box-shadow: var(--shadow-sm);
}
.visit-qr-code-wrap canvas, .visit-qr-code-wrap img { border-radius: 8px; display: block; }
.visit-qr-vn {
  margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--ink);
}
.info-col { display: flex; flex-direction: column; align-items: center; }
.visit-qr-card {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  background: #fff; box-shadow: inset 0 0 0 1px #e2eee9;
  text-align: left; font-size: 13px; color: var(--ink);
}
.visit-qr-patient-name { font-weight: 700; font-size: 14px; color: var(--teal-dk); }
.visit-qr-patient-meta { display: flex; gap: 8px; margin-top: 3px; font-size: 12px; color: var(--ink-soft); }
.visit-qr-hn { margin-top: 4px; font-weight: 700; font-size: 12px; }
#visit-qr-barcode {
  display: block; width: 100%; height: 80px; margin-top: 8px;
}
.visit-qr-pid { margin-top: 8px; font-size: 11px; color: var(--ink-soft); font-weight: 600; }

/* ── toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed; z-index: 60;
  left: 50%; bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  display: flex; flex-direction: column; align-items: center;
  background: rgba(31, 64, 53, .95); color: #fff;
  padding: 12px 22px; border-radius: 20px;
  box-shadow: 0 12px 30px rgba(0,0,0,.3);
  opacity: 0; transition: opacity .25s, transform .25s;
  max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-icon { font-size: 24px; }
.toast-title { font-weight: 700; font-size: 15px; }
.toast-sub { font-size: 12.5px; opacity: .85; }
.toast-close { font-size: 10.5px; opacity: .6; margin-top: 4px; }

/* ── misc responsive ───────────────────────────────────────── */
@media (max-width: 360px) {
  .head-meter { display: none; }
  .menu-t { font-size: 15.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .char, .head-avatar-wrap, .rail-step.now .bubble, .empty-ico { animation: none; }
}
