/* =====================================================================
   Mediqaro - design system v2  ·  "premium clinic SaaS"
===================================================================== */
:root {
  --brand: #2563EB;
  --brand-2: #0EA5E9;
  --brand-deep: #1D4FD7;
  --brand-soft: #EAF1FE;
  --brand-ring: rgba(37, 99, 235, .18);
  --grad: linear-gradient(135deg, #2563EB 0%, #0EA5E9 100%);

  --bg: #F3F6FB;
  --surface: #FFFFFF;
  --surface-2: #F8FAFD;
  --ink: #0C1B33;
  --ink-2: #4A5B78;
  --ink-3: #8895AD;
  --line: #E4EAF3;
  --line-strong: #CDD8E8;

  --paid: #0E9F5D;   --paid-bg: #E5F7EE;
  --pend: #B45309;   --pend-bg: #FEF3E2;
  --late: #DC2626;   --late-bg: #FEECEC;

  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow-xs: 0 1px 2px rgba(15, 29, 60, .05);
  --shadow: 0 1px 2px rgba(15, 29, 60, .05), 0 10px 30px -14px rgba(15, 29, 60, .14);
  --shadow-lg: 0 2px 6px rgba(15, 29, 60, .06), 0 30px 70px -24px rgba(15, 29, 60, .32);

  --logo-navy: #1E2A5E;
  --logo-teal: #16B3A6;

  --font-display: "Rubik", "Heebo", "Segoe UI", system-ui, sans-serif;
  --font-ui: "Heebo", "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #5B8CFF;
    --brand-2: #38BDF8;
    --brand-deep: #7DA4FF;
    --brand-soft: #16233F;
    --brand-ring: rgba(91, 140, 255, .25);
    --grad: linear-gradient(135deg, #3D6EF7 0%, #1899D6 100%);

    --bg: #0B1220;
    --surface: #121C30;
    --surface-2: #17223A;
    --ink: #E7EDF7;
    --ink-2: #9FAEC8;
    --ink-3: #64748F;
    --line: #1F2C47;
    --line-strong: #31415F;

    --paid: #4ADE80;  --paid-bg: #10301F;
    --pend: #FBBF24;  --pend-bg: #33260C;
    --late: #F87171;  --late-bg: #3A1515;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 30px -14px rgba(0, 0, 0, .55);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .4), 0 30px 70px -24px rgba(0, 0, 0, .7);

    --logo-navy: #E7EDF7;
    --logo-teal: #2DD4C5;
  }
}

/* ===== base ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 700; text-wrap: balance; line-height: 1.25; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; font-size: inherit; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::placeholder { color: var(--ink-3); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ===== buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 14.5px; cursor: pointer;
  transition: all .16s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.btn:active { transform: scale(.98); }
.btn svg { flex: none; }
.btn-primary {
  background: var(--grad); border: none; color: #fff; padding: 11px 22px;
  box-shadow: 0 6px 18px -6px rgba(37, 99, 235, .5);
}
.btn-primary:hover { color: #fff; background: var(--grad); filter: brightness(1.08); box-shadow: 0 8px 24px -6px rgba(37, 99, 235, .6); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.btn-danger:hover { background: var(--late-bg); border-color: var(--late); color: var(--late); }
.btn-lg { padding: 14px 28px; font-size: 16px; border-radius: 14px; }
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px; border: none;
  background: transparent; color: var(--ink-2); cursor: pointer; transition: all .15s;
}
.icon-btn:hover { background: var(--brand-soft); color: var(--brand); }
.icon-btn.danger:hover { background: var(--late-bg); color: var(--late); }

/* ===== forms ===== */
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring);
}
.input.ltr { direction: ltr; text-align: right; }
.textarea { resize: vertical; min-height: 76px; }
.select { appearance: none; padding-inline-end: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238895AD' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 13px center;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } .form-grid .span-2 { grid-column: span 1; } }

/* ===== cards ===== */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-xs);
}
.card-pad { padding: 24px; }
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; }

