/* Peygir «پیگیر» — styles from the Peygir Brand & Design System (Figma).
   Brand: follow-up teal #0B6F66, pine ink #173B38, soft mint #E5F2EB, clinic white #F6F8F7, warm accent #E2B563 (decorative only).
   Type: Vazirmatn (Persian) + Inter (Latin). Spacing: 4 px base, 8 px rhythm — only --s-* values are used for padding/gaps.
   Radii 6/10/16/24/full. Controls and touch targets 44 px. Focus: 2 px ring, 3 px offset. Motion 120/180/240 ms. */

:root {
  /* spacing scale */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-45: 20px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
  /* radii */
  --r-xs: 6px; --r-sm: 10px; --r-md: 16px; --r-lg: 24px; --r-full: 999px;
  /* motion */
  --t-fast: 120ms; --t-mid: 180ms; --t-slow: 240ms;
  --control: 44px;

  /* colours: aliases of the official tokens in brand/peygir-tokens.css (light + [data-theme="dark"]) */
  --bg: var(--color-bg-canvas);
  --card: var(--color-bg-surface);
  --raised: var(--color-bg-raised);
  --ink: var(--color-text-primary);
  --muted: var(--color-text-secondary);
  --line: var(--color-border-default);
  --field: var(--color-border-strong);
  --brand: var(--color-brand-primary);
  --brand-hover: var(--color-brand-hover);
  --brand-active: var(--color-brand-active);
  --brand-ink: var(--color-on-brand);
  --brand-soft: var(--color-brand-subtle);
  --focus: var(--color-focus);
  --gold: var(--color-accent-decorative);
  --ok: var(--color-success-fg);   --ok-soft: var(--color-success-bg);
  --warn: var(--color-warning-fg); --warn-soft: var(--color-warning-bg);
  --bad: var(--color-danger-fg);   --bad-soft: var(--color-danger-bg);
  --info: var(--color-info-fg);    --info-soft: var(--color-info-bg);
  --neutral: var(--color-text-secondary); --neutral-soft: var(--color-bg-subtle);
  --shadow: var(--shadow-card);
}
@media (prefers-reduced-motion: reduce) { :root { --t-fast: 0ms; --t-mid: 0ms; --t-slow: 0ms; } }

/* fonts bundled with the brand kit (SIL OFL, licences in brand/) */
@font-face { font-family: "Vazirmatn"; src: url("/brand/Vazirmatn.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/brand/Inter.ttf") format("truetype"); font-weight: 100 900; font-display: swap; unicode-range: U+0000-024F, U+2000-206F, U+20AC, U+2122; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: "Inter", var(--font-fa); font-size: 16px; line-height: 28px; letter-spacing: 0; font-synthesis: none; -webkit-text-size-adjust: 100%; }
.num, .pill, .stat b, table { font-variant-numeric: tabular-nums; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
/* type scale (brand kit): H1 32/48 page title · H2 24/40 section · H3 20/32 card heading · body 16/28 · label 14/24 · caption 12/20 */
h1, h2, h3 { font-weight: 600; margin: 0 0 var(--s-3); }
h1 { font-size: 32px; line-height: 48px; }
h2 { font-size: 24px; line-height: 40px; }
h3 { font-size: 20px; line-height: 32px; }
.card h2, fieldset h2 { font-size: 20px; line-height: 32px; }
@media (max-width: 860px) { h1 { font-size: 24px; line-height: 40px; } h2 { font-size: 20px; line-height: 32px; } }
.display { font-size: 32px; line-height: 48px; font-weight: 600; }
.small { font-size: 14px; line-height: 24px; }
.caption { font-size: 12px; line-height: 20px; }
.muted { color: var(--muted); }
[dir="ltr"] { unicode-bidi: isolate; }
.boot { padding: var(--s-7) var(--s-4); text-align: center; color: var(--muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--r-xs); }

/* ---------- app shell: right-side navigation on desktop, bottom tabs on phones ---------- */
.shell { min-height: 100vh; }
.side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 248px; background: var(--card); border-inline-end: 1px solid var(--line);
  padding: var(--s-5) var(--s-4); display: flex; flex-direction: column; gap: var(--s-1); z-index: 10; }
