/* ============================================================
   پنلِ کلینیکِ زیبایی — تمِ شیشه‌ای (Glassmorphism)
   رنگ‌ها از هویتِ برندِ پرنیشا: سرخابیِ #D30F3F، صورتیِ #F05C85، کرمِ #F5EDE6
   ============================================================ */
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2'); font-weight: 500 600; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2'); font-weight: 700 900; font-display: swap; }

:root {
  --brand: #D30F3F;
  --brand-600: #B90D37;
  --brand-soft: rgba(211, 15, 63, .10);
  --accent: #F05C85;
  --gold: #C9962B;
  --ink: #2E1D22;
  --ink-2: #4a3339;
  --muted: #765B63;
  --line: rgba(46, 29, 34, .09);
  --line-2: rgba(46, 29, 34, .14);
  --bg: #F5EDE6;
  --bg-1: #FBF5F1;
  --bg-2: #F1E3DC;
  --orb-1: rgba(240, 92, 133, .42);
  --orb-2: rgba(211, 15, 63, .22);
  --orb-3: rgba(201, 150, 43, .26);
  --glass: rgba(255, 255, 255, .50);
  --glass-2: rgba(255, 255, 255, .34);
  --glass-strong: rgba(255, 255, 255, .80);
  --glass-border: rgba(255, 255, 255, .72);
  --glass-edge: rgba(255, 255, 255, .9);
  --glass-shadow: 0 18px 50px -18px rgba(46, 29, 34, .18), 0 2px 8px rgba(46, 29, 34, .04);
  --blur: saturate(180%) blur(22px);
  --field: rgba(255, 255, 255, .62);
  --field-focus: rgba(255, 255, 255, .92);
  --ok: #1d8657; --ok-bg: rgba(29, 134, 87, .12);
  --warn: #a86a0c; --warn-bg: rgba(201, 150, 43, .16);
  --danger: #c3223f; --danger-bg: rgba(195, 34, 63, .11);
  --info: #3563a8; --info-bg: rgba(53, 99, 168, .11);
  --violet: #6b4fc0; --violet-bg: rgba(107, 79, 192, .12);
  --mute-bg: rgba(118, 91, 99, .12);
  --r-xl: 26px; --r-lg: 20px; --r: 14px; --r-sm: 10px;
  --side-w: 262px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ink: #F7ECEF; --ink-2: #e2cfd5; --muted: #BFA3AC;
  --line: rgba(255, 255, 255, .08); --line-2: rgba(255, 255, 255, .14);
  --bg: #150C10; --bg-1: #1b0f14; --bg-2: #120a0d;
  --orb-1: rgba(211, 15, 63, .38); --orb-2: rgba(240, 92, 133, .20); --orb-3: rgba(201, 150, 43, .14);
  --glass: rgba(44, 24, 32, .52); --glass-2: rgba(44, 24, 32, .34); --glass-strong: rgba(36, 20, 27, .92);
  --glass-border: rgba(255, 255, 255, .09); --glass-edge: rgba(255, 255, 255, .12);
  --glass-shadow: 0 20px 50px -20px rgba(0, 0, 0, .6), 0 1px 0 rgba(255, 255, 255, .04) inset;
  --field: rgba(255, 255, 255, .06); --field-focus: rgba(255, 255, 255, .11);
  --brand-soft: rgba(240, 92, 133, .16);
  --ok: #4cc58d; --warn: #e6b04f; --danger: #ff6b86; --info: #7fa7ea; --violet: #a993f0;
  color-scheme: dark;
}
:root[data-theme="dark"] .btn.primary, :root[data-theme="dark"] .nav a.active { box-shadow: 0 8px 20px -12px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.18); }
:root[data-theme="dark"] .brand img, :root[data-theme="dark"] .auth-brand img { box-shadow: 0 10px 24px -14px rgba(0,0,0,.8); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; font-family: Vazirmatn, Tahoma, system-ui, sans-serif; font-size: 14.5px; line-height: 1.75;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
/* لایه‌ی پس‌زمینه: گوی‌هایِ رنگیِ محو که شیشه‌ها رویشان معنا پیدا می‌کنند */
.backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; contain: strict; isolation: isolate;
  background: linear-gradient(160deg, var(--bg-1), var(--bg) 45%, var(--bg-2)); }