/* ===== status pills ===== */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.paid { color: var(--paid); background: var(--paid-bg); }
.pill.pending { color: var(--pend); background: var(--pend-bg); }
.pill.late { color: var(--late); background: var(--late-bg); }
.pill.draft { color: var(--ink-2); background: var(--surface-2); }
.pill.credit { color: #7C3AED; background: #F1EBFE; }
@media (prefers-color-scheme: dark) { .pill.credit { color: #C4B5FD; background: #241848; } }

.doc-badge { font-size: 11px; color: var(--ink-3); font-weight: 600; margin-top: 3px; }
.inv-hint { font-size: 12.5px; color: var(--ink-3); margin-top: 10px; line-height: 1.5; }
.inv-ref {
  font-size: 13px; font-weight: 600; color: var(--brand);
  background: var(--brand-soft); border-radius: var(--r-sm);
  padding: 8px 12px; margin-top: 12px;
}

/* =====================================================================
   LANDING
===================================================================== */
/* No min-height:100vh here: vh can resolve taller than the usable viewport,
   which pushed the footer into an area the page could not scroll to. */
.landing { position: relative; overflow-x: clip; }
.landing::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(52rem 30rem at 85% -8%, var(--brand-ring), transparent 60%),
    radial-gradient(40rem 26rem at 8% 22%, rgba(14, 165, 233, .12), transparent 60%);
}

.landing-nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(20px, 5vw, 72px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.wordmark { display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 40px; height: 40px; flex: none; }
.logo-text {
  font-family: var(--font-display); font-weight: 800; font-size: 23px;
  color: var(--logo-navy); letter-spacing: -.015em; direction: ltr; line-height: 1;
}
.logo-text em { font-style: normal; color: var(--logo-teal); }

.hero {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(36px, 6vw, 90px);
  align-items: center;
  max-width: 1220px; margin: 0 auto;
  padding: clamp(40px, 7vh, 88px) clamp(20px, 5vw, 72px) clamp(48px, 8vh, 96px);
}
@media (max-width: 940px) { .hero { grid-template-columns: minmax(0, 1fr); } }

.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--brand); font-weight: 600; font-size: 13.5px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 16px; margin-bottom: 22px;
  box-shadow: var(--shadow-xs);
}
.hero-eyebrow .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); position: relative; }
.hero-eyebrow .pulse::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--brand); opacity: .4; animation: pulse 2s ease-out infinite;
}
@keyframes pulse { from { transform: scale(.5); opacity: .6; } to { transform: scale(1.4); opacity: 0; } }

.hero-title {
  font-size: clamp(34px, 4.6vw, 54px); font-weight: 800; letter-spacing: -0.01em;
  margin-bottom: 20px;
}
.hero-title em {
  font-style: normal;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { font-size: 17.5px; color: var(--ink-2); max-width: 44ch; margin-bottom: 30px; }
.hero-points { display: flex; flex-direction: column; gap: 16px; padding: 0; margin: 0 0 6px; list-style: none; }
.hero-points li { display: flex; gap: 14px; align-items: flex-start; }
.hero-points .pt-icon {
  flex: none; width: 42px; height: 42px; border-radius: 13px;
  background: var(--surface); border: 1px solid var(--line); color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-xs);
}
.hero-points b { display: block; font-size: 15.5px; font-weight: 700; }
.hero-points span { color: var(--ink-2); font-size: 14px; }

