:root {
  --green: #13955B; --green-d: #0E7A49; --green-soft: #E7F5EE; --bg: #FAFBFA; --card: #fff; --text: #1C2430; --muted: #6B7280;
  --line: #ECEEF0; --red: #E0352B; --red-soft: #FDECEC; --orange: #EE7D1A; --orange-soft: #FEF2E6;
  --blue: #2F6FE4; --blue-soft: #EAF1FD; --purple: #7B3FE4; --purple-soft: #F2ECFD; --pink: #E0337E; --pink-soft: #FCEBF3;
  --tabs-h: 66px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: "Noto Sans Arabic", -apple-system, "SF Arabic", "Segoe UI", Tahoma, sans-serif;
  font-size: 16px; line-height: 1.5; overscroll-behavior-y: none;
  padding: env(safe-area-inset-top) 0 calc(var(--tabs-h) + env(safe-area-inset-bottom));
}
body.no-tabs { padding-bottom: env(safe-area-inset-bottom); }
button, input, textarea, select { font: inherit; color: inherit; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }

#view { max-width: 640px; margin: 0 auto; padding: 0 16px 120px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.bold { font-weight: 700; }
h2 { font-size: 17px; font-weight: 800; margin: 18px 0 8px; }

/* ---------- top bar: back on the right, centred title, ⊕ on the left ---------- */
.topbar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; height: 58px; position: sticky; top: 0; background: var(--bg); z-index: 5; margin: 0 -16px 6px; padding: 0 12px; }
.topbar h1 { font-size: 20px; font-weight: 800; margin: 0; text-align: center; }
.tbbtn { width: 40px; height: 40px; border: 0; background: transparent; display: grid; place-items: center; color: var(--text); padding: 0; }
.tbbtn svg { width: 24px; height: 24px; }
.tbbtn.plus { color: var(--green); }
.tbbtn.plus svg { width: 26px; height: 26px; }

.card { background: var(--card); border-radius: 18px; padding: 14px; box-shadow: 0 2px 14px rgba(20,40,30,.07); }
.card.flush { padding: 4px 14px; }
.tap { cursor: pointer; }
.tap:active { opacity: .85; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; align-items: end; }
.grid3 .f span { font-size: 12px; }
.grid3 .in { text-align: center; padding-left: 6px; padding-right: 6px; }
.stockcard { display: grid; gap: 10px; }
.stockcard .sttl { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; }
.stockcard .sttl svg { width: 22px; height: 22px; }
.stockgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stockgrid > div { background: #F1F3F2; border-radius: 14px; padding: 10px 4px; display: grid; }
.stockgrid b { font-size: 24px; font-weight: 800; }
.stockgrid span { font-size: 13px; color: var(--muted); }
.stockgrid .green { background: var(--green-soft); color: var(--green); }
.stockgrid .orange { background: var(--orange-soft); color: var(--orange); }
.stockgrid .red { background: var(--red-soft); color: var(--red); }
.list > .item + .item { border-top: 1px solid var(--line); }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; }

