/* ==========================================================================
   Life Pulse Health Check — design system (mobile-first, RTL)
   Tokens → base → layout → components → analysis → staff UI → utilities
   ========================================================================== */

@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Palette taken from the pharmacy logo (blue gradient + grey wordmark). */
  --brand: #2A71B5;
  --brand-deep: #21588C;
  --brand-light: #3794EE;
  --brand-grad: linear-gradient(135deg, #21588C 0%, #2A71B5 55%, #3794EE 100%);
  --ink: #1C2B3A;
  --muted: #5F6B77;
  --wordmark: #686868;
  --surface: #F3F7FB;
  --paper: #FFFFFF;
  --line: #D8E3EE;
  --ok: #1E8A5A;
  --watch: #C08A1E;
  --high: #D2601A;
  --urgent: #C0262D;
  --info: #5B7083;   /* slate, deliberately NOT the brand blue */
  --na: #8C98A4;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(28, 43, 58, .05), 0 6px 18px rgba(33, 88, 140, .06);
  --nav-h: 62px;
  --lv: var(--na);
}

.lv-ok { --lv: var(--ok); }
.lv-watch { --lv: var(--watch); }
.lv-high { --lv: var(--high); }
.lv-urgent { --lv: var(--urgent); }
.lv-info { --lv: var(--info); }
.lv-na { --lv: var(--na); }

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink);
  background: var(--surface);
  font-feature-settings: "ss01";
}
h1, h2, h3, h4 { line-height: 1.4; margin: 0 0 .5em; }
h1 { font-size: 1.35rem; font-weight: 800; }
h2 { font-size: 1.12rem; font-weight: 750; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .75em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
code, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85em; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }

.ic { width: 1.15em; height: 1.15em; vertical-align: -.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { top: 8px; }

/* -------------------------------------------------------------- layout */
.wrap { max-width: 1080px; margin: 0 auto; padding-inline: 16px; }
.main { padding-top: 16px; padding-bottom: calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); }

.topbar { position: sticky; top: 0; z-index: 30; background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar::after { content: ""; display: block; height: 3px; background: var(--brand-grad); }
.topbar-in { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); min-width: 0; }
.brand:hover { text-decoration: none; }
.brand img { width: 38px; height: 38px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.brand-text strong { font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--muted); font-size: .75rem; }
.logout { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.logout .who { display: none; flex-direction: column; line-height: 1.3; text-align: end; font-size: .85rem; }
.logout .who small { color: var(--muted); font-size: .72rem; }

.tabs-top { display: none; }
.tabs-bottom {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  display: flex; background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(20, 33, 43, .06);
}
.tabs-bottom a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--nav-h); color: var(--muted); font-size: .72rem; text-decoration: none;
}
.tabs-bottom a .ic { width: 22px; height: 22px; }
.tabs-bottom a[aria-current="page"] { color: var(--brand); font-weight: 700; }
.tabs-bottom a[aria-current="page"] .ic { stroke-width: 2.4; }