/* auth card */
.auth-card {
  padding: 30px; border-radius: 22px; box-shadow: var(--shadow-lg);
  border: 1px solid var(--line); position: relative; background: var(--surface);
}
.auth-card::before {
  content: ""; position: absolute; inset-inline: 22px; top: 0; height: 3.5px;
  border-radius: 0 0 6px 6px; background: var(--grad);
}
.auth-head { text-align: center; margin-bottom: 20px; }
.auth-head h2 { font-size: 20px; font-weight: 700; }
.auth-head p { color: var(--ink-2); font-size: 13.5px; margin-top: 3px; }
.auth-tabs { display: flex; background: var(--bg); border-radius: 13px; padding: 4px; margin-bottom: 22px; }
.auth-tabs button {
  flex: 1; padding: 9px; border: 0; background: transparent; border-radius: 10px;
  font-weight: 700; font-size: 14px; color: var(--ink-2); cursor: pointer; transition: all .15s;
}
.auth-tabs button.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-err {
  display: none; background: var(--late-bg); color: var(--late);
  border-radius: 12px; padding: 10px 14px; font-size: 13.5px; font-weight: 600;
}
.auth-err.show { display: block; }
.auth-ok {
  display: none; background: var(--paid-bg); color: var(--paid);
  border-radius: 12px; padding: 10px 14px; font-size: 13.5px; font-weight: 600; line-height: 1.55;
}
.auth-ok.show { display: block; }
.auth-lead { font-size: 13.5px; color: var(--ink-2); line-height: 1.6; margin-bottom: 2px; }
.auth-hint {
  font-size: 12.5px; color: var(--ink-2); line-height: 1.6;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 10px 12px;
}
.phone-linked {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--paid-bg); color: var(--paid);
  border-radius: var(--r-md); padding: 12px 16px; margin-bottom: 14px;
  font-weight: 600; font-size: 14px;
}
.phone-linked span { direction: ltr; }
.auth-forgot { display: flex; justify-content: space-between; gap: 12px; margin-top: -4px; }
.link-btn {
  background: none; border: 0; padding: 0;
  color: var(--brand); font-weight: 600; font-size: 13.5px; cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }
.auth-note { font-size: 12.5px; color: var(--ink-3); text-align: center; margin-top: 2px; }
.auth-note a { font-weight: 600; }

