/* Personal Health Dashboard — فرانت‌اند (RTL، موبایل‌محور). بدون فونت یا کتابخانه خارجی. */
.phd, .phd * { box-sizing: border-box; }
.phd-body { margin: 0; background: #f6f5f2; }
.phd {
  --bg: #f6f5f2; --card: #fff; --ink: #1f2937; --muted: #6b7280; --line: #e7e5e0;
  --g: #0f766e; --g-soft: #e6f4f1; --blue: #3b82f6; --blue-soft: #e8f0fe; --orange: #f59e0b; --orange-soft: #fef3e0;
  --red: #dc2626; --red-soft: #fdecec; --purple: #8b5cf6; --purple-soft: #f0ebff; --brown: #92400e;
  --r: 16px; --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 4px 14px rgba(20, 20, 30, .04);
  font-family: Vazirmatn, "IRANSansX", "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
  color: var(--ink); line-height: 1.7; font-size: 15px; direction: rtl; text-align: right;
  min-height: 100vh; min-height: 100dvh; background: var(--bg);
  display: grid; grid-template-columns: 250px 1fr; -webkit-text-size-adjust: 100%;
}
.phd h1, .phd h2, .phd h3, .phd p { margin: 0; }
.phd h1 { font-size: 22px; font-weight: 800; } .phd h2 { font-size: 16px; font-weight: 700; } .phd h3 { font-size: 16px; margin-bottom: 8px; }
.phd small { font-size: 12px; color: var(--muted); font-weight: 400; }
.phd button { font: inherit; cursor: pointer; color: inherit; }
.phd input, .phd select, .phd textarea { font: inherit; color: inherit; }
.phd-ic { width: 20px; height: 20px; flex: 0 0 auto; vertical-align: middle; }
.phd-muted { color: var(--muted); font-size: 13px; }
.phd-center { text-align: center; margin: 4px 0 -4px; }
.phd-bad { color: var(--red); }
.phd-mt { margin-top: 12px; }
.phd-noscroll { overflow: hidden; }

/* چیدمان */
.phd-side { position: sticky; top: 0; height: 100vh; height: 100dvh; background: #fff; border-inline-end: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 14px; }
.phd-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; color: var(--g); padding: 4px 8px; }
.phd-brand .phd-ic { width: 26px; height: 26px; }
.phd-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.phd-nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 0; background: none; border-radius: 12px; text-align: right; color: #374151; text-decoration: none; font-size: 15px; }
.phd-nav-item:hover { background: #f3f4f6; } .phd-nav-item.on { background: var(--g-soft); color: var(--g); font-weight: 700; }
.phd-logout { color: var(--muted); }
.phd-main { padding: 22px; max-width: 980px; width: 100%; margin-inline: auto; min-width: 0; padding-bottom: 40px; }
.phd-bottom, .phd-more { display: none; }
#phd-view { display: flex; flex-direction: column; gap: 14px; transition: opacity .15s; }
#phd-view.is-loading { opacity: .5; pointer-events: none; }
.is-busy { cursor: progress; }

/* کارت و عناصر */
.phd-card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.phd-card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.phd-h2 { margin: 6px 2px 8px; }
.phd-head { display: flex; flex-direction: column; gap: 2px; }
.phd-grid { display: grid; gap: 12px; min-width: 0; }
.phd-cards { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.phd-meals { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.phd-quick { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.phd-note { background: var(--orange-soft); color: #92400e; border-radius: 12px; padding: 9px 12px; font-size: 13px; }
.phd-note-s { color: var(--muted); font-size: 12px; }
.phd-empty { color: var(--muted); text-align: center; padding: 18px 8px; background: #fafaf8; border-radius: 12px; font-size: 14px; }
.phd-loading { text-align: center; color: var(--muted); padding: 40px 0; }
.phd-error { color: var(--red); align-items: flex-start; }
.phd-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #f1f1ee; color: #4b5563; font-size: 12px; white-space: nowrap; }
.phd-pill.ok { background: var(--g-soft); color: var(--g); } .phd-pill.warn { background: var(--orange-soft); color: #b45309; }

/* دکمه‌ها */
.phd-btn { border: 1px solid transparent; border-radius: 12px; padding: 0 18px; min-height: 46px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: #f1f1ee; transition: transform .06s, opacity .15s; }
.phd-btn:active { transform: scale(.98); } .phd-btn:disabled { opacity: .5; cursor: not-allowed; }
.phd-btn-primary { background: var(--g); color: #fff; } .phd-btn-danger { background: var(--red); color: #fff; }
.phd-btn-ghost { background: #fff; border-color: var(--line); } .phd-btn-block { width: 100%; }
.phd-big { min-height: 54px; font-size: 16px; } .phd-sm { min-height: 38px; padding: 0 12px; font-size: 13px; }
.phd-iconbtn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #fff; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.phd-iconbtn.phd-danger { color: var(--red); } .phd-iconbtn:disabled { opacity: .35; }
.phd :focus-visible { outline: 3px solid rgba(15, 118, 110, .45); outline-offset: 2px; }

/* نوار تاریخ */
.phd-datebar { display: flex; align-items: center; gap: 8px; }
.phd-datebtn { flex: 1; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #fff; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; padding: 0 12px; }

/* فرم */
.phd-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.phd-field > span { font-size: 13px; color: #4b5563; }
.phd-field input, .phd-field select, .phd-field textarea, .phd-input { width: 100%; min-height: 46px; padding: 8px 12px; border-radius: 12px; border: 1px solid #d9d7d0; background: #fff; text-align: right; }
.phd-field textarea { min-height: 72px; resize: vertical; }
.phd-field input[type=time] { direction: ltr; text-align: center; }
.phd-check { display: flex; align-items: center; gap: 8px; min-height: 46px; }
.phd-check input { width: 20px; height: 20px; accent-color: var(--g); }
.phd-row2 { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.phd-actions { display: flex; gap: 8px; flex-wrap: wrap; } .phd-actions .phd-btn { flex: 1; }
.phd-form-msg { color: var(--red); font-size: 13px; min-height: 0; }
.phd-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.phd-chip input { position: absolute; opacity: 0; pointer-events: none; }
.phd-chip span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid #d9d7d0; background: #fff; cursor: pointer; }
.phd-chip input:checked + span { background: var(--g-soft); border-color: var(--g); color: var(--g); font-weight: 700; }
.phd-chip input:focus-visible + span { outline: 3px solid rgba(15, 118, 110, .45); }
.phd-opts { display: flex; flex-direction: column; gap: 6px; }
.phd-opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid #e0ded7; border-radius: 12px; cursor: pointer; min-height: 46px; }
.phd-opt input { accent-color: var(--g); width: 18px; height: 18px; }
.phd-opt:has(input:checked) { border-color: var(--g); background: var(--g-soft); }
.phd-dt { display: flex; gap: 8px; } .phd-dt .phd-input { flex: 1; cursor: pointer; } .phd-dt input[type=time] { width: 120px; }
.phd-est { background: var(--orange-soft); border-radius: 12px; padding: 8px 12px; font-size: 13px; color: #7c4a03; }
.phd-est:empty { display: none; }

/* کارت آماری */
.phd-stat { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 6px; border-top: 4px solid var(--g); min-width: 0; }
.phd-stat.blue { border-top-color: var(--blue); } .phd-stat.purple { border-top-color: var(--purple); } .phd-stat.orange { border-top-color: var(--orange); } .phd-stat.brown { border-top-color: var(--brown); } .phd-stat.teal { border-top-color: #14b8a6; }
.phd-stat-h { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.phd-stat-v { font-size: 20px; font-weight: 800; line-height: 1.4; } .phd-stat-v small { font-size: 12px; }
.phd-stat-s { font-size: 12px; color: var(--muted); }
.phd-bar { height: 8px; background: #eeece6; border-radius: 99px; overflow: hidden; }
.phd-bar i { display: block; height: 100%; background: var(--g); border-radius: 99px; transition: width .3s; }
.phd-status { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.phd-status li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid #f0eee9; font-size: 14px; }
.phd-status li:last-child { border: 0; } .phd-status li span { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.phd-status li.done span { color: var(--g); } .phd-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #d4d2cb; margin: 0 6px; display: inline-block; }
.phd-qa { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 88px; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); font-weight: 700; text-align: center; }
.phd-qa .phd-ic { width: 26px; height: 26px; color: var(--g); } .phd-qa.on { background: var(--g-soft); border-color: var(--g); }

/* تایمر و بنر */
.phd-banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--orange-soft); }
.phd-banner > div { flex: 1; } .phd-b-sleep { background: var(--purple-soft); }
.phd-timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 22px; direction: ltr; text-align: right; }
.phd-timer.big { font-size: 44px; text-align: center; padding: 6px 0; }
.phd-live { align-items: stretch; text-align: center; } .phd-live .phd-pill { align-self: center; }
.phd-live.sleep { background: linear-gradient(180deg, #f5f1ff, #fff); }

/* آب */
.phd-water { flex-direction: row; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.phd-ring { position: relative; width: 150px; height: 150px; }
.phd-ring svg { width: 100%; height: 100%; } .phd-ring circle { fill: none; stroke-width: 10; } .phd-ring .bg { stroke: #e8eefb; } .phd-ring .fg { stroke: var(--blue); stroke-linecap: round; transition: stroke-dasharray .4s; }
.phd-ring-t { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; } .phd-ring-t b { font-size: 26px; }
.phd-kvs { display: flex; flex-direction: column; flex: 1; min-width: 200px; } .phd-kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f0eee9; font-size: 14px; } .phd-kv:last-child { border: 0; } .phd-kv span { color: var(--muted); }

/* لیست‌ها */
.phd-logs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.phd-log { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid #f0eee9; }
.phd-log:last-child { border: 0; } .phd-log-t { display: flex; flex-direction: column; min-width: 0; } .phd-log-t strong { font-size: 14px; } .phd-log-a { display: flex; gap: 6px; }
.phd-tabs { display: flex; gap: 6px; background: #ebe9e3; padding: 4px; border-radius: 14px; } .phd-tabs.wrap { flex-wrap: wrap; }
.phd-tabs button { flex: 1; min-height: 40px; border: 0; background: none; border-radius: 10px; font-weight: 700; color: #4b5563; padding: 0 10px; } .phd-tabs button.on { background: #fff; color: var(--g); box-shadow: var(--shadow); }
.phd-energy { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.phd-energy button { min-height: 64px; border-radius: 12px; border: 1px solid #d9d7d0; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; } .phd-energy button b { font-size: 18px; } .phd-energy button.on { background: var(--g); color: #fff; border-color: var(--g); }
.phd-rep { display: flex; flex-direction: column; gap: 14px; }

/* نمودار */
.phd-chart { position: relative; min-width: 0; }
.phd-chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.phd-chart svg { display: block; direction: ltr; }
.phd-chart .phd-gl { stroke: #ece9e2; stroke-width: 1; } .phd-chart .phd-goal { stroke: var(--orange); stroke-width: 1.5; stroke-dasharray: 5 4; }
.phd-chart .phd-axis { fill: #6b7280; font-size: 11px; font-family: inherit; }
.phd-chart [data-tip] { cursor: pointer; }
.phd-chart-tip { min-height: 22px; font-size: 13px; color: var(--g); text-align: center; opacity: 0; font-weight: 700; margin-top: 4px; }
.phd-chart-empty { text-align: center; color: var(--muted); padding: 28px 8px; background: #fafaf8; border-radius: 12px; font-size: 14px; }
.phd-legend { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; } .phd-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; }
.phd-hbars { display: flex; flex-direction: column; gap: 8px; } .phd-hbar { display: grid; grid-template-columns: 90px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.phd-hbar-t { height: 10px; background: #eeece6; border-radius: 99px; overflow: hidden; } .phd-hbar-t i { display: block; height: 100%; border-radius: 99px; } .phd-hbar-v { color: var(--muted); font-size: 12px; }

/* تقویم تاریخچه */
.phd-cal-nav { display: flex; align-items: center; gap: 6px; } .phd-cal-nav b { min-width: 110px; text-align: center; }
.phd-calgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; } .phd-calgrid > b { font-size: 12px; color: var(--muted); }
.phd-cd { min-height: 44px; border-radius: 10px; border: 1px solid transparent; background: #f4f3ef; } .phd-cd.full { background: #bfe6df; border-color: var(--g); } .phd-cd.part { background: #fde7bd; } .phd-cd.today { outline: 2px solid var(--blue); } .phd-cd:disabled { opacity: .35; }
.phd-legend .c-full { background: #bfe6df; } .phd-legend .c-part { background: #fde7bd; } .phd-legend .c-none { background: #f4f3ef; border: 1px solid #ddd; }

/* مودال، تست، انتخابگر تاریخ */
.phd-modal { position: fixed; inset: 0; z-index: 9000; display: flex; align-items: flex-end; justify-content: center; } .phd-modal[hidden] { display: none; }
.phd-modal-bg { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); }
.phd-sheet { position: relative; background: #fff; width: 100%; max-width: 480px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; animation: phd-up .18s ease-out; }
.phd-mform { display: flex; flex-direction: column; gap: 10px; }
@keyframes phd-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.phd-toasts { position: fixed; z-index: 9500; inset-inline: 0; bottom: calc(76px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.phd-toast { pointer-events: auto; background: #1f2937; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; max-width: 92vw; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); display: flex; gap: 12px; align-items: center; animation: phd-up .18s; transition: opacity .3s; }
.phd-toast.err { background: #b91c1c; } .phd-toast.out { opacity: 0; } .phd-toast-act { background: rgba(255, 255, 255, .2); border: 0; border-radius: 8px; padding: 4px 10px; color: #fff; }
.phd-dp-overlay { position: fixed; inset: 0; z-index: 10000; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; font-family: Vazirmatn, "Segoe UI", Tahoma, system-ui, sans-serif; }
.phd-dp { background: #fff; border-radius: 18px; padding: 14px; width: min(340px, 94vw); direction: rtl; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.phd-dp-head { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; } .phd-dp-head select { flex: 1; min-height: 40px; border-radius: 10px; border: 1px solid #d9d7d0; padding: 0 6px; font: inherit; background: #fff; }
.phd-dp-nav { width: 40px; height: 40px; border: 1px solid #d9d7d0; border-radius: 10px; background: #fff; font-size: 20px; cursor: pointer; }
.phd-dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; } .phd-dp-wd span { font-size: 12px; color: #6b7280; padding: 4px 0; }
.phd-dp-day { min-height: 40px; border: 0; border-radius: 10px; background: #f4f3ef; cursor: pointer; font: inherit; } .phd-dp-day.is-fri { color: #dc2626; } .phd-dp-day.is-today { outline: 2px solid #3b82f6; } .phd-dp-day.is-sel { background: #0f766e; color: #fff; } .phd-dp-day:disabled { opacity: .3; cursor: not-allowed; }
.phd-dp-foot { display: flex; gap: 8px; margin-top: 10px; } .phd-dp-foot .phd-btn { flex: 1; }
.phd-dp .phd-btn { border: 1px solid #d9d7d0; border-radius: 12px; min-height: 42px; background: #fff; font: inherit; font-weight: 700; cursor: pointer; }

/* ورود */
.phd-login-wrap { display: flex; align-items: center; justify-content: center; padding: 20px; grid-column: 1 / -1; }
.phd-login { width: min(400px, 100%); gap: 14px; padding: 26px 22px; } .phd-login h1 { text-align: center; }
.phd-login .phd-muted { text-align: center; } .phd-login-logo { align-self: center; width: 56px; height: 56px; border-radius: 18px; background: var(--g-soft); color: var(--g); display: flex; align-items: center; justify-content: center; } .phd-login-logo .phd-ic { width: 30px; height: 30px; }
.phd-login input { direction: ltr; text-align: left; }
@media (prefers-reduced-motion: reduce) { .phd * { animation: none !important; transition: none !important; } }
