/* ─────────────────────────────────────────
   style.css — نسخه ۳ | طراحی مدرن آیفون‌محور
   ───────────────────────────────────────── */

:root {
  --bg: #f0f4ff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-soft: #475569;
  --text-muted: #94a3b8;
  --text-faint: #cbd5e1;
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --indigo-600: #4f46e5;
  --emerald-50: #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-400: #34d399;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --orange-50: #fff7ed;
  --orange-200: #fed7aa;
  --orange-700: #c2410c;
  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-400: #f87171;
  --red-500: #ef4444;
  --purple-50: #faf5ff;
  --purple-600: #9333ea;
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.06);
  --shadow-md: 0 4px 16px rgba(15,23,42,0.10);
  --shadow-lg: 0 16px 48px rgba(15,23,42,0.16);
  --r-sm: 12px; --r-md: 16px; --r-lg: 20px; --r-xl: 24px; --r-2xl: 28px;
  /* Icon system — colored circle badges (iOS Settings / Telegram style) */
  --icon-badge-size: 30px;
  --icon-size: 16px;
  --icon-inline-size: 15px;

  /* Palmer notation tooth symbol — tune size/weight/spacing here */
  --palmer-size: 15px;
  --palmer-font-size: 17px;
  --palmer-font-weight: 700;
  --palmer-border-width: 1.6px;
  --palmer-border-color: currentColor;
  --palmer-gap: 5px;
}