.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 11px;
  width: 100%; padding: 12px; border-radius: 12px;
  border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 15px; cursor: pointer; transition: all .15s;
}
.google-btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.google-btn:active { transform: scale(.99); }
.google-btn[disabled] { opacity: .6; cursor: progress; }
.google-btn svg { flex: none; }
.auth-divider {
  display: flex; align-items: center; gap: 12px; margin: 4px 0;
  color: var(--ink-3); font-size: 12.5px; font-weight: 500;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* feature band */
.features {
  max-width: 1220px; margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 72px) clamp(56px, 8vh, 104px);
}
.features-head { text-align: center; max-width: 560px; margin: 0 auto 40px; }
.features-head h2 { font-size: clamp(24px, 3vw, 32px); font-weight: 800; margin-bottom: 10px; }
.features-head p { color: var(--ink-2); font-size: 16px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 860px) { .feature-grid { grid-template-columns: minmax(0, 1fr); } }
.feature-card {
  padding: 28px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-xs);
  transition: transform .2s ease, box-shadow .2s ease;
}
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.feature-card .f-icon {
  width: 52px; height: 52px; border-radius: 15px; margin-bottom: 18px;
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
  background: var(--grad); box-shadow: 0 8px 20px -8px rgba(37, 99, 235, .55);
}
.feature-card h3 { font-size: 17.5px; font-weight: 700; margin-bottom: 8px; }
.feature-card p { color: var(--ink-2); font-size: 14.5px; }

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.footer-inner {
  max-width: 1220px; margin: 0 auto;
  /* Extra bottom padding keeps the credit line clear of the very bottom
     edge, so it stays readable even if the last pixels get cut off. */
  padding: 22px clamp(20px, 5vw, 72px) 56px;
  display: flex; flex-direction: column; gap: 18px;
}
.footer-top {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
.footer-links { display: flex; gap: 22px; flex-wrap: wrap; }
.footer-links a { color: var(--ink-2); font-size: 14px; font-weight: 500; }
.footer-links a:hover { color: var(--brand); text-decoration: none; }
.footer-center {
  flex: 1; text-align: center;
  color: var(--ink-2); font-size: 13.5px; font-weight: 500;
}
.footer-center a { color: var(--brand); font-weight: 700; }
.footer-center a:hover { text-decoration: underline; }
@media (max-width: 860px) {
  .footer-center { flex-basis: 100%; order: 3; }
}

/* ===== legal pages ===== */
.legal-main { max-width: 780px; margin: 0 auto; padding: clamp(28px, 5vh, 56px) clamp(20px, 5vw, 40px) 72px; }
.legal-main h1 { font-size: clamp(26px, 3.4vw, 36px); font-weight: 800; margin-bottom: 8px; }
.legal-updated { color: var(--ink-3); font-size: 13.5px; margin-bottom: 30px; }
.legal-main h2 { font-size: 19px; font-weight: 700; margin: 34px 0 10px; }
.legal-main p, .legal-main li { color: var(--ink-2); font-size: 15px; line-height: 1.8; }
.legal-main p + p { margin-top: 10px; }
.legal-main ul { margin: 10px 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 7px; }
.legal-main strong { color: var(--ink); }
.legal-note {
  background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
  border-radius: var(--r-md); padding: 16px 20px; margin-bottom: 30px;
  color: var(--ink-2); font-size: 14px; line-height: 1.7;
}
.sidebar-legal {
  display: flex; justify-content: center; gap: 14px; padding-top: 12px;
  font-size: 11.5px;
}
.sidebar-legal a { color: var(--ink-3); }
.sidebar-legal a:hover { color: var(--brand); }
.sidebar-credit {
  text-align: center; padding-top: 8px;
  font-size: 11.5px; color: var(--ink-3);
}
.sidebar-credit a { color: var(--brand); font-weight: 700; }
.sidebar-credit a:hover { text-decoration: underline; }

/* =====================================================================
   APP SHELL - sidebar layout
===================================================================== */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: 252px; flex: none;
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0;
  /* dvh tracks the usable viewport; overflow-y keeps the bottom of the
     sidebar (profile, legal links, credit) reachable if space is tight. */
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  padding: 22px 16px 16px;
}
.sidebar .wordmark { padding: 0 10px 22px; }
.sidebar .logo-icon { width: 36px; height: 36px; }
.sidebar .logo-text { font-size: 20px; }

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-label { font-size: 11.5px; font-weight: 700; color: var(--ink-3); letter-spacing: .09em; padding: 10px 12px 6px; }
.app-tab {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border: 0; border-radius: 12px; background: transparent;
  color: var(--ink-2); font-weight: 600; font-size: 14.5px; cursor: pointer;
  text-align: right; transition: all .14s; position: relative;
}
.app-tab svg { flex: none; opacity: .85; }
.app-tab:hover { background: var(--surface-2); color: var(--ink); }
.app-tab.active { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.app-tab.active::before {
  content: ""; position: absolute; inset-inline-start: -16px; top: 50%; translate: 0 -50%;
  width: 4px; height: 22px; border-radius: 4px; background: var(--grad);
}

.side-user {
  margin-top: 12px; padding: 12px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--line);
  display: flex; align-items: center; gap: 11px;
}
.avatar {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  box-shadow: 0 4px 12px -4px rgba(37, 99, 235, .5);
}
.side-user-info { flex: 1; min-width: 0; }
.side-user-info h1 { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-info .id-line { color: var(--ink-3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-info .id-line span + span::before { content: " · "; }

/* topbar + content */
.app-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 15;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px clamp(18px, 3vw, 36px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}
.topbar .tb-date { color: var(--ink-2); font-size: 13.5px; font-weight: 500; }
.topbar .tb-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.topbar .tb-actions { display: flex; gap: 10px; align-items: center; }

/* offline / pending-sync indicator */
.sync-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.sync-pill .sync-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.sync-pill.offline { color: var(--pend); background: var(--pend-bg); }
.sync-pill.syncing { color: var(--brand); background: var(--brand-soft); }
.sync-pill.syncing .sync-dot { animation: syncBlink 1.1s ease-in-out infinite; }
@keyframes syncBlink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.app-main { flex: 1; padding: 26px clamp(18px, 3vw, 36px) 90px; max-width: 1200px; width: 100%; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; animation: viewIn .22s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.view-head h2 { font-size: 25px; font-weight: 800; letter-spacing: -.01em; }
.view-head .sub { color: var(--ink-2); font-size: 14px; margin-top: 3px; }

/* mobile nav */
.mobile-nav { display: none; }
@media (max-width: 860px) {
  .sidebar { display: none; }
  .mobile-nav {
    position: fixed; bottom: 0; inset-inline: 0; z-index: 30;
    display: flex; justify-content: space-around; gap: 2px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  }
  .mobile-nav .app-tab {
    flex-direction: column; gap: 3px; padding: 7px 10px; font-size: 10.5px; flex: 1;
  }
  .mobile-nav .app-tab.active::before { display: none; }
}

/* ===== dashboard ===== */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
@media (max-width: 1060px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { padding: 20px; position: relative; overflow: hidden; }
.stat .stat-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.stat .stat-icon {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.stat .stat-icon.total { background: var(--brand-soft); color: var(--brand); }
.stat .stat-icon.paid { background: var(--paid-bg); color: var(--paid); }
.stat .stat-icon.pending { background: var(--pend-bg); color: var(--pend); }
.stat .stat-icon.late { background: var(--late-bg); color: var(--late); }
.stat .stat-label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.stat .stat-value { font-family: var(--font-display); font-size: clamp(20px, 1.4vw + 12px, 26px); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .stat-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1060px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
.dash-col { display: flex; flex-direction: column; gap: 16px; }

.chart-wrap { position: relative; }
.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 5; display: none;
  background: var(--ink); color: var(--bg); border-radius: 10px; padding: 8px 13px;
  font-size: 12.5px; font-weight: 500; white-space: nowrap; box-shadow: var(--shadow-lg);
  transform: translate(-50%, -115%);
}
.chart-tooltip .tt-val { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }

.mini-list { display: flex; flex-direction: column; }
.mini-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 2px; border-bottom: 1px solid var(--line);
}
.mini-item:last-child { border-bottom: 0; padding-bottom: 2px; }
.mini-item:first-child { padding-top: 0; }
.mini-item .mi-main { min-width: 0; }
.mini-item .mi-main b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-item .mi-main span { font-size: 12.5px; color: var(--ink-3); }
.mini-item .mi-side { text-align: left; flex: none; }
.mini-item .mi-side .amount { font-weight: 700; font-variant-numeric: tabular-nums; display: block; font-size: 14.5px; }

.gauge-row { margin-bottom: 16px; }
.gauge-row:last-child { margin-bottom: 0; }
.gauge-head { display: flex; justify-content: space-between; font-size: 13.5px; font-weight: 600; margin-bottom: 7px; }
.gauge-head .g-val { color: var(--ink-2); font-variant-numeric: tabular-nums; font-weight: 500; }
.gauge-track { height: 9px; border-radius: 99px; background: var(--bg); overflow: hidden; }
.gauge-fill { height: 100%; border-radius: 99px; transition: width .6s cubic-bezier(.22,.9,.36,1); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty-state .es-icon {
  width: 62px; height: 62px; border-radius: 18px; margin: 0 auto 14px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-3);
  display: flex; align-items: center; justify-content: center;
}
.empty-state p { font-weight: 700; color: var(--ink-2); font-size: 15px; }
.empty-state span { font-size: 13px; }

/* ===== tables ===== */
.table-scroll { overflow-x: auto; border-radius: var(--r-lg); }
.data-table { width: 100%; border-collapse: collapse; min-width: 680px; }
.data-table th {
  text-align: right; font-size: 12px; color: var(--ink-3); font-weight: 700;
  letter-spacing: .05em; padding: 13px 18px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: var(--surface-2);
}
.data-table td { padding: 14px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .t-num { font-variant-numeric: tabular-nums; }
.data-table .t-actions { display: flex; gap: 2px; justify-content: flex-end; }
.data-table td.ltr { direction: ltr; text-align: right; }

/* ===== admin panel ===== */
.admin-note { padding: 26px 4px; color: var(--ink-3); font-size: 14px; font-weight: 600; }
#view-admin .stat .stat-value { font-size: clamp(24px, 1.6vw + 14px, 30px); }
#view-admin .card + .card, #view-admin .dash-grid + .card { margin-top: 18px; }
.client-cell { display: flex; align-items: center; gap: 11px; }
.client-chip {
  width: 36px; height: 36px; border-radius: 11px; flex: none;
  background: var(--brand-soft); color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}

.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.filter-bar .input, .filter-bar .select { width: auto; }
.filter-bar .search { flex: 1; min-width: 220px; }

/* ===== invoice form ===== */
.inv-section { margin-bottom: 26px; }
.inv-section-title {
  font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
}
.inv-section-title .st-num {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: var(--brand-soft); color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.inv-section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.seg { display: inline-flex; background: var(--bg); border-radius: 13px; padding: 4px; }
.seg button {
  padding: 8px 18px; border: 0; background: transparent; border-radius: 10px;
  font-weight: 600; font-size: 13.5px; color: var(--ink-2); cursor: pointer; transition: all .15s;
}
.seg button.active { background: var(--surface); color: var(--brand); font-weight: 700; box-shadow: var(--shadow); }

.lines-scroll { overflow-x: auto; }
.lines-table { width: 100%; border-collapse: collapse; }
.lines-table th { text-align: right; font-size: 12.5px; color: var(--ink-3); padding: 6px 8px; font-weight: 700; }
.lines-table td { padding: 5px 4px; }
.lines-table .line-total { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; padding-inline: 12px; }
.lines-table col.c-desc { width: 52%; }

.totals-box {
  margin-inline-start: auto; max-width: 360px; width: 100%;
  display: flex; flex-direction: column; gap: 9px; padding: 18px 20px; margin-top: 16px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
}
.totals-row { display: flex; justify-content: space-between; align-items: center; font-size: 14.5px; color: var(--ink-2); }
.totals-row .num { font-weight: 600; }
.totals-row.grand {
  border-top: 1.5px solid var(--line-strong); padding-top: 12px; margin-top: 4px;
  font-size: 16px; font-weight: 700; color: var(--ink);
}
.totals-row.grand .num {
  font-family: var(--font-display); font-size: 23px; font-weight: 800;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.vat-inline { display: flex; align-items: center; gap: 8px; }
.vat-inline .select { width: 96px; padding: 5px 10px; padding-inline-end: 32px; font-size: 13.5px; border-radius: 9px; }

.status-toggle { display: flex; gap: 12px; }
.status-opt {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 11px 22px; border-radius: 13px; border: 1.5px solid var(--line);
  font-weight: 600; color: var(--ink-2); background: var(--surface); transition: all .15s;
}
.status-opt:hover { border-color: var(--line-strong); }
.status-opt input { display: none; }
.status-opt.sel-pending { border-color: var(--pend); background: var(--pend-bg); color: var(--pend); font-weight: 700; }
.status-opt.sel-paid { border-color: var(--paid); background: var(--paid-bg); color: var(--paid); font-weight: 700; }

.sig-box { position: relative; border: 1.5px dashed var(--line-strong); border-radius: var(--r-md); background: var(--surface-2); transition: border-color .15s; }
.sig-box:hover { border-color: var(--brand); }
.sig-box canvas { display: block; width: 100%; height: 150px; border-radius: var(--r-md); cursor: crosshair; touch-action: none; }
.sig-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--ink-3); font-size: 13.5px; pointer-events: none;
}
.sig-actions { display: flex; gap: 10px; margin-top: 10px; align-items: center; flex-wrap: wrap; }

.form-footer {
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 20px; margin-top: 10px;
}

/* ===== appointments ===== */
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 9px; margin-bottom: 18px; }
@media (max-width: 640px) { .week-strip { gap: 5px; } .week-strip .d-count { display: none; } }
.day-btn {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 15px;
  padding: 12px 4px; text-align: center; cursor: pointer; transition: all .15s;
}
.day-btn:hover { border-color: var(--brand); transform: translateY(-2px); }
.day-btn .d-name { font-size: 11.5px; color: var(--ink-3); font-weight: 700; }
.day-btn .d-date { font-family: var(--font-display); font-size: 20px; font-weight: 800; margin-top: 3px; font-variant-numeric: tabular-nums; }
.day-btn .d-count { font-size: 11px; color: var(--ink-3); margin-top: 3px; min-height: 16px; }
.day-btn .d-count.has { color: var(--brand); font-weight: 700; }
.day-btn.active { border-color: transparent; background: var(--grad); box-shadow: 0 10px 24px -8px rgba(37, 99, 235, .5); }
.day-btn.active .d-name, .day-btn.active .d-date, .day-btn.active .d-count { color: #fff; }
.day-btn.today:not(.active) { border-color: var(--brand); }

.appt-list { display: flex; flex-direction: column; gap: 12px; }
.appt-item { display: flex; align-items: center; gap: 18px; padding: 16px 20px; }
.appt-time {
  flex: none; text-align: center; min-width: 60px;
  font-family: var(--font-display); font-weight: 800; font-size: 18px; color: var(--brand);
  font-variant-numeric: tabular-nums;
}
.appt-time small { display: block; font-family: var(--font-ui); font-weight: 500; font-size: 11px; color: var(--ink-3); }
.appt-sep { width: 1px; align-self: stretch; background: var(--line); }
.appt-body { flex: 1; min-width: 0; }
.appt-body b { font-size: 15.5px; }
.appt-body .appt-meta { font-size: 13px; color: var(--ink-2); }
.appt-item.done { opacity: .55; }
.appt-item.done .appt-body b { text-decoration: line-through; }
.appt-type {
  font-size: 12px; font-weight: 700; color: var(--brand); background: var(--brand-soft);
  padding: 3px 11px; border-radius: 99px; white-space: nowrap;
}

/* ===== modal ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8, 15, 30, .55); z-index: 50;
  display: none; align-items: flex-start; justify-content: center; padding: 5vh 16px;
  overflow-y: auto; backdrop-filter: blur(4px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 540px; padding: 28px; animation: modalIn .2s cubic-bezier(.22,.9,.36,1);
}
.modal.modal-wide { max-width: 880px; }
.modal.modal-sm { max-width: 460px; }
.confirm-text { color: var(--ink-2); font-size: 15px; line-height: 1.65; }
.confirm-text ol { margin: 12px 0 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 8px; }
.confirm-text li { line-height: 1.6; }
.confirm-text b { color: var(--ink); }

/* install-as-app button */
.btn-install {
  border-color: var(--brand); color: var(--brand); background: var(--brand-soft);
}
.btn-install:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); filter: brightness(.96); }
.btn-danger-solid {
  background: var(--late); border-color: var(--late); color: #fff;
}
.btn-danger-solid:hover { background: var(--late); border-color: var(--late); color: #fff; filter: brightness(1.08); }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-head h3 { font-size: 19px; font-weight: 800; }

/* ===== toast ===== */
.toast-wrap { position: fixed; bottom: 26px; inset-inline-start: 26px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 860px) { .toast-wrap { bottom: 84px; } }
.toast {
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 13px;
  font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px; animation: toastIn .28s cubic-bezier(.22,.9,.36,1);
}
.toast.ok svg { color: #4ADE80; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; } }

/* =====================================================================
   Printable invoice document
===================================================================== */
.invoice-doc {
  background: #fff; color: #14213A; direction: rtl;
  padding: 46px 50px; max-width: 800px; margin: 0 auto;
  font-family: var(--font-ui); font-size: 14px; line-height: 1.55;
}
.invoice-doc .doc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 20px; position: relative; }
.invoice-doc .doc-top::after { content: ""; position: absolute; bottom: 0; inset-inline: 0; height: 3px; border-radius: 3px; background: linear-gradient(135deg, #2563EB, #0EA5E9); }
.invoice-doc .doc-doctor h2 { font-family: var(--font-display); font-size: 22px; font-weight: 800; color: #14213A; }
.invoice-doc .doc-doctor .doc-spec { font-weight: 600; color: #2563EB; }
.invoice-doc .doc-doctor .doc-contact { font-size: 12.5px; color: #64748B; margin-top: 5px; }
.invoice-doc .doc-type { text-align: left; }
.invoice-doc .doc-type h3 { font-family: var(--font-display); font-size: 20px; font-weight: 800; }
.invoice-doc .doc-type .doc-num { font-size: 15px; font-weight: 700; color: #2563EB; font-variant-numeric: tabular-nums; }
.invoice-doc .doc-type .doc-origin { font-size: 11px; color: #94A3B8; letter-spacing: .1em; }
.invoice-doc .doc-meta { display: flex; gap: 36px; padding: 18px 0; border-bottom: 1px solid #E7EDF5; flex-wrap: wrap; }
.invoice-doc .doc-meta div b { display: block; font-size: 11.5px; color: #94A3B8; font-weight: 700; }
.invoice-doc .doc-meta div span { font-weight: 600; }
.invoice-doc .doc-items { width: 100%; border-collapse: collapse; margin: 24px 0 8px; }
.invoice-doc .doc-items th { text-align: right; background: #F1F6FE; padding: 10px 14px; font-size: 12.5px; color: #3B5178; }
.invoice-doc .doc-items th:first-child { border-radius: 0 10px 10px 0; }
.invoice-doc .doc-items th:last-child { border-radius: 10px 0 0 10px; }
.invoice-doc .doc-items td { padding: 11px 14px; border-bottom: 1px solid #EEF2F8; font-variant-numeric: tabular-nums; }
.invoice-doc .doc-totals { margin-inline-start: auto; max-width: 300px; margin-top: 12px; }
.invoice-doc .doc-totals .row { display: flex; justify-content: space-between; padding: 4px 0; color: #3B5178; font-variant-numeric: tabular-nums; }
.invoice-doc .doc-totals .row.grand { border-top: 2px solid #14213A; margin-top: 7px; padding-top: 10px; font-size: 17px; font-weight: 800; color: #14213A; }
.invoice-doc .doc-status { display: inline-block; margin-top: 22px; padding: 7px 20px; border-radius: 10px; font-weight: 800; font-size: 14px; border: 2px solid; }
.invoice-doc .doc-status.paid { color: #0E9F5D; border-color: #0E9F5D; background: #E5F7EE; }
.invoice-doc .doc-status.pending { color: #B45309; border-color: #B45309; background: #FEF3E2; }
.invoice-doc .doc-status.credit { color: #7C3AED; border-color: #7C3AED; background: #F1EBFE; }
.invoice-doc .doc-pay { margin-top: 14px; font-size: 13.5px; font-weight: 600; color: #3B5178; }
.invoice-doc .doc-notes { margin-top: 20px; font-size: 13px; color: #3B5178; background: #F7FAFE; border-radius: 10px; padding: 13px 17px; }
.invoice-doc .doc-notes b { font-size: 11.5px; color: #94A3B8; display: block; }
.invoice-doc .doc-sign { margin-top: 32px; display: flex; justify-content: flex-end; }
.invoice-doc .doc-sign .sig-slot { text-align: center; min-width: 200px; }
.invoice-doc .doc-sign img { max-height: 74px; max-width: 220px; }
.invoice-doc .doc-sign .sig-line { border-top: 1.5px solid #14213A; padding-top: 7px; font-size: 12.5px; color: #3B5178; }
.invoice-doc .doc-footer { margin-top: 38px; padding-top: 15px; border-top: 1px solid #E7EDF5; text-align: center; font-size: 11.5px; color: #94A3B8; }

#previewBody .invoice-doc { border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }

/* ===== print ===== */
#printArea { display: none; }
@media print {
  body { background: #fff; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
  .invoice-doc { max-width: none; padding: 10mm 12mm; }
  @page { size: A4; margin: 8mm; }
}