/* گوی‌ها با گرادیانِ شعاعی (نه filter: blur) — سبک‌تر و بدونِ باگِ ترکیب‌بندیِ کرومیوم هنگامِ اسکرول */
.backdrop i { position: absolute; border-radius: 50%; will-change: transform; animation: drift 38s var(--ease) infinite alternate; }
.backdrop i:nth-child(1) { width: 70vmax; height: 70vmax; background: radial-gradient(closest-side, var(--orb-1), transparent); top: -30vmax; left: -20vmax; }
.backdrop i:nth-child(2) { width: 58vmax; height: 58vmax; background: radial-gradient(closest-side, var(--orb-2), transparent); bottom: -26vmax; right: -16vmax; animation-duration: 46s; }
.backdrop i:nth-child(3) { width: 50vmax; height: 50vmax; background: radial-gradient(closest-side, var(--orb-3), transparent); top: 22%; left: 34%; animation-duration: 54s; }
#root { position: relative; z-index: 1; }
.backdrop::after { content: ''; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.35) 1px, transparent 1px); background-size: 3px 3px; opacity: .08; mix-blend-mode: overlay; }
@keyframes drift { to { transform: translate3d(6vmax, 4vmax, 0) scale(1.08); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

h1, h2, h3, h4 { margin: 0; line-height: 1.4; font-weight: 800; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
small { font-size: .82em; color: var(--muted); }
::selection { background: rgba(240, 92, 133, .3); }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---------- شیشه */
.glass, .glass-strong {
  background: var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); position: relative;
}
.glass::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  /* بدونِ mix-blend-mode: روی کارت‌هایِ بلند در کرومیوم باعثِ رنگ‌نشدنِ محتوا هنگامِ اسکرول می‌شد */
  background: linear-gradient(135deg, var(--glass-edge), transparent 28%); opacity: .35;
}
.glass-strong { background: var(--glass-strong); }

/* ---------- دکمه‌ها */
.btn {
  --b: var(--glass); font: inherit; font-weight: 600; font-size: .92rem; display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 40px; padding: 0 1rem; border-radius: 12px; border: 1px solid var(--glass-border); background: var(--b); color: var(--ink);
  cursor: pointer; transition: transform .15s var(--ease), background .2s, box-shadow .2s, border-color .2s; white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--glass-strong); border-color: var(--line-2); text-decoration: none; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn.primary {
  color: #fff; border: 0; background: linear-gradient(135deg, var(--accent), var(--brand) 55%, var(--brand-600));
  box-shadow: 0 10px 24px -10px rgba(46, 29, 34, .32), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.btn.primary:hover { filter: brightness(1.06); box-shadow: 0 14px 30px -12px rgba(46, 29, 34, .32), inset 0 1px 0 rgba(255,255,255,.35); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--glass-2); border-color: var(--line); }
.btn.danger { color: #fff; background: var(--danger); border: 0; }
.btn.danger.ghost { color: var(--danger); background: transparent; }
.btn.danger.ghost:hover { background: var(--danger-bg); }
.btn.ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.btn.soft { color: var(--brand); background: var(--brand-soft); border-color: transparent; }
.btn.sm { min-height: 32px; padding: 0 .7rem; font-size: .84rem; border-radius: 10px; }
.btn.icon { padding: 0; width: 40px; }
.btn.icon.sm { width: 32px; }
.btn.block { width: 100%; }
.grow { flex: 1; }

/* ---------- ورودی‌ها */
input, select, textarea {
  font: inherit; color: var(--ink); width: 100%; min-height: 42px; padding: .5rem .8rem; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--field); transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { resize: vertical; min-height: 70px; line-height: 1.8; }
select { appearance: none; padding-left: 2rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23765B63' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left .7rem center; }
select option, select optgroup { background: var(--bg-1); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); background-color: var(--field-focus); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand); padding: 0; }
input[type="color"] { padding: 3px; height: 42px; cursor: pointer; }
.invalid { border-color: var(--danger) !important; outline: 2px solid var(--danger) !important; outline-offset: 1px; }
input.money { font-variant-numeric: tabular-nums; text-align: left; }

.form-grid { display: grid; gap: .9rem 1rem; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field.full, .form-grid .full { grid-column: 1 / -1; }
.field .lbl { font-size: .84rem; font-weight: 600; color: var(--ink-2); }
.field .req { color: var(--brand); font-style: normal; margin-inline-start: 2px; }
.field.check { flex-direction: row; align-items: center; gap: .55rem; cursor: pointer; padding: .55rem .75rem; border-radius: 12px; background: var(--glass-2); border: 1px solid var(--line); }
.field .hint { font-size: .76rem; }
.form-section { font-weight: 800; font-size: .85rem; color: var(--brand); padding-top: .5rem; margin-bottom: -.3rem; display: flex; align-items: center; gap: .5rem; }
.form-section::after { content: ''; flex: 1; height: 1px; background: var(--line-2); }
.form-error { color: var(--danger); background: var(--danger-bg); padding: .6rem .9rem; border-radius: 12px; font-size: .88rem; font-weight: 600; }

/* انتخابگرِ تاریخ */
.date-input { position: relative; }
.date-input input { padding-left: 2.2rem; text-align: right; font-variant-numeric: tabular-nums; }
.date-ic { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; display: flex; }
.datepop { position: absolute; top: calc(100% + 6px); right: 0; z-index: 60; width: 286px; padding: .7rem; border-radius: 18px; }
.datepop.up { top: auto; bottom: calc(100% + 6px); }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.dp-wd { font-size: .75rem; color: var(--muted); font-weight: 700; padding: .2rem 0; }
.dp-day { font: inherit; font-size: .88rem; border: 0; background: transparent; color: var(--ink); height: 34px; border-radius: 10px; cursor: pointer; }
.dp-day:hover { background: var(--brand-soft); }
.dp-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); font-weight: 800; }
.dp-day.fri { color: var(--danger); }
.dp-day.sel { background: linear-gradient(135deg, var(--accent), var(--brand)); color: #fff; font-weight: 800; }
.dp-foot { display: flex; justify-content: space-between; margin-top: .4rem; }

/* انتخابِ مراجع */
.patient-picker { position: relative; }
.pp-list { position: absolute; top: calc(100% + 6px); inset-inline: 0; z-index: 60; border-radius: 16px; padding: .35rem; max-height: 330px; overflow: auto; }
.pp-item { display: flex; gap: .65rem; align-items: center; width: 100%; font: inherit; color: var(--ink); text-align: right; border: 0; background: transparent; padding: .5rem .6rem; border-radius: 12px; cursor: pointer; }
.pp-item:hover, .pp-item:focus { background: var(--brand-soft); outline: none; }
.pp-item span { display: flex; flex-direction: column; line-height: 1.45; }
.pp-new { color: var(--brand); }
.pp-none { padding: .6rem; color: var(--muted); font-size: .88rem; }
.pp-selected { display: flex; align-items: center; gap: .6rem; min-height: 42px; padding: .25rem .5rem .25rem .25rem; border-radius: 12px; background: var(--brand-soft); border: 1px solid transparent; }
.pp-selected > span { flex: 1; font-weight: 700; }

/* ---------- چیپ/بج */
.chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; font-weight: 700; padding: .12rem .6rem; border-radius: 999px; background: var(--mute-bg); color: var(--muted); white-space: nowrap; line-height: 1.7; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.violet { background: var(--violet-bg); color: var(--violet); }
.chip.brand { background: var(--brand-soft); color: var(--brand); }
.chip.gold { background: linear-gradient(135deg, rgba(201,150,43,.22), rgba(240,200,120,.25)); color: var(--warn); }
.chip svg { width: 13px; height: 13px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; }

.avatar {
  --av: var(--brand); display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 12px; font-weight: 800; font-size: .85rem;
  color: #fff; background: linear-gradient(135deg, color-mix(in srgb, var(--av) 70%, #fff), var(--av)); box-shadow: 0 4px 10px -6px rgba(46,29,34,.35);
}
.avatar.lg { width: 64px; height: 64px; border-radius: 20px; font-size: 1.35rem; }

/* ---------- اسکلتِ صفحه */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 14px; height: calc(100vh - 28px); margin: 14px 14px 14px 0; border-radius: var(--r-xl);
  display: flex; flex-direction: column; padding: 1.1rem .8rem; z-index: 40;
}
.brand { display: flex; align-items: center; gap: .7rem; padding: .2rem .5rem 1rem; border-bottom: 1px solid var(--line); margin-bottom: .6rem; }
.brand img { width: 44px; height: 44px; border-radius: 14px; background: #fff; padding: 3px; box-shadow: 0 8px 20px -10px rgba(46, 29, 34, .32); }
.brand strong { display: block; font-size: 1rem; font-weight: 900; line-height: 1.4; }
.brand small { display: block; line-height: 1.3; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; padding: .2rem 0; scrollbar-width: thin; }
.nav-group { font-size: .72rem; font-weight: 800; color: var(--muted); padding: .8rem .8rem .25rem; letter-spacing: .02em; }
.nav a {
  display: flex; align-items: center; gap: .75rem; padding: .58rem .8rem; border-radius: 14px; color: var(--ink-2); font-weight: 600; font-size: .93rem;
  text-decoration: none; transition: background .18s, color .18s, transform .18s var(--ease); position: relative;
}
.nav a:hover { background: var(--glass-2); color: var(--ink); }
.nav a.active { color: #fff; background: linear-gradient(135deg, var(--accent), var(--brand) 60%); box-shadow: 0 10px 22px -12px rgba(46, 29, 34, .32), inset 0 1px 0 rgba(255,255,255,.3); }
.nav a .badge { margin-inline-start: auto; font-size: .72rem; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 800; }
.nav a.active .badge { background: rgba(255,255,255,.28); }
.side-foot { border-top: 1px solid var(--line); padding-top: .7rem; display: flex; align-items: center; gap: .6rem; }
.side-foot .who { flex: 1; min-width: 0; line-height: 1.45; }
.side-foot .who b { display: block; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { min-width: 0; padding: 14px 14px 40px; display: flex; flex-direction: column; gap: 1.1rem; }
.topbar { position: sticky; top: 14px; z-index: 30; display: flex; align-items: center; gap: .7rem; padding: .55rem .6rem .55rem .9rem; border-radius: var(--r-lg); }
.topbar .search { position: relative; flex: 1; max-width: 460px; }
.topbar .search input { padding-right: 2.5rem; background: var(--glass-2); border-color: transparent; }
.topbar .search svg { position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar .today { font-weight: 700; color: var(--ink-2); font-size: .9rem; white-space: nowrap; }
.menu-btn { display: none; }
.view { display: flex; flex-direction: column; gap: 1.1rem; animation: rise .35s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .3rem .3rem 0; }
.page-head h1 { font-size: 1.55rem; letter-spacing: -.01em; }
.page-head p { color: var(--muted); margin-top: .15rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.card { border-radius: var(--r-lg); padding: 1.1rem 1.2rem; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .7rem; margin-bottom: .85rem; flex-wrap: wrap; }
.card-head h3 { font-size: 1rem; display: flex; align-items: center; gap: .5rem; }
.card-head h3 svg { color: var(--brand); }
.card-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.card.flush { padding: 0; }
.card.flush .card-head { padding: 1rem 1.2rem 0; }

.grid { display: grid; gap: 1.1rem; }
.grid.kpis { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.grid.two { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.grid.halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.thirds { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpi { display: flex; gap: .85rem; align-items: center; border-radius: var(--r-lg); padding: 1rem 1.1rem; text-align: right; font: inherit; color: inherit; cursor: default; }
button.kpi { cursor: pointer; transition: transform .2s var(--ease); }
button.kpi:hover { transform: translateY(-2px); }
.kpi-ic { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; flex: none; color: var(--brand); background: var(--brand-soft); }
.kpi.gold .kpi-ic { color: var(--warn); background: var(--warn-bg); }
.kpi.violet .kpi-ic { color: var(--violet); background: var(--violet-bg); }
.kpi.ok .kpi-ic { color: var(--ok); background: var(--ok-bg); }
.kpi.info .kpi-ic { color: var(--info); background: var(--info-bg); }
.kpi.danger .kpi-ic { color: var(--danger); background: var(--danger-bg); }
.kpi-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.45; }
.kpi-label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 1.35rem; font-weight: 900; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-body small { font-size: .76rem; }

/* ---------- جدول */
.tbl-wrap { overflow-x: auto; margin: 0 -.2rem; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.tbl th { text-align: right; font-size: .78rem; color: var(--muted); font-weight: 700; padding: .55rem .7rem; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl td { padding: .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.clickable { cursor: pointer; transition: background .15s; }
.tbl tr.clickable:hover td { background: var(--glass-2); }
.tbl tr.clickable:hover td:first-child { border-radius: 0 12px 12px 0; }
.tbl tr.clickable:hover td:last-child { border-radius: 12px 0 0 12px; }
.tbl tr.muted td { opacity: .5; }
.tbl .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .end { text-align: left; }
.tbl .nowrap { white-space: nowrap; }
.cell-person { display: flex; align-items: center; gap: .6rem; }
.cell-person b { display: block; line-height: 1.4; }
.cell-person small { display: block; line-height: 1.3; }
.pos { color: var(--ok); font-weight: 700; }
.neg { color: var(--danger); font-weight: 700; }

.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.toolbar input[type="search"], .toolbar .search-in { max-width: 300px; }
.toolbar select { width: auto; min-width: 150px; }
.toolbar .date-input { width: 150px; }

.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--glass-2); border: 1px solid var(--line); flex-wrap: wrap; }
.tab { font: inherit; font-weight: 700; font-size: .88rem; border: 0; background: transparent; color: var(--muted); padding: .42rem .95rem; border-radius: 11px; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; transition: background .15s, color .15s; }
.tab:hover { color: var(--ink); }
.tab.active { background: var(--glass-strong); color: var(--brand); box-shadow: 0 4px 12px -6px rgba(46, 29, 34, .25); }
.tab-count { font-size: .72rem; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 0 .45rem; }

.empty { display: flex; flex-direction: column; align-items: center; gap: .6rem; padding: 2.2rem 1rem; color: var(--muted); text-align: center; }
.empty-ic { width: 60px; height: 60px; border-radius: 20px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.loading { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; padding: 2.5rem; color: var(--muted); font-size: .85rem; }
.loading::before { content: 'در حال بارگذاری…'; }
.loading::after { content: ''; width: 140px; height: 3px; border-radius: 3px; background: linear-gradient(90deg, transparent, var(--accent), transparent) no-repeat, var(--line); background-size: 40% 100%, 100% 100%; animation: loadbar 1.2s var(--ease) infinite; }
.loading span { display: none; }
@keyframes loadbar { from { background-position: -60% 0, 0 0; } to { background-position: 160% 0, 0 0; } }

/* ---------- مودال و کشو */
.modal-wrap { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem; }
.modal-scrim { position: absolute; inset: 0; background: rgba(30, 12, 20, .28); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); opacity: 0; transition: opacity .22s; }
.modal {
  position: relative; width: min(680px, 100%); max-height: calc(100vh - 2rem); display: flex; flex-direction: column; border-radius: var(--r-xl);
  background: var(--glass-strong); border: 1px solid var(--glass-border); box-shadow: 0 40px 90px -30px rgba(20, 12, 16, .45);
  backdrop-filter: saturate(180%) blur(30px); -webkit-backdrop-filter: saturate(180%) blur(30px);
  transform: translateY(14px) scale(.98); opacity: 0; transition: transform .26s var(--ease), opacity .22s;
}
.modal.sm { width: min(440px, 100%); } .modal.lg { width: min(900px, 100%); } .modal.xl { width: min(1100px, 100%); }
.modal-wrap.in .modal-scrim { opacity: 1; } .modal-wrap.in .modal { transform: none; opacity: 1; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.3rem .6rem; }
.modal-head h2 { font-size: 1.1rem; }
.modal-body { padding: .4rem 1.3rem 1.2rem; overflow-y: auto; }
.modal-foot { display: flex; gap: .5rem; align-items: center; padding: .8rem 1.3rem 1.1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-wrap.is-drawer { place-items: stretch; justify-items: start; padding: 0; }
.modal.drawer { height: 100vh; max-height: none; width: min(460px, 100%); border-radius: var(--r-xl) 0 0 var(--r-xl); transform: translateX(-30px); }
.modal-wrap.in .modal.drawer { transform: none; }
.confirm-text { margin-bottom: .8rem; line-height: 1.9; }

/* ---------- توست */
#toasts { position: fixed; bottom: 18px; left: 18px; z-index: 200; display: flex; flex-direction: column; gap: .5rem; }
.toast { display: flex; align-items: center; gap: .6rem; padding: .75rem 1rem; border-radius: 14px; font-weight: 600; font-size: .9rem; background: var(--glass-strong); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); transform: translateY(12px); opacity: 0; transition: .25s var(--ease); max-width: 380px; }
.toast.in { transform: none; opacity: 1; }
.toast.ok svg { color: var(--ok); } .toast.err svg { color: var(--danger); }

/* ---------- نمودارها */
.chart-box { position: relative; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line-2); stroke-dasharray: 3 5; }
.chart .axis { fill: var(--muted); font-size: 10.5px; font-family: inherit; }
.chart .guide { stroke: var(--accent); stroke-dasharray: 4 4; }
.chart-tip { position: absolute; top: 0; min-width: 160px; padding: .5rem .7rem; font-size: .8rem; border-radius: 12px; background: var(--glass-strong); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); pointer-events: none; line-height: 1.7; }
.chart-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: .35rem; }
.chart-legend { display: flex; gap: 1rem; font-size: .82rem; color: var(--muted); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: .35rem; vertical-align: -1px; }
.donut-box { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.donut .donut-track { stroke: var(--line); }
.donut .donut-v { font-size: 17px; font-weight: 900; fill: var(--ink); font-family: inherit; }
.donut .donut-l { font-size: 10px; fill: var(--muted); font-family: inherit; }
.legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: .35rem; font-size: .86rem; }
.legend li { display: grid; grid-template-columns: 10px 1fr auto 40px; gap: .5rem; align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend small { text-align: left; }
.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .75rem; }
.hb-top { display: flex; justify-content: space-between; gap: .6rem; font-size: .88rem; margin-bottom: .25rem; }
.hb-top span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.hb-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), var(--accent)); }

/* ---------- داشبورد */
.hello { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-radius: var(--r-xl); padding: 1.4rem 1.6rem; overflow: hidden; }
.hello h1 { font-size: 1.5rem; }
.hello p { color: var(--muted); }
.hello::after { content: ''; position: absolute; left: -40px; top: -60px; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(circle, rgba(240,92,133,.35), transparent 70%); pointer-events: none; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.tl-item { display: grid; grid-template-columns: 58px 4px 1fr auto; gap: .8rem; align-items: center; padding: .55rem .6rem; border-radius: 14px; cursor: pointer; transition: background .15s; }
.tl-item:hover { background: var(--glass-2); }
.tl-time { font-weight: 800; font-variant-numeric: tabular-nums; text-align: center; line-height: 1.3; }
.tl-time small { display: block; font-weight: 500; }
.tl-bar { width: 4px; height: 100%; min-height: 38px; border-radius: 4px; background: var(--c, var(--brand)); }
.tl-main b { display: block; line-height: 1.5; }
.tl-main small { display: block; line-height: 1.4; }
.tl-item.past { opacity: .6; }
.tl-item.now { background: var(--brand-soft); }
.alerts-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.alerts-list li { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: 12px; background: var(--glass-2); font-size: .9rem; }
.alerts-list li b { flex: 1; }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: .4rem; align-items: end; height: 120px; }
.ws-col { display: flex; flex-direction: column; align-items: center; gap: .3rem; height: 100%; justify-content: flex-end; cursor: pointer; }
.ws-bar { width: 100%; max-width: 34px; border-radius: 10px 10px 6px 6px; background: linear-gradient(180deg, var(--accent), var(--brand)); min-height: 6px; }
.ws-col.off .ws-bar { background: var(--line-2); }
.ws-col small { font-size: .72rem; }
.ws-col b { font-size: .8rem; }

/* ---------- تقویمِ نوبت‌دهی */
.cal-toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; border-radius: var(--r-lg); padding: .6rem .7rem; }
.cal-title { font-weight: 900; font-size: 1.05rem; padding: 0 .4rem; min-width: 200px; }
.cal-title small { display: block; font-weight: 500; line-height: 1.2; }
.cal { border-radius: var(--r-lg); overflow: hidden; padding: 0; }
.cal-scroll { overflow: auto; max-height: calc(100vh - 220px); }
.cal-grid { display: grid; position: relative; min-width: 100%; }
.cal-head { position: sticky; top: 0; z-index: 5; display: contents; }
.cal-colhead { position: sticky; top: 0; z-index: 4; padding: .6rem .5rem; text-align: center; font-weight: 800; font-size: .88rem; background: var(--glass-strong); border-bottom: 1px solid var(--line-2); border-inline-start: 1px solid var(--line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); line-height: 1.4; }
.cal-colhead small { display: block; font-weight: 500; }
.cal-colhead.today { color: var(--brand); }
.cal-colhead .dot { margin-inline-end: .35rem; }
.cal-corner { position: sticky; top: 0; right: 0; z-index: 6; background: var(--glass-strong); border-bottom: 1px solid var(--line-2); }
.cal-times { position: sticky; right: 0; z-index: 3; background: var(--glass-strong); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.cal-time { height: var(--slot-h); font-size: .72rem; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; transform: translateY(-.6em); }
.cal-col { position: relative; border-inline-start: 1px solid var(--line); }
.cal-col.closed { background: repeating-linear-gradient(135deg, transparent 0 8px, var(--line) 8px 9px); }
.cal-slot { height: var(--slot-h); border-top: 1px solid var(--line); cursor: copy; }
.cal-slot.hour { border-top-color: var(--line-2); }
.cal-slot:hover { background: var(--brand-soft); }
.cal-now { position: absolute; inset-inline: 0; height: 2px; background: var(--brand); z-index: 2; pointer-events: none; }
.cal-now::before { content: ''; position: absolute; right: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.appt {
  --c: var(--brand); position: absolute; z-index: 2; border-radius: 12px; padding: .3rem .5rem; overflow: hidden; cursor: pointer; font-size: .78rem; line-height: 1.45;
  background: color-mix(in srgb, var(--c) 16%, var(--glass-strong)); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  box-shadow: 0 6px 14px -10px rgba(46,29,34,.3); transition: transform .15s var(--ease), box-shadow .15s;
  color: var(--ink);
}
.appt:hover { transform: translateY(-1px); box-shadow: 0 12px 22px -12px rgba(46,29,34,.4); z-index: 3; }
.appt b { display: block; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.appt.cancelled, .appt.no_show { opacity: .45; text-decoration: line-through; }
.appt.done { background: color-mix(in srgb, var(--c) 7%, var(--glass)); }
.appt .appt-st { position: absolute; top: 5px; left: 6px; width: 8px; height: 8px; border-radius: 50%; }
.appt-st.booked { background: var(--info); } .appt-st.confirmed { background: var(--violet); } .appt-st.arrived, .appt-st.in_progress { background: var(--warn); } .appt-st.done { background: var(--ok); }
.legend-row { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); padding: .2rem .4rem; }
.legend-row span { display: inline-flex; align-items: center; gap: .35rem; }

.detail-list { display: grid; grid-template-columns: auto 1fr; gap: .45rem 1rem; font-size: .92rem; }
.detail-list dt { color: var(--muted); font-weight: 600; }
.detail-list dd { margin: 0; font-weight: 600; }
.action-row { display: flex; gap: .45rem; flex-wrap: wrap; }
.status-row { display: flex; gap: .35rem; flex-wrap: wrap; margin: .9rem 0; }
.status-row .btn.on { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

/* ---------- پرونده‌ی بیمار */
.pt-hero { display: grid; grid-template-columns: auto 1fr auto; gap: 1.1rem; align-items: center; border-radius: var(--r-xl); padding: 1.3rem 1.4rem; }
.pt-hero h1 { font-size: 1.4rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.pt-meta { display: flex; gap: .4rem 1rem; flex-wrap: wrap; color: var(--muted); font-size: .88rem; margin-top: .2rem; }
.pt-meta span { display: inline-flex; align-items: center; gap: .3rem; }
.pt-flags { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .55rem; }
.pt-balance { text-align: left; }
.pt-balance strong { display: block; font-size: 1.3rem; font-weight: 900; }
.pt-actions { display: flex; gap: .45rem; flex-wrap: wrap; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem 1.2rem; }
.info-item span { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; }
.info-item b { font-weight: 600; white-space: pre-wrap; }
.medical-alert { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem 1rem; border-radius: 14px; background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.tx-list { list-style: none; margin: 0; padding: 0; position: relative; }
.tx-list::before { content: ''; position: absolute; right: 17px; top: 8px; bottom: 8px; width: 2px; background: var(--line-2); }
.tx { position: relative; padding: 0 3.1rem 1.1rem 0; }
.tx::before { content: ''; position: absolute; right: 11px; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--c, var(--brand)); border: 3px solid var(--glass-strong); box-sizing: content-box; right: 8px; }
.tx-card { border-radius: 16px; padding: .8rem 1rem; background: var(--glass-2); border: 1px solid var(--line); }
.tx-top { display: flex; justify-content: space-between; gap: .6rem; align-items: center; flex-wrap: wrap; }
.tx-top b { font-size: .98rem; }
.tx-fields { display: flex; gap: .3rem .9rem; flex-wrap: wrap; font-size: .85rem; color: var(--ink-2); margin-top: .35rem; }
.tx-fields span b { color: var(--muted); font-weight: 600; margin-inline-end: .2rem; }
.tx-notes { font-size: .88rem; margin-top: .35rem; white-space: pre-wrap; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.ph { position: relative; border-radius: 16px; overflow: hidden; background: var(--glass-2); border: 1px solid var(--line); aspect-ratio: 3 / 4; cursor: pointer; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s var(--ease); }
.ph:hover img { transform: scale(1.04); }
.ph .chip { position: absolute; top: 8px; right: 8px; background: var(--glass-strong); }
.ph .ph-cap { position: absolute; inset-inline: 0; bottom: 0; padding: 1.4rem .6rem .45rem; font-size: .76rem; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.ph.sel { outline: 3px solid var(--brand); outline-offset: -3px; }
.ph.doc { display: grid; place-items: center; color: var(--brand); }
.dropzone { border: 2px dashed var(--line-2); border-radius: 18px; padding: 1.2rem; text-align: center; color: var(--muted); transition: border-color .2s, background .2s; cursor: pointer; }
.dropzone.over { border-color: var(--accent); background: var(--brand-soft); }
.compare { position: relative; width: 100%; max-width: 720px; margin: 0 auto; aspect-ratio: 3 / 4; border-radius: 18px; overflow: hidden; user-select: none; background: #000; }
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.compare .cmp-top { clip-path: inset(0 0 0 var(--pos, 50%)); }
.compare .cmp-line { position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); width: 3px; background: #fff; transform: translateX(-50%); box-shadow: 0 0 12px rgba(0,0,0,.4); }
.compare .cmp-line::after { content: '⟷'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; border-radius: 50%; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 900; }
.compare input[type="range"] { position: absolute; inset: 0; opacity: 0; cursor: ew-resize; height: 100%; }
.cmp-tag { position: absolute; bottom: 10px; padding: .15rem .6rem; border-radius: 99px; background: rgba(0,0,0,.55); color: #fff; font-size: .78rem; }
.pkg { display: flex; align-items: center; gap: 1rem; padding: .8rem 1rem; border-radius: 16px; background: var(--glass-2); border: 1px solid var(--line); }
.pkg-ring { --p: 0; width: 54px; height: 54px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 900; font-size: .8rem; background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--line-2) 0); position: relative; }
.pkg-ring::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--glass-strong); }
.pkg-ring span { position: relative; }
.pkg-main { flex: 1; min-width: 0; }

/* ---------- فاکتور */
.inv-rows { display: flex; flex-direction: column; gap: .5rem; }
.inv-row { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.3fr) 70px minmax(0, 1.2fr) minmax(0, 1fr) 36px; gap: .45rem; align-items: center; }
.inv-row.head { font-size: .76rem; color: var(--muted); font-weight: 700; }
.inv-sum { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1.5rem; margin-top: 1rem; padding: .9rem 1rem; border-radius: 16px; background: var(--glass-2); font-size: .95rem; }
.inv-sum b { text-align: left; font-variant-numeric: tabular-nums; }
.inv-sum .total { font-size: 1.15rem; font-weight: 900; color: var(--brand); }
.pay-rows { display: flex; flex-direction: column; gap: .5rem; }
.pay-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 1.3fr) 36px; gap: .45rem; align-items: center; }

/* ---------- ورود */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.auth-card { width: min(430px, 100%); border-radius: 30px; padding: 2.2rem 2rem 1.8rem; }
.auth-brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .6rem; margin-bottom: 1.6rem; }
.auth-brand img { width: 76px; height: 76px; border-radius: 24px; background: #fff; padding: 5px; box-shadow: 0 16px 34px -14px rgba(46, 29, 34, .32); }
.auth-brand h1 { font-size: 1.35rem; }
.auth-brand p { color: var(--muted); font-size: .9rem; }
.auth form { display: flex; flex-direction: column; gap: .9rem; }
.auth .btn.primary { min-height: 48px; font-size: 1rem; margin-top: .3rem; }
.auth-foot { text-align: center; margin-top: 1.2rem; font-size: .78rem; color: var(--muted); }

.muted { color: var(--muted); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: .6rem; }
.mono { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: plaintext; }
.big-num { font-size: 1.6rem; font-weight: 900; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; direction: ltr; text-align: left; background: var(--glass-2); border: 1px solid var(--line); padding: .7rem .9rem; border-radius: 12px; white-space: pre-wrap; word-break: break-all; }
.svc-group { margin-bottom: 1.2rem; }
.svc-group h4 { display: flex; align-items: center; gap: .5rem; font-size: .95rem; margin: 0 0 .5rem; }
.scrim { display: none; }

/* ---------- واکنش‌گرا */
@media (max-width: 1180px) {
  .grid.two, .grid.thirds { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; right: 0; bottom: 0; height: 100vh; margin: 0; width: min(290px, 86vw); border-radius: var(--r-xl) 0 0 var(--r-xl); transform: translateX(105%); transition: transform .3s var(--ease); background: var(--glass-strong); }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(30, 12, 20, .3); backdrop-filter: blur(4px); }
  .menu-btn { display: inline-flex; }
  .topbar .today { display: none; }
  .grid.halves { grid-template-columns: 1fr; }
  .pt-hero { grid-template-columns: auto 1fr; }
  .pt-balance { grid-column: 1 / -1; text-align: right; }
}
@media (max-width: 640px) {
  body { font-size: 14px; }
  .main { padding: 10px 10px 30px; }
  .topbar { top: 10px; }
  .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 1.3rem; }
  .card { padding: .95rem; }
  .kpi-value { font-size: 1.15rem; }
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
  .kpi { padding: .8rem; gap: .6rem; }
  .kpi-ic { width: 38px; height: 38px; border-radius: 12px; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { padding: .6rem .2rem; border-bottom: 1px solid var(--line); }
  .tbl td { border: 0; padding: .15rem .3rem; display: flex; justify-content: space-between; gap: 1rem; }
  .tbl td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 600; }
  .tbl td.end { text-align: right; }
  .inv-row { grid-template-columns: 1fr 1fr; }
  .inv-row.head { display: none; }
  .pay-row { grid-template-columns: 1fr 1fr; }
  .modal-wrap { padding: 0; place-items: end stretch; }
  .modal { width: 100% !important; max-height: 92vh; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .modal.drawer { height: 92vh; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .hello { padding: 1.1rem; }
  .toolbar select, .toolbar input[type="search"], .toolbar .date-input { width: 100%; max-width: none; }
}
@media print {
  .sidebar, .topbar, .page-actions, .backdrop, .card-actions, .toolbar, .tabs { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .glass, .glass-strong { background: #fff !important; box-shadow: none !important; backdrop-filter: none !important; border: 1px solid #ddd; }
  .card, .kpi { break-inside: avoid; }
  @page { size: A4; margin: 12mm; }
}

/* ============================================================ نسخه‌ی ۱٫۱: بدهکاری، پذیرشِ لحظه‌ای، خلاصه‌ی بالینی، دوز، انبارِ چندبارمصرف */
.alert-box { display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; border-radius: 14px; font-size: .9rem; margin-bottom: .6rem; }
.alert-box small { display: block; }
.alert-box.danger { background: var(--danger-bg); color: var(--danger); }
.alert-box.warn { background: var(--warn-bg); color: var(--warn); }
.alert-box.ok { background: var(--ok-bg); color: var(--ok); }
.alert-box.info { background: var(--info-bg); color: var(--info); }
.alert-box .btn { flex: none; }
.pt-hero.has-debt { border-color: var(--danger); }
.pt-balance .btn { margin-top: .4rem; }
.appt-debt { position: absolute; bottom: 5px; left: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--danger); color: #fff; font-style: normal; font-size: .7rem; font-weight: 900; display: grid; place-items: center; line-height: 1; }
.watch-card { border: 1px solid var(--danger-bg); }
.alerts-list li.debt { background: var(--danger-bg); }
.alerts-list li small { flex: 1; }

/* تیپ پوست */
.skin-picker { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .45rem; }
.skin-opt { font: inherit; display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .5rem .3rem; border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--glass-2); color: var(--ink); cursor: pointer; transition: transform .15s var(--ease), border-color .15s, box-shadow .15s; }
.skin-opt:hover { transform: translateY(-2px); border-color: var(--accent); }
.skin-opt.on { border-color: var(--brand); outline: 2px solid var(--brand); outline-offset: 1px; background: var(--glass-strong); }
.skin-opt b { font-size: .95rem; line-height: 1.2; }
.skin-opt small { font-size: .7rem; line-height: 1.3; text-align: center; }
.skin-sw { width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.skin-picker.compact .skin-sw { width: 22px; height: 22px; }
@media (max-width: 640px) { .skin-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* دوز */
.dose-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.dose { font: inherit; font-weight: 800; min-width: 58px; min-height: 40px; padding: .3rem .7rem; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--glass-2); color: var(--ink); cursor: pointer; transition: all .15s; }
.dose small { font-weight: 500; color: var(--muted); }
.dose:hover { border-color: var(--gold); }
.dose.on { background: linear-gradient(135deg, #DDAE47, var(--gold)); color: #fff; border-color: transparent; }
.dose.on small { color: rgba(255,255,255,.85); }
.dose-hist { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.dose-pill { display: flex; flex-direction: column; align-items: center; padding: .2rem .55rem; border-radius: 10px; background: var(--warn-bg); line-height: 1.35; }
.dose-pill b { color: var(--warn); }
.dose-pill small { font-size: .68rem; }

/* خلاصه‌ی بالینی */
.clin-sum { display: flex; flex-direction: column; gap: .9rem; }
.sum-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .8rem; }
.sum-block { padding: .8rem .9rem; border-radius: 16px; background: var(--glass-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.sum-title { display: flex; align-items: center; gap: .4rem; font-weight: 800; font-size: .88rem; color: var(--ink-2); flex-wrap: wrap; }
.sum-title svg { color: var(--brand); }
.sum-title small { font-weight: 500; margin-inline-start: auto; }
.sum-plan { white-space: pre-wrap; font-weight: 600; }
.spark { display: block; flex: none; max-width: 100%; }
.tbl.compact td, .tbl.compact th { padding: .45rem .55rem; }

/* پذیرشِ لحظه‌ای */
.live-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.live-col { border-radius: var(--r-lg); padding: .8rem; min-height: 200px; }
.live-col > header { display: flex; align-items: center; gap: .45rem; padding: .2rem .3rem .7rem; }
.live-col > header b { flex: 1; }
.live-count { min-width: 28px; height: 28px; border-radius: 10px; display: grid; place-items: center; font-weight: 900; background: var(--glass-strong); }
.live-col.tone-warn > header { color: var(--warn); } .live-col.tone-brand > header { color: var(--brand); }
.live-col.tone-ok > header { color: var(--ok); } .live-col.tone-info > header { color: var(--info); }
.live-list { display: flex; flex-direction: column; gap: .6rem; }
.live-card { background: color-mix(in srgb, var(--c) 7%, var(--glass-strong)); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); border-radius: 16px; padding: .7rem .75rem; display: flex; flex-direction: column; gap: .4rem; box-shadow: 0 6px 16px -12px rgba(46,29,34,.4); }
.live-card.has-debt { border-color: var(--danger); }
.live-name { display: block; cursor: pointer; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-name:hover { color: var(--brand); }
.live-card small { display: block; line-height: 1.4; }
.live-where { display: flex; align-items: center; gap: .3rem; font-size: .84rem; font-weight: 700; color: var(--brand); }
.live-where.warn { color: var(--warn); }
.live-actions { display: flex; flex-wrap: wrap; gap: .3rem; }
.live-empty { text-align: center; padding: 1.2rem 0; font-size: .88rem; }
@media (max-width: 1180px) { .live-board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .live-board { grid-template-columns: 1fr; } }

/* دسترسی‌ها */
.caps-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.caps-grid.disabled { opacity: .55; }
.caps-group { border: 1px solid var(--line-2); border-radius: 14px; padding: .5rem .7rem .7rem; display: flex; flex-direction: column; gap: .35rem; margin: 0; }
.caps-group legend { font-weight: 800; font-size: .85rem; color: var(--brand); padding: 0 .3rem; }
.caps-group .field.check { padding: .35rem .55rem; }
@media (max-width: 640px) { .caps-grid { grid-template-columns: 1fr; } }

/* رنگِ خدمت */
.svc-sw { display: inline-block; width: 14px; height: 14px; border-radius: 5px; vertical-align: -2px; margin-inline-end: .4rem; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); flex: none; }
.svc-bars { display: flex; flex-direction: column; gap: .5rem; }
.svc-bar { display: grid; grid-template-columns: 14px minmax(120px, 220px) 1fr 44px 60px; gap: .6rem; align-items: center; font-size: .88rem; }
.svc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .svc-bar { grid-template-columns: 14px 1fr 40px; } .svc-bar .hb-track, .svc-bar small { display: none; } }
.body-cmp td:last-child { width: 150px; }

/* ============================================================ نسخه‌ی ۱٫۲: رضایت‌نامه‌ی دیجیتال و حالتِ تبلت */
.btn.big { min-height: 54px; padding: 0 1.6rem; font-size: 1.05rem; border-radius: 16px; }
.consent-form, .intake { display: flex; flex-direction: column; gap: 1.1rem; }
.cf-head h2 { font-size: 1.3rem; color: var(--brand); }
.cf-head p { color: var(--muted); margin-top: .3rem; }
.cf-sec { border-top: 1px solid var(--line); padding-top: 1rem; }
.cf-sec h3 { font-size: 1rem; margin-bottom: .6rem; }
.consent-text { line-height: 2.05; font-size: 1rem; }
.consent-text h3 { font-size: .98rem; color: var(--brand); margin: 1rem 0 .3rem; }
.consent-text p { margin-bottom: .5rem; }
.consent-text ul { margin: 0 0 .5rem; padding-inline-start: 1.3rem; }
.consent-text li { margin-bottom: .25rem; }
.q-list { display: flex; flex-direction: column; gap: .5rem; }
.q-row { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1rem; align-items: center; padding: .6rem .8rem; border-radius: 14px; background: var(--glass-2); border: 1px solid var(--line); }
.q-text { font-weight: 600; line-height: 1.8; }
.yn-note { grid-column: 1 / -1; color: var(--warn); font-weight: 700; }
.yn { display: inline-flex; gap: .35rem; }
.yn-btn, .seg-btn, .pick { font: inherit; font-weight: 700; min-width: 64px; min-height: 44px; padding: 0 1rem; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--glass-strong); color: var(--ink); cursor: pointer; }
.yn-btn.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.yn-btn.on:first-child { background: var(--ok); border-color: var(--ok); }
.seg { display: inline-flex; gap: .35rem; }
.seg-btn.on, .pick.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.pick-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.photo-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .5rem; }
.photo-opt { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--glass-2); cursor: pointer; font-weight: 600; }
.photo-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.photo-opt input { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand); }
.agree { display: flex; gap: .7rem; align-items: flex-start; font-weight: 700; margin-bottom: 1rem; cursor: pointer; line-height: 1.9; }
.agree input { width: 24px; height: 24px; min-height: 0; flex: none; margin-top: .2rem; accent-color: var(--brand); }
.big-check { min-height: 52px; }
.cf-actions { display: flex; gap: .6rem; align-items: center; }
.sig-wrap { position: relative; border: 2px dashed var(--line-2); border-radius: 18px; background: #fff; height: 220px; touch-action: none; }
.sig-wrap.inked { border-style: solid; border-color: var(--brand); }
.sig-canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; border-radius: 16px; }
.sig-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #b9a7ad; font-size: 1.1rem; pointer-events: none; }
.sig-wrap.inked .sig-hint { display: none; }
.sig-clear { position: absolute; top: 8px; left: 8px; color: #765B63; }
.sig-wrap::after { content: ''; position: absolute; inset-inline: 10%; bottom: 44px; border-bottom: 1px solid #e3d3d7; pointer-events: none; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.steps li { display: flex; align-items: center; gap: .45rem; padding: .5rem .6rem; border-radius: 12px; background: var(--glass-2); color: var(--muted); font-weight: 700; font-size: .88rem; }
.steps li b { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--line-2); color: var(--ink); flex: none; }
.steps li.on { color: var(--brand); background: var(--brand-soft); } .steps li.on b { background: var(--brand); color: #fff; }
.steps li.done b { background: var(--ok); color: #fff; }
.review { padding: .8rem 1rem; border-radius: 14px; background: var(--glass-2); font-size: 1.05rem; }
.consent-doc .sig-img { max-width: 320px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.hash { font-family: ui-monospace, Consolas, monospace; font-size: .72rem; direction: ltr; word-break: break-all; color: var(--muted); }

/* تبلت */
body.kiosk { font-size: 16px; }
.kiosk-idle { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; position: relative; }
.k-card { border-radius: 32px; padding: 2.6rem 2.4rem; text-align: center; max-width: 560px; width: 100%; display: flex; flex-direction: column; align-items: center; gap: .8rem; }
.k-card h1 { font-size: 1.7rem; }
.k-card p { font-size: 1.1rem; line-height: 2; color: var(--ink-2); }
.k-logo { width: 96px; height: 96px; border-radius: 28px; background: #fff; padding: 6px; }
.k-clock { font-size: 3.2rem; font-weight: 900; letter-spacing: .02em; color: var(--brand); line-height: 1.2; margin-top: .5rem; }
.k-check { width: 90px; height: 90px; border-radius: 50%; display: grid; place-items: center; background: var(--ok); color: #fff; }
.k-corner { position: absolute; top: 14px; left: 14px; border: 0; background: var(--glass-2); color: var(--muted); width: 40px; height: 40px; border-radius: 12px; cursor: pointer; }
.k-name { position: absolute; bottom: 12px; inset-inline: 0; text-align: center; }
.kiosk-task { max-width: 900px; margin: 0 auto; padding: 14px 14px 60px; display: flex; flex-direction: column; gap: 1rem; }
.k-top { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: 18px; background: var(--glass); }
.k-top img { width: 40px; height: 40px; border-radius: 12px; background: #fff; padding: 3px; }
.k-form { border-radius: 26px; padding: 1.5rem 1.6rem; }
.kiosk input, .kiosk select, .kiosk textarea { min-height: 52px; font-size: 1.05rem; }
.pair-code { font-size: 2.2rem !important; letter-spacing: .5em; text-align: center; font-weight: 900; min-height: 70px !important; }
@media (max-width: 640px) {
  .steps { grid-template-columns: repeat(2, 1fr); }
  .q-row { grid-template-columns: 1fr; }
  .k-form { padding: 1.1rem; }
}

/* ویرایشگرِ رضایت‌نامه */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.tpl-card { border-radius: var(--r-lg); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .55rem; min-height: 250px; }
.tpl-card.off { opacity: .6; }
.tpl-card h3 { font-size: 1rem; line-height: 1.6; }
.tpl-excerpt { font-size: .84rem; line-height: 1.9; }
.tpl-editor { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.1rem; align-items: start; }
.tpl-side { position: sticky; top: 90px; max-height: calc(100vh - 110px); overflow: auto; border-radius: var(--r-lg); }
.tpl-text { font-size: .95rem; line-height: 2; min-height: 420px; font-family: inherit; }
.tpl-toolbar { display: flex; gap: .3rem; flex-wrap: wrap; padding: .3rem; border-radius: 12px; background: var(--glass-2); border: 1px solid var(--line); }
.tpl-preview { background: #fff; color: #2E1D22; border-radius: 14px; padding: 1rem 1.2rem; border: 1px solid var(--line); }
.tpl-preview h3 { color: #D30F3F; }
.tpl-prev-title { font-size: 1.1rem; color: #D30F3F; margin-bottom: .6rem; }
.q-editor { display: flex; flex-direction: column; gap: .45rem; }
.q-edit-row { display: grid; grid-template-columns: 26px 1fr auto auto; gap: .45rem; align-items: center; }
.q-num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--line-2); font-size: .8rem; }
.flag-toggle { display: inline-flex; align-items: center; gap: .25rem; padding: .35rem .6rem; border-radius: 10px; border: 1.5px solid var(--line-2); font-size: .8rem; font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap; }
.flag-toggle input { width: 16px; height: 16px; min-height: 0; accent-color: var(--danger); }
.flag-toggle.on { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }
.btn.primary.unsaved { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (max-width: 1100px) { .tpl-editor { grid-template-columns: 1fr; } .tpl-side { position: static; max-height: none; } }
@media (max-width: 640px) { .q-edit-row { grid-template-columns: 26px 1fr; } }