html.dark {
  --bg: #0a0f1e;
  --surface: #1a2235;
  --surface-2: #111827;
  --surface-3: #0d1526;
  --border: #263352;
  --border-light: #1a2235;
  --text: #f1f5f9;
  --text-soft: #cbd5e1;
  /* A7: روشن‌تر برای کنتراست بهتر (WCAG AA ≥ 4.5:1) */
  --text-muted: #94a3b8;
  --text-faint: #475569;
  --blue-50: rgba(59,130,246,0.10);
  --blue-100: rgba(59,130,246,0.18);
  --emerald-50: rgba(16,185,129,0.10);
  --emerald-100: rgba(16,185,129,0.18);
  --orange-50: rgba(249,115,22,0.10);
  --red-50: rgba(239,68,68,0.10);
  --red-100: rgba(239,68,68,0.18);
  --purple-50: rgba(168,85,247,0.10);
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* B16: کلاس hidden با !important — جایگزین style="display:none" */
.hidden { display: none !important; }

/* A2: sr-only — برای screen reader فقط */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* B17: undo toast */
.undo-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text, #0f172a);
  color: var(--surface, #ffffff);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 9999;
  transition: transform 0.3s ease;
  font-size: 14px;
}
.undo-toast.show {
  transform: translateX(-50%) translateY(0);
}
.undo-toast .undo-btn {
  background: var(--accent, #3b82f6);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  font-family: inherit;
}

/* S3: هشدار عدم رمزنگاری */
.warning-text {
  color: var(--orange-700, #c2410c) !important;
  font-weight: 500;
}

/* B10: badge برای کیس‌های merge شده */
.case-card-merged-badge {
  display: inline-block;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-3);
  padding: 2px 8px;
  border-radius: 8px;
  margin-top: 4px;
}

/* B10: badge «مجانی» */
.tsr-service-price-display.free {
  color: var(--emerald-600);
  font-weight: 500;
}

/* S9: فونت Vazirmatn به‌صورت محلی (self-hosted) — به‌جای Google Fonts CDN.
   یک فایل variable-font که کل بازه‌ی وزن ۱۰۰ تا ۹۰۰ را پوشش می‌دهد. */
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Variable.woff2') format('woff2-variations'),
       url('../fonts/Vazirmatn-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

html { height: 100%; }
body {
  margin: 0; padding: 0; height: 100%;
  font-family: 'Vazirmatn','Tahoma','Arial',sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; }
button { font-family: inherit; cursor: pointer; }

/* ── App shell ── */
#app {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  overflow: hidden;
}

/* ── Lock screen ── */
.lock-screen {
  height: 100vh; height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: linear-gradient(160deg, #1e3a8a, #312e81, #1e1b4b);
}
.lock-card {
  width: 100%; max-width: 340px;
  background: var(--surface); border-radius: var(--r-2xl);
  box-shadow: var(--shadow-lg); padding: 36px 28px;
  text-align: center;
}
.lock-logo {
  width: 72px; height: 72px;
  background: linear-gradient(135deg,#2563eb,#4f46e5);
  border-radius: var(--r-lg); font-size: 34px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 28px;
  box-shadow: 0 8px 24px rgba(79,70,229,.35);
}
.lock-title { font-size: 17px; font-weight: 900; margin: 0 0 4px; color: var(--text); }
.lock-sub { font-size: 12px; color: var(--text-muted); margin: 0 0 20px; }
.lock-footer { font-size: 11px; color: var(--text-muted); margin-top: 16px; }
.field-center { display: flex; justify-content: center; }
.input-lock {
  width: 100%; max-width: 240px;
  padding: 14px 14px; text-align: center;
  font-size: 15px; font-weight: 700; letter-spacing: 3px;
  border: 1.5px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.input-lock:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.input-lock-mask.has-value { -webkit-text-security: disc; text-security: disc; }
.btn-biometric {
  width: 100%; padding: 12px; border: 2px solid var(--border);
  background: var(--surface-2); color: var(--text-soft);
  border-radius: 14px; font-size: 14px; font-weight: 700;
  margin-bottom: 8px;
}

/* ── Generic inputs ── */
.field { margin-bottom: 14px; text-align: right; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.required { color: var(--red-500); }
.input, textarea.input, select.input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: 14px; font-family: inherit;
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s; outline: none;
  -webkit-appearance: none;
}
.input:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
textarea.input { resize: none; }
.search-input-wrap { position: relative; }
.search-input-wrap .input { padding-right: 38px; }
.search-input-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.error-msg { font-size: 12px; color: var(--red-500); background: var(--red-50); border-radius: 10px; padding: 8px 12px; margin: 4px 0; }
.iso-hint { font-size: 11px; color: var(--text-muted); margin: 4px 0 0; direction: ltr; text-align: right; }

/* ── Buttons ── */
.btn-primary {
  padding: 12px 20px;
  background: linear-gradient(135deg,#2563eb,#4f46e5);
  color: #fff; border: none; border-radius: 14px;
  font-weight: 800; font-size: 14px;
  box-shadow: 0 6px 20px rgba(79,70,229,.28);
  transition: transform .1s, box-shadow .1s;
}
.btn-primary:active { transform: scale(.97); box-shadow: 0 2px 8px rgba(79,70,229,.2); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary.full { width: 100%; margin-top: 8px; }
.btn-secondary {
  padding: 12px 20px; background: var(--surface-2);
  border: 1.5px solid var(--border); color: var(--text-soft);
  border-radius: 14px; font-weight: 700; font-size: 14px;
}
.btn-purple { padding: 9px 16px; background: var(--purple-600); color: #fff; border: none; border-radius: 12px; font-weight: 700; font-size: 13px; }
.btn-dark { padding: 9px 16px; background: #334155; color: #fff; border: none; border-radius: 12px; font-weight: 700; font-size: 13px; }
.btn-centered { display: block; width: fit-content; margin-left: auto; margin-right: auto; }
.btn-danger { padding: 11px 18px; background: linear-gradient(135deg,#dc2626,#b91c1c); color: #fff; border: none; border-radius: 14px; font-weight: 800; font-size: 13px; box-shadow: 0 4px 12px rgba(220,38,38,.25); }
.btn-tag { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 12px; font-size: 13px; font-weight: 700; border: 1px solid transparent; }
.btn-tag-indigo { background: var(--blue-50); color: var(--blue-700); border-color: var(--blue-100); }
.btn-tag-orange { background: var(--orange-50); color: var(--orange-700); border-color: var(--orange-200); }

/* ── Header ── */
.header {
  flex-shrink: 0; z-index: 40;
  background: linear-gradient(135deg,#1e40af,#4f46e5);
  box-shadow: 0 2px 16px rgba(79,70,229,.22);
  padding-top: env(safe-area-inset-top);
}
html.dark .header { background: linear-gradient(135deg,#1e3a8a,#312e81); }
.header-inner {
  max-width: 760px; margin: 0 auto;
  padding: 13px 16px 11px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 36px; height: 36px; background: rgba(255,255,255,.18); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 19px; }
.brand-name { font-size: 14px; font-weight: 900; margin: 0; color: #fff; }
.icon-btn { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 10px; border: none; background: rgba(255,255,255,.18); color: #fff; font-size: 16px; transition: background .15s; }

/* ── Icon system ──
   .icon-badge  = colored circle with a white icon inside (list rows, nav, swipe actions)
   .icon        = plain icon, no circle, inherits currentColor (header buttons, inline labels)
   Colors are semantic modifiers (--blue/--emerald/--orange/--red/--purple/--indigo/--gray) so
   meaning stays consistent across the app (e.g. red = destructive, blue = primary/info). */
.icon { width: var(--icon-size); height: var(--icon-size); display: inline-block; vertical-align: middle; flex-shrink: 0; }
.icon-inline { width: var(--icon-inline-size); height: var(--icon-inline-size); display: inline-block; vertical-align: -3px; flex-shrink: 0; margin-left: 4px; }

.icon-badge {
  width: var(--icon-badge-size); height: var(--icon-badge-size); border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  color: #fff;
}
.icon-badge .icon { width: calc(var(--icon-badge-size) * .55); height: calc(var(--icon-badge-size) * .55); }
.icon-badge--blue   { background: linear-gradient(135deg,#60a5fa,#2563eb); }
.icon-badge--emerald{ background: linear-gradient(135deg,#34d399,#059669); }
.icon-badge--orange { background: linear-gradient(135deg,#fb923c,#ea580c); }
.icon-badge--red    { background: linear-gradient(135deg,#f87171,#dc2626); }
.icon-badge--purple { background: linear-gradient(135deg,#c084fc,#9333ea); }
.icon-badge--indigo { background: linear-gradient(135deg,#818cf8,#4f46e5); }
.icon-badge--pink   { background: linear-gradient(135deg,#f472b6,#db2777); }
.icon-badge--gray   { background: linear-gradient(135deg,#94a3b8,#64748b); }
.icon-badge--sm { --icon-badge-size: 24px; }
.icon-badge--lg { --icon-badge-size: 38px; }
.icon-btn:active { background: rgba(255,255,255,.30); }

/* ── Bottom nav ── */
.bottom-nav {
  flex-shrink: 0; z-index: 35;
  display: flex; align-items: flex-end; justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -1px 0 var(--border);
}
.bn-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: none; background: transparent; color: var(--text-muted);
  font-size: 10px; font-weight: 700; padding: 4px 4px 2px; border-radius: 12px;
}
.bn-icon-wrap { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: background .2s, transform .2s, color .2s; }
.bn-icon-wrap .icon { width: 19px; height: 19px; transition: none; }
.bn-tab.active .bn-icon-wrap { background: linear-gradient(135deg,#60a5fa,#2563eb); color: #fff; transform: scale(1.04); }
.bn-tab.active { color: var(--blue-600); }

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: calc(82px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  width: 50px; height: 50px; border-radius: 50%; border: 3px solid var(--bg);
  background: linear-gradient(135deg,#2563eb,#4f46e5);
  color: #fff; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 22px rgba(79,70,229,.42);
  z-index: 36;
  transition: transform .15s, box-shadow .15s;
}
.fab:active { transform: translateX(-50%) scale(.94); }
.fab .icon { width: 24px; height: 24px; }

/* ── Main scroll area ── */
.main {
  flex: 1 1 auto; min-height: 0;
  width: 100%; max-width: 760px; margin: 0 auto;
  padding: 16px 14px 24px;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.view { display: flex; flex-direction: column; gap: 12px; }

/* ── Cards ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px;
  box-shadow: var(--shadow-sm);
}
.card-title { font-size: 13px; font-weight: 800; color: var(--text-soft); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }

/* ── Daily view ── */
.daily-date-row {
  background: linear-gradient(135deg, var(--blue-50), var(--surface));
  border: 1px solid var(--blue-100); border-radius: var(--r-lg);
  padding: 14px 16px; display: flex; align-items: center; gap: 10px;
}
html.dark .daily-date-row { background: rgba(59,130,246,.08); border-color: rgba(59,130,246,.2); }
.daily-date-icon { font-size: 24px; }
.daily-date-text { font-size: 18px; font-weight: 900; color: var(--text); }
.daily-day-name { font-size: 12px; color: var(--text-muted); margin-right: 6px; }
.cases-list { display: flex; flex-direction: column; gap: 10px; }
.empty-state { text-align: center; padding: 48px 0; }
.empty-icon { font-size: 56px; margin-bottom: 10px; }
.empty-title { color: var(--text-soft); font-weight: 700; margin: 0; }
.empty-sub { color: var(--text-muted); font-size: 13px; margin: 4px 0 0; }

/* ── Case card ── */
.case-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer; transition: box-shadow .15s, transform .1s;
}
.case-card:active { opacity: .92; }
.case-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.case-card-name { font-weight: 800; font-size: 14px; margin: 0; color: var(--text); }
.case-number-small { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.case-card-actions { display: flex; gap: 6px; }
.case-card-btn { width: 30px; height: 30px; border: none; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.case-card-btn.history { background: var(--purple-50); color: var(--purple-600); }
.case-card-btn.edit { background: var(--blue-50); color: var(--blue-500); }
.case-card-btn.delete { background: var(--red-50); color: var(--red-400); }
.case-card-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.chip-service { padding: 2px 8px; background: var(--blue-50); color: var(--blue-700); border-radius: 7px; font-size: 11px; font-weight: 600; }
.case-card-notes { font-size: 11px; color: var(--text-muted); background: var(--surface-2); border-radius: 7px; padding: 5px 8px; margin: 0; }
.case-number-hint { font-size: 11px; color: rgba(255,255,255,.85); margin: 2px 0 0; text-align: right; direction: ltr; font-weight: 600; }

/* ── Date group header ── */
.date-group-head { position: relative; display: flex; align-items: center; min-height: 32px; margin-bottom: 8px; }
.date-group-pill { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 5px 10px; white-space: nowrap; }
.dgp-date { font-size: 12px; font-weight: 800; color: var(--text-soft); }
.dgp-day { font-size: 10px; color: var(--text-muted); }
.date-group-count { font-size: 11px; color: var(--text-muted); background: var(--blue-50); color: var(--blue-700); padding: 3px 8px; border-radius: 8px; font-weight: 700; margin-right: auto; }
.date-group-cases { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }

/* ── Period selector ── */
.period-card { display: flex; flex-direction: column; gap: 10px; }
.segmented { display: flex; gap: 3px; background: var(--surface-3); border-radius: 12px; padding: 3px; }
.seg-btn { flex: 1; padding: 8px 4px; border: none; border-radius: 9px; background: transparent; color: var(--text-muted); font-size: 12px; font-weight: 700; transition: all .15s; }
.seg-btn.active { background: var(--surface); color: var(--blue-700); box-shadow: var(--shadow-sm); font-weight: 800; }
.custom-range-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field-inline label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.period-summary { font-size: 12px; color: var(--text-muted); margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chips-center { justify-content: center; }
.chip-stat { padding: 5px 11px; background: var(--blue-50); color: var(--blue-700); border-radius: 10px; font-size: 12px; font-weight: 700; }

/* Services breakdown */
.breakdown-amount { margin-bottom: 8px; text-align: center; }
.breakdown-amount-chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 12px; font-size: 14px; font-weight: 900; color: #fff; background: linear-gradient(135deg,var(--emerald-500),var(--emerald-600)); box-shadow: 0 4px 12px rgba(16,185,129,.26); }
.breakdown-chips { justify-content: center; }

/* ── Financial view ── */
.fin-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fin-card {
  border-radius: var(--r-lg); padding: 16px 14px 14px;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--shadow-md); position: relative; overflow: hidden;
}
.fin-card::before { content:''; position:absolute; top:-30px; left:-20px; width:100px; height:100px; border-radius:50%; background:rgba(255,255,255,.10); }
.fin-card-work { background: linear-gradient(135deg,#1e40af,#4f46e5); color:#fff; }
.fin-card-receipt { background: linear-gradient(135deg,#047857,#059669); color:#fff; }
.fin-card-icon { margin-bottom: 4px; }
.fin-card-icon .icon { width: 20px; height: 20px; }
.fin-card-label { font-size: 11px; font-weight: 700; opacity: .8; }
.fin-card-value { font-size: 16px; font-weight: 900; line-height: 1.2; margin-top: 2px; }
.fin-card-count { font-size: 10px; opacity: .7; margin-top: 2px; }

/* Balance card */
.balance-card { gap: 0; }
.balance-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; font-size: 13px; color: var(--text-soft); border-bottom: 1px dashed var(--border-light); }
.balance-label { font-weight: 600; }
.balance-val { font-weight: 800; color: var(--text); }
.balance-val.balance-minus { color: var(--emerald-600); }
.balance-result { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding: 12px 14px; border-radius: 14px; font-weight: 900; font-size: 14px; background: var(--blue-50); color: var(--blue-700); }
.balance-result-label-wrap { display: flex; align-items: center; gap: 8px; }
.balance-result #balanceResult { font-size: 15px; }
#balanceResult.pos { color: var(--blue-700); }
#balanceResult.neg { color: var(--red-500); }
#balanceResult.zero { color: var(--emerald-700); }

/* Receipts/Expenses */
.receipt-form-row { display: flex; gap: 7px; align-items: flex-end; }
.receipt-form-row .field { flex: 1; margin-bottom: 0; }
.receipt-list { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; max-height: 240px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.receipt-row { display: flex; align-items: center; justify-content: space-between; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; }
.receipt-row-info { display: flex; flex-direction: column; gap: 3px; }
.receipt-row-date { font-size: 11px; color: var(--text-muted); }
.receipt-row-amount { font-size: 13px; font-weight: 800; color: var(--emerald-700); text-align: left; }
.receipt-total-row { display: flex; justify-content: space-between; align-items: center; background: var(--emerald-50); border: 1px solid var(--emerald-100); border-radius: 12px; padding: 10px 12px; margin-top: 10px; font-weight: 800; color: var(--emerald-700); }
.expense-total-row { display: flex; justify-content: space-between; align-items: center; background: var(--orange-50); border: 1px solid var(--orange-200); border-radius: 12px; padding: 10px 12px; margin-top: 10px; font-weight: 800; color: var(--orange-700); }
.expense-row-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.expense-row-note { font-size: 11px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expense-row-amount { font-size: 13px; font-weight: 800; color: var(--orange-700); }
.remove-x-btn { width: 26px; height: 26px; border-radius: 99px; border: none; background: linear-gradient(135deg,#f87171,#dc2626); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.remove-x-btn .icon { width: 13px; height: 13px; }

/* Trash bin */
.trash-count-badge { font-size: 10px; font-weight: 800; color: #fff; background: var(--red-500); border-radius: 99px; padding: 1px 7px; margin-right: 4px; }
.trash-list { display: flex; flex-direction: column; gap: 8px; }
.trash-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.trash-row-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.trash-row-name { font-size: 13px; font-weight: 800; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trash-row-date { font-size: 11px; color: var(--text-muted); }
.trash-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.trash-restore-btn { width: 30px; height: 30px; border-radius: 99px; border: none; background: linear-gradient(135deg,#34d399,#059669); color: #fff; display: flex; align-items: center; justify-content: center; }
.trash-restore-btn .icon { width: 15px; height: 15px; }
.trash-perm-delete-btn { width: 30px; height: 30px; border-radius: 99px; border: none; background: linear-gradient(135deg,#f87171,#dc2626); color: #fff; display: flex; align-items: center; justify-content: center; }
.trash-perm-delete-btn .icon { width: 14px; height: 14px; }

/* ── Modals ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 65;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 16px 16px 90px;
}
.modal-overlay-top { z-index: 75; align-items: center; padding-bottom: 16px; }
.modal {
  width: 100%; max-width: 620px;
  background: var(--surface); border-radius: var(--r-2xl);
  box-shadow: var(--shadow-lg); margin: 0 auto;
}
.modal-narrow { max-width: 360px; }
.modal-wide { max-width: 660px; }
.modal-wide { display: flex; flex-direction: column; max-height: 88vh; }
.modal-wide .modal-header { flex: 0 0 auto; }
.modal-wide .modal-body { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-wide .modal-actions { flex: 0 0 auto; padding: 12px 20px; margin: 0; border-top: 1px solid var(--border-light); background: var(--surface); border-radius: 0 0 var(--r-2xl) var(--r-2xl); }
.modal-header { border-radius: var(--r-2xl) var(--r-2xl) 0 0; display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; }
.modal-header h2 { color: #fff; font-size: 16px; margin: 0; font-weight: 800; }
.gradient-blue { background: linear-gradient(90deg,#2563eb,#4f46e5); }
.gradient-dark { background: linear-gradient(90deg,#334155,#0f172a); }
.modal-close { width: 28px; height: 28px; border-radius: 99px; border: none; background: rgba(255,255,255,.2); color: #fff; display: flex; align-items: center; justify-content: center; }
.modal-body { padding: 18px 20px 24px; }
.modal-title-plain { font-size: 15px; font-weight: 800; margin: 0 0 14px; color: var(--text); }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions > * { flex: 1; }
.bordered-top { border-top: 1px solid var(--border-light); padding-top: 12px; margin-top: 4px; }

/* ── Bottom sheet (settings, req #4) ── */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 65;
  background: rgba(0,0,0,.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 760px; max-height: 92vh;
  background: var(--surface); border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 99px; margin: 10px auto 0; flex-shrink: 0; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px 10px; flex-shrink: 0; border-bottom: 1px solid var(--border-light); }
.sheet-header h2 { font-size: 16px; font-weight: 800; margin: 0; color: var(--text); }
.dark-close { width: 28px; height: 28px; border-radius: 99px; border: none; background: var(--surface-3); color: var(--text-soft); display: flex; align-items: center; justify-content: center; }
.sheet-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px 24px; }

/* Settings */
.settings-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 13px; margin-bottom: 12px; }
.settings-box h3 { font-size: 13px; font-weight: 800; color: var(--text-soft); margin: 0 0 10px; }
.flex-row { display: flex; align-items: center; justify-content: space-between; }
.gap-sm { gap: 8px; }
.emoji-lg { font-size: 18px; }
.bold-sm { font-size: 13px; font-weight: 700; color: var(--text-soft); }
.toggle-switch { width: 44px; height: 26px; border-radius: 99px; border: none; background: var(--text-faint); position: relative; transition: background .15s; flex-shrink: 0; }
.toggle-switch.on { background: var(--blue-600); }
.toggle-knob { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 99px; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle-switch.on .toggle-knob { transform: translateX(-18px); }
.preset-chip-btn { padding: 5px 10px; border-radius: 8px; font-size: 11px; font-weight: 700; border: 1.5px solid var(--border); background: var(--surface); color: var(--text-soft); transition: all .15s; }
.preset-chip-btn:active { transform: scale(.97); }
.preset-chip-btn.active { background: var(--purple-600); border-color: var(--purple-600); color: #fff; }
.services-manage-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; margin-top: 10px; -webkit-overflow-scrolling: touch; }
.service-manage-row { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 11px; }
.service-manage-row span { font-size: 13px; color: var(--text); }
.data-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; justify-content: center; }
.data-buttons .btn-tag { justify-content: center; border-radius: 14px; }
.data-buttons .btn-tag-lg { flex: 1.4 1 150px; padding: 15px 18px; font-size: 15px; }
.data-buttons .btn-tag-sm { flex: 1 1 110px; padding: 10px 12px; font-size: 12.5px; }
.settings-field-label { display: block; font-size: 12px; font-weight: 700; color: var(--text-soft); margin: 0 0 6px; }
.muted-small { font-size: 12px; color: var(--text-muted); margin: 6px 0 0; }
.muted-center { color: var(--text-muted); font-size: 13px; text-align: center; padding: 14px 0; margin: 0; }

/* Settings collapsible (req #11) */
.settings-collapse-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; background: none; border: none; padding: 0; font-size: 13px; font-weight: 800; color: var(--text-soft); }
.settings-row-label { display: flex; align-items: center; gap: 10px; }
.collapse-arrow { font-size: 16px; color: var(--text-muted); transition: transform .2s; }
.collapse-arrow.open { transform: rotate(90deg); }

/* Tariff list (req #1) */
.tariff-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.tariff-row { display: flex; align-items: center; gap: 8px; }
.tariff-row label { font-size: 13px; color: var(--text); flex: 1; font-weight: 600; }
.tariff-row input { width: 120px; }
.tariff-hint-row { text-align: left; margin-top: 6px; }
.tariff-hint { font-size: 11px; font-weight: 700; color: var(--emerald-700); background: var(--emerald-50); border: 1.5px solid var(--emerald-400); border-radius: 999px; padding: 4px 10px; margin: 0; cursor: pointer; text-align: center; display: inline-flex; align-items: center; gap: 4px; width: auto; }
.tariff-hint:active { background: var(--emerald-100); }

/* Case modal "more" (notes + date) collapsible section — req #3, #9 */
.case-more-toggle { display: inline-block; background: none; border: none; padding: 4px 2px; margin: 12px 0 0; font-size: 12px; font-weight: 700; color: var(--blue-600); cursor: pointer; }
.case-more-toggle:active { opacity: .7; }
.case-more-body { margin-top: 4px; }

/* Patient autocomplete */
.patient-suggestions { background: var(--surface); border: 1.5px solid var(--blue-500); border-top: none; border-radius: 0 0 12px 12px; box-shadow: var(--shadow-md); overflow: hidden; }
.patient-suggestion-item { padding: 10px 14px; font-size: 13px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.patient-suggestion-item:hover, .patient-suggestion-item:active { background: var(--blue-50); }
.patient-suggestion-count { font-size: 11px; color: var(--text-muted); }

/* ── Tooth chart ── */
.tooth-chart {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 12px 6px;
}
.tc-row-labels { display: flex; justify-content: space-between; padding: 0 2px; margin-bottom: 6px; }
.tc-row-labels span { font-size: 9px; color: var(--text-muted); font-weight: 600; }
.tc-row-labels .tc-center-label { font-weight: 700; color: var(--text-soft); }
.tc-row { display: flex; justify-content: center; align-items: center; gap: 3px; margin-bottom: 3px; }
.tc-half { display: flex; gap: 2px; justify-content: center; flex: 1; min-width: 0; }
.tc-divider { width: 1px; background: var(--border); align-self: stretch; min-height: 24px; flex-shrink: 0; }
.tc-midline { position: relative; margin: 8px 0; text-align: center; }
.tc-midline::before { content:''; position:absolute; top:50%; left:0; right:0; border-top: 1.5px dashed var(--border); }
.tc-midline span { position: relative; background: var(--surface-2); padding: 0 6px; font-size: 9px; color: var(--text-muted); font-weight: 600; }
.tooth { display: flex; flex-direction: column; align-items: center; cursor: pointer; user-select: none; flex: 1 1 0; min-width: 0; }

/* ── Palmer notation tooth symbol ──
   Number nested directly in the corner formed by two borders (per quadrant),
   matching LaTeX/odontogram Palmer-system output. direction:ltr is forced so the
   left/right corner logic stays physically correct regardless of the page's RTL context.
   All sizing is driven by CSS variables (see :root) for easy, consistent tuning
   across screen, print, and PDF export. */
.palmer-tooth {
  display: inline-flex;
  direction: ltr;
  box-sizing: content-box;
  min-width: var(--palmer-size);
  min-height: var(--palmer-size);
  font-size: var(--palmer-font-size);
  font-weight: var(--palmer-font-weight);
  line-height: 1;
  font-variant-numeric: lining-nums;
  border-style: solid;
  border-width: 0;
  border-color: var(--palmer-border-color);
  vertical-align: middle;
  color: inherit;
}
.palmer-tooth--ur { border-top-width: var(--palmer-border-width); border-right-width: var(--palmer-border-width); align-items: flex-start; justify-content: flex-end; padding: var(--palmer-gap) var(--palmer-gap) 0 0; }
.palmer-tooth--ul { border-top-width: var(--palmer-border-width); border-left-width: var(--palmer-border-width); align-items: flex-start; justify-content: flex-start; padding: var(--palmer-gap) 0 0 var(--palmer-gap); }
.palmer-tooth--lr { border-bottom-width: var(--palmer-border-width); border-right-width: var(--palmer-border-width); align-items: flex-end; justify-content: flex-end; padding: 0 var(--palmer-gap) var(--palmer-gap) 0; }
.palmer-tooth--ll { border-bottom-width: var(--palmer-border-width); border-left-width: var(--palmer-border-width); align-items: flex-end; justify-content: flex-start; padding: 0 0 var(--palmer-gap) var(--palmer-gap); }

/* Compact variant for use inside small badges/pills */
.palmer-tooth--sm { --palmer-size: 11px; --palmer-font-size: 12px; --palmer-border-width: 1.2px; --palmer-gap: 4px; }

.tooth-btn {
  width: 100%; max-width: 28px; min-width: 14px; aspect-ratio: 1;
  margin: 0 auto; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(9px, 3vw, 13px); font-weight: 800; font-family: monospace;
  border: 1.5px solid var(--text-faint); background: var(--surface); color: var(--text-soft);
  transition: all .12s;
}
.tooth-btn.has-services { border-color: var(--blue-400); background: var(--blue-100); color: var(--blue-700); }
.tooth-btn.has-history { border-color: var(--emerald-400); background: var(--emerald-100); color: var(--emerald-700); }
.tc-legend { display: flex; gap: 14px; justify-content: center; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border-light); flex-wrap: wrap; }
.tc-legend-item { display: flex; align-items: center; gap: 5px; }
.tc-legend-swatch { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid; }
.tc-legend-swatch.normal { background: var(--surface); border-color: var(--text-faint); }
.tc-legend-swatch.treated { background: var(--blue-100); border-color: var(--blue-400); }
.tc-legend-swatch.history { background: var(--emerald-100); border-color: var(--emerald-400); }
.tc-legend-item span:last-child { font-size: 10px; color: var(--text-muted); }

/* Per-tooth services list */
.teeth-services-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.tooth-service-row { display: flex; align-items: flex-start; justify-content: space-between; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; cursor: pointer; }
.tooth-service-row-main { display: flex; align-items: flex-start; gap: 10px; flex: 1; }
.tooth-service-row-info { flex: 1; min-width: 0; }
.tooth-service-row-label { font-size: 13px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.tsr-service-lines { display: flex; flex-direction: column; gap: 6px; }
.tsr-service-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 6px; border-radius: 6px; transition: background .15s; cursor: pointer; }
.tsr-service-line.is-pending { background: var(--blue-50); }
.tsr-service-name { font-size: 12px; color: var(--text-soft); }
.tsr-service-price-display { font-size: 12px; font-weight: 700; color: var(--emerald-700); white-space: nowrap; }
.tsr-service-price-display.pending { color: var(--text-faint); font-weight: 500; font-style: italic; }
.tsr-service-line.is-pending .tsr-service-price-display.pending { color: var(--blue-600); font-style: normal; font-weight: 700; }
.computed-total-display { font-size: 13px; font-weight: 800; color: var(--emerald-700); background: var(--emerald-50); border-radius: 10px; padding: 8px 12px; margin: 8px 0 0; text-align: center; }
.tooth-service-row-chevron { color: var(--text-faint); font-size: 14px; margin-top: 3px; }

/* Per-tooth service picker popup */
.tooth-service-popup {
  position: fixed; z-index: 80; inset: 0;
  background: rgba(0,0,0,.5); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.tsp-card { width: 100%; max-width: 360px; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); overflow: hidden; }
.tsp-header { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; background: linear-gradient(90deg,var(--blue-600),var(--indigo-600)); color: #fff; font-weight: 800; font-size: 13px; }
.modal-close-dark { width: 26px; height: 26px; border-radius: 99px; border: none; background: rgba(255,255,255,.2); color: #fff; display: flex; align-items: center; justify-content: center; }
.tsp-body { padding: 14px 16px; }
/* Service grid (req #12 — tap a service and it auto-closes) */
.tsp-service-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 10px; }
.tsp-service-chip {
  padding: 10px 6px; background: var(--surface-2); border: 1.5px solid var(--border);
  border-radius: 12px; font-size: 12px; font-weight: 700; color: var(--text-soft);
  text-align: center; cursor: pointer; transition: all .12s;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tsp-service-chip:active { transform: scale(.96); }
.tsp-service-chip.selected { background: var(--blue-50); border-color: var(--blue-500); color: var(--blue-700); }
.tsp-chip-price { font-size: 10px; font-weight: 600; color: var(--emerald-600); background: var(--emerald-50); border-radius: 6px; padding: 1px 5px; }
.services-list { display: flex; flex-direction: column; gap: 7px; }
.service-item-row { display: flex; align-items: center; justify-content: space-between; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; }
.service-item-row span { font-size: 13px; font-weight: 700; color: var(--text); }
.add-service-row { display: flex; gap: 8px; }
.add-service-row .input { flex: 1; }

/* ── Patient detail (req #7: date left, repeat-session badges in header, amount own row) ── */
.patient-detail-case { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 11px; margin-bottom: 9px; }
.patient-detail-case-date { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.patient-detail-header-right { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.patient-detail-visit-num { font-size: 10px; color: var(--blue-600); font-weight: 700; }
.patient-detail-amount { font-size: 13px; font-weight: 800; color: var(--emerald-600); white-space: nowrap; }
.patient-detail-tooth-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; font-size: 12px; flex-wrap: wrap; }
.patient-detail-tooth-info { display: flex; align-items: baseline; gap: 6px; }
.patient-detail-tooth-right { display: flex; align-items: center; gap: 6px; }
.patient-detail-tooth-session { font-size: 10px; color: var(--orange-700); background: var(--orange-50); border-radius: 6px; padding: 1px 6px; font-weight: 700; }
.patient-detail-tooth-label { font-weight: 800; color: var(--text); white-space: nowrap; }
.patient-detail-tooth-services { color: var(--text-soft); }

/* ── Date picker ── */
.date-picker-btn { width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font-size: 13px; text-align: right; display: flex; align-items: center; justify-content: space-between; font-family: inherit; }
.date-picker-popup { position: absolute; z-index: 70; width: 280px; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); border: 1px solid var(--border); padding: 12px; }
.dp-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dp-nav { width: 28px; height: 28px; border-radius: 8px; border: none; background: transparent; color: var(--text-soft); font-size: 16px; }
.dp-nav:active { background: var(--surface-2); }
.dp-title { font-size: 13px; font-weight: 800; color: var(--text); }
.dp-weekdays { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; margin-bottom: 4px; }
.dp-weekdays span { text-align: center; font-size: 10px; font-weight: 800; color: var(--text-muted); padding: 3px 0; }
.dp-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; }
.dp-day { aspect-ratio:1; border-radius:8px; border:none; background:transparent; font-size:11px; font-weight:700; color:var(--text-soft); display:flex; align-items:center; justify-content:center; }
.dp-day:active { background: var(--surface-2); }
.dp-day.selected { background: var(--blue-600); color: #fff; }
.dp-day.today { background: var(--blue-50); color: var(--blue-700); border: 1px solid var(--blue-100); }
.dp-today-btn { width:100%; margin-top:8px; padding:8px; border:none; border-radius:10px; background:var(--blue-50); color:var(--blue-700); font-size:11px; font-weight:700; }

/* ── Modal-open guard (hides nav/fab while modal is open) ── */
body.modal-open .bottom-nav, body.modal-open .fab { display: none !important; }
body.sheet-open .bottom-nav, body.sheet-open .fab { display: none !important; }

/* ── Misc ── */
.muted-bold { font-size: 12px; font-weight: 700; color: var(--text-soft); margin: 0 0 6px; }