/* ---------- home ---------- */
.home-head { position: relative; display: grid; grid-template-columns: 52px 1fr 52px; align-items: start; padding-top: 14px; }
.roundbtn { width: 48px; height: 48px; border-radius: 50%; border: 0; background: #F1F3F2; display: grid; place-items: center; padding: 0; color: var(--green-d); }
.roundbtn svg { width: 26px; height: 26px; }
.brand { text-align: center; position: relative; }
.brand .logo { width: 82px; height: 82px; display: block; margin: 0 auto -6px; }
.brand .name { font-size: 38px; font-weight: 800; color: var(--green); margin: 0; line-height: 1.25; }
.brand .en { font-size: 19px; color: #2A3340; margin-top: -2px; }
.swoosh { position: absolute; left: -16px; top: 70px; width: 120px; height: 120px; pointer-events: none; }
.greet { margin: 16px 0 14px; }
.greet .hi { font-size: 26px; font-weight: 800; }
.greet .date { color: var(--muted); font-size: 15px; }
.tile { border-radius: 20px; padding: 22px 8px 18px; text-align: center; cursor: pointer; }
.tile:active { transform: scale(.98); }
.tile svg { width: 52px; height: 52px; }
.tile .t { font-size: 21px; font-weight: 800; margin-top: 6px; }
.tile .h { font-size: 14px; color: var(--muted); }
.next .title { font-size: 19px; font-weight: 800; margin-bottom: 10px; }
.today .title { font-size: 19px; font-weight: 800; margin-bottom: 2px; }
.count { min-width: 30px; height: 30px; border-radius: 15px; background: #EEF0EF; display: grid; place-items: center; font-weight: 700; padding: 0 8px; }
.item .ico { width: 26px; height: 26px; flex: none; }

/* ---------- pieces ---------- */
.thumb { width: 58px; height: 58px; border-radius: 14px; flex: none; display: grid; place-items: center; overflow: hidden; background: #F1F3F2; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb svg { width: 30px; height: 30px; }
.avatar { width: 56px; height: 56px; border-radius: 14px; background: var(--blue-soft); display: grid; place-items: center; font-size: 34px; flex: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 12px; padding: 4px 10px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.chip svg { width: 18px; height: 18px; }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.solid { background: var(--green); color: #fff; font-size: 19px; padding: 8px 18px; border-radius: 24px; }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.orange { background: var(--orange-soft); color: var(--orange); }
button.chip { border: 0; font-family: inherit; font-size: 15px; padding: 9px 16px; border-radius: 16px; cursor: pointer; }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.gray { background: var(--line); color: var(--muted); }
.times { color: var(--muted); font-size: 13px; }
.chev { width: 20px; height: 20px; color: #1C2430; flex: none; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty svg { width: 64px; height: 64px; display: block; margin: 0 auto 10px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }

.seg { display: flex; background: #F1F3F2; border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 11px; height: 40px; font-weight: 700; color: var(--text); }
.seg button.on { background: var(--green); color: #fff; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 54px; border: 0; border-radius: 27px; background: var(--green); color: #fff; font-weight: 800; font-size: 17px; text-decoration: none; }
.btn:disabled { opacity: .6; }
.btn.soft { background: var(--green-soft); color: var(--green); height: 44px; font-size: 15px; }
.btn.danger { background: var(--red-soft); color: var(--red); height: 44px; font-size: 15px; }
.btn.gray { background: #F1F3F2; color: var(--text); height: 44px; font-size: 15px; }
.btn.orange { background: var(--orange-soft); color: var(--orange); height: 44px; font-size: 15px; }
.btn.small { height: 36px; width: auto; padding: 0 16px; font-size: 14px; border-radius: 18px; }
.btnrow { display: flex; gap: 8px; }
.btnrow > * { flex: 1; }
.dock { position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding: 10px 16px 14px; background: linear-gradient(to top, var(--bg) 75%, transparent); z-index: 6; }
body.no-tabs .dock { bottom: env(safe-area-inset-bottom); }
.dock .btn { max-width: 608px; margin: 0 auto; box-shadow: 0 6px 16px rgba(19,149,91,.28); }
.dock.pill .btn { width: 72%; max-width: 300px; height: 52px; }
.linkbtn { border: 0; background: transparent; color: var(--green); font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; margin: 4px auto 0; }
.linkbtn svg { width: 18px; height: 18px; }

/* ---------- forms ---------- */
label.f { display: block; }
label.f > span { display: block; font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.in { width: 100%; min-height: 50px; border: 1px solid #E3E6E8; background: #fff; border-radius: 14px; padding: 10px 14px; font-size: 16px; outline: none; -webkit-appearance: none; appearance: none; }
.in:focus { border-color: var(--green); }
textarea.in { min-height: 90px; resize: vertical; }
input[type=date].in, input[type=time].in { direction: ltr; text-align: right; }
.timechips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-start; }
.timechip { display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid #E3E6E8; border-radius: 14px; padding: 2px 6px 2px 12px; position: relative; }
.timechip input { border: 0; font-size: 18px; font-weight: 700; background: transparent; direction: ltr; width: 96px; min-height: 44px; -webkit-appearance: none; text-align: center; padding: 0; }
.timechip svg { width: 20px; height: 20px; flex: none; }
.timechip .x { position: absolute; top: -8px; left: -8px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--red); color: #fff; font-size: 12px; line-height: 1; padding: 0; }
.switchrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; }
.switchrow .bold { font-size: 16px; }
.sw { appearance: none; -webkit-appearance: none; width: 52px; height: 32px; margin: 0; border: 0; border-radius: 16px; background: #D5D9DD; position: relative; flex: none; transition: background .2s; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: left .2s; }
.sw:checked { background: var(--green); }
.sw:checked::after { left: 23px; }
.photos { display: flex; gap: 12px; justify-content: center; align-items: stretch; }
.photo { flex: 1; height: 210px; border-radius: 18px; background: #F1F3F2; display: grid; place-items: center; overflow: hidden; position: relative; }
.photo img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.photo svg { width: 48px; height: 48px; }
.photo .x { position: absolute; top: 8px; left: 8px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 14px; padding: 0; }
.cambtn { width: 88px; height: 210px; border-radius: 18px; background: var(--green-soft); display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; cursor: pointer; color: var(--green); font-weight: 700; font-size: 13px; text-align: center; }
.cambtn svg { width: 34px; height: 34px; }
.thumb img[data-zoom] { cursor: zoom-in; }
.viewer { position: fixed; inset: 0; z-index: 2500; background: #000; display: flex; flex-direction: column; }
.vbar { position: absolute; top: 0; left: 0; right: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; color: #fff; font-size: 15px; }
.vbtn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255,255,255,.18); color: #fff; font-size: 18px; padding: 0; }
.vstage { flex: 1; display: grid; place-items: center; overflow: hidden; touch-action: none; }
.vstage img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; user-select: none; -webkit-user-drag: none; }
details.more { background: #fff; border: 1px solid #E3E6E8; border-radius: 14px; padding: 0 14px; }
details.more summary { padding: 13px 0; font-weight: 700; color: var(--muted); list-style: none; cursor: pointer; }
details.more summary::-webkit-details-marker { display: none; }
details.more[open] { padding-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 0; background: var(--purple-soft); color: var(--purple); border-radius: 12px; padding: 5px 10px; font-size: 13px; }
.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cats button { display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid #E3E6E8; background: #fff; border-radius: 14px; padding: 10px 6px; font-weight: 700; font-size: 14px; }
.cats button svg { width: 22px; height: 22px; }
.cats button.on { border: 2px solid var(--green); background: var(--green-soft); color: var(--green); }
.files { display: flex; flex-wrap: wrap; gap: 8px; }
.file { width: 100px; height: 100px; border-radius: 12px; background: var(--blue-soft); position: relative; overflow: hidden; display: grid; place-items: center; color: var(--red); font-weight: 700; font-size: 12px; }
.file img { width: 100%; height: 100%; object-fit: cover; }
.file svg { width: 40px; height: 40px; }
.file .del { position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--red); color: #fff; font-size: 14px; line-height: 1; }

/* tests */
.ttile { border-radius: 18px; padding: 18px 8px 14px; text-align: center; cursor: pointer; }
.ttile svg { width: 46px; height: 46px; }
.ttile .t { font-size: 17px; font-weight: 800; margin-top: 4px; line-height: 1.3; }
.ttile .h { font-size: 13px; color: var(--text); }
.fileico { width: 40px; height: 40px; flex: none; display: grid; place-items: center; }
.fileico svg { width: 30px; height: 30px; }

/* doctors / visits */
.callsq { width: 46px; height: 46px; border-radius: 14px; background: var(--green); display: grid; place-items: center; flex: none; border: 0; }
.callsq svg { width: 22px; height: 22px; }
.callsq.map { background: var(--blue); }
.vline { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.vline svg { width: 24px; height: 24px; flex: none; }

/* settings */
.srow { display: flex; align-items: center; gap: 14px; padding: 16px 14px; background: #fff; border-radius: 16px; box-shadow: 0 2px 14px rgba(20,40,30,.06); cursor: pointer; }
.srow + .srow { margin-top: 12px; }
.srow .sico { width: 30px; height: 30px; flex: none; color: var(--green); }
.srow .sico svg { width: 30px; height: 30px; }
.srow .st { font-weight: 800; font-size: 17px; }
.srow .ss { font-size: 13px; color: var(--muted); }

/* ---------- tabs ---------- */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding: 6px 6px env(safe-area-inset-bottom); background: #fff; display: flex; box-shadow: 0 -2px 14px rgba(0,0,0,.06); z-index: 10; }
#tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: #2A3340; text-decoration: none; font-size: 12px; border-radius: 16px; margin: 0 2px; }
#tabs a svg { width: 26px; height: 26px; }
#tabs a.on { color: var(--green); font-weight: 800; background: var(--green-soft); }

/* ---------- login / dose ---------- */
.center { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; align-items: stretch; gap: 14px; text-align: center; }
.pin { font-size: 28px; letter-spacing: 10px; text-align: center; direction: ltr; }
.dosebig .pic { width: 220px; height: 220px; margin: 0 auto; border-radius: 28px; }
.dosebig .pic svg { width: 64px; height: 64px; }
.dosebig h1 { font-size: 26px; margin: 12px 0 2px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + 90px + env(safe-area-inset-bottom)); background: rgba(28,36,48,.92); color: #fff; padding: 10px 18px; border-radius: 20px; z-index: 3000; font-size: 14px; max-width: 90vw; text-align: center; }
.warn { background: var(--red-soft); }
.warn .t { color: var(--red); font-weight: 800; }
.info { background: var(--blue-soft); }

/* ---------- location / maps ---------- */
.minimap { height: 170px; border-radius: 16px; overflow: hidden; direction: ltr; background: var(--blue-soft); position: relative; z-index: 0; }
.mapov { position: fixed; inset: 0; z-index: 2000; background: #fff; display: flex; flex-direction: column; }
.mapbar { display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; font-size: 17px; }
.mapbar .tbbtn { background: #F1F3F2; border-radius: 50%; }
.mpwrap { flex: 1; position: relative; }
#mpMap { position: absolute; inset: 0; direction: ltr; z-index: 0; }
/* the pin's tip (bottom centre of the icon) sits exactly on the map centre, which is what gets saved */
.mppin { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; transform: translate(-50%, -89.6%); z-index: 1000; pointer-events: none; filter: drop-shadow(0 3px 4px rgba(0,0,0,.35)); }
.mppin svg { width: 46px; height: 46px; }
.mpbtns { padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px); display: grid; gap: 8px; }
.sheetov { position: fixed; inset: 0; z-index: 2100; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; }
.sheet { background: #fff; width: 100%; border-radius: 22px 22px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 16px); display: grid; gap: 10px; }

.lcard { margin-top: 14px; background: #0F1D16; border-radius: 26px; padding: 8px 6px 0; overflow: hidden; }
/* line chart (weight history) */
.lchart { width: 100%; height: 140px; display: block; }
.lgrid { stroke: rgba(255,255,255,.12); stroke-width: 1; }
.llab { fill: rgba(255,255,255,.55); font-size: 11px; font-weight: 700; }
.lnow { fill: #fff; font-size: 12px; font-weight: 800; }
.lgoal { stroke: rgba(255,255,255,.75); stroke-width: 1.6; stroke-dasharray: 1.5 4; stroke-linecap: round; }
.lline { stroke: #3BE38B; stroke-width: 3.5; }
.larea { fill: url(#none); fill: rgba(59,227,139,.12); }
.ldot { fill: #fff; }
.ldotnow { fill: #fff; stroke: #3BE38B; stroke-width: 0; filter: drop-shadow(0 0 0 #fff); }
.lcard.light { background: #F4F7F6; }
.lchart.light .lgrid { stroke: #E3E8E6; }
.lchart.light .llab { fill: var(--muted); }
.lchart.light .lnow { fill: var(--text); }
.lchart.light .lline { stroke: var(--green); }
.lchart.light .larea { fill: rgba(19,149,91,.1); }
.lchart.light .ldot, .lchart.light .ldotnow { fill: var(--green); }
/* profile */
.pavatar { width: 92px; height: 92px; border-radius: 50%; background: var(--green-soft); display: grid; place-items: center; font-size: 54px; margin: 4px auto 0; }
.bmibar { position: relative; height: 10px; border-radius: 6px; margin-top: 10px; background: linear-gradient(270deg, #2F6FE4 0 17%, #13955B 17% 50%, #EE7D1A 50% 75%, #E0352B 75%); }
.bmibar i { position: absolute; top: -5px; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 3px solid var(--text); transform: translateX(50%); }
.bmilab { display: grid; grid-template-columns: 17% 33% 25% 25%; font-size: 11px; color: var(--muted); margin-top: 4px; text-align: center; }
.xbtn { border: 0; background: #F1F3F2; border-radius: 50%; width: 28px; height: 28px; padding: 0; color: var(--muted); }

.kgbox { margin-top: 10px; border-radius: 14px; padding: 10px 12px; font-size: 16px; text-align: center; }
.kgbox b { font-size: 20px; }

/* own photo */
.meimg { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.roundbtn, .sround { overflow: hidden; }
.pphoto { position: relative; width: 112px; margin: 4px auto 0; }
.pphoto .pavatar { width: 112px; height: 112px; overflow: hidden; margin: 0; }
.pphoto .pavatar img { width: 100%; height: 100%; object-fit: cover; }
.pcam { position: absolute; bottom: 2px; left: 2px; width: 38px; height: 38px; border-radius: 50%; background: var(--green); border: 3px solid #fff; display: grid; place-items: center; cursor: pointer; }
.pcam svg { width: 20px; height: 20px; }
/* medicines tab in the middle, bigger */
#tabs a.mid { flex: 1.15; justify-content: flex-end; position: relative; color: #2563EB; font-weight: 800; }
#tabs a.mid i { position: absolute; top: -26px; width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(145deg, #4F8DF7, #1D4FD8); display: grid; place-items: center; box-shadow: 0 6px 16px rgba(29,79,216,.35), 0 0 0 5px #fff; }
#tabs a.mid i svg { width: 32px; height: 32px; }
#tabs a.mid.on { background: transparent; }
#tabs a.mid.on i { background: linear-gradient(145deg, #6AA2FF, #2563EB); box-shadow: 0 6px 18px rgba(37,99,235,.5), 0 0 0 5px #fff; }
body:not(.no-tabs) .dock { padding-bottom: 30px; }
/* blood pressure */
.bpcard { display: flex; align-items: center; gap: 12px; }
.bpico { flex: none; width: 56px; height: 56px; border-radius: 16px; background: #FDECEC; display: grid; place-items: center; }
.bpico svg { width: 32px; height: 32px; }
.bpline { display: flex; align-items: baseline; gap: 10px; }
.bpline b { font-size: 24px; font-weight: 800; }
.bpline span { color: var(--muted); font-weight: 700; }
.bpcard .chev { width: 20px; height: 20px; flex: none; }
.bpnums { display: flex; justify-content: space-around; align-items: end; margin: 10px 0 6px; text-align: center; }
.bpnums div { display: grid; }
.bpnums b { font-size: 46px; font-weight: 800; line-height: 1.1; }
.bpnums b i { font-style: normal; color: var(--muted); font-weight: 400; margin: 0 2px; }
.bpnums span { font-size: 13px; color: var(--muted); }
.bpdot { flex: none; width: 12px; height: 12px; border-radius: 50%; }
.bpin { font-size: 26px; font-weight: 800; text-align: center; direction: ltr; }
.bpchart { height: 170px; }
.bpref { stroke: #C9D2CE; stroke-width: 1.2; stroke-dasharray: 4 4; }
.bpreft { fill: var(--muted); font-size: 10px; }
.bpline { white-space: nowrap; }