.brandmark { display: flex; align-items: center; gap: var(--s-2); color: var(--ink); font-size: 20px; line-height: 32px; font-weight: 600; }
.brandmark:hover { text-decoration: none; }
.brandmark svg { width: 32px; height: 32px; flex: none; }
.side .tagline { font-size: 12px; line-height: 20px; color: var(--muted); margin: 0 0 var(--s-4); padding-inline-start: 40px; }
.side a.nav { display: flex; align-items: center; gap: var(--s-3); min-height: var(--control); padding: 0 var(--s-3); border-radius: var(--r-sm);
  color: var(--ink); font-size: 14px; line-height: 24px; font-weight: 500; transition: background var(--t-fast); }
.side a.nav:hover { background: var(--bg); text-decoration: none; }
.side a.nav.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side a.nav .i { width: 20px; text-align: center; }
.side .foot { margin-top: auto; font-size: 12px; line-height: 20px; color: var(--muted); }
main { margin-inline-start: 248px; padding: var(--s-6) var(--s-6) var(--s-7); max-width: calc(1120px + 248px); }
.topbar { display: none; }
.tabbar { display: none; }
@media (max-width: 860px) {
  .side { display: none; }
  main { margin-inline-start: 0; padding: var(--s-4) var(--s-4) calc(var(--s-8) + var(--s-5)); }
  .topbar { display: flex; position: sticky; top: 0; z-index: 10; align-items: center; gap: var(--s-3); background: var(--card);
    border-bottom: 1px solid var(--line); padding: calc(env(safe-area-inset-top) + var(--s-2)) var(--s-4) var(--s-2); min-height: 56px; }
  .tabbar { display: flex; position: fixed; bottom: 0; inset-inline: 0; z-index: 10; background: var(--card); border-top: 1px solid var(--line);
    padding: var(--s-1) var(--s-1) calc(env(safe-area-inset-bottom) + var(--s-1)); }
  .tabbar a { flex: 1; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
    color: var(--muted); font-size: 12px; line-height: 20px; border-radius: var(--r-sm); }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a .i { font-size: 20px; line-height: 24px; }
  .tabbar a.on { color: var(--brand); font-weight: 600; }
}

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-5); }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); font-size: 14px; line-height: 24px; }

/* ---------- surfaces ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-45); box-shadow: var(--shadow); margin-bottom: var(--s-5); }
.card > h2:first-child, .card > .row:first-child > h2 { margin-bottom: var(--s-3); }
@media (max-width: 860px) { .card { padding: var(--s-4); } }
.row { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* stat card */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); margin-bottom: var(--s-5); }
@media (max-width: 860px) { .stats { grid-template-columns: repeat(2, 1fr); gap: var(--s-3); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-4); box-shadow: var(--shadow); }
.stat > span { display: block; font-size: 14px; line-height: 24px; color: var(--muted); }
.stat b { display: block; font-size: 32px; line-height: 48px; font-weight: 600; }
.stat.bad b { color: var(--bad); } .stat.warn b { color: var(--warn); } .stat.ok b { color: var(--ok); }

/* lists & patient rows */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list a.item { display: flex; gap: var(--s-3); align-items: center; padding: var(--s-3) 0; min-height: 64px; color: inherit; }
.list a.item:hover { text-decoration: none; background: linear-gradient(to left, transparent, var(--bg), transparent); }
.item .name { font-weight: 600; font-size: 16px; line-height: 28px; }
.item .meta { font-size: 12px; line-height: 20px; color: var(--muted); }
.avatar { width: 40px; height: 40px; border-radius: var(--r-full); background: var(--brand-soft); color: var(--brand); flex: none;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 16px; }
.list li.pad { padding: var(--s-3) 0; }

/* status badge: colour always paired with a text label */
.pill { display: inline-flex; align-items: center; font-size: 12px; line-height: 20px; font-weight: 500; padding: var(--s-1) var(--s-3);
  border-radius: var(--r-full); background: var(--neutral-soft); color: var(--neutral); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.gray { background: var(--neutral-soft); color: var(--muted); }

/* ---------- fields ---------- */
label { display: block; font-size: 14px; line-height: 24px; font-weight: 500; color: var(--ink); margin-bottom: var(--s-1); }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--card); border: 1px solid var(--field);
  border-radius: var(--r-sm); padding: var(--s-2) var(--s-3); min-height: var(--control); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
