/* ==========================================================================
 * InstaPraxis PWA — mobile-first app shell
 * One sheet, no framework. Designed for iOS Safari (PWA standalone) and
 * Android Chrome (PWA + TWA). Lighthouse PWA score target: 100.
 * ==========================================================================
 */

:root{
  --navy:        #0a2e57;
  --navy-deep:   #06203a;
  --navy-ink:    #0d3b66;
  --teal:        #1b9aaa;
  --teal-bright: #62d9c8;
  --green:       #84c441;
  --orange:      #f7a621;
  --bg:          #f4f7fa;
  --card:        #ffffff;
  --line:        #e5ecf1;
  --ink:         #0d2c3b;
  --ink-soft:    #4a6275;
  --ink-faint:   #8aa0b2;
  --danger:      #e85a4f;
  --shadow-sm:   0 1px 3px rgba(15, 60, 90, .06);
  --shadow-md:   0 4px 14px rgba(15, 60, 90, .10);
  --shadow-lg:   0 12px 32px rgba(15, 60, 90, .14);
  --radius:      18px;
  --radius-sm:   12px;
  --tap:         44px;
  --safe-t:      env(safe-area-inset-top,  0px);
  --safe-b:      env(safe-area-inset-bottom, 0px);
  --safe-l:      env(safe-area-inset-left, 0px);
  --safe-r:      env(safe-area-inset-right, 0px);
  --top-h:       54px;
  --tabs-h:      66px;
}