@media (min-width: 900px) {
  .tabs-bottom { display: none; }
  .main { padding-bottom: 48px; }
  .tabs-top { display: flex; gap: 4px; margin-inline-start: 16px; }
  .tabs-top a {
    display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px;
    color: var(--muted); font-size: .9rem; text-decoration: none;
  }
  .tabs-top a:hover { background: var(--surface); color: var(--ink); }
  .tabs-top a[aria-current="page"] { background: color-mix(in srgb, var(--brand) 10%, #fff); color: var(--brand); font-weight: 700; }
  .logout .who { display: flex; }
}

.bare-main { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; }

/* --------------------------------------------------------------- panels */
.panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.panel.narrow { max-width: 560px; margin-inline: auto; width: 100%; }
.subpanel { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 14px; margin: 12px 0; background: var(--surface); }
@media (min-width: 700px) { .panel { padding: 20px 24px; } }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 2px 0 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.p-title { display: flex; align-items: center; gap: 12px; }
.h-sm { font-size: 1rem; font-weight: 750; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.big-icon { display: inline-flex; width: 64px; height: 64px; border-radius: 50%; align-items: center; justify-content: center; color: var(--lv); background: color-mix(in srgb, var(--lv) 12%, #fff); margin-bottom: 8px; }
.big-icon .ic { width: 32px; height: 32px; }

/* -------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand-grad); border-color: var(--brand-deep); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--urgent); border-color: var(--urgent); color: #fff; }
.btn-sm { min-height: 34px; padding: 4px 10px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); color: var(--muted); cursor: pointer; }
.btn-icon:hover { color: var(--urgent); }
.link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; }
.link:disabled { color: var(--muted); cursor: default; }

/* ---------------------------------------------------------------- forms */
.form { display: block; }
.field { margin-bottom: 14px; border: 0; padding: 0; min-width: 0; }
.field > label, .field > legend, .field .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
input[type="text"], input[type="tel"], input[type="password"], input[type="search"], input[type="number"], input:not([type]), select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); color: var(--ink); font: inherit; font-size: 16px; /* 16px: no iOS zoom */
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
input:disabled, select:disabled { background: var(--surface); color: var(--muted); }
input[type="file"] { font: inherit; max-width: 100%; }
input[type="color"] { width: 56px; height: 44px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
input[dir="ltr"] { text-align: left; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--urgent); }
.err { color: var(--urgent); font-size: .85rem; margin: 6px 0 0; }
.hint { color: var(--muted); font-size: .82rem; margin: 6px 0 0; }
/* Password show/hide + keyboard hints (added by app.js to every password field). */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-left: 50px; }
.pw-toggle {
  position: absolute; left: 3px; top: 50%; transform: translateY(-50%); width: 44px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--brand); background: var(--surface); outline: none; }
.pw-toggle .ic { width: 20px; height: 20px; }
.kb-hint { display: flex; align-items: center; gap: 6px; color: #8a5d00; font-size: .82rem; margin: 6px 0 0; }
.kb-hint[hidden] { display: none; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 8px; }
.sticky-actions { position: sticky; bottom: calc(var(--nav-h) + 8px); background: var(--surface); padding: 10px 0; z-index: 5; }
@media (min-width: 900px) { .sticky-actions { bottom: 0; } }

.grid-2, .grid-3, .grid-4 { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 640px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: span 2; }
}
@media (min-width: 900px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

.input-unit { display: flex; align-items: stretch; }
.input-unit input { border-start-end-radius: 0; border-end-end-radius: 0; }
.input-unit .unit {
  display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--line); border-inline-start: 0;
  border-radius: 0 10px 10px 0; background: var(--surface); color: var(--muted); font-size: .8rem; white-space: nowrap;
}
[dir="rtl"] .input-unit .unit { border-radius: 10px 0 0 10px; }

.choice-row, .choice-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.choice { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; position: relative; }
.choice-row .choice, .choice-grid .choice {
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; min-height: 44px; background: var(--paper);
}
.choice-grid .choice { border-radius: 10px; }
.choice input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; flex: none; }
.choice:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, #fff); }
.choice.confirm { margin: 10px 0; font-weight: 600; }
fieldset.q { border: 0; padding: 12px 0; margin: 0; border-bottom: 1px solid var(--line); }
fieldset.q:last-child { border-bottom: 0; }
fieldset.q legend { font-weight: 650; padding: 0; margin-bottom: 8px; }
.q-title { color: var(--brand-deep); margin: 16px 0 4px; font-size: .95rem; }
.color-row { display: flex; align-items: center; gap: 10px; }

.search-box { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 4px 4px 4px 4px; padding-inline-start: 12px; background: var(--paper); }
.search-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.search-box input { border: 0; min-height: 42px; padding: 6px 4px; box-shadow: none !important; }
.search-box .ic { color: var(--muted); }

/* ------------------------------------------------------ notices & badges */
.notice {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; margin: 0 0 12px;
  border-radius: var(--radius-sm); border: 1px solid color-mix(in srgb, var(--lv) 30%, transparent);
  border-inline-start: 4px solid var(--lv); background: color-mix(in srgb, var(--lv) 7%, #fff);
}
.notice > .ic { color: var(--lv); margin-top: 4px; }
.notice p { margin: 0; }
.alert {
  display: flex; gap: 12px; padding: 14px 16px; margin: 0 0 16px; border-radius: var(--radius);
  background: var(--lv); color: #fff;
}
.alert-ic .ic { width: 28px; height: 28px; }
.alert p { margin: 4px 0 0; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  font-size: .76rem; font-weight: 700; line-height: 1.8; white-space: nowrap;
  color: color-mix(in srgb, var(--lv) 85%, #000); background: color-mix(in srgb, var(--lv) 13%, #fff);
}
.est-tag, .est-label { color: var(--info); font-style: normal; font-size: .78rem; font-weight: 600; }
.est-tag { background: color-mix(in srgb, var(--info) 10%, #fff); padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.est-label { display: flex; align-items: center; gap: 6px; margin: 6px 0 10px; }

.toast {
  position: fixed; inset-inline: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 60;
  max-width: 480px; margin: 0 auto; padding: 12px 16px; border-radius: 12px; color: #fff; background: var(--lv);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18); text-align: center;
}
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* ------------------------------------------------------- metric cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
.m-card {
  position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; overflow: hidden;
}
.m-card::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--lv); }
.m-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
.m-label { font-weight: 700; font-size: .88rem; color: var(--muted); }
.m-value { font-size: 1.55rem; font-weight: 800; line-height: 1.3; }
.m-value small { font-size: .75rem; font-weight: 500; color: var(--muted); }
.m-note { margin: 0; font-size: .8rem; color: var(--muted); }
.m-caption { font-size: .75rem; color: var(--muted); text-align: center; }

/* the signature "range strip" */
.strip { position: relative; display: flex; height: 8px; border-radius: 999px; overflow: visible; margin: 8px 0 4px; gap: 2px; }
.strip .seg { display: block; height: 100%; background: color-mix(in srgb, var(--lv) 55%, #fff); }
.strip .seg:first-child { border-radius: 999px 0 0 999px; }
.strip .seg:last-of-type { border-radius: 0 999px 999px 0; }
.strip .mark {
  position: absolute; top: 50%; width: 16px; height: 16px; margin-left: -8px; margin-top: -8px; border-radius: 50%;
  background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.strip-seg .seg { flex: 1; opacity: .35; }
.strip-seg .seg:first-child { border-radius: 0 999px 999px 0; }
.strip-seg .seg:last-child { border-radius: 999px 0 0 999px; }
.strip-seg .seg.on { opacity: 1; outline: 2px solid var(--ink); outline-offset: 1px; border-radius: 4px; }

/* -------------------------------------------------------------- analysis */
.analysis { display: block; }
.a-sec { margin: 0 0 22px; }
.sec-title { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; margin-bottom: 12px; }
.sec-no {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-grad); color: #fff; font-size: .85rem; font-weight: 800; flex: none;
}
.overall-box { border: 1px solid color-mix(in srgb, var(--lv) 35%, var(--line)); background: color-mix(in srgb, var(--lv) 6%, #fff); border-radius: var(--radius); padding: 14px 16px; }
.overall .overall-box { --lv: inherit; }
.overall-level { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; margin-bottom: 6px; }
.overall-level strong { color: color-mix(in srgb, var(--lv) 85%, #000); }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--lv); flex: none; display: inline-block; }
.good-list { color: var(--ok); font-size: .88rem; margin: 0 0 8px; }
.direction { border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 10px; }
.direction p { margin: 4px 0 0; }
.dir-label { font-size: .9rem; }
.key-point { border-radius: var(--radius); padding: 14px 16px; background: color-mix(in srgb, var(--lv) 8%, #fff); border-inline-start: 5px solid var(--lv); }
.key-point p { margin: 6px 0 0; }
.recs { list-style: none; margin: 0; padding: 0; counter-reset: rec; display: grid; gap: 10px; }
@media (min-width: 900px) { .recs { grid-template-columns: repeat(3, 1fr); } }
.recs li { counter-increment: rec; position: relative; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; padding-top: 38px; background: var(--paper); }
.recs li::before {
  content: counter(rec, persian); position: absolute; top: 10px; inset-inline-start: 14px; width: 24px; height: 24px;
  border-radius: 8px; background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); font-weight: 800;
  display: flex; align-items: center; justify-content: center; font-size: .85rem;
}
.recs li p { margin: 6px 0 0; font-size: .92rem; }
.trend-list, .followups { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.trend-list li { display: flex; gap: 10px; align-items: baseline; }
.trend-list li .dot { transform: translateY(2px); }
.followups li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--lv) 7%, #fff); border: 1px solid color-mix(in srgb, var(--lv) 25%, transparent); }
.followups li .ic { color: var(--lv); margin-top: 4px; }
.det-group { font-size: .95rem; color: var(--brand-deep); margin: 16px 0 8px; }
.det-items { display: grid; gap: 8px; }
.det { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.det p { margin: 4px 0 0; font-size: .92rem; }
.det .badge { margin-top: 2px; }
.bia-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 8px; }
.bia-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; display: flex; flex-direction: column; }
.bia-item span { font-size: .8rem; color: var(--muted); }
.bia-item b { font-size: 1.15rem; }
.bia-item small { color: var(--muted); font-size: .72rem; }
.disclaimer { border-top: 1px solid var(--line); padding-top: 12px; color: var(--muted); font-size: .82rem; }
.disclaimer p { display: flex; gap: 8px; margin: 0 0 6px; }

/* ----------------------------------------------------------- trend tabs */
.trend-tabs { margin-top: 8px; }
.tablist { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.tablist [role="tab"] {
  flex: none; min-height: 38px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper); color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer;
}
.tablist [role="tab"][aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.tabpanel { padding-top: 8px; }
.js .tabpanel[data-inactive] { display: none; }
.tab-print-title { display: none; }
.js .trend-tabs .tab-print-title { display: none; }
html:not(.js) .tab-print-title { display: block; }
.chart-wrap { width: 100%; overflow: hidden; }
.chart { width: 100%; height: auto; display: block; font-family: inherit; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 12px; }
.chart-line { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-pt { fill: var(--paper); stroke: var(--brand); stroke-width: 2; }
.chart-pt-last { fill: var(--brand); }
.chart-band { fill: var(--ok); fill-opacity: .1; }
.chart-value { fill: var(--ink); font-size: 13px; font-weight: 800; }
.legend { font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: 6px; margin: 4px 0 0; }
.legend-band { width: 14px; height: 10px; background: color-mix(in srgb, var(--ok) 18%, #fff); border: 1px solid color-mix(in srgb, var(--ok) 40%, #fff); display: inline-block; }

/* ---------------------------------------------------------------- lists */
.patient-list, .visit-list { list-style: none; margin: 0; padding: 0; }
.patient-list li + li, .visit-list li + li { border-top: 1px solid var(--line); }
.patient-list a, .pick-btn { display: flex; align-items: center; gap: 12px; padding: 12px 4px; color: var(--ink); text-decoration: none; min-height: 56px; }
.patient-list a:hover { background: var(--surface); text-decoration: none; }
.p-main { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.5; }
.p-main small { color: var(--muted); }
.p-meta { display: flex; flex-direction: column; align-items: flex-end; font-size: .82rem; color: var(--muted); text-align: end; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none;
  font-weight: 800; color: var(--brand-deep); background: color-mix(in srgb, var(--brand) 14%, #fff);
}
.avatar.f { color: #8A3B62; background: #F6E6EE; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.3rem; }
.pick-btn { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); font: inherit; cursor: pointer; flex-direction: column; align-items: flex-start; padding: 10px 14px; margin-bottom: 8px; text-align: start; }
.pick-btn:hover { border-color: var(--brand); }
.pick-btn small { color: var(--muted); }
.patient-list.pick li + li { border: 0; }
.visit-list a { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 4px; color: var(--ink); text-decoration: none; }
.visit-list a:hover { background: var(--surface); text-decoration: none; }
.v-date { font-weight: 700; min-width: 110px; }
.v-vals { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: .88rem; flex: 1; }
.v-vals b { color: var(--ink); }
.visit-list li.voided { opacity: .6; }
.chosen { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--brand); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--brand) 6%, #fff); margin-bottom: 12px; }
.chosen > div { flex: 1; display: flex; flex-direction: column; line-height: 1.5; }
.chosen small { color: var(--muted); }

/* --------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; white-space: nowrap; }
.table tr.inactive td { color: var(--muted); }
.table tr.row-warn td { background: color-mix(in srgb, var(--watch) 6%, #fff); }
.kv { width: 100%; border-collapse: collapse; }
.kv th, .kv td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: start; }
.kv th { font-weight: 600; color: var(--muted); width: 45%; font-size: .9rem; }
.kv tr.staff-only th, .kv tr.staff-only td { background: color-mix(in srgb, var(--watch) 6%, #fff); }
.kv-inline { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
.kv-inline dt { color: var(--muted); }
.kv-inline dd { margin: 0; font-weight: 600; }
.sub-title { display: flex; align-items: center; gap: 8px; font-size: .95rem; margin: 16px 0 6px; }
.answers { display: grid; grid-template-columns: 1fr; gap: 2px 16px; margin: 10px 0 0; }
.answers dt { color: var(--muted); font-size: .85rem; margin-top: 6px; }
.answers dd { margin: 0; font-weight: 600; }
@media (min-width: 700px) { .answers { grid-template-columns: max-content 1fr; } .answers dt { margin: 0; } }
.staff-panel { border-color: color-mix(in srgb, var(--watch) 45%, var(--line)); background: color-mix(in srgb, var(--watch) 3%, #fff); }
.staff-note { white-space: normal; }
details > summary { cursor: pointer; list-style-position: inside; }
details > summary.h-sm { display: list-item; }

/* -------------------------------------------------------------- stepper */
.steps-nav { list-style: none; margin: 0 0 12px; padding: 0 0 4px; display: flex; gap: 6px; overflow-x: auto; }
.steps-nav li { flex: none; }
.steps-nav button {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--paper);
  border-radius: 999px; padding: 6px 12px 6px 14px; font: inherit; font-size: .85rem; color: var(--muted); cursor: pointer; min-height: 40px;
}
.steps-nav .n { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--surface); font-weight: 800; }
.steps-nav button[aria-current="step"] { border-color: var(--brand); color: var(--brand); font-weight: 700; }
.steps-nav button[aria-current="step"] .n { background: var(--brand); color: #fff; }
.steps-nav button.done .n { background: color-mix(in srgb, var(--ok) 20%, #fff); color: var(--ok); }
.step-actions {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 5; display: flex; gap: 10px;
  justify-content: space-between; padding: 10px 0; background: linear-gradient(to top, var(--surface) 70%, transparent);
}
.step-actions [data-action="next"], .step-actions [data-action="submit"] { margin-inline-start: auto; min-width: 140px; }
@media (min-width: 900px) { .step-actions { bottom: 0; } }
.bmi-live { display: flex; flex-direction: column; justify-content: center; }
.bmi-live output { font-size: 1.6rem; font-weight: 800; color: var(--brand-deep); line-height: 1.3; }
.scale-preview { margin: 10px 0 0; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px; background: var(--surface); }
.scale-preview img { display: block; max-height: 420px; margin: 0 auto; border-radius: 6px; }
.scale-preview figcaption { text-align: center; margin-top: 6px; }
#bia-body.is-blocked { opacity: .45; pointer-events: none; }
.technique { margin-top: 8px; font-size: .88rem; }
.review { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 16px; }
.review dt { color: var(--muted); }
.review dd { margin: 0; font-weight: 600; }
.progress { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 8px 0; }
.progress span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }

/* ---------------------------------------------------------------- admin */
.subtabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 16px; padding-bottom: 4px; }
.subtabs a { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--muted); font-size: .88rem; }
.subtabs a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.subtabs a:hover { text-decoration: none; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat b { font-size: 1.6rem; }
.dist { display: grid; gap: 8px; }
.dist-row { display: grid; grid-template-columns: 110px 1fr 48px; align-items: center; gap: 10px; font-size: .88rem; }
.dist-bar { height: 10px; background: var(--surface); border-radius: 999px; overflow: hidden; }
.dist-bar i { display: block; height: 100%; background: var(--lv); border-radius: 999px; }
.checks { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.checks li { display: flex; gap: 10px; align-items: flex-start; }
.checks li .ic { color: var(--lv); margin-top: 4px; }
.checks li span { display: flex; flex-direction: column; }
.checks li small { color: var(--muted); }
.checks li small[dir="ltr"] { text-align: right; }
.vis-list { display: grid; gap: 4px; }
.vis-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.vis-row select { width: auto; min-width: 130px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: end; }
@media (min-width: 900px) { .filters { grid-template-columns: 2fr 1fr 1fr 1.5fr auto; } }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 12px 0; }
.perm-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px) { .perm-grid { grid-template-columns: 1fr 1fr; } }
.perm { align-items: flex-start; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.perm span { display: flex; flex-direction: column; line-height: 1.5; }
.perm small { color: var(--muted); }
.logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.logo-preview { border: 1px solid var(--line); border-radius: 12px; object-fit: contain; background: #fff; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------------------------------------------------------------- login */
.login-panel { padding: 24px; }
.login-brand { text-align: center; margin-bottom: 16px; }
.login-brand img { width: 64px; height: 64px; border-radius: 16px; object-fit: contain; }
.login-brand h1 { margin: 8px 0 0; font-size: 1.2rem; }
.otp-input { font-size: 1.6rem !important; letter-spacing: .5em; text-align: center !important; }
.profile-switch { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
.profile-switch select { width: auto; min-width: 200px; }

/* ---------------------------------------------------------- report (screen) */
.report-body { background: #E9EEF0; }
.report-toolbar { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 16px; background: var(--paper); border-bottom: 1px solid var(--line); }
.report { background: #fff; max-width: 210mm; margin: 16px auto; padding: 14mm 14mm 10mm; box-shadow: 0 2px 20px rgba(0, 0, 0, .1); }
@media (max-width: 700px) { .report { padding: 16px; margin: 0; } }
.rp-head { display: flex; align-items: center; gap: 12px; border-bottom: 2px solid var(--brand); padding-bottom: 10px; margin-bottom: 12px; }
.rp-head img { width: 56px; height: 56px; object-fit: contain; }
.rp-org { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); line-height: 1.6; }
.rp-org strong { color: var(--ink); font-size: 1rem; }
.rp-title { margin-inline-start: auto; text-align: end; font-size: .8rem; color: var(--muted); }
.rp-title h1 { color: var(--brand-deep); font-size: 1.15rem; margin: 0; }
.rp-person { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px; background: var(--surface); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
@media (min-width: 700px) { .rp-person { grid-template-columns: repeat(4, 1fr); } }
.rp-person div { display: flex; flex-direction: column; font-size: .85rem; }
.rp-person span { color: var(--muted); font-size: .75rem; }
.rp-block { margin-bottom: 14px; }
.rp-foot { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 8px; font-size: .78rem; }
label.is-optional::after { content: " (برای این سن اختیاری)"; color: var(--muted); font-weight: 400; font-size: .8rem; }


/* ===================================================== v1.1 components */
.req { color: var(--urgent); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.grid-2.tight, .grid-3.tight { gap: 0 12px; grid-template-columns: 1fr 1fr; }
.grid-3.tight .bp-pair { grid-column: span 2; }
@media (min-width: 900px) { .grid-3.tight { grid-template-columns: 1fr 1.6fr 1fr; } .grid-3.tight .bp-pair { grid-column: auto; } }
@media (max-width: 480px) {
  .steps-nav { gap: 4px; }
  .steps-nav button:not([aria-current]) .t { display: none; }
  .steps-nav button { padding: 5px 8px; }
}
.login-brand img.login-logo { width: 118px; height: auto; margin: 0 auto 6px; display: block; }
.login-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 14px; font-size: .88rem; }
.login-links form { display: inline; }
.inline-row { display: flex; gap: 10px; align-items: flex-start; }
.inline-row .grow { flex: 1; margin: 0; }
form.inline { display: inline; }
.link.danger { color: var(--urgent); }
details.more { margin: 10px 0; }
details.more > summary { color: var(--brand); font-size: .9rem; padding: 6px 0; }
.search-box.big input { font-size: 1.25rem; letter-spacing: .06em; min-height: 50px; }
.notice-inline { background: color-mix(in srgb, var(--brand) 7%, #fff); border-radius: 10px; padding: 8px 12px; font-size: .9rem; }
.pick-list { display: grid; gap: 8px; }
.pick-btn.add { color: var(--brand); border-style: dashed; align-items: center; }

/* live BMI in the form */
.bmi-live { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0 0 14px; background: color-mix(in srgb, var(--brand) 4%, #fff); }
.bmi-live-head { display: flex; align-items: center; gap: 10px; }
.bmi-live-head output { font-size: 1.5rem; font-weight: 800; color: var(--brand-deep); }
.mini-gauge { position: relative; display: flex; height: 8px; gap: 2px; margin-top: 8px; }
.mini-gauge span { background: color-mix(in srgb, var(--lv) 60%, #fff); border-radius: 3px; }
.mini-gauge i { position: absolute; top: -5px; width: 4px; height: 18px; margin-left: -2px; background: var(--ink); border-radius: 2px; }

/* blood pressure pair */
.bp-inputs { display: flex; align-items: center; gap: 6px; }
.bp-inputs input { width: 5.2em; text-align: center; }
.bp-inputs .unit { color: var(--muted); font-size: .78rem; }

/* scale report */
.scale-box { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 12px; }
.upload-btn { display: flex; align-items: center; gap: 12px; border: 2px dashed color-mix(in srgb, var(--brand) 45%, var(--line)); border-radius: var(--radius); padding: 14px; cursor: pointer; background: color-mix(in srgb, var(--brand) 4%, #fff); margin: 8px 0; }
.upload-btn .ic { width: 28px; height: 28px; color: var(--brand); }
.upload-btn span { display: flex; flex-direction: column; line-height: 1.5; }
.upload-btn small { color: var(--muted); }
.upload-btn:focus-within, .upload-btn:hover { border-color: var(--brand); }
.ocr-status { margin: 8px 0; }
.bia-checklist { margin: 10px 0; }
.checklist { width: 100%; border-collapse: collapse; font-size: .9rem; }
.checklist td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.checklist .c-check { width: 34px; }
.checklist .c-check input { width: 22px; height: 22px; accent-color: var(--brand); }
.checklist .c-value input { min-height: 40px; padding: 6px 8px; width: 100%; max-width: 110px; }
.checklist .c-unit { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.checklist tr.off .c-label { color: var(--muted); }
.src-badge { display: inline-block; margin-inline-start: 6px; font-size: .68rem; border-radius: 999px; padding: 0 7px; }
.src-badge.ok { background: color-mix(in srgb, var(--ok) 14%, #fff); color: var(--ok); }
.src-badge.warn { background: color-mix(in srgb, var(--watch) 18%, #fff); color: #8a5d00; }
.src-badge.bad { background: color-mix(in srgb, var(--urgent) 12%, #fff); color: var(--urgent); }
.src-badge.edit { background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand-deep); }
.photo-preview { max-width: 180px; border-radius: 10px; margin: 8px 0; display: block; }

/* metric cards with graphics */
.m-card.wide { grid-column: 1 / -1; }
.gauge-wrap { margin-top: 4px; }
.gauge { width: 100%; height: auto; display: block; font-family: inherit; }
.g-seg { fill: color-mix(in srgb, var(--lv) 38%, #fff); }
.g-seg.on { fill: var(--lv); }
.g-lbl { font-size: 11px; fill: var(--muted); }
.g-lbl.on { fill: var(--ink); font-weight: 800; }
.g-num { font-size: 10px; fill: var(--muted); }
.g-mark line { stroke: var(--ink); stroke-width: 3; }
.g-mark circle { fill: #fff; stroke: var(--ink); stroke-width: 3; }
.g-val { font-size: 12px; font-weight: 800; fill: var(--ink); }
.gauge-info { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.gauge-info li { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: .88rem; padding: 7px 10px; border-radius: 10px; background: var(--surface); }
.gauge-info li.ok { background: color-mix(in srgb, var(--ok) 9%, #fff); }
.gauge-info b { white-space: nowrap; }
.growth { width: 100%; height: auto; display: block; }
.gr-band-ok { fill: color-mix(in srgb, var(--ok) 13%, #fff); }
.gr-band-watch { fill: color-mix(in srgb, var(--watch) 13%, #fff); }
.gr-line { fill: none; stroke: var(--na); stroke-width: 1.5; stroke-dasharray: 4 3; }
.gr-line.mid { stroke: var(--ok); stroke-dasharray: none; stroke-width: 2; }
.gr-lbl { font-size: 10px; fill: var(--muted); }
.gr-point { fill: var(--brand); stroke: #fff; stroke-width: 3; }
.comp-bar { display: flex; height: 30px; border-radius: 8px; overflow: hidden; margin-top: 6px; font-size: .8rem; font-weight: 700; color: #fff; }
.comp-bar span { display: flex; align-items: center; justify-content: center; min-width: 2.5em; }
.comp-fat { background: var(--watch); }
.comp-lean { background: var(--brand); }
.comp-legend { font-size: .75rem; color: var(--muted); margin: 4px 0 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.comp-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.goal-bar { height: 10px; background: var(--surface); border-radius: 999px; overflow: hidden; margin: 8px 0 2px; }
.goal-bar span { display: block; height: 100%; background: var(--brand-grad); }
.goal-line { margin: -6px 0 14px; color: var(--brand-deep); }
.missing-list { margin: 0 0 6px; padding-inline-start: 20px; }
.more-data .sec-no { background: var(--info); }

/* photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-bottom: 8px; }
.photo-grid.small { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
.photo-grid figure { margin: 0; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.photo-grid figcaption { font-size: .72rem; color: var(--muted); display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
img.avatar.photo { object-fit: cover; padding: 0; }

/* admin branches */
.branch-list { list-style: none; padding: 0; margin: 0; }
.branch-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.branch-list li div { display: flex; flex-direction: column; }
.branch-list small { color: var(--muted); }
.branch-list li.inactive { opacity: .6; }

/* report additions */
.rp-logo { width: 64px; height: auto; object-fit: contain; }
.rp-qr { display: flex; align-items: center; gap: 10px; float: left; font-size: .75rem; color: var(--muted); }
.rp-qr #report-qr { width: 84px; height: 84px; }
.rp-qr svg { width: 100%; height: 100%; }

/* mobile polish */
@media (max-width: 480px) {
  .panel { padding: 14px; border-radius: 12px; }
  .page-head h1 { font-size: 1.15rem; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .m-value { font-size: 1.3rem; }
  .steps-nav .t { font-size: .78rem; }
  .steps-nav button { padding: 5px 10px; }
  .gauge-info li { font-size: .82rem; }
  .tabs-bottom a { font-size: .68rem; }
}
