/* =========================================================
   MEDRA NFC Patient Profile — style.css
   Brand tokens: replace --medra-blue / --medra-teal with the
   exact hex values from the MEDRA brand guide if they differ.
   ========================================================= */
:root {
  --medra-navy: #10224F;
  --medra-blue: #17377A;      /* navy tint for text/icons on light surfaces */
  --medra-blue-2: #2459B8;
  --medra-teal: #0FA79D;
  --medra-teal-2: #35CFC2;
  --teal-ink: #0A7F78;        /* teal dark enough for small text on white */
  --brand-grad: linear-gradient(135deg, #10224F 0%, #17377A 55%, #0FA79D 100%);
  --brand-grad-soft: linear-gradient(135deg, rgba(16,34,79,.08), rgba(15,167,157,.12));

  --danger: #E5383B;
  --danger-2: #FF5A5F;
  --warn: #F59E0B;
  --ok: #10B981;

  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-2: #F7F9FC;
  --line: #E4E8F0;
  --text: #0E1A33;
  --text-2: #4A5874;
  --text-3: #8592AB;

  --c-bp: #E5383B;
  --c-glu: #F59E0B;
  --c-wt: #8B5CF6;
  --c-hr: #EC4899;

  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(14,26,51,.04), 0 8px 24px rgba(14,26,51,.06);
  --shadow-lg: 0 20px 50px rgba(16,34,79,.25);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0A1226;
    --surface: #121C36;
    --surface-2: #192546;
    --line: #25345A;
    --medra-blue: #A9C1F5;
    --medra-blue-2: #7FA8F7;
    --teal-ink: #35CFC2;
    --text: #EEF2FA;
    --text-2: #A9B5CC;
    --text-3: #6F7D99;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
}
html[lang="ar"] { --font: "Cairo", "Inter", system-ui, sans-serif; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select { font: inherit; color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }
html[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.em-person .avatar svg.i { width: 34px; height: 34px; stroke: #fff; }
.num { font-family: "Inter", system-ui, sans-serif; font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* ---------- Splash ---------- */
.splash {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(120% 80% at 50% 0%, #1D4590 0%, #10224F 55%, #0A1633 100%);
  display: grid; place-items: center; color: #fff;
  transition: opacity .6s ease, visibility .6s;
}
.splash.done { opacity: 0; visibility: hidden; }
.splash-inner { text-align: center; width: min(320px, 84vw); }
.splash-logo { width: 92px; height: 92px; margin: 0 auto 14px; animation: pop .8s cubic-bezier(.2,1.4,.4,1) both; }
.splash-word { font-family: "Inter"; font-weight: 800; font-size: 34px; letter-spacing: .32em; padding-inline-start: .32em; }
.splash-tag { opacity: .75; font-size: 14px; margin-top: 4px; }
.ecg { width: 100%; height: 60px; margin: 28px 0 18px; }
.ecg-line {
  fill: none; stroke: var(--medra-teal-2); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 520; stroke-dashoffset: 520;
  filter: drop-shadow(0 0 6px rgba(53,207,194,.8));
  animation: ecg 1.6s linear infinite;
}
.splash-status { font-size: 12.5px; opacity: .8; display: inline-flex; gap: 8px; align-items: center; }
.lock-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--medra-teal-2); box-shadow: 0 0 0 0 rgba(53,207,194,.7); animation: pulse 1.4s infinite; }
@keyframes ecg { to { stroke-dashoffset: -520; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(53,207,194,0); } 100% { box-shadow: 0 0 0 0 rgba(53,207,194,0); } }

/* ---------- Official logo (remote image, SVG fallback) ---------- */
html.has-logo .logo-img-wrap { display: block !important; }
html.has-logo .logo-fallback { display: none !important; }
.logo-img { display: block; width: 100%; height: 100%; object-fit: contain; }
.splash-logo-tile {
  width: 220px; height: 220px; margin: 0 auto 20px; padding: 16px;
  background: #fff; border-radius: 36px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35), 0 0 0 6px rgba(255,255,255,.08);
  animation: pop .8s cubic-bezier(.2,1.4,.4,1) both;
}
.brand-logo { height: 56px; width: auto; border-radius: 14px; overflow: hidden; background: #fff; box-shadow: var(--shadow); padding: 5px 9px; box-sizing: border-box; }
.brand-logo .logo-img { height: 46px; width: auto; max-width: 220px; }

/* ---------- Shell ---------- */
.app { max-width: 480px; margin: 0 auto; min-height: 100%; position: relative; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
}
.brand { display: flex; align-items: center; gap: 8px; font-family: "Inter"; font-weight: 800; letter-spacing: .14em; font-size: 15px; color: var(--medra-blue); flex: 1; }
.brand-mark { width: 24px; height: 24px; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.lang-switch {
  min-width: 52px; height: 34px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow);
  font-weight: 700; font-size: 13px; color: var(--medra-blue);
}
html[lang="en"] .lang-switch { font-family: "Cairo"; }
.demo-banner {
  margin: 0 16px; padding: 6px 12px; border-radius: 10px;
  background: repeating-linear-gradient(-45deg, rgba(245,158,11,.14) 0 10px, rgba(245,158,11,.08) 10px 20px);
  color: #92580A; font-size: 11.5px; font-weight: 600; text-align: center;
}
@media (prefers-color-scheme: dark) { .demo-banner { color: #FBBF24; } }

.view { padding: 14px 16px calc(28px + var(--safe-b)); outline: none; }
.app.has-tabbar .view { padding-bottom: calc(100px + var(--safe-b)); }
.screen-enter { animation: enter .42s cubic-bezier(.2,.8,.2,1) both; }
@keyframes enter { from { opacity: 0; transform: translateY(14px) scale(.985); } }

/* ---------- Emergency ID ---------- */
.em-hero {
  position: relative; overflow: hidden;
  border-radius: 28px; padding: 20px 20px 22px; color: #fff;
  background: var(--brand-grad);
  box-shadow: var(--shadow-lg);
}
.em-hero::before, .em-hero::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,.18), transparent 70%);
}
.em-hero::before { width: 260px; height: 260px; top: -120px; inset-inline-end: -80px; }
.em-hero::after { width: 180px; height: 180px; bottom: -90px; inset-inline-start: -50px; }
.em-hero .hero-ecg { position: absolute; inset-inline: 0; bottom: 64px; height: 40px; opacity: .25; }
.em-hero .hero-ecg path { fill: none; stroke: #fff; stroke-width: 2; }
.em-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: relative; }
.em-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 8px; border-radius: 999px;
  background: rgba(255,255,255,.16); backdrop-filter: blur(8px);
  font-weight: 700; font-size: 12.5px;
}
html[dir="rtl"] .em-badge { padding: 6px 8px 6px 12px; }
.em-badge .cross { width: 22px; height: 22px; border-radius: 50%; background: #fff; display: grid; place-items: center; }
.em-badge .cross svg { width: 14px; height: 14px; fill: var(--danger); }
.nfc-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; opacity: .85; font-family: "Inter"; }
.nfc-chip svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.em-person { display: flex; align-items: center; gap: 14px; margin-top: 18px; position: relative; }
.avatar {
  width: 68px; height: 68px; border-radius: 22px; flex: none;
  background: rgba(255,255,255,.2); border: 2px solid rgba(255,255,255,.5);
  display: grid; place-items: center; font-weight: 800; font-size: 24px; overflow: hidden;
}
.avatar svg { width: 100%; height: 100%; }
.avatar.photo { padding: 0; background: #fff; }
.avatar.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.em-name { font-size: 22px; font-weight: 800; line-height: 1.2; }
.em-meta { font-size: 12.5px; opacity: .85; margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.em-meta svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 2.4; }
.em-blood {
  margin-top: 18px; position: relative;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22);
  border-radius: 18px; padding: 12px 16px; backdrop-filter: blur(6px);
}
.em-blood .lbl { font-size: 12.5px; opacity: .85; font-weight: 600; }
.em-blood .val { font-family: "Inter"; font-weight: 800; font-size: 34px; line-height: 1; letter-spacing: -.02em; }
.em-blood .drop { width: 40px; height: 40px; border-radius: 12px; background: #fff; display: grid; place-items: center; }
.em-blood .drop svg { width: 22px; height: 22px; fill: var(--danger); }

.call-btn {
  margin-top: 14px; width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 16px; border-radius: 20px;
  background: linear-gradient(180deg, var(--danger-2), var(--danger));
  color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: 0 10px 26px rgba(229,56,59,.38), inset 0 1px 0 rgba(255,255,255,.25);
  position: relative; overflow: hidden; text-decoration: none;
}
.call-btn .ring { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.22); display: grid; place-items: center; animation: ring 2s infinite; }
.call-btn svg { width: 20px; height: 20px; fill: #fff; }
.call-btn small { display: block; font-weight: 600; font-size: 12px; opacity: .9; }
@keyframes ring { 0%,100% { box-shadow: 0 0 0 0 rgba(255,255,255,.5); } 60% { box-shadow: 0 0 0 12px rgba(255,255,255,0); } }

.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 4px 10px; }
.section-title h2 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.section-title a, .section-title button { font-size: 13.5px; color: var(--medra-blue-2); font-weight: 600; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }
.mcard-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.mcard-ico { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.mcard-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.mcard-head h3 { margin: 0; font-size: 15.5px; font-weight: 700; }
.ico-red { background: rgba(229,56,59,.12); color: var(--danger); }
.ico-blue { background: rgba(36,89,184,.12); color: var(--medra-blue-2); }
.ico-teal { background: rgba(15,167,157,.14); color: var(--medra-teal); }
.ico-amber { background: rgba(245,158,11,.15); color: #D97706; }
.ico-violet { background: rgba(139,92,246,.14); color: #7C3AED; }
.ico-pink { background: rgba(236,72,153,.13); color: #DB2777; }

.allergy {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px; border-radius: 14px;
  background: rgba(229,56,59,.07); border: 1px solid rgba(229,56,59,.18);
}
.allergy + .allergy { margin-top: 8px; }
.allergy b { display: block; font-size: 17px; color: var(--danger); }
.allergy span { font-size: 13px; color: var(--text-2); }
.sev { margin-inline-start: auto; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 4px 8px; border-radius: 8px; background: var(--danger); color: #fff; white-space: nowrap; }
.cond { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); font-weight: 600; font-size: 16px; }
.cond:first-of-type { border-top: 0; padding-top: 2px; }
.cond .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--medra-blue-2); flex: none; }
.cond small { display: block; font-weight: 500; color: var(--text-3); font-size: 12.5px; }
.instr { font-size: 16px; line-height: 1.6; }
.instr li { margin: 6px 0; }
.instr ol { margin: 0; padding-inline-start: 22px; }
.contact-row { display: flex; align-items: center; gap: 12px; }
.contact-row .avatar { width: 48px; height: 48px; border-radius: 16px; background: var(--brand-grad-soft); color: var(--medra-blue); border: 0; font-size: 18px; }
.contact-row b { font-size: 17px; display: block; }
.contact-row span { font-size: 13px; color: var(--text-3); }
.round-call { margin-inline-start: auto; width: 46px; height: 46px; border-radius: 50%; background: var(--ok); display: grid; place-items: center; box-shadow: 0 6px 16px rgba(16,185,129,.35); }
.round-call svg { width: 20px; height: 20px; fill: #fff; }

.privacy-note {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 18px 4px 0; font-size: 12.5px; color: var(--text-2); line-height: 1.55;
}
.privacy-note svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--medra-teal); stroke-width: 2; margin-top: 2px; }

.access-paths { margin-top: 22px; display: grid; gap: 10px; }
.path-btn {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: start;
  padding: 15px 16px; border-radius: 20px;
}
.path-btn .pi { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.path-btn .pi svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.path-btn .pt { flex: 1; }
.path-btn .pt b { display: block; font-size: 16px; }
.path-btn .pt span { font-size: 12.5px; opacity: .8; }
.path-btn .chev { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; opacity: .7; }
.path-patient { background: var(--brand-grad); color: #fff; box-shadow: 0 10px 24px rgba(36,89,184,.3); }
.path-patient .pi { background: rgba(255,255,255,.18); }
.path-doctor { background: var(--surface); color: var(--text); box-shadow: var(--shadow); border: 1.5px solid var(--line); }
.path-doctor .pi { background: rgba(15,167,157,.12); color: var(--medra-teal); }

.footer-id { text-align: center; color: var(--text-3); font-size: 11.5px; margin-top: 22px; }

.revoked { text-align: center; padding: 48px 20px; }
.revoked .big-ico { width: 84px; height: 84px; margin: 0 auto 16px; border-radius: 28px; background: rgba(229,56,59,.1); display: grid; place-items: center; }
.revoked .big-ico svg { width: 40px; height: 40px; fill: none; stroke: var(--danger); stroke-width: 2; }

/* ---------- Auth ---------- */
.auth-head { text-align: center; margin: 8px 0 22px; }
.auth-ico { width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 24px; display: grid; place-items: center; background: var(--brand-grad); color: #fff; box-shadow: var(--shadow-lg); }
.auth-ico.doc { background: linear-gradient(135deg, #0B7A70, var(--medra-teal)); }
.auth-ico svg { width: 34px; height: 34px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.auth-head h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.auth-head p { margin: 6px 0 0; color: var(--text-2); font-size: 14px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { padding: 9px 6px; border-radius: 10px; font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--medra-blue); box-shadow: var(--shadow); }
.field { margin-top: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin: 0 4px 6px; }
.input {
  width: 100%; height: 52px; border-radius: 14px; padding: 0 16px;
  background: var(--surface); border: 1.5px solid var(--line); outline: none; font-size: 16px;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus { border-color: var(--medra-blue-2); box-shadow: 0 0 0 4px rgba(47,116,240,.15); }
.input.err { border-color: var(--danger); }
.phone-wrap { display: flex; gap: 8px; direction: ltr; }
.phone-wrap .cc { width: 88px; flex: none; text-align: center; padding: 0; font-weight: 600; }
.otp { display: flex; gap: 8px; direction: ltr; justify-content: center; }
.otp input { width: 46px; height: 56px; text-align: center; font-size: 22px; font-weight: 700; padding: 0; }
.err-msg { color: var(--danger); font-size: 12.5px; margin: 6px 4px 0; min-height: 1em; }
.btn {
  width: 100%; height: 54px; border-radius: 16px; margin-top: 18px;
  font-weight: 700; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: 0 10px 24px rgba(36,89,184,.28); }
.btn-teal { background: linear-gradient(135deg, #0B7A70, var(--medra-teal)); color: #fff; box-shadow: 0 10px 24px rgba(15,167,157,.28); }
.btn-ghost { background: transparent; color: var(--medra-blue-2); height: 44px; margin-top: 8px; }
.btn-outline { background: var(--surface); border: 1.5px solid var(--line); color: var(--text); }
.btn-danger-outline { background: transparent; border: 1.5px solid rgba(229,56,59,.4); color: var(--danger); }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.btn[disabled] { opacity: .6; pointer-events: none; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.secure-line { display: flex; justify-content: center; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); margin-top: 18px; }
.secure-line svg { width: 14px; height: 14px; fill: none; stroke: var(--ok); stroke-width: 2.4; }
.demo-note { font-size: 11.5px; color: #92580A; background: rgba(245,158,11,.1); border-radius: 10px; padding: 8px 10px; margin-top: 14px; text-align: center; }
.passkey-art { display: grid; place-items: center; margin: 22px 0 6px; }
.passkey-art .fp { width: 96px; height: 96px; border-radius: 30px; background: var(--brand-grad-soft); display: grid; place-items: center; }
.passkey-art svg { width: 54px; height: 54px; fill: none; stroke: var(--medra-blue-2); stroke-width: 1.6; stroke-linecap: round; }
.hint { font-size: 13px; color: var(--text-2); text-align: center; line-height: 1.6; margin: 8px 6px 0; }
.warn-box { display: flex; gap: 10px; padding: 12px 14px; border-radius: 14px; background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); font-size: 13px; line-height: 1.55; margin-top: 4px; }
.warn-box svg { width: 20px; height: 20px; flex: none; fill: none; stroke: #D97706; stroke-width: 2; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 9px 14px; border-radius: 999px; background: var(--surface); border: 1.5px solid var(--line); font-size: 13.5px; font-weight: 600; }
.chip[aria-pressed="true"] { border-color: var(--medra-teal); background: rgba(15,167,157,.1); color: var(--teal-ink); }

/* ---------- Dashboard ---------- */
.dash-head { display: flex; align-items: center; gap: 12px; margin: 4px 2px 16px; }
.dash-head .avatar { width: 52px; height: 52px; border-radius: 18px; background: var(--brand-grad); color: #fff; border: 0; font-size: 19px; }
.dash-head .hi { color: var(--text-3); font-size: 13px; }
.dash-head h1 { margin: 0; font-size: 22px; font-weight: 800; }
.role-pill { margin-inline-start: auto; font-size: 11.5px; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: rgba(15,167,157,.12); color: var(--teal-ink); }
.audit-bar { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 14px; background: rgba(15,167,157,.1); border: 1px solid rgba(15,167,157,.3); font-size: 12.5px; margin-bottom: 14px; }
.audit-bar .rec { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: pulse 1.4s infinite; flex: none; }

.alert {
  display: flex; gap: 12px; padding: 14px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow);
  border-inline-start: 4px solid var(--warn);
}
.alert + .alert { margin-top: 10px; }
.alert.info { border-inline-start-color: var(--medra-blue-2); }
.alert b { display: block; font-size: 14.5px; }
.alert span { font-size: 13px; color: var(--text-2); }
.alert time { font-size: 11.5px; color: var(--text-3); display: block; margin-top: 4px; }

.vgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vcard { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; text-align: start; width: 100%; position: relative; overflow: hidden; }
.vcard .vt { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.vcard .vt svg { width: 16px; height: 16px; fill: currentColor; }
.vcard .vv { margin-top: 10px; display: flex; align-items: baseline; gap: 4px; }
.vcard .vv b { font-family: "Inter"; font-size: 28px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.vcard .vv span { font-size: 12px; color: var(--text-3); font-weight: 600; }
.vcard .vs { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.vcard .spark { margin-top: 8px; height: 34px; width: 100%; }
.vcard .live { position: absolute; top: 14px; inset-inline-end: 14px; font-size: 10px; font-weight: 800; color: var(--danger); display: flex; align-items: center; gap: 4px; }
.vcard .live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s infinite; }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; margin-top: 6px; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.in { color: var(--ok); }
.status.out { color: #D97706; }
.status.none { color: var(--text-3); }
.c-bp { color: var(--c-bp); } .c-glu { color: var(--c-glu); } .c-wt { color: var(--c-wt); } .c-hr { color: var(--c-hr); }

.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; width: 100%; text-align: start; }
.row + .row { border-top: 1px solid var(--line); }
.row .ri { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.row .ri svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.row .rt { flex: 1; min-width: 0; }
.row .rt b { display: block; font-size: 15px; font-weight: 700; }
.row .rt span { display: block; font-size: 12.5px; color: var(--text-3); line-height: 1.45; }
.vcard .vv span { white-space: nowrap; }
.row .re { font-size: 12.5px; color: var(--text-3); text-align: end; }
.row .chev { width: 16px; height: 16px; fill: none; stroke: var(--text-3); stroke-width: 2.4; }

.appt { display: flex; gap: 14px; align-items: center; }
.appt .date { width: 58px; height: 64px; border-radius: 16px; background: var(--brand-grad); color: #fff; display: grid; place-items: center; text-align: center; flex: none; line-height: 1.1; }
.appt .date b { font-family: "Inter"; font-size: 22px; display: block; }
.appt .date span { font-size: 11px; font-weight: 600; opacity: .9; }
.appt .info b { display: block; font-size: 15.5px; }
.appt .info span { font-size: 13px; color: var(--text-2); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: rgba(36,89,184,.1); color: var(--medra-blue-2); margin-top: 6px; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; gap: 12px; }
.toggle-row + .toggle-row { border-top: 1px solid var(--line); }
.toggle-row span { font-size: 15px; font-weight: 600; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: .25s; }
.switch i::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: .25s; }
.switch input:checked + i { background: var(--medra-teal); }
.switch input:checked + i::after { transform: translateX(20px); }
html[dir="rtl"] .switch input:checked + i::after { transform: translateX(-20px); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px rgba(47,116,240,.35); }

.big-chart { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.big-chart + .big-chart { margin-top: 12px; }
.big-chart .bc-head { display: flex; justify-content: space-between; align-items: flex-start; }
.big-chart .bc-head b { font-size: 15px; display: flex; gap: 6px; align-items: center; }
.big-chart .bc-head b svg { width: 16px; height: 16px; fill: currentColor; }
.big-chart .bc-val { font-family: "Inter"; font-size: 30px; font-weight: 800; margin-top: 6px; }
.big-chart .bc-val small { font-size: 13px; color: var(--text-3); font-weight: 600; margin-inline-start: 4px; }
.big-chart svg.chart { width: 100%; height: 140px; margin-top: 10px; direction: ltr; }
.big-chart .range-note { font-size: 12px; color: var(--text-3); margin-top: 8px; display: flex; gap: 6px; align-items: center; }
.range-swatch { width: 14px; height: 8px; border-radius: 3px; background: rgba(16,185,129,.18); border: 1px dashed rgba(16,185,129,.6); }
.chart-days { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 4px; direction: ltr; }

.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kv div { background: var(--surface-2); border-radius: 14px; padding: 12px; }
.kv span { display: block; font-size: 12px; color: var(--text-3); }
.kv b { font-size: 15px; }

.device-batt { display: inline-flex; align-items: center; gap: 4px; }
.batt { width: 22px; height: 11px; border: 1.5px solid var(--text-3); border-radius: 3px; position: relative; padding: 1px; }
.batt i { display: block; height: 100%; background: var(--ok); border-radius: 1px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 30;
  width: min(480px, 100%);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px 8px calc(8px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
.tab { display: grid; justify-items: center; gap: 3px; padding: 6px 0; font-size: 10.5px; font-weight: 600; color: var(--text-3); border-radius: 12px; }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--medra-blue-2); }
.tab[aria-current="page"] svg { stroke-width: 2.4; }

/* ---------- Sheet / toast ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(5,15,44,.45); z-index: 60; display: flex; align-items: flex-end; justify-content: center; animation: fade .25s; }
.sheet { width: min(480px, 100%); background: var(--surface); border-radius: 28px 28px 0 0; padding: 10px 20px calc(22px + var(--safe-b)); animation: up .32s cubic-bezier(.2,.8,.2,1); max-height: 88vh; overflow: auto; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 16px; }
.sheet h3 { margin: 0 0 8px; font-size: 19px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 18px; font-size: 13.5px; font-weight: 600; line-height: 1.45; opacity: 0; pointer-events: none; transition: .3s; z-index: 80; width: max-content; max-width: min(440px, calc(100vw - 32px)); text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.app.has-dock ~ .toast { bottom: calc(150px + var(--safe-b)); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.muted { color: var(--text-3); }
.mt-0 { margin-top: 0 !important; }
.sp { height: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (min-width: 520px) {
  body { background: radial-gradient(80% 60% at 50% 0%, rgba(36,89,184,.10), transparent), var(--bg); }
}

/* ---------- Emergency call dock (fixed bottom) ---------- */
.dock {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 30;
  width: min(480px, 100%);
  display: grid; gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(14,26,51,.08);
  animation: dockIn .45s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes dockIn { from { transform: translate(-50%, 100%); } }
.app.has-dock .view { padding-bottom: calc(150px + var(--safe-b)); }
.dock-btn {
  display: grid; justify-items: center; align-content: center; gap: 2px;
  min-height: 82px; padding: 8px 4px; border-radius: 18px;
  text-decoration: none; text-align: center; color: var(--text);
  background: var(--surface-2); border: 1.5px solid var(--line);
  transition: transform .15s;
}
.dock-btn:active { transform: scale(.96); }
.dock-btn b { font-size: 13.5px; font-weight: 800; line-height: 1.25; }
.dock-btn small { font-size: 11px; color: var(--text-3); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-ico { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 3px; }
.dock-ico svg { width: 18px; height: 18px; }
.dock-ico svg.i { stroke-width: 2.2; }
.d-patient { background: var(--brand-grad); border-color: transparent; color: #fff; box-shadow: 0 8px 20px rgba(36,89,184,.3); }
.d-patient small { color: rgba(255,255,255,.85); }
.d-patient .dock-ico { background: rgba(255,255,255,.2); color: #fff; }
.d-pro { background: var(--surface); }
.d-pro .dock-ico { background: rgba(15,167,157,.14); color: var(--medra-teal); }

.d-sos { background: linear-gradient(180deg, var(--danger-2), var(--danger)); border-color: transparent; color: #fff; box-shadow: 0 8px 20px rgba(229,56,59,.35); }
.d-sos b { font-size: 15px; }
.d-sos small { color: #fff; font-weight: 800; font-size: 14px; }
.d-sos .dock-ico { background: rgba(255,255,255,.22); animation: ring 2s infinite; }
.d-sos .dock-ico svg { fill: #fff; }
.dock { gap: 7px; padding-inline: 10px; }
.dock-btn b { font-size: 12.5px; }
.dock-btn small { font-size: 10.5px; white-space: normal; line-height: 1.3; }


/* =========================================================
   v2 — Native-like mobile app layer
   ========================================================= */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-height: 100dvh; }
button, a, label { touch-action: manipulation; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(47,116,240,.55); outline-offset: 2px; }
.app { min-height: 100dvh; }
.view { padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
.app.has-tabbar .view { padding-bottom: calc(104px + var(--safe-b)); }
.topbar { padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); border-bottom: 1px solid transparent; transition: border-color .2s; }
.topbar.scrolled { border-bottom-color: var(--line); }
.icon-btn { width: 44px; height: 44px; position: relative; color: var(--medra-blue); }
.lang-switch { height: 44px; }
.bell-badge { position: absolute; top: 4px; inset-inline-end: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--surface); }

/* ---------- Bottom navigation ---------- */
.tabbar { padding: 6px 6px calc(6px + var(--safe-b)); box-shadow: 0 -6px 24px rgba(14,26,51,.07); }
.tab { position: relative; min-height: 54px; align-content: center; font-size: 11.5px; font-weight: 700; line-height: 1.3; transition: color .2s; }
.tab svg { transition: transform .2s cubic-bezier(.2,1.4,.4,1); }
.tab:active svg { transform: scale(.88); }
.tab[aria-current="page"] { color: var(--teal-ink); }
.tab[aria-current="page"] svg { transform: translateY(-1px); }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: -6px; left: 50%; width: 30px; height: 3px; margin-left: -15px; border-radius: 0 0 4px 4px; background: var(--medra-teal); }
.tab[aria-current="page"]::after { content: ""; position: absolute; top: 3px; left: 50%; width: 52px; height: 30px; margin-left: -26px; border-radius: 15px; background: rgba(15,167,157,.12); z-index: -1; }

/* ---------- Page titles ---------- */
.page-title { margin: 2px 4px 14px; font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.page-sub { margin: -8px 4px 14px; font-size: 13.5px; color: var(--text-2); line-height: 1.55; }

/* ---------- Digital patient card ---------- */
.pcard { position: relative; overflow: hidden; border-radius: 26px; padding: 18px; color: #fff; background: var(--brand-grad); box-shadow: var(--shadow-lg); }
.pcard::before { content: ""; position: absolute; width: 240px; height: 240px; top: -130px; inset-inline-end: -70px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.16), transparent 70%); pointer-events: none; }
.pcard-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: relative; }
.pcard-brand { font-family: "Inter"; font-weight: 800; letter-spacing: .2em; font-size: 13px; opacity: .9; }
.nfc-status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.16); font-size: 12px; font-weight: 700; }
.nfc-status svg.i { width: 15px; height: 15px; }
.nfc-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #5EF0B5; box-shadow: 0 0 0 3px rgba(94,240,181,.25); }
.nfc-status.off .dot { background: #FF8A8D; box-shadow: 0 0 0 3px rgba(255,138,141,.25); }
.pcard-body { display: flex; align-items: center; gap: 14px; margin-top: 16px; position: relative; }
.pcard-info { flex: 1; min-width: 0; }
.pcard-name { font-size: 21px; font-weight: 800; line-height: 1.25; }
.pcard-kv { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; }
.pcard-kv span { display: block; font-size: 11.5px; opacity: .78; font-weight: 600; }
.pcard-kv b { font-size: 15px; font-weight: 800; }
.pcard-qr { flex: none; width: 96px; height: 96px; padding: 6px; border-radius: 16px; background: #fff; box-shadow: 0 8px 20px rgba(0,0,0,.2); display: block; }
.pcard-qr svg { width: 100%; height: 100%; }
.pcard-actions { display: flex; gap: 8px; margin-top: 16px; position: relative; }
.pcard-btn { flex: 1; min-height: 46px; padding: 0 12px; border-radius: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; font-size: 14px; background: #fff; color: #10224F; }
.pcard-btn.ghost { background: rgba(255,255,255,.16); color: #fff; }
.pcard-btn svg.i { width: 18px; height: 18px; }
.pcard.big .pcard-body { flex-direction: column; align-items: stretch; text-align: center; }
.pcard.big .pcard-kv { justify-content: center; }
.pcard.big .pcard-qr { width: min(230px, 68%); height: auto; aspect-ratio: 1; margin: 6px auto 0; padding: 10px; border-radius: 22px; }
.pcard-hint { text-align: center; font-size: 12.5px; opacity: .85; margin-top: 10px; position: relative; }

/* ---------- Quick actions ---------- */
.qa-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.qa { display: grid; justify-items: center; align-content: start; gap: 8px; min-height: 98px; padding: 14px 6px 10px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); font-size: 12.5px; font-weight: 700; line-height: 1.35; text-align: center; text-decoration: none; color: var(--text); transition: transform .15s; }
.qa:active { transform: scale(.96); }
.qa .mcard-ico { width: 44px; height: 44px; border-radius: 15px; }
.qa .mcard-ico svg { width: 22px; height: 22px; }

/* ---------- Location widget ---------- */
.loc-head { display: flex; align-items: center; gap: 10px; }
.loc-head h3 { margin: 0; font-size: 15.5px; font-weight: 700; flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.on { background: rgba(15,167,157,.13); color: var(--teal-ink); }
.pill.on::before { animation: pulse 1.4s infinite; box-shadow: 0 0 0 0 rgba(15,167,157,.6); }
.pill.warn { background: rgba(229,56,59,.1); color: var(--danger); }
.loc-rows { margin-top: 12px; border-radius: 16px; background: var(--surface-2); padding: 2px 14px; }
.loc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; font-size: 13.5px; }
.loc-row + .loc-row { border-top: 1px solid var(--line); }
.loc-row span { color: var(--text-2); }
.loc-row b { font-weight: 700; text-align: end; }
.loc-row small { display: block; font-weight: 500; color: var(--text-3); font-size: 12px; }
.loc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.loc-actions .btn { margin-top: 0; height: 50px; font-size: 14.5px; text-decoration: none; }
.loc-actions .wide { grid-column: 1 / -1; }
.btn-danger { background: linear-gradient(180deg, var(--danger-2), var(--danger)); color: #fff; box-shadow: 0 10px 24px rgba(229,56,59,.28); }
.btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.loc-msg { margin-top: 10px; font-size: 12.5px; line-height: 1.55; color: var(--danger); }
.note { display: flex; gap: 10px; align-items: flex-start; margin: 14px 4px 0; font-size: 12.5px; color: var(--text-2); line-height: 1.6; }
.note svg.i { width: 18px; height: 18px; margin-top: 2px; color: var(--medra-teal); }

/* ---------- Install ---------- */
.install-card { position: relative; display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); border: 1.5px solid rgba(15,167,157,.35); margin-bottom: 14px; }
.install-card img { width: 52px; height: 52px; border-radius: 14px; flex: none; }
.install-card .ic-t { flex: 1; min-width: 0; padding-inline-end: 18px; }
.install-card .ic-t b { display: block; font-size: 15px; }
.install-card .ic-t span { display: block; font-size: 12.5px; color: var(--text-2); line-height: 1.5; margin-top: 2px; }
.install-card .btn { width: auto; height: 42px; margin: 10px 0 0; padding: 0 16px; font-size: 14px; border-radius: 13px; }
.install-card .x { position: absolute; top: 6px; inset-inline-end: 6px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--text-3); }
.install-card .x svg.i { width: 16px; height: 16px; }
.btn-install { background: linear-gradient(135deg, #0B857D, var(--medra-teal)); color: #fff; box-shadow: 0 10px 24px rgba(15,167,157,.28); }
.sheet { position: relative; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-close { position: absolute; top: 14px; inset-inline-end: 14px; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--text-2); z-index: 2; }
.sheet-close svg.i { width: 16px; height: 16px; stroke-width: 2.6; }
.app-id { display: flex; align-items: center; gap: 14px; margin: 4px 0 14px; padding-inline-end: 40px; }
.app-id .app-icon { width: 64px; height: 64px; border-radius: 16px; box-shadow: 0 8px 20px rgba(16,34,79,.25); flex: none; }
.app-id b { display: block; font-size: 19px; font-family: "Inter", var(--font); letter-spacing: .02em; }
.app-id span { font-size: 13px; color: var(--text-2); }
.app-id .app-logo { height: 30px; width: auto; margin-inline-start: auto; background: #fff; border-radius: 8px; padding: 3px 6px; }
.install-lead { font-size: 17px; font-weight: 800; margin: 0 0 4px; }
.install-text { font-size: 14px; color: var(--text-2); line-height: 1.65; margin: 0 0 14px; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: st; }
.steps li { counter-increment: st; display: flex; align-items: center; gap: 12px; padding: 11px 0; font-size: 14.5px; line-height: 1.5; font-weight: 600; }
.steps li + li { border-top: 1px solid var(--line); }
.steps li::before { content: counter(st); font-family: "Inter"; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--brand-grad); color: #fff; font-size: 13px; font-weight: 800; display: grid; place-items: center; }
.steps li > span { flex: 1; }
.steps .st-ico { flex: none; width: 38px; height: 38px; border-radius: 11px; background: var(--surface-2); color: var(--medra-blue-2); display: grid; place-items: center; }
.steps .st-ico svg.i { width: 20px; height: 20px; }
.steps .st-ico img { width: 26px; height: 26px; border-radius: 7px; }
.steps .st-ico b { font-size: 12px; font-weight: 800; color: var(--medra-blue-2); }
.sheet h3.install-h { font-size: 16px; margin: 4px 0 2px; }

/* ---------- States: skeleton / empty / error ---------- */
.skel { position: relative; overflow: hidden; background: var(--line); border-radius: 16px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: shimmer 1.3s infinite; }
@media (prefers-color-scheme: dark) { .skel::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent); } }
@keyframes shimmer { to { transform: translateX(100%); } }
.skel + .skel { margin-top: 12px; }
.skel-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.skel-row .skel { margin-top: 0; }
.state { text-align: center; padding: 28px 18px; }
.state .big-ico { width: 68px; height: 68px; margin: 0 auto 12px; border-radius: 22px; background: var(--surface-2); color: var(--text-3); display: grid; place-items: center; }
.state .big-ico svg.i { width: 30px; height: 30px; }
.state.err .big-ico { background: rgba(229,56,59,.1); color: var(--danger); }
.state h2 { margin: 0 0 4px; font-size: 17px; }
.state p { margin: 0; font-size: 13.5px; color: var(--text-2); line-height: 1.6; }
.state .btn { margin-top: 16px; }
.list .state { padding: 22px 16px; }

/* ---------- Offline bar / pull to refresh ---------- */
.net-bar { position: sticky; top: calc(64px + var(--safe-t)); z-index: 19; margin: 0 16px 8px; padding: 9px 14px; border-radius: 12px; background: #3A2A08; color: #FFD27A; font-size: 13px; font-weight: 700; text-align: center; box-shadow: var(--shadow); }
.ptr { position: fixed; top: calc(70px + var(--safe-t)); left: 50%; z-index: 25; width: 40px; height: 40px; margin-left: -20px; border-radius: 50%; background: var(--surface); box-shadow: 0 6px 18px rgba(14,26,51,.18); display: grid; place-items: center; opacity: 0; transform: translateY(-60px); pointer-events: none; }
.ptr.settle { transition: transform .25s, opacity .25s; }
.ptr-spin { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--medra-teal); }
.ptr.loading .ptr-spin { animation: spin .7s linear infinite; }

/* ---------- Segmented control inside History ---------- */
.seg.seg-4 { margin-bottom: 16px; position: sticky; top: calc(70px + var(--safe-t)); z-index: 5; box-shadow: var(--shadow); }
.seg button { min-height: 40px; }
.seg button[aria-selected="true"] { color: var(--teal-ink); }

/* ---------- Installed (standalone) app ---------- */
@media (display-mode: standalone) {
  body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  input, textarea, .num, .selectable { -webkit-user-select: text; user-select: text; }
  [data-install] { display: none !important; }
}

/* ---------- Offline fallback page ---------- */
.offline-page { display: grid; place-items: center; min-height: 100dvh; padding: 24px; font-family: "Cairo", "Inter", system-ui, sans-serif; }
.offline-box { width: min(380px, 100%); text-align: center; }
.offline-box img { border-radius: 22px; box-shadow: var(--shadow-lg); }
.offline-box h1 { font-size: 22px; margin: 18px 0 6px; }
.offline-box p { color: var(--text-2); font-size: 14.5px; line-height: 1.7; margin: 0 0 4px; }
.offline-box .btn { text-decoration: none; }

/* ---------- Public Emergency ID inside the app shell: nav + slim call bar ---------- */
.app.has-tabbar .dock { display: block; bottom: calc(66px + var(--safe-b)); padding: 8px 12px; border-top: 0; background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: none; animation: none; pointer-events: none; }
.app.has-tabbar .dock .dock-btn { pointer-events: auto; display: flex; width: 100%; min-height: 54px; gap: 10px; justify-content: center; align-items: center; border-radius: 18px; padding: 6px 14px; }
.app.has-tabbar .dock .dock-ico { margin: 0; width: 34px; height: 34px; }
.app.has-tabbar .dock .d-sos b { font-size: 16px; }
.app.has-tabbar .dock .d-sos small { font-size: 16px; }
.app.has-dock.has-tabbar .view { padding-bottom: calc(168px + var(--safe-b)); }
.app.has-dock ~ .toast { bottom: calc(160px + var(--safe-b)); }
.em-hero + .access-paths { margin-top: 14px; }
.em-hero .hero-ecg { bottom: 8px; }
.em-hero:has(.call-btn) .hero-ecg { bottom: 64px; }

/* ---------- v3: consent box, scan-location card ---------- */
.consent-box { margin-top: 12px; padding: 14px; border-radius: 16px; background: rgba(15,167,157,.08); border: 1.5px solid rgba(15,167,157,.3); font-size: 13.5px; line-height: 1.65; }
.consent-box b { display: block; margin-bottom: 6px; font-size: 14.5px; }
.consent-box ul { margin: 0; padding-inline-start: 18px; color: var(--text-2); }
.consent-box li + li { margin-top: 5px; }
.loc-msg[role="status"] { color: #B26A00; }
.scan-share { margin-top: 14px; }
.scan-share .btn { margin-top: 12px; }