textarea { min-height: 88px; resize: vertical; line-height: 28px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
input:disabled, select:disabled, textarea:disabled { background: var(--brand-soft); color: var(--muted); border-color: var(--line); }
input[aria-invalid="true"] { border-color: var(--bad); }
input[dir="ltr"] { text-align: right; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-4); }
.grid.two { grid-template-columns: repeat(2, 1fr); }
.grid .wide { grid-column: 1 / -1; }
@media (max-width: 860px) { .grid, .grid.two { grid-template-columns: 1fr 1fr; gap: var(--s-3); } }
@media (max-width: 480px) { .grid, .grid.two { grid-template-columns: 1fr; } }
fieldset, details.fs { border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-3) var(--s-45) var(--s-45); margin: 0 0 var(--s-5); background: var(--card); }
@media (max-width: 860px) { fieldset, details.fs { padding: var(--s-3) var(--s-4) var(--s-4); } }
legend { padding: 0 var(--s-2); font-size: 16px; line-height: 28px; font-weight: 600; color: var(--ink); }
details > summary { cursor: pointer; color: var(--brand); min-height: var(--control); display: flex; align-items: center; }
details.fs > summary { font-weight: 600; color: var(--ink); margin: 0; }
details.fs[open] > summary { margin-bottom: var(--s-3); }
.checks { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); }
.check { display: inline-flex; align-items: center; gap: var(--s-2); min-height: var(--control); font-size: 14px; line-height: 24px; font-weight: 400; color: var(--ink); margin: 0; }
.check input { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--brand); box-shadow: none; }
.date-wrap { display: flex; gap: var(--s-2); }
.date-wrap input { flex: 1; min-width: 0; }
.date-wrap button { flex: none; }

/* ---------- buttons ---------- */
button, .btn { font: inherit; font-size: 14px; line-height: 24px; font-weight: 600; border: 1px solid var(--field); background: var(--card); color: var(--ink);
  border-radius: var(--r-sm); padding: var(--s-2) var(--s-4); min-height: var(--control); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
button:hover, .btn:hover { background: var(--bg); text-decoration: none; }
button.primary, .btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.primary:hover, .btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
button.primary:active, .btn.primary:active { background: var(--brand-active); }
button.danger { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
button.danger:hover { background: var(--bad); color: var(--card); }
button.link { border: 0; background: none; color: var(--brand); padding: 0 var(--s-1); min-height: 0; font-weight: 500; }
button.link:hover { text-decoration: underline; background: none; }
button:disabled { background: var(--brand-soft); color: var(--muted); border-color: var(--brand-soft); cursor: default; }
.actions { display: flex; gap: var(--s-3); flex-wrap: wrap; margin-top: var(--s-4); }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: var(--s-3) 0; margin-top: 0; z-index: 5; border-top: 1px solid var(--line); }
@media (max-width: 860px) { .sticky-actions { bottom: calc(env(safe-area-inset-bottom) + 60px); } }
.err { color: var(--bad); background: var(--bad-soft); border-radius: var(--r-sm); padding: var(--s-2) var(--s-3); margin: var(--s-3) 0; font-size: 14px; line-height: 24px; }
.note { color: var(--warn); background: var(--warn-soft); border-radius: var(--r-sm); padding: var(--s-2) var(--s-3); font-size: 14px; line-height: 24px; margin: 0 0 var(--s-3); }

/* ---------- sign-in ---------- */
.auth { max-width: 416px; margin: 0 auto; padding: var(--s-7) var(--s-4); }
.auth .brand { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); color: var(--ink); font-size: 32px; line-height: 48px; font-weight: 600; margin-bottom: var(--s-1); }
.auth .brand svg { width: 56px; height: 56px; }
.auth .tag { text-align: center; color: var(--muted); font-size: 14px; line-height: 24px; margin-bottom: var(--s-5); }
.auth form > * + * { margin-top: var(--s-4); }
.auth .switch { text-align: center; margin-top: var(--s-4); }