@media (prefers-color-scheme: dark){
  :root{
    --bg:        #06121f;
    --card:      #0f223a;
    --line:      #1c3553;
    --ink:       #e8eef5;
    --ink-soft:  #a9bccd;
    --ink-faint: #6b8398;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
    --shadow-md: 0 4px 14px rgba(0,0,0,.5);
    --shadow-lg: 0 12px 32px rgba(0,0,0,.55);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body{ margin: 0; padding: 0; }
html{ -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body{
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  overscroll-behavior-y: contain;
  padding-top: calc(var(--top-h) + var(--safe-t));
  padding-bottom: calc(var(--tabs-h) + var(--safe-b) + 16px);
}
button, input, textarea, select{ font: inherit; color: inherit; }
button{ background: none; border: 0; padding: 0; cursor: pointer; }
img, svg{ max-width: 100%; display: block; }
a{ color: var(--teal); text-decoration: none; }

/* ---------- Splash (covers first paint) ---------- */
.app-splash{
  position: fixed; inset: 0;
  background: radial-gradient(800px 600px at 50% 30%, rgba(27,154,170,.45), transparent 60%),
              linear-gradient(160deg, #06203a 0%, #0d3b66 100%);
  color: white;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 999;
  transition: opacity .35s ease;
}
.app-splash.fade-out{ opacity: 0; pointer-events: none; }
.splash-mark{ filter: drop-shadow(0 4px 18px rgba(0,0,0,.45)); margin-bottom: 14px; }
.splash-word{ font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.splash-word b{ color: var(--teal-bright); font-weight: 800; }
.splash-sub{ font-size: 13px; color: rgba(255,255,255,.7); margin-top: 4px; }
.splash-dot{
  margin-top: 22px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--teal-bright);
  animation: dotPulse 1.1s infinite ease-in-out;
}
@keyframes dotPulse{
  0%, 100% { transform: scale(1);   opacity: .4; }
  50%      { transform: scale(1.8); opacity: 1;  }
}

/* ---------- Top bar (sticky) ---------- */
.app-top{
  position: fixed; top: 0; left: 0; right: 0;
  height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) 14px 0 14px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-ink) 100%);
  color: white;
  display: flex; align-items: center; gap: 10px;
  z-index: 50;
  box-shadow: 0 1px 0 rgba(255,255,255,.05);
}
.app-top .t-brand{ flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -.01em; }
.app-top .t-brand img{ background: #fff; border-radius: 6px; padding: 2px; }
.app-top .t-brand b{ color: var(--teal-bright); }
.app-top .t-icon{
  width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  color: white;
  position: relative;
  transition: background .12s ease;
}
.app-top .t-icon:active{ background: rgba(255,255,255,.12); }
.app-top .t-icon .dot{
  position: absolute; top: 8px; right: 9px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 2px var(--navy);
}

/* ---------- Update banner ---------- */
.update-banner{
  position: fixed; top: calc(var(--top-h) + var(--safe-t)); left: 12px; right: 12px;
  background: var(--ink);
  color: white; border-radius: 12px;
  padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  z-index: 49;
  animation: slideDown .25s ease;
}
.update-banner .upd-btn{
  background: var(--teal-bright); color: var(--navy);
  font-weight: 700; padding: 7px 14px; border-radius: 8px;
}
@keyframes slideDown{ from{ transform: translateY(-12px); opacity:0 } to{ transform: translateY(0); opacity:1 } }

/* ---------- Install banner ---------- */
.install-banner{
  position: fixed;
  bottom: calc(var(--tabs-h) + var(--safe-b) + 12px);
  left: 12px; right: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 48;
  animation: popUp .3s ease;
}
.install-banner img{ border-radius: 9px; }
.install-banner .ib-body{ flex: 1; min-width: 0; }
.install-banner .ib-title{ font-weight: 700; font-size: 14px; color: var(--ink); }
.install-banner .ib-sub{ font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.install-banner .ib-btn{
  background: var(--navy); color: white;
  padding: 8px 14px; border-radius: 10px; font-weight: 700; font-size: 13px;
}
.install-banner .ib-x{
  width: 30px; height: 30px; border-radius: 50%;
  color: var(--ink-faint); font-size: 22px; line-height: 28px;
}
@keyframes popUp{ from{ transform: translateY(20px); opacity:0 } to{ transform: translateY(0); opacity:1 } }

/* ---------- Screens (generic) ---------- */
.screen{
  max-width: 720px; margin: 0 auto;
  padding: 14px 16px 20px;
}

/* ---------- Role gate ---------- */
.screen-gate{
  padding-top: 18px;
}
.gate-hero{
  text-align: center;
  padding: 22px 16px 28px;
}
.gate-mark{
  display: inline-flex; align-items: center; justify-content: center;
  width: 84px; height: 84px;
  background: white; border-radius: 22px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 18px;
}
.gate-hero h1{
  margin: 0;
  font-size: clamp(26px, 7vw, 34px);
  line-height: 1.1;
  letter-spacing: -.02em;
  color: var(--ink);
}
.gate-hero h1 .hl{ color: var(--teal); }
.gate-hero .gate-lead{
  margin: 14px auto 0;
  max-width: 520px;
  color: var(--ink-soft);
  font-size: 15px;
}
.role-cards{
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 8px;
}
@media (min-width: 560px){ .role-cards{ grid-template-columns: 1fr 1fr; } }
.role-card{
  display: flex; align-items: center; gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease;
  width: 100%;
}
.role-card:active{ transform: scale(.985); box-shadow: var(--shadow-md); }
.role-card .rc-ico{
  flex: none;
  width: 48px; height: 48px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  color: white;
}
.role-card.r-patient .rc-ico{ background: linear-gradient(135deg, #1b9aaa, #0d3b66); }
.role-card.r-doctor  .rc-ico{ background: linear-gradient(135deg, #84c441, #1b9aaa); }
.role-card.r-clinic  .rc-ico{ background: linear-gradient(135deg, #f7a621, #e85a4f); }
.role-card .rc-text{ flex: 1; min-width: 0; }
.role-card .rc-text b{ display: block; font-size: 15px; color: var(--ink); }
.role-card .rc-text em{ display: block; font-style: normal; font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.role-card .rc-arr{ color: var(--ink-faint); font-size: 22px; }

.gate-bottom{
  margin-top: 22px;
  text-align: center;
  padding: 0 8px;
}
.quick-cta{
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--teal); color: white;
  padding: 12px 18px; border-radius: 999px;
  font-weight: 700; font-size: 14px;
  box-shadow: 0 8px 20px rgba(27,154,170,.35);
}
.quick-cta:active{ transform: scale(.98); }
.gate-bottom .trust{
  margin: 18px 0 0;
  color: var(--ink-faint);
  font-size: 12px;
}

/* ---------- Patient / Doctor / Clinic home ---------- */
.hello-strip{
  display: flex; align-items: center; gap: 12px;
  padding: 2px 2px 14px;
}
.hello-strip > div:first-child{ flex: 1; min-width: 0; }
.hello-eye{ font-size: 11.5px; color: var(--ink-faint); letter-spacing: .8px; text-transform: uppercase; }
.hello-name{ font-size: 20px; font-weight: 800; color: var(--ink); letter-spacing: -.01em; margin-top: 2px; }
.hello-avatar{
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--navy));
  color: white; font-weight: 800; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}

/* search card */
.search-card{
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  color: var(--ink-soft);
  margin-bottom: 16px;
}
.search-card input{
  flex: 1; min-width: 0; border: 0; outline: 0;
  background: transparent;
  font-size: 15px;
  color: var(--ink);
}
.search-card input::placeholder{ color: var(--ink-faint); }
.search-card .mic{
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg);
  color: var(--teal);
  display: inline-flex; align-items: center; justify-content: center;
}

/* quick grid (4 tiles) */
.quick-grid{
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-bottom: 16px;
}
.qg-tile{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 6px 10px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease;
}
.qg-tile:active{ transform: scale(.95); }
.qg-tile .qg-ico{
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px;
  margin-bottom: 6px;
  color: white;
}
.qg-tile .qg-1{ background: linear-gradient(135deg, #1b9aaa, #0d3b66); }
.qg-tile .qg-2{ background: linear-gradient(135deg, #84c441, #1b9aaa); }
.qg-tile .qg-3{ background: linear-gradient(135deg, #f7a621, #e85a4f); }
.qg-tile .qg-4{ background: linear-gradient(135deg, #6b5cf0, #1b9aaa); }
.qg-tile .qg-t{ display: block; font-size: 12.5px; color: var(--ink); font-weight: 600; }

/* generic card */
.card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.card-h{
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.ch-eye{ font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; }
.ch-link{ font-size: 13px; color: var(--teal); font-weight: 600; }

.appt-body{ min-height: 80px; }
.empty-stub{
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 18px 12px;
  color: var(--ink-faint);
  text-align: center;
}
.empty-stub p{ margin: 8px 0 0; font-size: 13px; }
.empty-stub .link{ color: var(--teal); font-weight: 600; }

/* vitals grid */
.vitals-grid{
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-bottom: 12px;
}
.v-cell{
  background: linear-gradient(160deg, rgba(27,154,170,.10), rgba(27,154,170,.02));
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
}
.v-l{ display: block; font-size: 10.5px; color: var(--ink-faint); font-weight: 700; letter-spacing: .5px; text-transform: uppercase; }
.v-v{ display: block; font-size: 18px; font-weight: 800; color: var(--ink); margin: 2px 0; }
.v-u{ display: block; font-size: 10px; color: var(--ink-faint); }
.run-scan{
  width: 100%; padding: 11px; border-radius: 12px;
  background: var(--navy); color: white; font-weight: 700; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.run-scan:active{ background: var(--navy-deep); }

/* speciality row (horizontal scroller) */
.spec-row{
  display: flex; gap: 10px; overflow-x: auto;
  padding: 4px 0 6px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.spec-row::-webkit-scrollbar{ display: none; }
.spec-row .sp-chip{
  flex: none; min-width: 110px;
  background: var(--bg);
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
  font-size: 12.5px; color: var(--ink);
  scroll-snap-align: start;
  border: 1px solid var(--line);
}
.spec-row .sp-chip b{ display: block; font-size: 22px; margin-bottom: 4px; }

/* KPI row for doctor / clinic */
.kpi-row{
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-bottom: 14px;
}
.kpi{
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.kpi-v{ display: block; font-size: 20px; font-weight: 800; color: var(--ink); }
.kpi-l{ display: block; font-size: 10.5px; color: var(--ink-faint); letter-spacing: .6px; text-transform: uppercase; margin-top: 2px; }

.action-grid{
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
@media (max-width: 380px){ .action-grid{ grid-template-columns: repeat(2, 1fr); } }
.ag-tile{
  background: var(--bg);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  font-size: 13px; color: var(--ink); font-weight: 600;
  border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.ag-tile svg{ color: var(--teal); }
.ag-tile:active{ background: var(--card); }

/* ---------- Bottom tab bar ---------- */
.app-tabs{
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--tabs-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  z-index: 50;
  box-shadow: 0 -4px 16px rgba(15,60,90,.06);
}
.app-tabs .tab{
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  color: var(--ink-faint);
  font-size: 10.5px; font-weight: 600;
  position: relative;
}
.app-tabs .tab.is-active{ color: var(--teal); }
.app-tabs .tab.is-active::before{
  content: ""; position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  width: 22px; height: 3px; border-radius: 3px;
  background: var(--teal);
}
.app-tabs .tab-fab{ position: relative; }
.app-tabs .tab-fab .fab{
  position: absolute; top: -22px;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-bright), var(--teal));
  color: white;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 22px rgba(27,154,170,.45);
  border: 4px solid var(--card);
}

/* ---------- Toast ---------- */
.toast{
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 22px);
  transform: translateX(-50%);
  background: var(--ink);
  color: white; font-size: 13px;
  padding: 10px 16px; border-radius: 999px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  max-width: calc(100% - 32px);
  text-align: center;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce){
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
