:root {
  --pri: #1d7fe0;
  --pri-d: #155fb0;
  --bg: #f0f7ff;
  --card: #fff;
  --text: #0c2a4a;
  --muted: #5b7290;
  --line: #dbe8f7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --yel: #78350f;
  --yel-bg: #fef3c7;
  --yel-b: #f59e0b;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --r: 20px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}
#app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 14px calc(env(safe-area-inset-bottom) + 150px);
}
h1 { font-size: 1.5rem; margin: 0; line-height: 1.3; }
h2 { font-size: 1.1rem; margin: 1.4em 0 .4em; }
.mt0 { margin-top: 0; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); font-size: .92rem; }
.red { color: var(--red); font-weight: 600; }
.center { text-align: center; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.count { background: var(--line); border-radius: 99px; padding: 0 10px; font-size: .85rem; vertical-align: middle; }

/* cards */
.card {
  display: block;
  background: var(--card);
  border-radius: var(--r);
  padding: 14px 16px;
  margin: 10px 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .07);
}
a.card:active { transform: scale(.99); }
.pre { white-space: pre-wrap; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 1.05rem; }
.empty.small { padding: 16px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 12px 18px; min-height: 50px;
  font: inherit; font-weight: 600; background: var(--pri); color: #fff; cursor: pointer;
}
.btn:active { background: var(--pri-d); }
.btn.secondary { background: #e7ebef; color: var(--text); }
.btn.danger { background: var(--red-bg); color: var(--red); }
.btn.block { width: 100%; margin-top: 10px; }
.link { background: none; border: 0; color: var(--pri); font: inherit; font-weight: 600; cursor: pointer; padding: 4px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.row > .narrow { flex: 0 0 90px; }
.actions .btn { min-height: 58px; font-size: 1.05rem; }

/* page header */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 12px; }
.page-head input[type=date] { width: auto; max-width: 160px; }
.daynav { display: flex; gap: 8px; margin-bottom: 6px; }
.daynav .btn { flex: 1; min-height: 44px; padding: 8px; font-size: .9rem; }

/* warnings & notes */
.warn { background: var(--red-bg); color: var(--red); border-inline-start: 6px solid var(--red); }
.warn ul { margin: 6px 0 0; padding-inline-start: 20px; }
.warn-inline { color: var(--red); font-weight: 600; font-size: .95rem; margin-top: 4px; }
.next-note { background: var(--yel-bg); color: var(--yel); border-inline-start: 6px solid var(--yel-b); border-radius: 10px; padding: 8px 12px; margin-top: 8px; }
.next-note.big { font-size: 1.05rem; padding: 14px 16px; }
.nn-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.owe-box { background: #fff7ed; color: #9a3412; }
.banner { background: #e0f2fe; color: #075985; font-weight: 600; }
.call { color: var(--pri); font-weight: 600; font-size: 1.1rem; }

/* today */
.appt-head { display: flex; align-items: center; gap: 12px; }
.appt .time { font-weight: 700; color: var(--pri); direction: ltr; min-width: 52px; }
.appt .name { font-weight: 700; font-size: 1.1rem; flex: 1; }
.appt.done { opacity: .65; }
.badge { border-radius: 99px; padding: 2px 10px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.owe { background: #ffedd5; color: #9a3412; direction: ltr; }
.fab {
  position: fixed; left: 16px; bottom: calc(env(safe-area-inset-bottom) + 82px);
  background: var(--pri); color: #fff; font-weight: 700; font-size: 1.05rem;
  padding: 14px 22px; border-radius: 99px; box-shadow: 0 6px 18px rgba(29, 127, 224, .35);
}

/* patients */
.search { margin-bottom: 4px; }
.prow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.prow .name { font-weight: 600; }
.prow[hidden] { display: none; }
.dot-red { display: inline-block; width: 10px; height: 10px; background: var(--red); border-radius: 50%; margin-inline-end: 8px; vertical-align: middle; }
.urow { display: flex; justify-content: space-between; align-items: center; }
.x { background: none; border: 0; font-size: 1.2rem; color: var(--muted); padding: 8px 12px; cursor: pointer; }
.v-head { display: flex; justify-content: space-between; gap: 8px; }
.tooth { color: var(--pri); font-weight: 600; direction: ltr; }
.v-done { margin: 4px 0; }

/* forms */
.form label { display: block; margin: 12px 0; font-weight: 600; font-size: .95rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px;
  font: inherit; font-size: 17px; font-weight: 400; color: var(--text);
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pri); }
textarea { resize: vertical; }
fieldset { border: 1.5px solid var(--line); border-radius: var(--r); padding: 6px 14px 4px; margin: 14px 0; background: #fff; }
legend { font-weight: 700; padding: 0 6px; }
.warn-box { border-color: #fca5a5; }
.warn-box legend { color: var(--red); }
.form label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 8px 0; }
.check input { width: 24px; height: 24px; margin: 0; accent-color: var(--red); }
.hl { background: var(--yel-bg); padding: 10px 12px; border-radius: 12px; color: var(--yel); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; direction: ltr; }
.chip { border: 1.5px solid var(--pri); color: var(--pri); background: #fff; border-radius: 99px; padding: 6px 14px; font: inherit; font-size: .9rem; cursor: pointer; }
.chip:active { background: var(--pri); color: #fff; }
.file-btn { cursor: pointer; }

/* lock screen */
.lock { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 6vh; }
.lock .form { width: 100%; }
.lock-logo { font-size: 3.2rem; }
.dots { display: flex; gap: 16px; margin: 18px 0 26px; direction: ltr; }
.dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--pri); }
.dots span.on { background: var(--pri); }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px 26px; direction: ltr; }
.keypad button {
  width: 76px; height: 76px; border-radius: 50%; border: 0; background: #fff;
  font-size: 1.8rem; font-weight: 500; color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .1); cursor: pointer;
}
.keypad button:active { background: var(--line); }
#lock-extra { margin-top: 22px; }
.hint { color: var(--yel); background: var(--yel-bg); border-radius: 10px; padding: 0 12px; }
.hint:not(:empty) { padding: 8px 12px; }

/* tab bar */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
#tabbar[hidden] { display: none; }
#tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px 0 6px; font-size: .8rem; color: var(--muted); }
#tabbar a span { font-size: 1.4rem; filter: grayscale(1); opacity: .6; }
#tabbar a.active { color: var(--pri); font-weight: 700; }
#tabbar a.active span { filter: none; opacity: 1; }

.toast {
  position: fixed; top: calc(env(safe-area-inset-top) + 14px); left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 99px; z-index: 9; font-weight: 600;
  animation: fade 2.2s forwards;
}
@keyframes fade { 0% { opacity: 0; } 10%, 85% { opacity: 1; } 100% { opacity: 0; } }

/* compact date picker on the Today page */
.pick { position: relative; flex: 0 0 64px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; background: #e7ebef; border-radius: 12px; cursor: pointer; }
.pick input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.toast { white-space: nowrap; max-width: 92vw; }

/* ---------------- stage 2 ---------------- */
h3 { font-size: 1rem; margin: 1em 0 .4em; }
.small { font-size: .85rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: .9rem; }
.actions { gap: 8px; }
.actions .btn { padding: 10px 8px; font-size: 1rem; }
.with-btn { display: flex; gap: 6px; align-items: stretch; margin-top: 6px; }
.with-btn input { margin-top: 0; }
.with-btn .btn { min-height: 0; padding: 0 12px; font-size: 1.2rem; flex: 0 0 auto; }
.ltr-input { direction: ltr; text-align: right; }
#tabbar a { position: relative; font-size: .72rem; }
.tab-badge { position: absolute; top: 4px; left: calc(50% + 6px); background: var(--red); color: #fff; border-radius: 99px; font-size: .7rem; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; }
.tab-badge[hidden] { display: none; }

/* tooth chart */
.chart { direction: ltr; display: grid; gap: 10px; }
.jaw { display: grid; grid-template-columns: 1fr; gap: 6px; }
.jaw.lower { border-top: 2px dashed var(--line); padding-top: 10px; }
@media (min-width: 560px) { .jaw { grid-template-columns: 1fr 1fr; } }
.quad-label { direction: rtl; font-size: .78rem; color: var(--muted); margin-bottom: 2px; }
.quad-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.tooth-cell {
  position: relative; aspect-ratio: 1 / 1.15; min-height: 38px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff; font: inherit; font-size: .9rem; font-weight: 600; color: var(--text); cursor: pointer; padding: 0;
}
.tooth-cell[style] { background: color-mix(in srgb, var(--c) 18%, white); border-color: var(--c); color: color-mix(in srgb, var(--c) 75%, black); }
.tooth-cell.st-missing { text-decoration: line-through; border-style: dashed; }
.tooth-cell.st-todo { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px rgba(220, 38, 38, .25); } }
.tooth-cell.sel { outline: 3px solid var(--pri); outline-offset: 1px; background: #dbeafe; }
.has-note { position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--text); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: .85rem; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 5px; vertical-align: middle; }

/* bottom sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 16px); animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
body.no-scroll { overflow: hidden; }
.status-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.status-pick button { border: 2px solid var(--c, var(--line)); background: #fff; border-radius: 99px; padding: 8px 14px; font: inherit; font-size: .9rem; cursor: pointer; }
.status-pick button.on { background: var(--c, var(--text)); color: #fff; }
.form-l { display: block; margin: 14px 0; font-weight: 600; font-size: .95rem; }
.hist { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.sheet-actions { margin-top: 16px; }

/* labs */
.lab.late { border-inline-start: 6px solid var(--red); }
.lab.received { border-inline-start: 6px solid var(--ok); }
.lab .lab-name { display: block; font-weight: 600; color: var(--pri); margin: 2px 0; }
.lab-foot { margin-top: 8px; }
.badge.late { background: var(--red-bg); color: var(--red); }
.badge.warnb { background: #ffedd5; color: #9a3412; }
.badge.muted { background: var(--line); }
.lab-inline { font-size: .92rem; font-weight: 600; margin-top: 6px; }
.lab-inline.sent { color: #c2410c; }
.lab-inline.received { color: var(--ok); }
.lab-alert { background: #fff7ed; color: #7c2d12; border-inline-start: 6px solid #ea580c; }
.lab-alert div { margin-top: 4px; }
.lab-alert .red { color: var(--red); font-weight: 700; }
.done-list summary { cursor: pointer; color: var(--muted); padding: 12px 0; }

/* money */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: #fff; border-radius: var(--r); padding: 12px 10px; box-shadow: 0 1px 3px rgba(0, 0, 0, .07); }
.stat b { display: block; font-size: 1.15rem; direction: ltr; text-align: right; margin-top: 4px; }
.stat .muted { font-size: .78rem; }
.stat.owe b { color: #9a3412; }
.visit.pay { background: #f0fdf4; }
.btn.small { white-space: nowrap; flex: 0 0 auto; }

/* ---------------- stage 3: photos ---------------- */
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.thumb { position: relative; padding: 0; border: 0; border-radius: 10px; overflow: hidden; aspect-ratio: 1; background: #111; cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .kind {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 2px 6px; font-size: .7rem; font-weight: 600;
  color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); text-align: start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.preview-strip { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; }
.preview-strip img { height: 90px; border-radius: 10px; flex: 0 0 auto; }
#kinds { margin-bottom: 4px; }
#kinds button.on, .status-pick button.on:not([style]) { background: var(--pri); border-color: var(--pri); color: #fff; }

.viewer { position: fixed; inset: 0; z-index: 30; background: #000; color: #fff; display: flex; flex-direction: column; touch-action: manipulation; }
.v-top, .v-bottom { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; }
.v-top { padding-top: calc(env(safe-area-inset-top) + 10px); }
.v-bottom { padding-bottom: calc(env(safe-area-inset-bottom) + 10px); }
.v-btn { background: rgba(255, 255, 255, .14); color: #fff; border: 0; border-radius: 99px; min-width: 48px; height: 48px; font-size: 1.3rem; cursor: pointer; }
.v-btn:disabled { opacity: .25; }
.v-stage { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; }
.v-stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-select: none; }
.v-stage img.zoomed { max-width: none; max-height: none; width: 250%; }
.v-info { padding: 6px 16px; font-size: .92rem; color: #e5e7eb; }
.v-stage.zoom { display: block; }
[hidden] { display: none !important; }
#vcount { direction: ltr; unicode-bidi: isolate; }

/* tooth chart: mouth seen from above, glass look (style 20) */
.chart.chart-3d { display: block; direction: ltr; }
.chart-3d svg { width: 100%; height: auto; display: block; touch-action: manipulation; }
.chart-3d .tooth-g { cursor: pointer; }
.chart-3d .tooth-g:active { opacity: .7; }
.chart-3d .tnum { font: 600 11px "IBM Plex Sans Arabic", system-ui, sans-serif; fill: #0369a1; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.chart-3d .tnum.on { fill: #1d7fe0; font-size: 14px; }
.chart-3d .tjaw { font: 600 12px "IBM Plex Sans Arabic", system-ui, sans-serif; fill: #7dd3fc; text-anchor: middle; direction: rtl; }
.chart-3d .todo-ring { fill: none; stroke: #dc2626; stroke-width: 2; pointer-events: none; animation: ring-pulse 1.4s ease-in-out infinite; }
@keyframes ring-pulse { 50% { stroke-opacity: .15; } }
.legend i { border-radius: 50%; }

/* in-app dialogs (instead of prompt / confirm / alert) */
.sheet-bg.dialog-bg { z-index: 40; align-items: center; padding: 16px; }
.dialog-bg .sheet { border-radius: 18px; max-width: 420px; padding-bottom: 16px; }
.dlg-text { font-weight: 600; font-size: 1.05rem; margin: 4px 0 12px; white-space: pre-wrap; }
#dlgIn { margin-top: 0; }
.btn.danger-solid { background: var(--red); color: #fff; }

/* patient credit (پێشەکی) */
.credit-box { background: #f0fdf4; color: #166534; }
.credit-box .muted { color: #15803d; margin-top: 4px; }
.badge.credit { background: #dcfce7; color: #166534; direction: ltr; }
.credit-hint { background: #f0fdf4; color: #166534; border-radius: 10px; padding: 8px 12px; font-size: .9rem; margin-top: 12px; }

/* paid / debt / part paid + "how much is left" box */
.money-box { border-color: #fcd34d; }
.money-box legend { color: #92400e; }
.pay-mode { display: flex; gap: 6px; margin: 4px 0 10px; }
.pay-mode button { flex: 1; border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 4px; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; }
.pay-mode button.on[data-mode=full] { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.pay-mode button.on[data-mode=debt] { border-color: #ea580c; background: #ffedd5; color: #9a3412; }
.pay-mode button.on[data-mode=part] { border-color: var(--pri); background: #dbeafe; color: var(--pri-d); }
.pay-err { color: var(--red); font-weight: 600; margin: 0 0 8px; }
.calc { margin: 6px 0 10px; }
.calc:empty { display: none; }
.calc-row { display: flex; justify-content: space-between; padding: 4px 2px; font-size: .95rem; border-bottom: 1px dashed var(--line); }
.calc-row b { direction: ltr; }
.calc-row.paid b { color: var(--ok); }
.calc-row.debt b { color: #c2410c; }
.calc-total { margin-top: 8px; padding: 12px; border-radius: 12px; font-size: 1.05rem; font-weight: 600; }
.calc-total b { font-size: 1.2rem; }
.calc-total.debt { background: #ffedd5; color: #9a3412; }
.calc-total.ok { background: var(--ok-bg); color: var(--ok); }

/* old debt */
.visit.old-debt { background: #fff7ed; }
.money-actions { margin-top: 10px; }
.money-actions .btn { padding: 10px 6px; }

/* =====================================================================
   Style 13 · dental blue (chosen design)
   ===================================================================== */
html { background: var(--bg); }
body { background: transparent; position: relative; min-height: 100vh; }
/* blue header band: its height is measured in app.js (--band) so it always ends under the page header */
body::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: var(--band, 0px); z-index: -1;
  background: radial-gradient(circle at 85% 20%, #7cc4ff 0, #1d7fe0 55%, #155fb0 100%);
  border-radius: 0 0 30px 30px;
}
body.tall-band::after { content: "🦷"; position: absolute; top: calc(var(--band) - 150px); left: 22px; font-size: 64px; opacity: .22; pointer-events: none; z-index: -1; }
body.has-band .page-head h1, body.has-band .page-head .muted { color: #fff; }
body.has-band .page-head .muted { color: rgba(255, 255, 255, .85); }
body.has-band .page-head .btn.secondary, body.has-band .daynav .btn.secondary, body.has-band .pick { background: rgba(255, 255, 255, .22); color: #fff; }
body.has-band .page-head .btn:not(.secondary) { background: #fff; color: var(--pri); }
body.has-band .page-head .count { background: rgba(255, 255, 255, .25); color: #fff; }

/* lock screen: full blue */
body.locked { --band: 100vh; }
body.locked::before { border-radius: 0; min-height: 100vh; }
body.locked .lock h1 { color: #fff; }
body.locked .lock .muted, body.locked .lock .link { color: rgba(255, 255, 255, .9); }
body.locked .dots span { border-color: #fff; }
body.locked .dots span.on { background: #fff; }
body.locked .keypad button { background: rgba(255, 255, 255, .95); color: #0c2a4a; box-shadow: 0 4px 14px rgba(0, 0, 0, .12); }
body.locked .lock-logo { filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .2)); }

/* cards and buttons */
.card { box-shadow: 0 6px 18px rgba(29, 127, 224, .10); }
.btn { border-radius: 14px; }
.btn.secondary { background: #e6f0fb; color: #0c4a8a; }
.count { background: #e6f0fb; color: #0c4a8a; }
.banner { background: #fff; color: var(--pri); }
.ic { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; flex: 0 0 auto; }

/* "next time" note: blue, dashed */
.next-note { background: #e8f3ff; color: #0c4a8a; border: 1px dashed #93c5fd; border-inline-start: 1px dashed #93c5fd; }
.hl { background: #e8f3ff; color: #0c4a8a; border: 1px dashed #93c5fd; }
.warn { border-inline-start-width: 4px; }
.warn-inline { color: #e03131; display: flex; align-items: center; gap: 6px; }
.appt .time { color: var(--pri); }
.appt .appt-head { flex-wrap: wrap; row-gap: 4px; }
.badge.ok { background: #e0f7ef; color: #0f8a5f; display: inline-flex; align-items: center; gap: 4px; }
.appt.done { opacity: 1; }
.appt.done > * { opacity: .78; }
.lab-inline { display: flex; align-items: center; gap: 6px; }
.lab-inline.sent { color: #e8590c; }
.lab-inline.received { color: #0f8a5f; }
.appt .next-note { display: flex; gap: 6px; align-items: flex-start; }

/* floating button */
.fab { background: var(--pri); box-shadow: 0 8px 20px rgba(29, 127, 224, .35); display: inline-flex; align-items: center; gap: 6px; }

/* tab bar with line icons */
#tabbar { background: #fff; border-top: 1px solid var(--line); }
#tabbar a { gap: 3px; font-weight: 600; }
#tabbar a .ic { width: 23px; height: 23px; }
#tabbar a.active { color: var(--pri); }
#tabbar a span { display: none; }
.tab-badge { top: 3px; }
.money-box { border-color: #bfdbfe; }
.money-box legend { color: #1d4ed8; }

/* patient list (style 13) */
.search-box { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 0 14px; color: #8aa0ba; margin: 4px 0 12px; }
.search-box input { border: 0; margin: 0; padding: 12px 0; background: transparent; }
.search-box input:focus { outline: none; }
.search-box:focus-within { border-color: var(--pri); }
.pcard { padding: 12px 14px; }
.pcard[hidden] { display: none; }
.pc-head { display: flex; align-items: center; gap: 10px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.pc-main { flex: 1; min-width: 0; }
.pc-main .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-main .muted { font-size: .85rem; }
.pc-warn { color: #e03131; display: flex; }
.pc-next { margin-top: 10px; padding: 8px 12px; border-radius: 12px; font-size: .9rem; font-weight: 600; background: #e8f3ff; color: #155fb0; border: 1px dashed #93c5fd; display: flex; align-items: center; gap: 6px; }
.pc-next.none { background: #f4f7fb; color: #8aa0ba; border-color: transparent; }
.empty .ic { width: 40px; height: 40px; }

/* no browser focus ring on the tab bar after a tap */
#tabbar a:focus:not(:focus-visible) { outline: none; }
#tabbar a { -webkit-tap-highlight-color: transparent; }

/* money page (style 13) */
.money-head .mh { width: 100%; color: #fff; }
.mh-label { margin-top: 10px; opacity: .85; font-size: .92rem; }
.mh-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mh-total { font-size: 2.3rem; font-weight: 700; line-height: 1.2; }
.mh-pct { display: inline-flex; align-items: center; gap: 4px; background: #fff; color: #0f8a5f; border-radius: 99px; padding: 3px 12px; font-weight: 700; font-size: .9rem; }
.mh-pct.down { color: #c92a2a; }
.mh-sub { font-size: .82rem; opacity: .9; }
.m-chart { width: 100%; height: 76px; margin-top: 8px; direction: ltr; display: block; }
.m-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.m-tile { margin: 0; }
.m-tile b { display: block; font-size: 1.35rem; text-align: right; margin-top: 2px; }
.owe-txt { color: #c2410c; }
.credit-txt { color: #0f8a5f; }
.mrow { justify-content: flex-start; gap: 10px; }
.mrow > b { flex: 0 0 auto; }

/* money page (style 4: wallet card) */
.plain-head { margin: 8px 2px 12px; }
.plain-head h1 { font-size: 1.7rem; }
.wallet {
  position: relative; overflow: hidden; color: #fff; border-radius: 24px; padding: 20px 18px 16px;
  background: linear-gradient(135deg, #155fb0, #1d7fe0 50%, #7cc4ff);
  box-shadow: 0 12px 28px rgba(29, 127, 224, .35);
}
.wallet::before { content: ""; position: absolute; left: -36px; top: -36px; width: 140px; height: 140px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.wallet::after { content: ""; position: absolute; left: 40px; bottom: -60px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.w-label { opacity: .88; font-size: .92rem; position: relative; }
.w-total { display: block; font-size: 2.3rem; font-weight: 700; text-align: right; margin: 4px 0 14px; position: relative; }
.w-row { display: flex; justify-content: space-between; font-size: .92rem; position: relative; }
.tx-list { padding: 4px 0; }
.tx { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.tx + .tx { border-top: 1px solid #eef3fa; }
.tx-ic { width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.tx-ic.in { background: #e0f7ef; color: #0f8a5f; }
.tx-ic.debt { background: #ffedd5; color: #c2410c; }
.tx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tx-main .muted { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.in-txt { color: #0f8a5f; }

/* weekly backup reminder */
.banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.banner a { display: flex; align-items: center; gap: 6px; flex: 1; }
.banner-later { flex: 0 0 auto; border: 0; background: #e6f0fb; color: #155fb0; font: inherit; font-size: .85rem; font-weight: 700; border-radius: 10px; padding: 6px 12px; cursor: pointer; }

/* patient form (style 1: grouped cards) */
.pform .fsec { padding: 14px 14px 4px; margin: 0 0 12px; }
.fsec-title { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.fsec-title.red { color: #c92a2a; }
.opt { font-weight: 400; font-size: .8rem; color: var(--muted); }
.pform label { margin: 10px 0; }
.pform label.mt0 { margin-top: 0; }
.with-ic { display: flex; align-items: center; gap: 8px; margin-top: 6px; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 12px; color: #7d93ad; }
.with-ic:focus-within { border-color: var(--pri); }
.with-ic input { border: 0; margin: 0; padding: 12px 0; background: transparent; }
.with-ic input:focus { outline: none; }
.warn-sec { border: 1.5px solid #fecaca; }
.wchips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.wchip { display: inline-flex !important; align-items: center; gap: 6px; margin: 0 !important; padding: 8px 13px; border-radius: 99px; border: 1.5px solid var(--line); background: #fff; font-weight: 600 !important; font-size: .9rem !important; color: #334e6b; cursor: pointer; user-select: none; }
.wchip input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.wchip .i-on { display: none; }
.wchip:has(input:checked) { background: #fee2e2; border-color: #f87171; color: #b91c1c; }
.wchip:has(input:checked) .i-on { display: inline-flex; }
.wchip:has(input:checked) .i-off { display: none; }
.wchip:has(input:focus-visible) { outline: 2px solid var(--pri); outline-offset: 2px; }
.save-bar { position: sticky; bottom: calc(env(safe-area-inset-bottom) + 72px); display: flex; gap: 8px; padding: 10px 0 4px; background: linear-gradient(transparent, var(--bg) 35%); z-index: 2; }
.save-bar .btn { flex: 1; }
.save-bar .btn.secondary { flex: 0 0 34%; }

/* doctor's name on the Today header */
.head-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.dr-name {
  font-family: "Dancing Script", cursive; font-weight: 700; font-size: clamp(1.15rem, 5.6vw, 1.7rem); line-height: 1.1;
  direction: ltr; text-align: left; color: #fff; text-shadow: 0 2px 8px rgba(0, 0, 0, .18); white-space: nowrap;
}
body:not(.has-band) .dr-name { color: var(--pri); text-shadow: none; }
body.tall-band::after { content: none; }
.page-head .muted { white-space: nowrap; }

/* ================= login (username + password) ================= */
.auth { min-height: calc(100vh - 24px); display: flex; flex-direction: column; margin: calc(-1 * (env(safe-area-inset-top) + 12px)) -14px 0; }
.auth-top { display: flex; flex-direction: column; align-items: center; color: #fff; padding: calc(env(safe-area-inset-top) + 44px) 20px 34px; text-align: center; }
.auth-logo { width: 78px; height: 78px; border-radius: 26px; background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .35); display: flex; align-items: center; justify-content: center; color: #fff; box-shadow: 0 10px 26px rgba(0, 0, 0, .15); }
.auth-logo svg { width: 46px; height: 46px; }
.auth-dr { color: #fff !important; font-size: 2.1rem !important; margin-top: 12px; }
.auth-sub { opacity: .85; font-size: .9rem; margin-top: 2px; }
.auth-sheet { flex: 1; background: #fff; border-radius: 32px 32px 0 0; padding: 26px 22px calc(env(safe-area-inset-bottom) + 30px); box-shadow: 0 -10px 30px rgba(12, 42, 74, .12); }
.auth-sheet h1 { color: var(--text) !important; font-size: 1.5rem; }
.auth-sheet > .muted { margin: 4px 0 18px; }
.auth-field { display: flex; align-items: center; gap: 10px; background: #f4f8fd; border: 1.5px solid var(--line); border-radius: 16px; padding: 0 14px; margin: 0 0 12px; color: #7d93ad; transition: border-color .15s, box-shadow .15s; }
.auth-field:focus-within { border-color: var(--pri); box-shadow: 0 0 0 4px rgba(29, 127, 224, .14); background: #fff; color: var(--pri); }
.auth-field input { border: 0; margin: 0; padding: 15px 0; background: transparent; font-size: 1.02rem; }
.auth-field input:focus { outline: none; }
.auth-field input[dir=ltr]::placeholder { direction: rtl; text-align: right; }
.auth-field .ic { width: 20px; height: 20px; }
.eye { border: 0; background: none; color: #7d93ad; padding: 8px; margin: 0 -6px 0 -8px; cursor: pointer; display: flex; }
.auth-err { color: #c92a2a; background: #fff5f5; border: 1px solid #fecaca; border-radius: 12px; padding: 8px 12px; font-weight: 600; font-size: .92rem; margin: 2px 0 10px; }
.auth-btn { min-height: 54px; font-size: 1.08rem; margin-top: 6px; box-shadow: 0 8px 20px rgba(29, 127, 224, .3); }
.auth-btn:disabled { opacity: .7; }
.auth-forgot { display: block; margin: 14px auto 0; text-align: center; }
.auth-sheet.shake { animation: shake .4s; }
body.locked .auth-sheet .hint { color: var(--yel); }
body.locked #app { padding-bottom: 0; }
.auth { min-height: 100vh; min-height: 100dvh; }

/* danger zone */
.danger-zone { border: 1.5px solid #fecaca; background: #fffafa; }
.dialog-bg .auth-field { margin: 4px 0 10px; }
.dialog-bg .sheet h2.red { color: #c92a2a; display: flex; align-items: center; gap: 6px; }

/* maker credit */
.by { direction: ltr; text-align: center; font-size: .82rem; font-weight: 600; letter-spacing: .02em; color: #7d93ad; }
.by-auth { margin-top: 26px; }
.by-app { margin: 18px 0 6px; font-size: .9rem; color: var(--pri); }

/* language switch: Kurdish / English */
.lang-switch { display: flex; gap: 6px; background: #eef5fd; border-radius: 14px; padding: 4px; }
.lang-switch button { flex: 1; border: 0; background: transparent; border-radius: 10px; padding: 10px 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.lang-switch button[data-lang="en"] { direction: ltr; }
.lang-switch button.on { background: #fff; color: var(--pri); box-shadow: 0 2px 8px rgba(29, 127, 224, .18); }
.lang-switch.auth-lang { background: rgba(255, 255, 255, .18); margin-top: 16px; width: 210px; }
.lang-switch.auth-lang button { color: rgba(255, 255, 255, .85); padding: 7px 8px; font-size: .9rem; }
.lang-switch.auth-lang button.on { color: var(--pri); }

/* English is written left-to-right: mirror the places that were aligned for Kurdish */
html[dir="ltr"] .ltr-input,
html[dir="ltr"] .stat b,
html[dir="ltr"] .m-tile b,
html[dir="ltr"] .w-total { text-align: left; }
html[dir="ltr"] .auth-field input[dir=ltr]::placeholder { direction: ltr; text-align: left; }
html[dir="ltr"] .quad-label { direction: ltr; }
html[dir="ltr"] .fab { left: auto; right: 16px; }
html[dir="ltr"] body.tall-band::after { left: auto; right: 22px; }
html[dir="ltr"] .has-note { right: auto; left: 3px; }