/* ---------- patient page ---------- */
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-4) var(--s-5); }
@media (max-width: 860px) { .facts { grid-template-columns: 1fr 1fr; gap: var(--s-3) var(--s-4); } }
.facts > div > span { display: block; font-size: 12px; line-height: 20px; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { border-inline-start: 2px solid var(--brand-soft); padding: 0 var(--s-4) var(--s-4); position: relative; }
.timeline > li::before { content: ""; position: absolute; inset-inline-start: -7px; top: var(--s-2); width: 12px; height: 12px; border-radius: var(--r-full); background: var(--brand); }
.chart { margin-bottom: var(--s-3); }
.chart svg { width: 100%; height: auto; display: block; }
table.sched { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 24px; }
table.sched th, table.sched td { border-bottom: 1px solid var(--line); padding: var(--s-2); text-align: start; }
table.sched th { font-weight: 500; color: var(--muted); }
table.sched input { min-height: 36px; padding: var(--s-1) var(--s-2); width: 72px; }
.imaging-row { border: 1px dashed var(--field); border-radius: var(--r-sm); padding: var(--s-3); margin-bottom: var(--s-3); }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s-3); margin-top: var(--s-4); }
.file { border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--bg); }
.file .thumb { display: flex; align-items: center; justify-content: center; height: 112px; background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.file .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file > div { padding: var(--s-2) var(--s-3); word-break: break-word; }

/* ---------- misc ---------- */
#toast { position: fixed; bottom: var(--s-8); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: var(--s-2) var(--s-4); border-radius: var(--r-full); opacity: 0; pointer-events: none; transition: opacity var(--t-mid); z-index: 50; max-width: 90vw; font-size: 14px; line-height: 24px; }
#toast.show { opacity: 1; }
@media (min-width: 861px) { #toast { bottom: var(--s-6); left: calc(50% - 124px); } }
.search { margin-bottom: var(--s-4); }
.filters { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-bottom: var(--s-4); }
.filters button, .filters .btn { min-height: 36px; padding: var(--s-1) var(--s-3); border-radius: var(--r-full); font-weight: 500; border-color: var(--line); }
.filters button.on, .filters .btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.empty { text-align: center; color: var(--muted); padding: var(--s-5) var(--s-2); font-size: 14px; line-height: 24px; }
.fineprint { font-size: 12px; line-height: 20px; color: var(--muted); margin-top: var(--s-4); }

/* booking page doctor card */
.doc-card { text-align: center; }
.doc-mark { width: 64px; height: 64px; border-radius: var(--r-full); margin: 0 auto var(--s-3); background: var(--brand); color: var(--brand-ink);
  display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 600; }
.creds { list-style: none; padding: 0; margin: var(--s-3) 0 0; font-size: 14px; line-height: 24px; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: center; margin-top: var(--s-2); }
.chips .pill { white-space: normal; background: var(--brand-soft); color: var(--brand); }

@media print {
  .side, .topbar, .tabbar, .actions, .sticky-actions { display: none !important; }
  main { margin: 0; padding: 0; } body { background: #fff; } .card { box-shadow: none; break-inside: avoid; }
}
.brandmark-link:hover { text-decoration: none; }
.brand-mark { display: inline-flex; flex-direction: column; align-items: center; gap: var(--s-2); }
.brand-mark svg { width: 56px; height: 56px; }
.page-head > div:first-child > .muted, .page-head .small { margin-top: 0; }
@media (max-width: 860px) {
  .filters { flex-wrap: nowrap; overflow-x: auto; margin-inline: calc(-1 * var(--s-4)); padding: 0 var(--s-4) var(--s-1); scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .filters > * { flex: none; }
}
/* intake: collapsible extra sections */
details.more > summary { cursor: pointer; font-weight: 600; padding: var(--s-2, 8px) 0; color: var(--color-brand-primary, #0B6F66); }
details.more[open] > summary { margin-bottom: var(--s-2, 8px); }
h3.sub { font-size: 0.95rem; margin: var(--s-4, 16px) 0 var(--s-2, 8px); color: var(--color-text-secondary, #526763); }
