/* Visual identity: docs/BRAND.md is the reference. Colors, fonts, radii and shadows come only from these tokens. */
:root {
  /* Fonts */
  --font-display: "Alexandria", "Cairo", system-ui, sans-serif;
  --font: "Cairo", "Segoe UI", Tahoma, system-ui, sans-serif;

  /* Teal */
  --teal-50: #EEF7F6; --teal-100: #D5ECEA; --teal-200: #A9D8D4; --teal-300: #73BDB7; --teal-400: #3E9D96;
  --teal-500: #1C807A; --teal-600: #11665F; --teal-700: #0E524D; --teal-800: #0C403C; --teal-900: #082E2B;

  /* Gold */
  --gold-50: #FBF6EC; --gold-100: #F4E8CC; --gold-300: #E2C68A; --gold-500: #C9A45C; --gold-600: #AD8743; --gold-700: #8A6A33;

  /* Neutrals */
  --white: #FFFFFF; --neutral-50: #F6F8F7; --neutral-100: #EDF1F0; --neutral-200: #DDE4E2; --neutral-300: #C3CDCA;
  --neutral-500: #5B6D6A; --neutral-700: #3F524F; --neutral-900: #142725;

  /* Status */
  --success: #1E7A4A; --success-bg: #E6F4EC;
  --danger:  #B4232A; --danger-bg:  #FCEBEC;
  --warning: #9A6200; --warning-bg: #FDF3DD;
  --info:    #2F5EA8; --info-bg:    #E8EFFA;
  --doctor:  #6A3FB0; --doctor-bg:  #F0E8FB;

  /* Semantic aliases (what components should use) */
  --bg: var(--neutral-50);
  --surface: var(--white);
  --surface-2: var(--neutral-100);
  --line: var(--neutral-200);
  --line-2: var(--neutral-300);
  --ink: var(--neutral-900);
  --ink-2: var(--neutral-700);
  --muted: var(--neutral-500);
  --brand: var(--teal-600);
  --brand-hover: var(--teal-500);
  --brand-strong: var(--teal-700);
  --brand-soft: var(--teal-50);
  --accent: var(--gold-500);
  --accent-ink: var(--teal-900);

  /* Charts (income = teal-300 per the identity; expenses = soft danger) */
  --chart-in: var(--teal-300);
  --chart-out: #E5A3A0;

  /* Gradients */
  --gradient-hero: linear-gradient(135deg, #082E2B 0%, #0E524D 55%, #1C807A 100%);
  --gradient-gold: linear-gradient(135deg, #E2C68A 0%, #C9A45C 50%, #AD8743 100%);
  --glow-hero: radial-gradient(600px circle at 80% 20%, rgba(201, 164, 92, .18), transparent 60%);

  /* Shape */
  --radius-sm: 8px; --radius: 12px; --radius-lg: 16px; --radius-xl: 24px; --radius-pill: 999px;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(8, 46, 43, .06);
  --shadow: 0 1px 2px rgba(8, 46, 43, .05), 0 6px 20px rgba(8, 46, 43, .06);
  --shadow-lg: 0 12px 40px rgba(8, 46, 43, .12);
  --ring: 0 0 0 3px rgba(28, 128, 122, .25);

  /* Theme-aware aliases (light values here, dark values below) */
  --brand-ink: var(--teal-600);      /* brand-coloured text on surfaces */
  --link: var(--teal-500);
  --brand-soft-2: var(--teal-100);
  --line-brand: var(--teal-200);
  --surface-3: var(--neutral-50);    /* sunken areas: dashed cards, permission boxes */
  --on-brand: var(--white);          /* text on teal fills */
  --danger-fill: var(--danger);      /* fill behind white text */
  /* 3D buttons: lower edge, top highlight, drop shadow */
  --btn-edge: var(--teal-800); --btn-edge-strong: var(--teal-900); --btn-edge-ghost: var(--neutral-300); --btn-edge-danger: #7E171D;
  --btn-shine: rgba(255, 255, 255, .22); --btn-shine-ghost: rgba(255, 255, 255, .95);
  --btn-glow: rgba(8, 46, 43, .22); --btn-glow-soft: rgba(8, 46, 43, .08);
  color-scheme: light;
}

/* ---------- dark mode ----------
   Same identity on a deep-teal night background. Applies when the user picks it
   (data-theme="dark"), or follows the device when nothing was picked. Keep both blocks identical. */
:root[data-theme="dark"] {
  --bg: #0B1716; --surface: #112220; --surface-2: #172C2A; --surface-3: #0E1D1B;
  --line: #223A37; --line-2: #31504C;
  --ink: #E4EEEC; --ink-2: #B3C4C1; --muted: #8EA4A0;
  --brand: var(--teal-500); --brand-hover: var(--teal-400); --brand-strong: var(--teal-800);
  --brand-ink: var(--teal-300); --link: var(--teal-300);
  --brand-soft: rgba(115, 189, 183, .12); --brand-soft-2: rgba(115, 189, 183, .2); --line-brand: rgba(115, 189, 183, .35);
  --success: #5CC48D; --success-bg: rgba(30, 122, 74, .2);
  --danger: #F08A8F; --danger-bg: rgba(180, 35, 42, .22); --danger-fill: #B4232A;
  --warning: #E0B04F; --warning-bg: rgba(154, 98, 0, .24);
  --info: #8FB0EA; --info-bg: rgba(47, 94, 168, .24);
  --doctor: #B79AE8; --doctor-bg: rgba(106, 63, 176, .26);
  --chart-out: #C2716C;
  --btn-edge: var(--teal-900); --btn-edge-strong: #051F1D; --btn-edge-ghost: #08110F; --btn-shine-ghost: rgba(255, 255, 255, .06); --btn-glow: rgba(2, 10, 9, .55); --btn-glow-soft: rgba(2, 10, 9, .4);
  --shadow-sm: 0 1px 2px rgba(2, 10, 9, .4);
  --shadow: 0 1px 2px rgba(2, 10, 9, .35), 0 6px 20px rgba(2, 10, 9, .35);
  --shadow-lg: 0 12px 40px rgba(2, 10, 9, .55);
  --ring: 0 0 0 3px rgba(115, 189, 183, .35);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1716; --surface: #112220; --surface-2: #172C2A; --surface-3: #0E1D1B;
    --line: #223A37; --line-2: #31504C;
    --ink: #E4EEEC; --ink-2: #B3C4C1; --muted: #8EA4A0;
    --brand: var(--teal-500); --brand-hover: var(--teal-400); --brand-strong: var(--teal-800);
    --brand-ink: var(--teal-300); --link: var(--teal-300);
    --brand-soft: rgba(115, 189, 183, .12); --brand-soft-2: rgba(115, 189, 183, .2); --line-brand: rgba(115, 189, 183, .35);
    --success: #5CC48D; --success-bg: rgba(30, 122, 74, .2);
    --danger: #F08A8F; --danger-bg: rgba(180, 35, 42, .22); --danger-fill: #B4232A;
    --warning: #E0B04F; --warning-bg: rgba(154, 98, 0, .24);
    --info: #8FB0EA; --info-bg: rgba(47, 94, 168, .24);
    --doctor: #B79AE8; --doctor-bg: rgba(106, 63, 176, .26);
    --chart-out: #C2716C;
    --btn-edge: var(--teal-900); --btn-edge-strong: #051F1D; --btn-edge-ghost: #08110F; --btn-shine-ghost: rgba(255, 255, 255, .06); --btn-glow: rgba(2, 10, 9, .55); --btn-glow-soft: rgba(2, 10, 9, .4);
    --shadow-sm: 0 1px 2px rgba(2, 10, 9, .4);
    --shadow: 0 1px 2px rgba(2, 10, 9, .35), 0 6px 20px rgba(2, 10, 9, .35);
    --shadow-lg: 0 12px 40px rgba(2, 10, 9, .55);
    --ring: 0 0 0 3px rgba(115, 189, 183, .35);
    color-scheme: dark;
  }
}
/* The prescription is paper: always printed light, whatever the screen theme */
.rx-sheet { --ink: var(--neutral-900); --ink-2: var(--neutral-700); --muted: var(--neutral-500); --line: var(--neutral-200);
  --line-2: var(--neutral-300); --brand: var(--teal-600); color-scheme: light; }

/* Theme switch in the top bar: shows the moon in light mode, the sun in dark mode */
.theme-toggle .ic-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ic-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .ic-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .ic-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .ic-moon { display: none; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); font-size: .9375rem; line-height: 1.65; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; }
h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
h2 { font-size: 1.0625rem; font-weight: 600; line-height: 1.35; margin-bottom: .75rem; }
p { margin: .3rem 0; }
code, pre { font-family: ui-monospace, Menlo, Consolas, monospace; direction: ltr; }
.muted { color: var(--muted); }
.d-block { display: block; }
.ta-end { text-align: right; }
.warn-text { color: var(--danger); font-weight: 600; }
.good-text { color: var(--success); }
.more-link { display: inline-flex; align-items: center; gap: .15rem; white-space: nowrap; }
.more-link .ic { width: 16px; height: 16px; }
.title-icon { display: flex; align-items: center; gap: .4rem; color: var(--success); }
.alert-icon { display: flex; align-items: flex-start; gap: .5rem; }
.alert-icon .ic { margin-top: .2rem; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; overflow: visible; }
/* Duotone layer: the icon shape filled with its own colour at low opacity */
.ic .ic-fill { fill: currentColor; fill-opacity: var(--ic-fill, .14); stroke: none; }
:root[data-theme="dark"] .ic .ic-fill { --ic-fill: .22; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ic .ic-fill { --ic-fill: .22; } }
.ic-dots { stroke-width: 3.2; }
:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------- top bar & nav ---------- */
/* Dropdown options always use the theme surface and text, even when the closed select is see-through (top bar) */
select option, select optgroup { background-color: var(--surface); color: var(--ink); }
.banner { padding: .6rem 1.25rem; font-size: .92rem; text-align: center; }
.banner-danger { background: var(--danger-bg); color: var(--danger); }
.banner-warn { background: var(--warning-bg); color: var(--warning); }

/* ---------- layout ---------- */
.container { max-width: 1240px; margin: 0 auto; padding: 1.25rem; padding-bottom: 4rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head .muted { margin-top: .2rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.25rem 1.5rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.narrow { max-width: 560px; }
.card.dashed { border-style: dashed; border-color: var(--line-2); box-shadow: none; background: var(--surface-3); }
.card.highlight { border-color: var(--line-brand); background: var(--brand-soft); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.grid-2.wide-first { grid-template-columns: 1.6fr 1fr; }
.grid-2.wide-last { grid-template-columns: minmax(300px, 1fr) 1.7fr; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: start; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; align-items: start; }
.cards .card { margin-bottom: 0; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.grid-2, .grid-3 { margin-bottom: 1rem; }
@media (max-width: 900px) {
  .grid-2, .grid-2.wide-first, .grid-2.wide-last, .grid-3 { grid-template-columns: 1fr; }
  .container { padding: 1rem 1rem 4rem; }
  .card { padding: 1rem 1.1rem; }
}

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stats.compact { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .75rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1rem 1.25rem; box-shadow: var(--shadow); }
.stat span { display: block; color: var(--muted); font-size: .8125rem; font-weight: 500; }
.stat strong { display: block; font-size: 1.5rem; font-weight: 700; line-height: 1.2; margin-top: .25rem; font-variant-numeric: tabular-nums; }
.stats.compact .stat strong { font-size: 1.1rem; }
/* The screen's key figure: the one gold touch allowed per screen */
.stat-accent { border-top: 3px solid transparent; background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--gradient-gold) border-box; }
.stat-accent strong { color: var(--brand-ink); }
.stat-good strong { color: var(--success); }
.stat-bad strong { color: var(--danger); }

/* ---------- buttons (3D) ----------
   Flat brand fill + a solid lower edge (the "lip"), a light top highlight and a soft drop shadow.
   Hover lifts the button 1px, press sinks it onto its edge. Each variant only sets the --b-* variables. */
.btn, .icon-btn {
  --b-bg: var(--brand); --b-bg-hover: var(--brand-hover); --b-fg: var(--on-brand); --b-border: var(--brand);
  --b-edge: var(--btn-edge); --b-shine: var(--btn-shine); --b-glow: var(--btn-glow); --b-lip: 3px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  background: var(--b-bg); color: var(--b-fg); border: 1px solid var(--b-border);
  box-shadow: inset 0 1px 0 var(--b-shine), 0 var(--b-lip) 0 var(--b-edge), 0 calc(var(--b-lip) + 3px) 12px var(--b-glow);
  font: inherit; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform .09s ease, box-shadow .09s ease, background-color .15s ease;
}
.btn { padding: .625rem 1.15rem; border-radius: var(--radius); font-weight: 600; font-size: .92rem; line-height: 1.4; margin-bottom: 3px; }
.btn:hover, .icon-btn:hover { background: var(--b-bg-hover); text-decoration: none; transform: translateY(-1px);
  box-shadow: inset 0 1px 0 var(--b-shine), 0 calc(var(--b-lip) + 1px) 0 var(--b-edge), 0 calc(var(--b-lip) + 6px) 16px var(--b-glow); }
.btn:active, .icon-btn:active, details[open] > summary.btn { transform: translateY(var(--b-lip));
  box-shadow: inset 0 1px 0 var(--b-shine), 0 0 0 var(--b-edge), 0 1px 3px var(--b-glow); }
.btn:focus-visible, .icon-btn:focus-visible {
  box-shadow: inset 0 1px 0 var(--b-shine), 0 var(--b-lip) 0 var(--b-edge), 0 calc(var(--b-lip) + 3px) 12px var(--b-glow), var(--ring); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { --b-bg: var(--brand-strong); --b-bg-hover: var(--brand); --b-border: var(--brand-strong); --b-edge: var(--btn-edge-strong); }
.btn-ghost { --b-bg: var(--surface); --b-bg-hover: var(--brand-soft); --b-fg: var(--brand-ink); --b-border: var(--line-2);
  --b-edge: var(--btn-edge-ghost); --b-shine: var(--btn-shine-ghost); --b-glow: var(--btn-glow-soft); }
.btn-danger { --b-bg: var(--danger-fill); --b-bg-hover: var(--danger-fill); --b-border: var(--danger-fill); --b-edge: var(--btn-edge-danger); }
.btn-danger:hover { filter: brightness(1.08); }
.btn-sm { --b-lip: 2px; padding: .32rem .8rem; font-size: .84rem; font-weight: 600; border-radius: var(--radius-sm); margin-bottom: 2px; }
.btn-block { width: 100%; }
.btn .ic { width: 18px; height: 18px; }
.btn:not(.btn-ghost) .ic .ic-fill { fill-opacity: .25; }
.btn-sm .ic { width: 16px; height: 16px; }
/* Square icon buttons: same 3D build, quieter by default */
.icon-btn { --b-bg: var(--surface); --b-bg-hover: var(--brand-soft); --b-fg: var(--ink-2); --b-border: var(--line-2);
  --b-edge: var(--btn-edge-ghost); --b-shine: var(--btn-shine-ghost); --b-glow: var(--btn-glow-soft); --b-lip: 2px;
  width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); margin-bottom: 2px; flex: none; }
.icon-btn .ic { width: 19px; height: 19px; }
.icon-btn[title="حذف"]:hover { --b-bg-hover: var(--danger-bg); color: var(--danger); }

/* ---------- forms ---------- */
.form label { display: block; font-size: .8125rem; color: var(--ink-2); margin-bottom: .75rem; font-weight: 500; }
input, select, textarea { display: block; width: 100%; margin-top: .3rem; padding: .55rem .75rem; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: .95rem; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-hover); box-shadow: var(--ring); }
input[type=checkbox], input[type=radio] { display: inline; width: auto; margin: 0 0 0 .4rem; accent-color: var(--brand); }
input[type=checkbox]:focus, input[type=radio]:focus { box-shadow: none; }
.form label.check, label.check { display: flex; align-items: center; gap: .2rem; color: var(--ink); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 .75rem; }
.form h2 { margin-top: .4rem; padding-top: .4rem; }
.form h2:not(:first-of-type) { border-top: 1px solid var(--line); padding-top: 1rem; }
.input-affix { display: flex; align-items: center; gap: .3rem; }
.input-affix em { font-style: normal; color: var(--muted); white-space: nowrap; margin-top: .3rem; }
.inline, .inline-form { display: inline-flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.inline input, .inline select, .inline-form input, .inline-form select { width: auto; margin: 0; }
.inline-form .check { margin: 0; font-size: .85rem; }
.row-line { display: flex; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.row-line.dashed { border: 0; padding-top: 1rem; }
.row-line input:first-of-type { flex: 1; min-width: 160px; }
.w-sm { max-width: 110px; }
.toolbar { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar label { font-size: .8125rem; color: var(--muted); }
.toolbar input, .toolbar select { width: auto; padding: .35rem .5rem; }
.search { display: flex; gap: .5rem; align-items: center; }
.search input { margin: 0; flex: 1; }
.search select { width: auto; margin: 0; }
.picked { display: flex; flex-wrap: wrap; gap: .3rem 1rem; align-items: baseline; background: var(--brand-soft); padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; }

/* ---------- tables & lists ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
.table th { text-align: right; font-weight: 600; color: var(--muted); background: var(--surface-2); font-size: .8125rem; padding: .55rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table thead th:first-child { border-start-start-radius: var(--radius-sm); border-end-start-radius: var(--radius-sm); }
.table thead th:last-child { border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); }
.table td { padding: .65rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: var(--brand-soft); }
.table tfoot th { color: var(--ink); background: none; font-size: .9rem; border-top: 2px solid var(--line-2); border-bottom: 0; }
.table.compact td { padding: .45rem .5rem; }
@media (max-width: 600px) { .table { font-size: .875rem; } }
tr.dim td { opacity: .5; }
.row-actions { display: flex; gap: .35rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.note { display: block; color: var(--warning); font-size: .8125rem; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list small { display: block; }
.plain { padding-right: 1.2rem; }
.empty { color: var(--muted); text-align: center; padding: 1rem 0; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .8125rem; }
.dl dd { margin: 0; }
.pager { display: flex; gap: 1rem; justify-content: center; align-items: center; margin: 1rem 0; }
.tabs { display: flex; gap: .3rem; margin-bottom: 1rem; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs a { padding: .55rem 1rem; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--brand-ink); border-color: var(--brand-ink); font-weight: 600; }
.tabs a:hover { text-decoration: none; }
.quick { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- badges & alerts ---------- */
.badge { display: inline-block; padding: .1rem .6rem; border-radius: var(--radius-pill); font-size: .75rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.badge-booked { background: var(--info-bg); color: var(--info); }
.badge-arrived { background: var(--warning-bg); color: var(--warning); }
.badge-in { background: var(--doctor-bg); color: var(--doctor); }
.badge-done, .badge-answered { background: var(--success-bg); color: var(--success); }
.badge-no_show, .badge-cancelled, .badge-open { background: var(--danger-bg); color: var(--danger); }
.badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-confirmed { background: var(--success-bg); color: var(--success); }
.badge-disputed { background: var(--danger-bg); color: var(--danger); }
.badge-closed { background: var(--surface-2); color: var(--muted); }
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .93rem; }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-warn { background: var(--warning-bg); color: var(--warning); }
.alert-info { background: var(--info-bg); color: var(--info); }

/* ---------- dropdown ---------- */
details.more { position: relative; }
details.more summary { list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more .menu { position: absolute; left: 0; top: 110%; z-index: 10; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 170px; padding: .3rem; }
details.more .menu a, details.more .menu button:not(.btn) { display: block; width: 100%; text-align: right; padding: .45rem .75rem; border: 0; background: none; font: inherit; color: var(--ink); cursor: pointer; border-radius: var(--radius-sm); font-size: .88rem; }
details.more .menu a:hover, details.more .menu button:not(.btn):hover { background: var(--brand-soft); text-decoration: none; }

/* ---------- visits / rx ---------- */
.timeline .visit, .visit { border-right: 3px solid var(--line-brand); padding: .3rem 1rem .5rem 0; margin-bottom: 1rem; }
.visit header { display: flex; flex-wrap: wrap; gap: .3rem .75rem; align-items: center; }
.visit header .row-actions { margin-right: auto; }
.visit.small p { font-size: .88rem; }
.rx-row { display: grid; grid-template-columns: 2fr 1.5fr 1fr auto; gap: .5rem; margin-bottom: .5rem; }
.rx-row input { margin: 0; }
@media (max-width: 600px) { .rx-row { grid-template-columns: 1fr 1fr; } .rx-row input:first-child { grid-column: 1 / -1; } }

/* ---------- bars ---------- */
.bar { position: relative; height: 10px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; min-width: 80px; }
.bar span { position: absolute; inset: 0 0 0 auto; background: var(--brand-hover); border-radius: var(--radius-pill); }
.series-row { display: grid; grid-template-columns: 110px 1fr; gap: .75rem; align-items: center; padding: .25rem 0; font-size: .85rem; }
.series-label { color: var(--muted); }
.series-bars { display: grid; gap: 3px; }
.series-bars .bar { display: flex; align-items: center; gap: .45rem; height: auto; overflow: visible; background: none; border-radius: 0; }
.series-bars .bar span { position: static; display: block; height: 14px; min-width: 2px; max-width: 80%; flex: none; border-radius: 4px; }
.series-bars .bar em { font-style: normal; font-size: .75rem; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar-in span { background: var(--chart-in); }
.bar-out span { background: var(--chart-out); }
.legend { display: flex; align-items: center; gap: .4rem; font-size: .8125rem; color: var(--muted); margin-bottom: .6rem; }
.key { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.key-in { background: var(--chart-in); } .key-out { background: var(--chart-out); margin-right: .6rem; }

/* ---------- support thread ---------- */
.thread { display: flex; flex-direction: column; gap: .75rem; }
.msg { max-width: 80%; padding: .75rem 1rem; border-radius: var(--radius-lg); }
.msg-clinic { background: var(--brand-soft); align-self: flex-start; border-top-right-radius: 4px; }
.msg-support { background: var(--surface-2); border: 1px solid var(--line); align-self: flex-end; border-top-left-radius: 4px; }
.msg-meta { font-size: .75rem; color: var(--muted); margin-bottom: .2rem; }
.copy-box { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 1rem; white-space: pre-wrap; text-align: right; font-size: .9rem; }
.danger-zone { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-color: var(--danger-bg); }

/* ---------- auth / bare pages (login, errors, landing): hero gradient + display font ---------- */
body.bare { min-height: 100vh; display: grid; place-items: center; background: var(--glow-hero), var(--gradient-hero); background-attachment: fixed; padding: 1rem; }
.auth-wrap { width: 100%; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl); padding: 2rem 1.5rem; box-shadow: var(--shadow-lg); text-align: center; }
.auth-card.form { text-align: right; }
.auth-card h1 { text-align: center; font-family: var(--font-display); font-weight: 700; }
.auth-card > .muted { text-align: center; margin-bottom: 1.25rem; }
.err-code { font-family: var(--font-display); font-size: 3rem; font-weight: 700; color: var(--brand-ink); }

/* ---------- prescription sheet (print + live preview in settings) ----------
   --rx-accent is the doctor's own colour (Settings → الوصفة الطبية); --rx-wm the watermark opacity. */
.print-body { background: var(--surface-2); padding: 1rem; }
.print-tools { display: flex; gap: .6rem; align-items: center; justify-content: center; flex-wrap: wrap; margin-bottom: 1rem; }
.rx-sheet { --rx-accent: var(--teal-600); position: relative; overflow: hidden; isolation: isolate; background: var(--white); color: var(--ink);
  width: 148mm; min-height: 210mm; margin: 0 auto; padding: 11mm 12mm 9mm; display: flex; flex-direction: column; box-shadow: var(--shadow); font-size: 14px; line-height: 1.6; }
.rx-sheet.rx-paper-A4 { width: 210mm; min-height: 297mm; padding: 14mm 16mm 12mm; font-size: 15px; }
.rx-sheet.rx-font-small { font-size: 12.5px; }
.rx-sheet.rx-font-large { font-size: 16px; }
.rx-sheet.rx-paper-A4.rx-font-small { font-size: 13.5px; }
.rx-sheet.rx-paper-A4.rx-font-large { font-size: 17px; }
.rx-sheet > *:not(.rx-watermark) { position: relative; z-index: 1; }
.rx-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; border-bottom: 2px solid var(--rx-accent); padding-bottom: 3.5mm; }
.rx-title { display: flex; align-items: center; gap: .8em; }
.rx-head h1 { font-size: 1.6em; line-height: 1.25; color: var(--rx-accent); margin: 0; }
.rx-head p { font-size: .88em; margin: 0; color: var(--ink-2); }
.rx-clinic { display: flex; align-items: center; gap: .8em; text-align: left; font-size: .88em; }
.rx-clinic p { margin: 0; color: var(--ink-2); }
.rx-logo { display: block; width: auto; max-width: 40mm; object-fit: contain; }
.rx-logo-top { flex: 1 1 100%; display: flex; justify-content: center; }
.rx-align-center .rx-head { flex-direction: column; text-align: center; }
.rx-align-center .rx-title { flex-direction: column; }
.rx-align-center .rx-clinic { text-align: center; flex-direction: column; }
.rx-patient { display: flex; flex-wrap: wrap; gap: .3rem 1.4rem; padding: 3mm 0; border-bottom: 1px solid var(--line); font-size: .95em; }
.rx-diag { font-size: .93em; margin-top: 3mm; }
.rx-symbol { font-family: Georgia, serif; font-size: 2.1em; font-weight: 700; color: var(--rx-accent); margin: 2.5mm 0 1mm; }
.rx-list { flex: 1; margin: 0; padding-right: 1.4rem; }
.rx-list li { margin-bottom: 3.5mm; }
.rx-list li::marker { color: var(--rx-accent); font-weight: 700; }
.rx-list strong { display: block; font-size: 1.05em; text-align: right; }
.rx-list span { font-size: .92em; color: var(--ink-2); }
.rx-notes { border-top: 1px dashed var(--line-2); padding-top: 3mm; font-size: .93em; }
.rx-foot { border-top: 1px solid var(--line); padding-top: 3mm; margin-top: 4mm; font-size: .9em; }
.rx-foot-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.rx-foot .sig { color: var(--muted); border-top: 1px solid var(--line-2); padding-top: 1mm; min-width: 40mm; text-align: center; }
.rx-footer-text { margin-top: 2.5mm; padding-top: 2mm; border-top: 2px solid var(--rx-accent); text-align: center; font-size: .85em; color: var(--ink-2); }
.rx-watermark { position: absolute; inset: 0; z-index: 0; display: grid; place-items: center; pointer-events: none; opacity: var(--rx-wm, .08); }
.rx-watermark img { max-height: 80%; object-fit: contain; }
.rx-watermark-text span { color: var(--rx-accent); font-weight: 700; white-space: nowrap; transform: rotate(-30deg); line-height: 1; }
@page { size: A5; margin: 0; }
@media print {
  .no-print { display: none !important; }
  .print-body { background: var(--white); padding: 0; }
  .rx-sheet { box-shadow: none; width: auto; min-height: 100vh; }
  .rx-sheet, .rx-watermark { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (max-width: 600px) { .print-body .rx-sheet { width: 100%; min-height: auto; padding: 6mm; } }

/* ---------- staff permissions ---------- */
.cards.wide { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); margin-bottom: 1rem; }
@media (max-width: 600px) { .cards.wide { grid-template-columns: 1fr; } }
.dim-card { opacity: .6; }
.perms { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem .8rem; margin: 0 0 .8rem; }
.perms legend { font-weight: 600; font-size: .9rem; padding: 0 .3rem; }
.presets { display: flex; flex-wrap: wrap; gap: .35rem .9rem; margin-bottom: .6rem; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .5rem; }
.form label.perm, label.perm { display: flex; gap: .5rem; align-items: flex-start; margin: 0; padding: .5rem .75rem; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; background: var(--surface-3); }
label.perm:has(input:checked) { border-color: var(--line-brand); background: var(--brand-soft); }
label.perm:has(input:disabled) { cursor: default; }
label.perm input { margin-top: .35rem; }
label.perm strong { display: block; font-size: .88rem; color: var(--ink); }
label.perm small { display: block; font-size: .75rem; color: var(--muted); font-weight: 400; line-height: 1.5; }

/* ---------- product logo (assets/brand) ---------- */
.logo-big { display: block; width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.brand-logo { display: block; }
.brand-logo img { display: block; width: 100%; height: auto; }
.brand-logo .for-dark { display: none; }
:root[data-theme="dark"] .brand-logo .for-light { display: none; }
:root[data-theme="dark"] .brand-logo .for-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo .for-light { display: none; }
  :root:not([data-theme="light"]) .brand-logo .for-dark { display: block; }
}
.auth-logo { width: 150px; margin: 0 auto 1.1rem; }
.powered { margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.powered .brand-logo { width: 96px; margin: 0 auto; opacity: .8; }

/* ---------- live search ---------- */
[aria-busy="true"] { opacity: .55; transition: opacity .15s ease; }
input[type=search]::-webkit-search-cancel-button { cursor: pointer; }

/* ---------- cross-branch settlements ---------- */
.elsewhere { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.elsewhere h2 { margin-bottom: .25rem; }
.visit header .muted { font-size: .8125rem; }
.note.note-info { color: var(--info); }

/* ---------- patient balance ---------- */
.balance { display: inline-block; margin-inline-start: .4rem; padding: .05rem .55rem; border-radius: var(--radius-pill); font-size: .75rem; font-weight: 700; white-space: nowrap; vertical-align: middle; font-variant-numeric: tabular-nums; }
.balance-due { background: var(--danger-bg); color: var(--danger); }
.balance-credit { background: var(--success-bg); color: var(--success); }
.balance-settled { background: var(--surface-2); color: var(--muted); }
td > .balance:first-child, dd > .balance:first-child { margin-inline-start: 0; }
.credit-card { margin-top: 1rem; border-color: var(--line-brand); }

/* ---------- doctor's live monitor ---------- */
.monitor-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.monitor-head h2 { margin: 0; }
.monitor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.monitor-grid .card { margin-bottom: 0; }
.monitor-card h3 { margin: 0; font-size: 1.0625rem; }
.mon-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .75rem 0; }
/* the live counts: the same solid slab as the totals, smaller (no shadow blur, a crisp lower edge) */
.mon-num { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .65rem .8rem .55rem; margin-bottom: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .85), 0 3px 0 #d3dcda; }
:root[data-theme="dark"] .mon-num { background: var(--surface-2); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 3px 0 #050c0b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mon-num { background: var(--surface-2); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 3px 0 #050c0b; } }
.mon-num > span { display: block; font-size: .88rem; color: var(--ink-2); font-weight: 600; }
.mon-num > strong { display: block; font-size: 1.9rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.mon-wait > strong { color: var(--warning); }
.mon-in > strong { color: var(--doctor); }
.mon-done > strong { color: var(--success); }
.split { display: flex; flex-wrap: wrap; gap: .15rem .5rem; margin-top: .2rem; font-size: .8rem; color: var(--ink-2); }
.split b { font-variant-numeric: tabular-nums; }
.fu-quick { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.fu-chip { padding: .3rem .75rem; border-radius: var(--radius-pill); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font: inherit; font-size: .8125rem; font-weight: 600; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.fu-chip:hover { border-color: var(--brand); color: var(--brand-ink); }
.fu-chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--white); }
.fu-day { display: block; min-height: 1.2em; margin: .35rem 0 .6rem; font-size: .8rem; }
.mon-now { display: flex; align-items: center; gap: .75rem; margin: 0 0 .75rem; padding: .7rem .8rem; border-radius: var(--radius); background: var(--warning-bg); border: 1px solid color-mix(in srgb, var(--warning) 25%, transparent); }
.mon-now.is-in { background: var(--doctor-bg); border-color: color-mix(in srgb, var(--doctor) 28%, transparent); }
.mon-now-ic { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; flex: none; border-radius: 50%; background: var(--surface); color: var(--warning); }
.mon-now.is-in .mon-now-ic { color: var(--doctor); }
.mon-now-text { flex: 1; min-width: 0; display: grid; line-height: 1.35; }
.mon-now-text small { font-size: .75rem; color: var(--ink-2); font-weight: 600; }
.mon-now-text strong { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mon-now-text .muted { font-size: .8rem; }
.mon-now .btn { flex: none; }
@media (max-width: 600px) { .mon-now { flex-wrap: wrap; } .mon-now .btn { width: 100%; justify-content: center; } }
.mon-money { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 .75rem; padding: .5rem .75rem; border-radius: var(--radius); background: var(--brand-soft); }
.mon-money span { color: var(--ink-2); font-size: .875rem; }
.mon-money strong { font-size: 1.15rem; color: var(--brand-ink); font-variant-numeric: tabular-nums; }
.mon-line { list-style: none; margin: 0; padding: 0; }
.mon-line li { display: grid; grid-template-columns: 2rem 1fr auto; grid-template-areas: "pos name time" "pos svc time"; align-items: center; column-gap: .6rem; padding: .5rem 0; border-top: 1px solid var(--line); }
.mon-line li > .mon-pos { grid-area: pos; }
.mon-line li > strong { grid-area: name; }
.mon-line li > .muted:not(small) { grid-area: svc; font-size: .8125rem; }
.mon-line li > small { grid-area: time; font-size: .8125rem; white-space: nowrap; }
.mon-pos { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--warning-bg); color: var(--warning); font-weight: 700; font-variant-numeric: tabular-nums; }
.mon-line li.is-in .mon-pos { background: var(--doctor-bg); color: var(--doctor); }
.mon-line li.is-in .mon-pos .ic { width: 16px; height: 16px; }
@media (max-width: 600px) { .mon-nums { grid-template-columns: repeat(3, 1fr); } .monitor-grid { grid-template-columns: 1fr; } }

/* ---------- appointments: grouped sections ---------- */
.appt-group .card-head h2 { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.appt-group .count { font-size: .8125rem; font-weight: 700; min-width: 1.75rem; text-align: center; padding: .05rem .5rem; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--ink-2); }
.appt-line .count { background: var(--warning-bg); color: var(--warning); }
details.appt-group > summary { cursor: pointer; list-style: none; }
details.appt-group > summary::-webkit-details-marker { display: none; }
details.appt-group > summary h2::after { content: ""; width: .5rem; height: .5rem; border-inline-start: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); margin-inline-start: .25rem; transition: transform .15s ease; }
details.appt-group[open] > summary h2::after { transform: rotate(-135deg); }
details.appt-group:not([open]) > summary h2 { margin-bottom: 0; }
.doctor-mode { margin-top: .75rem; display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; } .doctor-mode label.perm { flex: 1; min-width: 260px; }

/* ---------- phones: tables become cards ----------
   app.js labels every cell with its column title and marks the row's title (cell-main), its buttons
   (cell-actions) and the # column (cell-index). Below 720px a row is a small card: title on top,
   the other values in two columns with their label above, buttons full width at the bottom. */
@media (max-width: 720px) {
  .table.stackable, .table.stackable tbody, .table.stackable tfoot, .table.stackable tr, .table.stackable td, .table.stackable th { display: block; }
  .table.stackable thead { display: none; }
  .table.stackable tbody tr, .table.stackable tfoot tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: .55rem .9rem; align-items: start;
    padding: .85rem .9rem; margin-bottom: .6rem; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface); box-shadow: var(--shadow-sm);
  }
  .table.stackable tbody tr:hover { background: var(--surface); }
  .table.stackable tfoot tr { background: var(--surface-2); }
  .table.stackable td, .table.stackable tfoot th { padding: 0; border: 0; text-align: start; white-space: normal; min-width: 0; font-weight: 500; }
  .table.stackable td[data-label]:not([data-label=""])::before, .table.stackable tfoot th[data-label]:not([data-label=""])::before {
    content: attr(data-label); display: block; margin-bottom: .1rem; font-size: .72rem; font-weight: 500; color: var(--muted);
  }
  .table.stackable td:empty, .table.stackable .cell-index { display: none; }
  .table.stackable .cell-main { grid-column: 1 / -1; order: -1; font-size: 1rem; padding-bottom: .45rem; border-bottom: 1px dashed var(--line); }
  .table.stackable .cell-main::before { display: none !important; }
  .table.stackable .cell-actions { grid-column: 1 / -1; order: 99; padding-top: .55rem; border-top: 1px solid var(--line); }
  .table.stackable .cell-actions::before { display: none !important; }
  .table.stackable .cell-actions .row-actions { justify-content: stretch; }
  .table.stackable .cell-actions .row-actions > a, .table.stackable .cell-actions .row-actions > form { flex: 1 1 auto; }
  .table.stackable .cell-actions .row-actions > form .btn, .table.stackable .cell-actions .row-actions > a.btn { width: 100%; }
  .table.stackable .cell-actions .row-actions > details { flex: none; }
  .table.stackable .cell-actions .btn-sm { padding: .5rem .8rem; font-size: .875rem; }
  .table.stackable tr.dim td { opacity: 1; }
  .table.stackable tr.dim { opacity: .6; }
  .table.stackable td[colspan] { grid-column: 1 / -1; }
  /* the card already frames each row, so the table's own card gets lighter */
  .card.table-wrap:has(> .table.stackable), .card:has(> .table-wrap > .table.stackable) { background: transparent; border: 0; box-shadow: none; padding: 0; }
  .card.table-wrap:has(> .table.stackable) > h2, .card.table-wrap:has(> .table.stackable) > .card-head { padding: 0 .1rem; }
  .table-wrap { overflow-x: visible; }
  details.more .menu { left: 0; right: auto; }

  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }
  .toolbar > .btn, .toolbar > form { flex: 1 1 auto; }
  .toolbar input[type=date] { width: 100%; }
}
@media (max-width: 720px) {
  /* status badge sits in the card's top corner, next to the title */
  .table.stackable tr { position: relative; }
  .table.stackable .cell-status { position: absolute; top: .85rem; inset-inline-end: .9rem; }
  .table.stackable .cell-status::before { display: none !important; }
  .table.stackable tr:has(.cell-status) .cell-main { padding-inline-end: 6.5rem; }
}
@media (max-width: 720px) {
  /* the row's buttons share one line: main step, collect, then the ⋯ menu */
  .table.stackable .cell-actions .row-actions { flex-wrap: nowrap; gap: .4rem; }
  .table.stackable .cell-actions .row-actions > a, .table.stackable .cell-actions .row-actions > form { flex: 1 1 0; min-width: 0; }
  .table.stackable .cell-actions .btn { overflow: hidden; text-overflow: ellipsis; padding-inline: .5rem; }
}
@media (max-width: 720px) {
  /* day navigation: the date on its own line, then previous and next side by side, then "today" */
  .toolbar .day-pick { order: -1; flex: 1 1 100%; }
  .toolbar .day-pick select { flex: 1 1 auto; }
  .toolbar .day-prev, .toolbar .day-next { flex: 1 1 0; }
  .toolbar .day-today { flex: 1 1 100%; }
}

/* ---------- payments: total and what it is made of ---------- */
.pay-summary { display: grid; grid-template-columns: minmax(170px, 1fr) 2fr; gap: 1rem; margin-bottom: 1rem; padding: 1rem 1.1rem; border-radius: var(--radius-lg);
  border: 1px solid var(--line); border-top: 3px solid transparent; background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--gradient-gold) border-box; }
.pay-total span { display: block; font-size: .8125rem; color: var(--muted); font-weight: 500; }
.pay-total strong { display: block; font-size: 1.9rem; font-weight: 700; line-height: 1.2; color: var(--brand-ink); font-variant-numeric: tabular-nums; }
.pay-split { border-inline-start: 1px solid var(--line); padding-inline-start: 1rem; }
.pay-split-title { display: block; font-size: .8125rem; color: var(--muted); font-weight: 500; margin-bottom: .35rem; }
.pay-split ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.pay-split li { display: grid; grid-template-columns: 6.5rem 1fr auto 2.6rem; align-items: center; gap: .6rem; }
.pay-method { font-weight: 600; font-size: .9rem; }
.pay-split strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pay-split small { text-align: end; font-variant-numeric: tabular-nums; }
.pay-bar { height: 8px; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; }
.pay-bar i { display: block; height: 100%; border-radius: var(--radius-pill); background: var(--teal-300); }
.pay-instapay .pay-bar i { background: var(--teal-500); }
.pay-wallet .pay-bar i { background: var(--gold-500); }
.pay-card .pay-bar i { background: var(--teal-700); }
@media (max-width: 720px) {
  .pay-summary { grid-template-columns: 1fr; gap: .75rem; }
  .pay-split { border-inline-start: 0; padding-inline-start: 0; border-top: 1px solid var(--line); padding-top: .75rem; }
  .pay-split li { grid-template-columns: 5.5rem 1fr auto 2.4rem; }
}

/* ---------- prescription designer (settings) ---------- */
.rx-designer { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 1.25rem; align-items: start; }
.rx-form { margin-bottom: 0; }
.rx-group { border: 0; border-top: 1px solid var(--line); margin: 0; padding: .9rem 0 .4rem; }
.rx-group:first-of-type { border-top: 0; padding-top: 0; }
.rx-group legend { font-weight: 700; font-size: .95rem; padding: 0 0 .35rem; color: var(--ink); }
.seg-row { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; margin-bottom: .75rem; }
.seg-label { font-size: .8125rem; color: var(--ink-2); font-weight: 500; min-width: 5.5rem; }
.form label.seg, label.seg { display: inline-flex; margin: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: .35rem .75rem; border: 1px solid var(--line-2); border-radius: var(--radius-sm); font-size: .84rem; color: var(--ink-2); background: var(--surface); transition: background .12s, border-color .12s; }
.seg input:checked + span { background: var(--brand-soft); border-color: var(--line-brand); color: var(--brand-ink); font-weight: 600; }
.seg input:focus-visible + span { box-shadow: var(--ring); }
.form label.color-pick { display: flex; align-items: center; gap: .75rem; }
.color-pick input[type=color] { width: 3rem; height: 2.2rem; padding: .15rem; margin: 0; cursor: pointer; }
.form label.range { display: grid; grid-template-columns: 5.5rem 1fr 3rem; align-items: center; gap: .6rem; }
.range input[type=range] { margin: 0; padding: 0; border: 0; background: none; accent-color: var(--brand); }
.range output { font-variant-numeric: tabular-nums; font-weight: 600; text-align: end; }
.rx-image-pick { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.rx-thumb { display: grid; place-items: center; width: 64px; height: 64px; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); background: var(--surface-3); overflow: hidden; }
.rx-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.file-btn { cursor: pointer; }
.rx-save { position: sticky; bottom: 0; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .75rem 0 .1rem; background: var(--surface); border-top: 1px solid var(--line); }
.rx-preview-wrap { position: sticky; top: 1.5rem; }
.rx-preview-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.rx-preview-head h2 { margin: 0; }
.rx-preview-frame { position: relative; overflow: hidden; padding: 0; border-radius: var(--radius); background: var(--surface-2); }
#rx-preview { width: max-content; transform-origin: top right; }
#rx-preview .rx-sheet { margin: 0; box-shadow: var(--shadow-lg); }
@media (max-width: 1000px) {
  .rx-designer { grid-template-columns: 1fr; }
  .rx-preview-wrap { position: static; order: -1; }
}
.rx-designer > * { min-width: 0; }
.rx-hint { font-size: .8125rem; margin: 0 0 .6rem; }
.rx-text-row { display: grid; grid-template-columns: 1.5rem 1fr; align-items: end; gap: .4rem; }
.rx-text-row > input[type=checkbox] { margin: 0 0 1.3rem; justify-self: center; }
.rx-always { width: 1.5rem; }
.rx-sample-note { font-size: .8125rem; color: var(--ink-2); background: var(--info-bg); border-radius: var(--radius-sm); padding: .5rem .75rem; margin: 0 0 .6rem; }
.rx-fixed-notes { border-top: 0; padding-top: 0; color: var(--ink-2); }
/* edit before printing */
.rx-sheet.is-editing { outline: 2px dashed var(--rx-accent); outline-offset: 6px; cursor: text; }
.rx-sheet.is-editing :is(h1, p, span, li, strong, b):hover { background: var(--teal-50); border-radius: 3px; }
.rx-sheet[contenteditable="true"]:focus { outline: 2px dashed var(--rx-accent); }
.rx-edit-hint { max-width: 148mm; margin: 0 auto .75rem; text-align: center; font-size: .875rem; color: var(--info); background: var(--info-bg); border-radius: var(--radius-sm); padding: .5rem .75rem; }
@media print { .rx-sheet.is-editing { outline: 0; } .rx-sheet.is-editing :hover { background: none; } }

/* ======================================================================
   App shell: side menu on desktop, slim top bar + bottom tab bar on phones
   ====================================================================== */
body.app { --sb-w: 264px; }
body.app.sb-collapsed { --sb-w: 84px; }
.app-main { margin-inline-start: var(--sb-w); min-height: 100vh; transition: margin .2s ease; }
.app-main > .container { padding-top: 1.75rem; }

/* ---- sidebar ---- */
.sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 30; width: var(--sb-w); display: flex; flex-direction: column; gap: .25rem;
  padding: 1rem .8rem .9rem; overflow-y: auto; overflow-x: hidden; color: var(--on-brand);
  background: radial-gradient(420px circle at 100% 0%, rgba(201, 164, 92, .10), transparent 60%), linear-gradient(180deg, var(--teal-800), var(--teal-900));
  transition: width .2s ease; scrollbar-width: thin; }
.sb-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 44px; }
.sb-brand { display: flex; align-items: center; gap: .65rem; min-width: 0; color: inherit; }
.sb-brand:hover { text-decoration: none; }
.sb-mark { width: 40px; height: 40px; border-radius: 12px; flex: none; box-shadow: 0 2px 8px rgba(2, 10, 9, .3); }
.sb-name { min-width: 0; line-height: 1.3; }
.sb-name strong { display: block; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-name small { display: block; font-size: .75rem; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-logo-wide { height: 30px; width: auto; display: block; }
.sb-mark-only { display: none; }
.sb-tag { align-self: flex-start; margin: .2rem 0 .1rem; font-size: .72rem; font-weight: 600; padding: .1rem .6rem; border-radius: var(--radius-pill); background: rgba(255,255,255,.1); }
/* collapse handle: a paper-like tab pulled out of the menu edge, in the menu colour, level with the logo */
.sb-toggle { position: fixed; z-index: 29; top: 1.35rem; inset-inline-start: calc(var(--sb-w) - 1px); display: grid; place-items: center; width: 20px; height: 52px; padding: 0;
  border: 0; border-start-end-radius: 12px; border-end-end-radius: 12px; color: rgba(255, 255, 255, .78); cursor: pointer;
  background: radial-gradient(60px circle at 0 0, rgba(201, 164, 92, .12), transparent 70%), linear-gradient(180deg, var(--teal-800), #0B3a37);
  box-shadow: -3px 3px 10px -2px rgba(8, 46, 43, .35), inset 1px 0 0 rgba(255, 255, 255, .06);
  transition: inset-inline-start .2s ease, width .15s ease, color .15s; }
[dir="ltr"] .sb-toggle { box-shadow: 3px 3px 10px -2px rgba(8, 46, 43, .35); }
.sb-toggle:hover { width: 26px; color: var(--white); }
.sb-toggle:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }
.sb-toggle .ic { width: 15px; height: 15px; stroke-width: 2.4; }
.sidebar .clinic-switch { display: flex; align-items: center; gap: .5rem; margin: .75rem 0 .35rem; padding: .3rem .55rem; border-radius: var(--radius); background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14); font-size: .875rem; }
.clinic-switch .nav-ic .ic { width: 17px; height: 17px; opacity: .8; }
.sidebar .clinic-switch select, .mbar .clinic-switch select { flex: 1; min-width: 0; margin: 0; padding: .25rem 0; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; cursor: pointer; box-shadow: none; }
.clinic-switch.is-fixed span:last-child { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-nav { display: flex; flex-direction: column; gap: .2rem; margin-top: .6rem; flex: 1; }
.sb-item { display: flex; align-items: center; gap: .75rem; padding: .45rem .55rem; border-radius: var(--radius); color: rgba(255,255,255,.8); font-weight: 500; font-size: .95rem; white-space: nowrap; transition: background .15s, color .15s; }
.sb-item:hover { background: rgba(255,255,255,.08); color: var(--white); text-decoration: none; }
.nav-ic { display: grid; place-items: center; flex: none; }
.sb-item .nav-ic { width: 36px; height: 36px; border-radius: 11px; background: rgba(255,255,255,.07); transition: background .18s ease, transform .18s ease, box-shadow .18s ease; }
.sb-item .ic { width: 19px; height: 19px; }
.sb-item.on { background: var(--surface); color: var(--brand-ink); font-weight: 700; box-shadow: 0 6px 18px rgba(2, 10, 9, .28); }
.sb-item.on .nav-ic { background: var(--brand-soft); }
.sb-item.on .ic .ic-fill { --ic-fill: .26; }
.sb-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .75rem; padding-top: .8rem; border-top: 1px solid rgba(255,255,255,.12); }
.sb-user { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; font-weight: 700; font-size: 1rem; color: var(--white);
  background: linear-gradient(135deg, var(--teal-400), var(--teal-600)); box-shadow: inset 0 0 0 2px rgba(255,255,255,.18); }
.sb-user-text { min-width: 0; line-height: 1.3; }
.sb-user-text strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: .84rem; line-height: 1.25; overflow: hidden; overflow-wrap: anywhere; }
.sb-user-text small { display: block; font-size: .72rem; opacity: .7; }
.sb-actions { display: flex; gap: .35rem; flex: none; }
/* Two rows: who is signed in, then the buttons (language takes the free width) */
body:not(.sb-collapsed) .sidebar .sb-foot { flex-direction: column; align-items: stretch; gap: .65rem; }
body:not(.sb-collapsed) .sidebar .sb-actions { width: 100%; }
body:not(.sb-collapsed) .sidebar .sb-actions .lang-switch.icon-btn { flex: 1; }
body:not(.sb-collapsed) .sidebar .sb-actions form { display: flex; }
.lang-switch .ls-short { display: none; }
/* Short screens: one row again (the menu should not need scrolling), language as «EN» / «ع» */
@media (min-width: 901px) and (max-height: 700px) {
  body:not(.sb-collapsed) .sidebar .sb-foot { flex-direction: row; align-items: center; gap: .5rem; }
  body:not(.sb-collapsed) .sidebar .sb-actions { width: auto; }
  body:not(.sb-collapsed) .sidebar .sb-actions .lang-switch.icon-btn { flex: none; }
  .sidebar .lang-switch .ls-full { display: none; }
  .sidebar .lang-switch .ls-short { display: inline; font-weight: 700; font-size: .72rem; }
}
.sidebar .icon-btn, .mbar .icon-btn { --b-bg: rgba(255,255,255,.08); --b-bg-hover: rgba(255,255,255,.16); --b-fg: var(--on-brand);
  --b-border: rgba(255,255,255,.18); --b-edge: rgba(4,20,19,.45); --b-shine: rgba(255,255,255,.14); --b-glow: transparent; width: 34px; height: 34px; }

/* collapsed: icons only */
body.sb-collapsed .sidebar { padding-inline: .6rem; }
body.sb-collapsed .sb-top { flex-direction: column; gap: .6rem; }
body.sb-collapsed .sb-name, body.sb-collapsed .sb-logo-wide, body.sb-collapsed .nav-label, body.sb-collapsed .sb-user-text, body.sb-collapsed .sb-tag, body.sb-collapsed .sidebar .clinic-switch { display: none; }
body.sb-collapsed .sb-mark-only { display: block; }
/* the arrow points where the menu edge will move: right to collapse, left to expand (RTL) */
.sb-toggle .ic { transform: rotate(180deg); transition: transform .2s; }
body.sb-collapsed .sb-toggle .ic { transform: none; }
body.sb-collapsed .sb-item { justify-content: center; padding-inline: 0; }
body.sb-collapsed .sb-foot { flex-direction: column; }
body.sb-collapsed .sb-actions { flex-direction: column; }

/* ---- phones and small tablets ---- */
.mbar, .bbar, .more-sheet { display: none; }
@media (max-width: 900px) {
  .sidebar, .sb-toggle { display: none; }
  .app-main { margin-inline-start: 0; padding-bottom: calc(4.6rem + env(safe-area-inset-bottom)); }
  .app-main > .container { padding-top: 1rem; }
  .mbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: .6rem;
    padding: .5rem .85rem; padding-top: max(.5rem, env(safe-area-inset-top)); color: var(--on-brand);
    background: linear-gradient(135deg, var(--teal-800), var(--teal-700)); box-shadow: 0 2px 12px rgba(8, 46, 43, .18); }
  .mbar-brand { display: flex; align-items: center; gap: .55rem; min-width: 0; color: inherit; }
  .mbar-brand:hover { text-decoration: none; }
  .mbar-brand .sb-mark { width: 34px; height: 34px; border-radius: 10px; }
  .mbar-brand strong { font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mbar-end { display: flex; align-items: center; gap: .45rem; flex: none; }
  .mbar .clinic-switch { display: flex; align-items: center; gap: .3rem; max-width: 9.5rem; padding: .2rem .6rem; border-radius: var(--radius-pill); background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); font-size: .8rem; }
  .mbar .clinic-switch .nav-ic { display: none; }
  .mbar .clinic-switch.is-fixed span:last-child { max-width: 8rem; }

  .bbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 40; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    padding: .35rem .35rem calc(.35rem + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgba(8, 46, 43, .08); }
  .bb-item { display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .25rem 0; border: 0; background: none; font: inherit;
    font-size: .7rem; font-weight: 600; color: var(--muted); cursor: pointer; }
  .bb-item:hover { text-decoration: none; }
  .bb-item .nav-ic { width: 52px; height: 30px; border-radius: var(--radius-pill); transition: background .15s, color .15s; }
  .bb-item .ic { width: 21px; height: 21px; }
  .bb-item.on { color: var(--brand-ink); }
  .bb-item.on .nav-ic { background: var(--brand-soft); }
  .bb-item.on .ic .ic-fill { --ic-fill: .28; }

  .more-sheet:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 60; }
  .more-backdrop { position: absolute; inset: 0; background: rgba(8, 46, 43, .45); animation: fade-in .18s ease; }
  .more-panel { position: absolute; inset-inline: 0; bottom: 0; padding: .6rem 1rem calc(1rem + env(safe-area-inset-bottom)); background: var(--surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0; box-shadow: var(--shadow-lg); animation: sheet-up .22s ease; }
  .more-grip { width: 42px; height: 5px; margin: 0 auto .8rem; border-radius: var(--radius-pill); background: var(--line-2); }
  .more-panel .sb-user { padding: 0 .2rem .8rem; border-bottom: 1px solid var(--line); margin-bottom: .8rem; color: var(--ink); }
  .more-panel .sb-user-text small { color: var(--muted); opacity: 1; }
  .more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
  .more-item-form { margin: 0; display: contents; }
  .more-item { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .7rem .3rem; border-radius: var(--radius); border: 1px solid var(--line);
    background: var(--surface-3); color: var(--ink-2); font: inherit; font-size: .8rem; font-weight: 600; text-align: center; cursor: pointer; }
  .more-item:hover { text-decoration: none; background: var(--brand-soft); }
  .more-item .nav-ic { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); }
  .more-item.on { border-color: var(--line-brand); color: var(--brand-ink); background: var(--brand-soft); }
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .more-panel, .more-backdrop { animation: none; } .sidebar, .app-main { transition: none; } }
/* Short screens (e.g. laptops): the menu parts never squeeze into each other; the menu scrolls instead,
   and items get a little tighter so they usually still fit */
.sidebar > * { flex-shrink: 0; }
.sb-nav { flex: 1 0 auto; }
@media (min-width: 901px) and (max-height: 900px) {
  .sidebar { padding-block: .7rem .6rem; }
  .sidebar .clinic-switch { margin: .5rem 0 .2rem; }
  .sb-nav { gap: .1rem; margin-top: .35rem; }
  .sb-item { padding-block: .3rem; }
  .sb-item .nav-ic { width: 32px; height: 32px; border-radius: 10px; }
  .sb-foot { margin-top: .5rem; padding-top: .55rem; }
  .avatar { width: 34px; height: 34px; }
}
/* very short windows: tighter still, so the whole menu stays in view down to about 600px */
@media (min-width: 901px) and (max-height: 690px) {
  .sidebar { padding-block: .5rem .45rem; }
  .sb-nav { gap: 0; margin-top: .2rem; }
  .sb-item { padding-block: .15rem; font-size: .9rem; }
  .sb-item .nav-ic { width: 28px; height: 28px; border-radius: 9px; }
  .sb-item .ic { width: 17px; height: 17px; }
}

/* ---------- notifications: bell, live cards, list ---------- */
.bell { position: relative; }
.bell-count { position: absolute; top: -6px; inset-inline-start: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill);
  background: var(--danger-fill); color: var(--white); font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--teal-800); font-variant-numeric: tabular-nums; }
.sb-top .bell { margin-inline-start: auto; }
body.sb-collapsed .sb-top .bell { margin-inline-start: 0; }
.live-stack { position: fixed; top: 1rem; inset-inline-end: 1rem; z-index: 80; display: grid; gap: .6rem; width: min(400px, calc(100vw - 2rem)); }
/* Live card: coloured by group (patients teal, money gold, team blue, support violet) */
.live-item { --lc: var(--teal-500); --lc-soft: rgba(28, 128, 122, .12); --lc-grad: var(--gradient-hero); --lc-ink: var(--white);
  position: relative; display: grid; grid-template-columns: 2.75rem 1fr auto; gap: .8rem; align-items: start; padding: .95rem 1rem 1.05rem; overflow: hidden;
  background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 2px 6px rgba(8, 46, 43, .06), 0 18px 48px -12px rgba(8, 46, 43, .28);
  animation: live-in .34s cubic-bezier(.2, .9, .3, 1.2); text-decoration: none; }
.live-item::before { content: ""; position: absolute; inset: 0; background: radial-gradient(420px circle at 100% 0%, var(--lc-soft), transparent 55%); pointer-events: none; }
.live-item[data-grp="money"] { --lc: var(--gold-600); --lc-soft: rgba(201, 164, 92, .16); --lc-grad: var(--gradient-gold); --lc-ink: var(--teal-900); }
.live-item[data-grp="team"] { --lc: var(--info); --lc-soft: rgba(47, 94, 168, .13); --lc-grad: linear-gradient(135deg, #1F3F75, #3D6CC0); }
.live-item[data-grp="support"] { --lc: var(--doctor); --lc-soft: rgba(106, 63, 176, .13); --lc-grad: linear-gradient(135deg, #4A2B85, #7B53C4); }
.live-item:hover { text-decoration: none; border-color: color-mix(in srgb, var(--lc) 45%, var(--line)); }
.live-item:hover .live-cta { gap: .5rem; }
.live-item.out { animation: live-out .3s ease forwards; }
.live-ic { position: relative; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 14px; background: var(--lc-grad); color: var(--lc-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 6px 14px -4px color-mix(in srgb, var(--lc) 60%, transparent); }
.live-ic .ic { width: 22px; height: 22px; --ic-fill: .28; }
.live-main { position: relative; min-width: 0; display: grid; gap: .15rem; }
.live-head { display: flex; align-items: center; gap: .45rem; font-size: .72rem; line-height: 1.4; }
.live-group { color: var(--lc); font-weight: 700; letter-spacing: .01em; }
.live-time { color: var(--muted); }
.live-time::before { content: "•"; margin-inline-end: .45rem; opacity: .6; }
.live-title { font-family: var(--font-display); font-size: .95rem; font-weight: 600; line-height: 1.45; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-line { font-size: .82rem; line-height: 1.5; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-cta { display: inline-flex; align-items: center; gap: .3rem; margin-top: .3rem; font-size: .78rem; font-weight: 700; color: var(--lc); transition: gap .15s; }
.live-cta::after { content: "←"; }
.live-x { position: relative; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; margin: -.2rem -.3rem 0 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.live-x:hover { background: var(--surface-2); color: var(--ink); }
.live-x svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.live-bar { position: absolute; inset-inline: 0; bottom: 0; height: 3px; background: var(--lc); opacity: .7; transform-origin: right; animation: live-bar 7s linear forwards; }
.live-item.hold .live-bar { animation-play-state: paused; }
@keyframes live-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes live-out { to { opacity: 0; transform: translateX(-24px); } }
@keyframes live-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (max-width: 900px) { .live-stack { top: 4.2rem; inset-inline: .75rem; width: auto; } .bell-count { box-shadow: 0 0 0 2px var(--teal-700); } }
@media (prefers-reduced-motion: reduce) { .live-item, .live-item.out { animation: none; } .live-bar { animation: none; display: none; } }

.seg-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.seg-tabs a { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .85rem; border-radius: var(--radius-pill); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-size: .875rem; font-weight: 600; }
.seg-tabs a:hover { text-decoration: none; background: var(--brand-soft); }
.seg-tabs a.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.seg-tabs a span { font-size: .75rem; opacity: .8; font-variant-numeric: tabular-nums; }
.notif-list { padding: .5rem 1rem; }
.notif-day { font-size: .78rem; font-weight: 700; color: var(--muted); padding: .8rem 0 .3rem; }
.notif { display: grid; grid-template-columns: 2.4rem 1fr auto; gap: .75rem; align-items: start; padding: .7rem .4rem; border-top: 1px solid var(--line); color: var(--ink); border-radius: var(--radius-sm); }
.notif:hover { text-decoration: none; background: var(--brand-soft); }
.notif-ic { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 12px; background: var(--surface-2); color: var(--ink-2); }
.notif.is-new .notif-ic { background: var(--brand-soft); color: var(--brand-ink); }
.notif-main { display: grid; gap: .15rem; min-width: 0; }
.notif-main span { font-size: .85rem; color: var(--ink-2); }
.notif-time { font-size: .78rem; color: var(--muted); white-space: nowrap; text-align: end; font-variant-numeric: tabular-nums; }
.notif-time em { display: block; font-style: normal; font-weight: 700; color: var(--brand-ink); }
.notif.k-arrival .notif-ic { background: var(--warning-bg); color: var(--warning); }
.notif.k-payment .notif-ic { background: var(--success-bg); color: var(--success); }
.notif.k-missed .notif-ic { background: var(--danger-bg); color: var(--danger); }
.push-box { max-width: 720px; }
.push-state { font-size: .8125rem; font-weight: 600; padding: .15rem .65rem; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--ink-2); }
.push-state.on { background: var(--success-bg); color: var(--success); }
.push-state.off { background: var(--warning-bg); color: var(--warning); }
.push-devices-title { font-size: .9rem; margin: 1rem 0 .3rem; }
.push-ios { background: var(--info-bg); color: var(--info); border-radius: var(--radius-sm); padding: .5rem .75rem; }
.notify-settings { align-items: start; }
.notify-side { display: grid; gap: 16px; align-content: start; }
.notify-side > .card { margin: 0; }
.notify-events { margin-bottom: 1rem; }
.notify-events strong { display: flex !important; align-items: center; gap: .35rem; }
.notify-events strong .ic { width: 16px; height: 16px; color: var(--brand-ink); }
.tg-steps { margin: 0 0 1rem; padding-inline-start: 1.2rem; color: var(--ink-2); font-size: .9rem; }
.tg-steps li { margin-bottom: .35rem; }
.tg-linked { display: flex; align-items: center; gap: .4rem; color: var(--success); font-weight: 600; }
.tg-card .actions form { margin: 0; }

/* ======================================================================
   Patient files: lab results, X-rays, reports (patient file + exam page)
   ====================================================================== */
.visit-side { display: grid; gap: 1rem; align-content: start; }
.visit-side > .card { margin: 0; }
.files-panel .card-head h2 { display: flex; align-items: center; gap: .45rem; }
.files-panel .card-head h2 .ic { width: 20px; height: 20px; color: var(--brand-ink); }
.files-msg { margin: 0 0 .75rem; }
.files-upload { margin-bottom: 1rem; }
.files-upload .drop { position: relative; display: flex; align-items: center; gap: .85rem; padding: 1rem 1.1rem; border: 1.5px dashed var(--line-2); border-radius: var(--radius-lg);
  background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; margin: 0; }
.files-upload .drop:hover, .files-upload .drop.is-over { border-color: var(--brand); background: var(--brand-soft); }
.files-upload .drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.drop-ic { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; flex: none; border-radius: 14px; background: var(--brand); color: var(--white); box-shadow: 0 6px 14px -6px var(--brand); }
.drop-ic .ic { width: 22px; height: 22px; --ic-fill: .25; }
.drop-text { display: grid; gap: .1rem; line-height: 1.45; }
.drop-text strong { font-size: .95rem; color: var(--ink); }
.drop-text small { font-size: .78rem; color: var(--muted); font-weight: 400; }
.files-meta { display: grid; gap: .6rem; margin-top: .75rem; }
.files-meta input[name="title"] { margin: 0; }
.files-cats { display: flex; flex-wrap: wrap; gap: .35rem; }
.files-cat { margin: 0; cursor: pointer; }
.files-cat input { position: absolute; opacity: 0; pointer-events: none; }
.files-cat span { display: inline-block; padding: .3rem .85rem; border-radius: var(--radius-pill); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-size: .8125rem; font-weight: 600; transition: background .15s, color .15s, border-color .15s; }
.files-cat input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--white); }
.files-cat input:focus-visible + span { box-shadow: var(--ring); }
.files-go { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.files-go .muted { font-size: .8rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.files-progress span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .15s; }
.files-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.is-compact .files-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.file-tile { position: relative; display: grid; gap: .4rem; min-width: 0; }
.file-thumb { position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.file-thumb:hover { border-color: var(--brand); text-decoration: none; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.file-thumb:hover img { transform: scale(1.04); }
.file-thumb.is-doc { align-content: center; gap: .2rem; color: var(--danger); }
.file-thumb.is-doc .ic { width: 38px; height: 38px; stroke-width: 1.4; }
.file-thumb.is-doc b { font-size: .75rem; letter-spacing: .08em; }
.file-cat { position: absolute; top: .4rem; inset-inline-start: .4rem; padding: .05rem .5rem; border-radius: var(--radius-pill); font-size: .7rem; font-weight: 700; background: rgba(8, 46, 43, .78); color: var(--white); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.file-cat.cat-lab { background: rgba(28, 128, 122, .9); }
.file-cat.cat-xray { background: rgba(47, 94, 168, .9); }
.file-cat.cat-report { background: rgba(106, 63, 176, .9); }
.file-info { display: grid; min-width: 0; line-height: 1.4; padding-inline-end: 1.6rem; }
.file-info strong { font-size: .84rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info small { font-size: .72rem; }
.file-tile form { position: absolute; bottom: 0; inset-inline-end: 0; margin: 0; }
.file-del { display: grid; place-items: center; width: 1.6rem; height: 1.6rem; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; }
.file-del:hover { background: var(--danger-bg); color: var(--danger); }
.file-del .ic { width: 15px; height: 15px; }
/* image viewer */
.lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(4, 14, 13, .92); color: #fff; }
.lightbox::backdrop { background: transparent; }
.lightbox figure { margin: 0; height: 100%; display: grid; grid-template-rows: 1fr auto; place-items: center; padding: 3.5rem 1rem 1rem; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 7rem); object-fit: contain; border-radius: 6px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); background: #fff; }
.lightbox figcaption { padding: .75rem 0 0; font-size: .9rem; opacity: .85; text-align: center; }
.lb-btn { position: fixed; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer; text-decoration: none; }
.lb-btn:hover { background: rgba(255, 255, 255, .24); text-decoration: none; color: #fff; }
.lb-close { top: .9rem; inset-inline-start: .9rem; }
.lb-open { top: .9rem; inset-inline-end: .9rem; font-size: 1.2rem; }
.lb-prev { top: 50%; inset-inline-start: .9rem; transform: translateY(-50%); }
.lb-next { top: 50%; inset-inline-end: .9rem; transform: translateY(-50%); }
@media (max-width: 600px) { .files-grid, .is-compact .files-grid { grid-template-columns: repeat(2, 1fr); } .lb-prev, .lb-next { top: auto; bottom: 1rem; transform: none; } }
/* Google Drive: link notice on the files panel, settings tab */
.drive-need { display: flex; align-items: center; gap: .75rem; padding: .85rem 1rem; margin-bottom: 1rem; border-radius: var(--radius-lg); background: var(--info-bg); color: var(--ink); }
.drive-need > .ic { width: 22px; height: 22px; flex: none; color: var(--info); }
.drive-need > div { flex: 1; display: grid; line-height: 1.45; }
.drive-need small { color: var(--ink-2); font-size: .8rem; }
.drive-need .btn { flex: none; }
.drive-status { display: flex; align-items: flex-start; gap: .65rem; padding: .7rem .85rem; margin: 0 0 .6rem; border-radius: var(--radius); background: var(--success-bg); }
.drive-status.warn { background: var(--warning-bg); }
.drive-status > .ic { width: 20px; height: 20px; flex: none; margin-top: .15rem; color: var(--success); }
.drive-status.warn > .ic { color: var(--warning); }
.drive-status > div { display: grid; line-height: 1.5; min-width: 0; }
.drive-status small { font-size: .8rem; }
.drive-settings hr { border: 0; border-top: 1px solid var(--line); margin: 1.1rem 0; }
.drive-settings h3 { font-size: 1rem; margin: 0 0 .25rem; }
.drive-steps .steps { margin: .25rem 0 1rem; padding-inline-start: 1.3rem; display: grid; gap: .8rem; line-height: 1.7; }
.drive-steps summary { cursor: pointer; }
.code-box { position: relative; margin-top: .45rem; }
.code-box textarea { width: 100%; direction: ltr; text-align: left; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-3); color: var(--ink-2); border-radius: var(--radius); resize: vertical; margin: 0; white-space: pre; }
.code-box .btn { margin-bottom: .4rem; }
.sub-steps { margin: .35rem 0 0; padding-inline-start: 1.1rem; display: grid; gap: .3rem; list-style: disc; color: var(--ink-2); font-size: .92rem; }
bdi.en { font-weight: 700; color: var(--ink); background: var(--surface-2); padding: 0 .35rem; border-radius: 5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }
.drive-link { display: flex; gap: .5rem; margin-top: .45rem; flex-wrap: wrap; }
.drive-link input { flex: 1 1 240px; margin: 0; }
.ic.flip-y { transform: scaleY(-1); }
.small { font-size: .8rem; }
/* Expense receipts */
.receipt-pick, .form .receipt-pick { position: relative; display: flex; align-items: center; gap: .75rem; padding: .7rem .85rem; margin: 0 0 .9rem; border: 1.5px dashed var(--line-2); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.receipt-pick:hover, .receipt-pick.is-picked { border-color: var(--brand); background: var(--brand-soft); }
.receipt-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.receipt-pick .drop-ic { width: 2.3rem; height: 2.3rem; border-radius: 11px; }
.receipt-pick .drop-ic .ic { width: 19px; height: 19px; }
.receipt-pick .drop-text strong { font-size: .875rem; }
.receipt-off { display: flex; align-items: center; gap: .4rem; }
.receipt-off .ic { width: 16px; height: 16px; flex: none; }
.receipts { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.receipt { position: relative; }
.receipt-thumb { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); color: var(--danger); }
.receipt-thumb img { width: 100%; height: 100%; object-fit: cover; }
.receipt-thumb .ic { width: 20px; height: 20px; }
.receipt-thumb:hover { border-color: var(--brand); }
.receipt form { position: absolute; top: -6px; inset-inline-end: -6px; margin: 0; }
.receipt-del { display: none; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: var(--danger); color: #fff; font-size: 13px; line-height: 18px; cursor: pointer; }
.receipt:hover .receipt-del, .receipt:focus-within .receipt-del { display: block; }
@media (hover: none) { .receipt-del { display: block; } }
.receipt-add { margin: 0; }
.receipt-add label { position: relative; display: inline-flex; align-items: center; gap: .25rem; height: 40px; padding: 0 .55rem; margin: 0; border: 1px dashed var(--line-2); border-radius: 8px; color: var(--ink-2); font-size: .8rem; font-weight: 600; cursor: pointer; }
.receipt-add label:hover { border-color: var(--brand); color: var(--brand-ink); }
.receipt-add input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.receipt-add .ic { width: 16px; height: 16px; }
.receipt-add.is-busy label { opacity: .5; pointer-events: none; }

/* ======================================================================
   Subscriptions: contract form + live summary, the subscription card, charges
   ====================================================================== */
.seg-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.seg-choice label { position: relative; margin: 0; cursor: pointer; }
.seg-choice input { position: absolute; opacity: 0; pointer-events: none; }
.seg-choice span { display: grid; gap: .15rem; padding: .75rem .9rem; border: 1.5px solid var(--line-2); border-radius: var(--radius); background: var(--surface); transition: border-color .15s, background .15s; }
.seg-choice b { color: var(--ink); font-size: .95rem; }
.seg-choice small { color: var(--muted); font-size: .78rem; font-weight: 400; }
.seg-choice input:checked + span { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.seg-choice input:focus-visible + span { box-shadow: var(--ring); }
.contract .form-row label small { font-weight: 400; }
.calc-out { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem; margin: .25rem 0 1rem; }
.calc-out > p { grid-column: 1 / -1; margin: 0; }
.calc-block { padding: .8rem .9rem; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.calc-block h4 { display: flex; justify-content: space-between; gap: .5rem; margin: 0 0 .45rem; font-size: .9rem; }
.calc-block h4 b { color: var(--brand-ink); font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.calc-block > p { margin: 0 0 .35rem; font-size: .8rem; }
.calc-lines, .mini-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.calc-lines li, .mini-lines li { display: flex; justify-content: space-between; gap: .75rem; font-size: .8rem; color: var(--ink-2); line-height: 1.5; }
.calc-lines b, .mini-lines b { color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.billing .card-head h2 { display: flex; align-items: center; gap: .45rem; }
.bill-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.bill-box { display: grid; gap: .25rem; align-content: start; padding: .85rem 1rem; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.bill-box > small:first-child { color: var(--muted); font-size: .78rem; font-weight: 600; }
.bill-box > strong { font-size: 1.15rem; font-family: var(--font-display); line-height: 1.4; }
.bill-box.is-late { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.bill-box .mini-lines { margin-top: .35rem; padding-top: .4rem; border-top: 1px dashed var(--line-2); }
.usage { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .82rem; color: var(--ink-2); }
.usage b { color: var(--brand-ink); }
.charges td { vertical-align: top; }
.charge-state { display: inline-block; padding: .05rem .55rem; border-radius: var(--radius-pill); font-size: .75rem; font-weight: 700; }
.st-paid { background: var(--success-bg); color: var(--success); }
.st-soon { background: var(--surface-2); color: var(--ink-2); }
.st-today { background: var(--warning-bg); color: var(--warning); }
.st-late { background: var(--danger-bg); color: var(--danger); }
tr.charge-paid td { color: var(--ink-2); }
.charge-lines { margin-top: .25rem; font-size: .8rem; }
.charge-lines summary { cursor: pointer; color: var(--link); font-weight: 600; width: max-content; }
.charge-lines ul { list-style: none; margin: .35rem 0 0; padding: .5rem .7rem; display: grid; gap: .2rem; background: var(--surface-2); border-radius: var(--radius-sm); }
.charge-lines li { display: flex; justify-content: space-between; gap: .75rem; color: var(--ink-2); }
.charge-lines li b { color: var(--ink); white-space: nowrap; }
.charge-lines li.sum { border-top: 1px solid var(--line); padding-top: .25rem; font-weight: 700; }
.pay-more .menu.pay-form { min-width: 240px; padding: .8rem; inset-inline-end: 0; }
.pay-form label { margin-bottom: .5rem; }
.pay-form > .btn { width: 100%; justify-content: center; margin-top: .25rem; }
.price-list li { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.dues li.is-late strong { color: var(--danger); }
.stat strong.stat-text { font-size: 1rem; line-height: 1.5; }
.legacy-plans summary { cursor: pointer; }
.legacy-plans[open] summary { margin-bottom: .5rem; }

/* ======================================================================
   Pop-up messages (saved / error / warning / info)
   ====================================================================== */
.js [data-flash] { display: none; }   /* shown as a pop-up instead; stays inline without JavaScript */
.toasts { position: fixed; z-index: 120; top: 1.1rem; left: 50%; transform: translateX(-50%); width: min(480px, calc(100vw - 1.5rem)); display: grid; gap: .55rem; pointer-events: none; }
.toast { --tc: #1E7A4A; position: relative; display: flex; align-items: center; gap: .8rem; padding: .9rem 1rem .95rem; overflow: hidden; pointer-events: auto;
  border-radius: 16px; background: var(--tc); color: #fff; font-size: .98rem; font-weight: 600; line-height: 1.55;
  box-shadow: 0 14px 40px -10px color-mix(in srgb, var(--tc) 70%, #000), 0 2px 6px rgba(0, 0, 0, .12);
  animation: toast-in .38s cubic-bezier(.2, .9, .3, 1.25); }
.toast-success { --tc: #17804C; }
.toast-danger { --tc: #C0282F; }
.toast-warn { --tc: #B86A00; }
.toast-info { --tc: #2F5EA8; }
.toast.out { animation: toast-out .28s ease forwards; }
.toast-ic { display: grid; place-items: center; width: 2.3rem; height: 2.3rem; flex: none; border-radius: 50%; background: rgba(255, 255, 255, .2); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }
.toast-ic svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-x { flex: none; align-self: flex-start; width: 1.8rem; height: 1.8rem; margin: -.2rem -.3rem 0 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: rgba(255, 255, 255, .85); font-size: 1.35rem; line-height: 1; cursor: pointer; }
.toast-x:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.toast-bar { position: absolute; inset-inline: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .45); transform-origin: right; animation: toast-bar var(--life, 5s) linear forwards; }
.toast.hold .toast-bar { animation-play-state: paused; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-18px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-12px) scale(.97); } }
@keyframes toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (max-width: 900px) { .toasts { top: .7rem; } .toast { font-size: .93rem; } }
@media (prefers-reduced-motion: reduce) { .toast, .toast.out { animation: none; } .toast-bar { display: none; } }

/* ======================================================================
   Platform team: a doctor's file (profile, money, usage, timeline)
   ====================================================================== */
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--brand-soft); }
.profile-head { display: flex; align-items: center; gap: .85rem; margin-bottom: 1rem; }
.profile-head h2 { margin: 0; }
.profile-head p { margin: 0; }
.profile-head .badge { margin-inline-start: auto; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.5rem; }
.profile-side { display: grid; gap: 1rem; align-content: start; }
.profile-side > .card { margin: 0; }
.money-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.mt { display: grid; gap: .1rem; padding: .7rem .8rem; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.mt > span { font-size: .76rem; color: var(--muted); font-weight: 600; }
.mt > strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; line-height: 1.35; overflow-wrap: anywhere; }
.mt > strong small { font-size: .78rem; color: var(--muted); font-weight: 500; }
.mt > small { font-size: .76rem; color: var(--muted); }
.mt.good > strong { color: var(--success); }
.mt.bad { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.mt.bad > strong { color: var(--danger); }
.integrations { margin-top: .9rem; }
.integrations li > span:first-child { display: inline-flex; align-items: center; gap: .45rem; }
.integrations .ic { width: 17px; height: 17px; color: var(--muted); }
.ok-text { color: var(--success); font-weight: 600; }
.perm-tags { display: flex; flex-wrap: wrap; gap: .25rem; }
.perm-tags span { padding: .05rem .5rem; border-radius: var(--radius-pill); background: var(--surface-2); border: 1px solid var(--line); font-size: .74rem; white-space: nowrap; }
.timeline-events { list-style: none; margin: 0; padding: 0; }
.timeline-events li { position: relative; display: grid; grid-template-columns: 2.2rem 1fr auto; gap: .7rem; align-items: start; padding: .6rem 0; }
.timeline-events li + li { border-top: 1px solid var(--line); }
.ev-ic { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); }
.ev-ic .ic { width: 17px; height: 17px; }
.ev-good .ev-ic { background: var(--success-bg); color: var(--success); }
.timeline-events li > div { display: grid; min-width: 0; line-height: 1.5; }
.timeline-events small { font-size: .8rem; }
.timeline-events time { font-size: .78rem; white-space: nowrap; }
@media (max-width: 600px) { .timeline-events li { grid-template-columns: 2.2rem 1fr; } .timeline-events time { grid-column: 2; } }
.charge-lines li.disc, .calc-lines li.disc { color: var(--success); }
/* inside the charges table the small forms open in place (an absolute menu would be clipped by the scrolling table) */
.charges td:last-child { min-width: 9.5rem; }
.charges details.pay-more { display: block; margin-bottom: .35rem; }
.charges details.pay-more > summary { width: 100%; justify-content: center; }
.charges .pay-more .menu.pay-form { position: static; min-width: 0; width: 15rem; max-width: 70vw; margin-top: .4rem; padding: .7rem; box-shadow: none; border: 1px solid var(--line); background: var(--surface-2); }
.disc-note { display: block; margin-top: .15rem; font-size: .75rem; color: var(--success); font-weight: 600; }
.undo-disc { margin: .1rem 0 0; }
.link-btn { padding: 0; border: 0; background: none; color: var(--danger); font: inherit; font-size: .75rem; font-weight: 600; text-decoration: underline; cursor: pointer; }
.link-btn:hover { color: var(--ink); }

/* ======================================================================
   Confirmation dialog (in the middle of the screen)
   ====================================================================== */
.confirm-dlg { --cd: var(--brand); width: min(420px, calc(100vw - 2rem)); padding: 1.6rem 1.5rem 1.3rem; border: 0; border-radius: 22px; text-align: center;
  background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45); animation: cd-in .22s cubic-bezier(.2, .9, .3, 1.2); }
.confirm-dlg.is-danger { --cd: var(--danger); }
.confirm-dlg::backdrop { background: rgba(4, 14, 13, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.cd-ic { display: grid; place-items: center; width: 3.6rem; height: 3.6rem; margin: 0 auto .8rem; border-radius: 50%;
  background: color-mix(in srgb, var(--cd) 14%, var(--surface)); color: var(--cd); box-shadow: 0 0 0 7px color-mix(in srgb, var(--cd) 7%, transparent); }
.cd-ic svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.cd-title { margin: 0 0 .4rem; font-family: var(--font-display); font-size: 1.2rem; }
.cd-msg { margin: 0 0 1.3rem; font-size: 1rem; line-height: 1.7; color: var(--ink-2); white-space: pre-line; }
.cd-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.cd-actions .btn { justify-content: center; width: 100%; min-height: 2.8rem; font-size: .98rem; }
@keyframes cd-in { from { opacity: 0; transform: translateY(10px) scale(.95); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .confirm-dlg { animation: none; } }

/* ---------- subscription contract (admin: new doctor / doctor's page → print, lib/contract.php) ---------- */
.ct-sheet { background: var(--white); color: #1d2433; width: 210mm; min-height: 297mm; margin: 0 auto; padding: 10mm 14mm 9mm; box-shadow: var(--shadow);
  font-size: 12.5px; line-height: 1.6; display: flex; flex-direction: column; }
.ct-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-bottom: 2px solid var(--teal-600); padding-bottom: 2.5mm; }
.ct-brand .brand-logo img { height: 11mm; width: auto; }
.ct-brand .for-dark { display: none !important; }
.ct-brand .for-light { display: block !important; }
.ct-meta { text-align: left; font-size: .92em; color: #4a5468; }
.ct-meta b { color: #1d2433; }
.ct-title { text-align: center; font-family: var(--font-display); font-size: 1.45em; color: var(--teal-700); margin: 3.5mm 0 3mm; }
.ct-parties { display: grid; grid-template-columns: 1fr; gap: 4mm; margin-bottom: 2.5mm; }
.ct-party { border: 1px solid #d9dee8; border-radius: 3mm; padding: 2mm 3.5mm; }
.ct-party h2, .ct-sign h2, .ct-addons h2 { font-size: 1em; color: var(--teal-600); margin: 0 0 1.5mm; }
.ct-party p { margin: 0; }
.ct-terms { padding-right: 1.3em; margin: 0 0 4mm; }
.ct-terms > li { margin-bottom: 1.3mm; }
.ct-table, .ct-sign, .ct-addons { break-inside: avoid; }
.ct-terms > li::marker { color: var(--teal-600); font-weight: 700; }
.ct-table { width: 100%; border-collapse: collapse; margin: 1mm 0 .5mm; font-size: .95em; }
.ct-table th, .ct-table td { border: 1px solid #d9dee8; padding: .6mm 2.5mm; text-align: right; }
.ct-table thead th, .ct-table tfoot th { background: #f1f5f4; }
.ct-table .num { text-align: left; white-space: nowrap; width: 30%; }
.ct-table .ct-disc td { color: #b42318; }
.ct-blank { display: inline-block; min-width: 38mm; border-bottom: 1px dotted #8a93a6; vertical-align: bottom; height: 1.3em; }
.ct-sign { display: grid; grid-template-columns: minmax(0, 85mm); justify-content: start; gap: 10mm; margin-top: auto; padding-top: 4mm; border-top: 1px solid #d9dee8; }
.ct-sign p { margin: 0 0 3mm; }
.ct-sign .ct-blank { min-width: 50mm; }
.ct-sheet.is-editing { outline: 2px dashed var(--teal-600); outline-offset: 6px; cursor: text; }
.ct-sheet ~ .rx-edit-hint, .print-body .rx-edit-hint { max-width: 210mm; }
.contract-preview { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .75rem; }
@media print {
  .ct-sheet { box-shadow: none; width: auto; min-height: 100vh; }
  .ct-sheet.is-editing { outline: 0; }
  .ct-sheet, .ct-table { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (max-width: 820px) {
  .print-body .ct-sheet { width: 100%; min-height: auto; padding: 6mm; font-size: 13px; }
  .ct-parties, .ct-sign { grid-template-columns: 1fr; }
}

/* ---------- support ticket popup (app.js showTickets: centred, stays until answered) ---------- */
.ticket-dlg { --cd: var(--doctor); width: min(460px, calc(100vw - 2rem)); }
.ticket-dlg .cd-ic { animation: td-ring 1.1s ease-in-out 2; }
.td-items { display: grid; gap: .5rem; max-height: 45vh; overflow: auto; margin: .25rem 0 1rem; text-align: start; }
.td-item { display: grid; gap: .15rem; padding: .7rem .9rem; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--doctor) 30%, var(--line));
  background: color-mix(in srgb, var(--doctor) 7%, var(--surface)); color: var(--ink); }
.td-item:hover { text-decoration: none; border-color: var(--doctor); }
.td-title { font-weight: 700; }
.td-line { font-size: .9rem; color: var(--ink-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ticket-dlg .cd-ok { background: var(--doctor); border-color: var(--doctor); color: var(--surface); }
@keyframes td-ring { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(-14deg); } 30% { transform: rotate(12deg); } 45% { transform: rotate(-8deg); } 60% { transform: rotate(5deg); } 75% { transform: rotate(0); } }
@media (prefers-reduced-motion: reduce) { .ticket-dlg .cd-ic { animation: none; } }
.ticket-closed { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; background: var(--surface-2); }
.ticket-closed p { margin: 0; display: flex; align-items: center; gap: .5rem; color: var(--ink-2); }
.ticket-closed svg { width: 20px; height: 20px; flex: none; color: var(--success, var(--teal-600)); }
.ct-sub { text-align: center; margin: -1.5mm 0 3mm; color: #4a5468; }
.contracts-card td[dir="ltr"] { text-align: right; }
.range-presets { margin: .25rem 0 .75rem; }
.cat-totals li { font-size: .9rem; }
a.stat { color: inherit; } a.stat:hover { text-decoration: none; border-color: var(--brand); }
.commission { border: 1px dashed var(--line-2); border-radius: var(--radius); padding: .75rem 1rem .9rem; margin: .5rem 0; display: grid; gap: .5rem; }
.commission legend { padding: 0 .4rem; font-weight: 700; font-size: .95rem; }
.staff-request { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-style: dashed; }
.staff-request p { margin: .25rem 0 0; max-width: 60ch; }
.staff-rows { display: grid; gap: .75rem; margin-bottom: .6rem; }
.staff-row { border: 1px dashed var(--line-2); border-radius: var(--radius); padding: .75rem 1rem; display: grid; gap: .5rem; }
.staff-row .form-row:last-child { align-items: end; }
.staff-row-x { align-self: end; margin-bottom: .2rem; }
.creds-list { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin: .5rem 0 1rem; }
.creds-item { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; background: var(--surface); display: grid; gap: .5rem; }
.creds-who { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.creds-item { min-width: 0; overflow: hidden; }
.creds-item .copy-box { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .82rem; max-width: 100%; box-sizing: border-box; }
.creds-item .actions { gap: .4rem; }
.btn-wa { background: #1f9d55; border-color: #1f9d55; color: #fff; }
.btn-wa:hover { background: #17834a; color: #fff; }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.phone-form { display: flex; flex-wrap: nowrap; gap: .3rem; align-items: center; }
.phone-form input { width: 9.5rem; padding: .3rem .5rem; font-size: .85rem; }

/* ---------- profile photos (lib/avatar.php, app.js [data-avatar-file]) ---------- */
.avatar.has-img { padding: 0; overflow: hidden; background: var(--surface-2); }
.avatar.has-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-xl { width: 96px; height: 96px; font-size: 2.4rem; }
.avatar-sm { width: 30px; height: 30px; font-size: .8rem; }
.avatar-box { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.avatar-box-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.avatar-box-actions label.btn { cursor: pointer; }
.crop-dlg { width: min(360px, calc(100vw - 2rem)); }
.crop-hint { margin: 0 0 .8rem; font-size: .85rem; color: var(--ink-2); }
.crop-stage { position: relative; margin: 0 auto; overflow: hidden; border-radius: 18px; background: #111; touch-action: none; cursor: grab; user-select: none; max-width: 100%; }
.crop-stage:active { cursor: grabbing; }
.crop-stage img { position: absolute; max-width: none; pointer-events: none; }
.crop-ring { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 999px rgba(0, 0, 0, .55); outline: 2px solid rgba(255, 255, 255, .85); pointer-events: none; }
.crop-tools { display: flex; align-items: center; gap: .5rem; margin: .9rem 0 1.1rem; }
.crop-tools input[type=range] { flex: 1; accent-color: var(--brand); }
.user-cell { display: flex; align-items: center; gap: .55rem; }
.staff-photo { margin-bottom: .5rem; }
.avatar-xs { width: 22px; height: 22px; font-size: .7rem; display: inline-grid; vertical-align: middle; margin-inline-end: .35rem; }
.msg-photos { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.msg-photos .receipt-thumb { width: 84px; height: 84px; }
.share-form { display: flex; gap: .3rem; align-items: center; flex-wrap: nowrap; }
.share-form input { width: 13rem; padding: .3rem .5rem; font-size: .85rem; }

/* ---------- language (lib/i18n.php) ---------- */
.bare-tools { position: fixed; top: 1rem; inset-inline-end: 1rem; z-index: 5; }
.lang-switch { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; font-size: .85rem; text-decoration: none; }
.lang-switch:not(.icon-btn) { color: var(--ink-2); border: 1px solid var(--line-2); border-radius: var(--radius-pill); padding: .3rem .7rem; background: var(--surface); }
.lang-switch:not(.icon-btn):hover { text-decoration: none; border-color: var(--brand); color: var(--brand-ink); }
.lang-switch svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
/* In the menu: the same dark 3D square as its neighbours, with «EN» / «ع» beside the globe */
.sb-actions .lang-switch.icon-btn { width: auto; gap: .25rem; padding: 0 .5rem; }
.sb-actions .lang-switch span { font-size: .8rem; font-weight: 600; line-height: 1; }
.sb-actions .lang-switch:hover { text-decoration: none; }

/* English (dir="ltr"): the same layout mirrored where the rules above name a side */
[dir="ltr"] .ta-end, [dir="ltr"] .contracts-card td[dir="ltr"] { text-align: left; }
[dir="ltr"] .table th, [dir="ltr"] .copy-box, [dir="ltr"] .auth-card.form, [dir="ltr"] details.more .menu a, [dir="ltr"] details.more .menu button:not(.btn) { text-align: left; }
[dir="ltr"] .plain { padding-right: 0; padding-left: 1.2rem; }
[dir="ltr"] details.more .menu { left: auto; right: 0; }
[dir="ltr"] .timeline .visit, [dir="ltr"] .visit { border-right: 0; border-left: 3px solid var(--line-brand); padding: .3rem 0 .5rem 1rem; }
[dir="ltr"] .visit header .row-actions { margin-right: 0; margin-left: auto; }
[dir="ltr"] .key-out { margin-right: 0; margin-left: .6rem; }
[dir="ltr"] .msg-clinic { border-top-right-radius: var(--radius); border-top-left-radius: 4px; }
[dir="ltr"] .msg-support { border-top-left-radius: var(--radius); border-top-right-radius: 4px; }
/* arrows drawn for Arabic point the other way */
[dir="ltr"] .ic-back, [dir="ltr"] .ic-next, [dir="ltr"] .ic-more { transform: scaleX(-1); }
[dir="ltr"] .sb-toggle .ic { transform: none; }
[dir="ltr"] body.sb-collapsed .sb-toggle .ic { transform: rotate(180deg); }
/* the prescription printed in English */
.rx-sheet[dir="ltr"] .rx-clinic { text-align: right; }
.rx-sheet[dir="ltr"] .rx-list { padding-right: 0; padding-left: 1.4rem; }
.rx-sheet[dir="ltr"] .rx-list strong { text-align: left; }
.ct-lang-pick { display: inline-flex; gap: .2rem; }
.ct-sheet[dir="ltr"] .ct-meta { text-align: right; }
.ct-sheet[dir="ltr"] .ct-terms { padding-right: 0; padding-left: 1.3em; }
.ct-sheet[dir="ltr"] .ct-table th, .ct-sheet[dir="ltr"] .ct-table td { text-align: left; }
.ct-sheet[dir="ltr"] .ct-table .num { text-align: right; }

/* ======================================================================
   Dashboard totals as 3D buttons (layout.php stat_btn) + the dialog with what each total is made of
   ====================================================================== */
.stat-btn {
  /* A solid «slab»: flat face, a crisp neutral lower edge (no coloured blur), one colour line on the reading side.
     Readable at a glance for every age: the label in clear ink, the figure large and bold. */
  --sb-c: var(--brand); --sb-edge: #d3dcda; --sb-lip: 4px;
  position: relative; display: flex; flex-direction: column; align-items: stretch; width: 100%; text-align: start; font: inherit; color: var(--ink);
  cursor: pointer; margin-bottom: calc(var(--sb-lip) + 2px); padding: 1rem 1.15rem .8rem 1.15rem; padding-inline-start: 1.35rem;
  border-radius: 18px; border: 1px solid var(--line); background: linear-gradient(180deg, var(--surface) 0%, var(--surface) 70%, var(--surface-2) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .85), 0 var(--sb-lip) 0 var(--sb-edge), 0 calc(var(--sb-lip) + 4px) 8px -6px rgba(8, 46, 43, .18);
  transition: transform .1s ease, box-shadow .1s ease, border-color .15s ease; }
:root[data-theme="dark"] .stat-btn { --sb-edge: #050c0b; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 var(--sb-lip) 0 var(--sb-edge), 0 calc(var(--sb-lip) + 4px) 10px -6px rgba(0, 0, 0, .6); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stat-btn { --sb-edge: #050c0b; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 var(--sb-lip) 0 var(--sb-edge), 0 calc(var(--sb-lip) + 4px) 10px -6px rgba(0, 0, 0, .6); } }
/* the colour line, inset on the start side */
.stat-btn::before { content: ""; position: absolute; inset-block: 14px; inset-inline-start: 0; width: 4px; border-start-end-radius: 4px; border-end-end-radius: 4px; background: var(--sb-c); }
[dir="ltr"] .stat-btn::before { border-radius: 0 4px 4px 0; }
.stat-btn > span { color: var(--ink-2); font-size: .95rem; font-weight: 600; line-height: 1.4; }
.stat-btn > strong { margin-top: .3rem; font-size: 1.9rem; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; color: var(--ink); }
.stat-btn.stat-good > strong { color: var(--success); }
.stat-btn.stat-bad > strong { color: var(--danger); }
.stat-btn.stat-accent > strong { color: var(--brand-ink); }
.stat-btn.stat-good { --sb-c: var(--success); }
.stat-btn.stat-bad { --sb-c: var(--danger); }
.stat-btn.stat-accent { --sb-c: var(--gold-500); }
.stat-btn.stat-accent::before { background: var(--gradient-gold); }
.stat-btn:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--sb-c) 40%, var(--line)); --sb-lip: 6px; }
.stat-btn:active { transform: translateY(3px); --sb-lip: 1px; }
.stat-btn:focus-visible { outline: 2px solid var(--sb-c); outline-offset: 3px; }
/* «التفاصيل ‹» at the foot, clear but quiet */
.stat-btn .stat-hint { display: inline-flex; align-items: center; gap: .3rem; align-self: flex-end; margin-top: .6rem; font-style: normal; font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.stat-btn .stat-hint .ic { width: 18px; height: 18px; padding: 3px; border-radius: 50%; color: #fff; background: var(--sb-c); }
.stat-btn.stat-accent .stat-hint .ic { background: var(--gold-600); }
.stat-btn:hover .stat-hint { color: var(--ink); }
[dir="ltr"] .stat-btn .stat-hint .ic { transform: scaleX(-1); }
.stats.compact .stat-btn { padding-block: .8rem .65rem; }
.stats.compact .stat-btn > strong { font-size: 1.4rem; }
.stats.compact .stat-btn .stat-hint { margin-top: .35rem; }
@media (max-width: 600px) { .stat-btn > strong { font-size: 1.6rem; } }
@media (prefers-reduced-motion: reduce) { .stat-btn, .stat-btn:hover, .stat-btn:active { transition: none; transform: none; } }

.stat-dlg { --sd-c: var(--brand); width: min(540px, calc(100vw - 1.5rem)); max-height: min(86vh, 760px); padding: 0; border: 0; border-radius: 22px;
  background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .5); overflow: hidden; animation: cd-in .22s cubic-bezier(.2, .9, .3, 1.2); }
.stat-dlg[open] { display: flex; flex-direction: column; }
.stat-dlg::backdrop { background: rgba(4, 14, 13, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.stat-dlg.stat-good { --sd-c: var(--success); } .stat-dlg.stat-bad { --sd-c: var(--danger); } .stat-dlg.stat-accent { --sd-c: var(--gold-500); }
.sd-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.15rem 1.35rem 1rem;
  background: linear-gradient(160deg, color-mix(in srgb, var(--sd-c) 16%, var(--surface)) 0%, var(--surface) 100%); border-bottom: 1px solid var(--line); }
.sd-label { display: block; color: var(--ink-2); font-size: .88rem; font-weight: 600; }
.sd-value { display: block; margin-top: .15rem; font-size: 1.75rem; font-weight: 800; line-height: 1.2; color: var(--sd-c); font-variant-numeric: tabular-nums; }
.stat-dlg.stat-accent .sd-value { color: var(--brand-ink); }
.sd-x { flex: none; display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink-2); cursor: pointer; }
.sd-x:hover { background: var(--surface-2); color: var(--ink); }
.sd-x svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.sd-body { flex: 1; overflow-y: auto; padding: .4rem 1.35rem 1rem; overscroll-behavior: contain; }
.sd-part { margin-top: .9rem; }
.sd-part h4 { margin: 0 0 .35rem; font-size: .8rem; font-weight: 700; color: var(--muted); letter-spacing: .01em; }
.sd-rows { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.sd-rows li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .55rem .8rem; font-size: .92rem; }
.sd-rows li + li { border-top: 1px solid var(--line); }
.sd-rows li:nth-child(even) { background: var(--surface-2); }
.sd-l { min-width: 0; }
.sd-l a { color: var(--ink); font-weight: 600; }
.sd-l a:hover { color: var(--link, var(--brand-ink)); }
.sd-l small { display: block; color: var(--muted); font-size: .76rem; margin-top: .05rem; }
.sd-rows b { flex: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sd-total { display: flex; justify-content: space-between; margin: .4rem 0 0; padding: .5rem .8rem; border-radius: var(--radius);
  background: color-mix(in srgb, var(--sd-c) 11%, var(--surface)); font-weight: 700; }
.sd-total b { font-variant-numeric: tabular-nums; }
.sd-rest { margin: .35rem .2rem 0; color: var(--muted); font-size: .8rem; }
.sd-body > .empty { margin: 1.2rem 0 .4rem; text-align: center; }
.sd-foot { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; padding: .85rem 1.35rem 1.1rem; border-top: 1px solid var(--line); background: var(--surface); }
.sd-foot.is-single { grid-template-columns: 1fr; }
.sd-foot .btn { width: 100%; min-height: 2.7rem; }
@media (prefers-reduced-motion: reduce) { .stat-dlg { animation: none; } }
body.sb-collapsed .sb-actions .lang-switch.icon-btn { width: 34px; padding: 0; }
body.sb-collapsed .sb-actions .lang-switch span { display: none; }

/* ---------- where a new patient came from (helpers.php source_pick) ---------- */
.src-pick { border: 0; padding: 0; margin: .2rem 0 .9rem; min-width: 0; }
.src-pick legend { padding: 0; margin-bottom: .45rem; font-size: .875rem; font-weight: 600; color: var(--ink-2); }
.src-opts { display: flex; flex-wrap: wrap; gap: .45rem; }
.src-opt { position: relative; margin: 0; cursor: pointer; }
.src-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.src-opt span { display: inline-flex; align-items: center; gap: .35rem; padding: .42rem .85rem; border-radius: var(--radius-pill); font-size: .86rem; font-weight: 600;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--line-2);
  box-shadow: inset 0 1px 0 var(--btn-shine-ghost), 0 2px 0 var(--btn-edge-ghost); transition: transform .08s ease, box-shadow .08s ease, background-color .15s ease; }
.src-opt:hover span { background: var(--brand-soft); transform: translateY(-1px); }
.src-opt input:checked + span { background: var(--brand); color: var(--on-brand); border-color: var(--brand);
  box-shadow: inset 0 1px 0 var(--btn-shine), 0 2px 0 var(--btn-edge); }
.src-opt input:checked + span::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.src-opt input:focus-visible + span { box-shadow: var(--ring); }
.form .src-opt { display: inline-block; margin: 0; font-weight: inherit; }
.slot-hint { display: block; margin-top: .3rem; font-size: .75rem; font-weight: 400; line-height: 1.5; }

/* ---------- «is the patient in the clinic now?» on the booking form: two big 3D choices, «not here» by default ---------- */
.here-pick { border: 0; padding: 0; margin: .3rem 0 1rem; min-width: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.here-pick[hidden] { display: none; }
.here-pick legend { grid-column: 1 / -1; padding: 0; margin-bottom: .5rem; font-size: .9rem; font-weight: 700; color: var(--ink); }
.form .here-opt { position: relative; display: block; margin: 0; cursor: pointer; color: var(--ink); font-weight: inherit; }
.here-opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.here-opt > span { --h-c: var(--ink-2); display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: .65rem; align-items: center;
  padding: .75rem .9rem; border-radius: var(--radius); border: 1.5px solid var(--line-2); background: var(--surface);
  box-shadow: inset 0 1px 0 var(--btn-shine-ghost), 0 3px 0 var(--btn-edge-ghost), 0 6px 14px var(--btn-glow-soft);
  transition: transform .09s ease, box-shadow .09s ease, background-color .15s ease, border-color .15s ease; }
.here-opt > span .ic { grid-row: 1 / 3; width: 2.3rem; height: 2.3rem; padding: .45rem; border-radius: 50%; color: var(--h-c);
  background: color-mix(in srgb, var(--h-c) 12%, var(--surface)); }
.here-opt b { font-size: .95rem; line-height: 1.3; }
.here-opt small { font-size: .75rem; color: var(--muted); }
.here-opt:hover > span { transform: translateY(-1px); border-color: var(--brand); }
.here-opt input:focus-visible + span { box-shadow: var(--ring); }
.here-no input:checked + span { --h-c: var(--brand-ink); border-color: var(--brand); background: color-mix(in srgb, var(--brand) 9%, var(--surface));
  box-shadow: inset 0 1px 0 var(--btn-shine-ghost), 0 3px 0 var(--btn-edge), 0 6px 14px var(--btn-glow-soft); }
.here-yes input:checked + span { --h-c: #fff; border-color: var(--success); background: var(--success); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 3px 0 color-mix(in srgb, var(--success) 60%, #000), 0 8px 18px color-mix(in srgb, var(--success) 35%, transparent); }
.here-yes input:checked + span small { color: rgba(255,255,255,.85); }
.here-yes input:checked + span .ic { background: rgba(255,255,255,.18); }
:root[data-theme="dark"] .here-yes input:checked + span { background: #1E7A4A; border-color: #2E9A62; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .here-yes input:checked + span { background: #1E7A4A; border-color: #2E9A62; } }
@media (max-width: 520px) { .here-pick { grid-template-columns: 1fr; } }
/* the chosen side gets a tick in its corner, and «not here» a firmer fill, so the choice reads at a glance */
.here-opt > span { position: relative; }
.here-opt input:checked + span::after { content: ""; position: absolute; top: -.45rem; inset-inline-start: -.45rem; width: 1.35rem; height: 1.35rem; border-radius: 50%;
  background: var(--h-tick, var(--brand)) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E") center / 60% no-repeat;
  box-shadow: 0 0 0 2px var(--surface); }
.here-yes { --h-tick: #145C37; }
.here-no input:checked + span { background: color-mix(in srgb, var(--brand) 16%, var(--surface)); border-width: 2px; }

/* ---------- hide / show the money on the home screen (layout.php money_toggle) ---------- */
.money-toggle .ic-hide, .money-toggle .mt-show { display: none; }
.money-hidden .money-toggle .ic-hide, .money-hidden .money-toggle .mt-show { display: inline; }
.money-hidden .money-toggle .ic-show, .money-hidden .money-toggle .mt-hide { display: none; }
.money-hidden .money-toggle { --b-fg: var(--on-brand); --b-bg: var(--brand); --b-bg-hover: var(--brand-hover); --b-border: var(--brand); --b-edge: var(--btn-edge); --b-shine: var(--btn-shine); }
.money-hidden .is-money strong { position: relative; color: transparent !important; text-shadow: none; user-select: none; }
.money-hidden .is-money strong::after { content: "• • • • •"; position: absolute; inset-inline-start: 0; top: 50%; transform: translateY(-50%);
  color: var(--muted); letter-spacing: .05em; white-space: nowrap; }
.money-hidden .mon-money strong::after { inset-inline-start: auto; inset-inline-end: 0; }
.money-hidden .stat-btn.is-money .stat-hint { visibility: hidden; }
@keyframes mt-nudge { 0%, 100% { transform: none; } 25% { transform: translateY(-3px) scale(1.04); } 60% { transform: translateY(1px); } }
.money-toggle.nudge { animation: mt-nudge .45s ease 2; }
@media (prefers-reduced-motion: reduce) { .money-toggle.nudge { animation: none; } }
@media (max-width: 640px) { .money-toggle span { display: none !important; } .money-toggle { padding-inline: .7rem; } }

/* ---------- booking without a chosen patient: search first, registering a new one is a separate step ---------- */
.pick-first .pick-new { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem; flex-wrap: wrap; margin-top: .9rem; padding: .8rem 1rem;
  border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--surface-2); }
.pick-first .pick-new > span { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; color: var(--ink-2); }
.pick-first .pick-new > span .ic { width: 20px; height: 20px; color: var(--brand-ink); }

/* ---------- WhatsApp message after a booking (lib/wa_msg.php, pages/tenant/messages.php) ---------- */
.btn-wa { --b-bg: #1f9d55; --b-bg-hover: #23ad5f; --b-border: #1f9d55; --b-fg: #fff; --b-edge: #12683a; --b-shine: rgba(255,255,255,.22); }
.btn-wa:hover { color: #fff; }
.form-actions .wa-edit-link { font-size: .82rem; font-weight: 600; margin-inline-start: auto; }
.form-actions .small .ic { width: 16px; height: 16px; vertical-align: -3px; }
.wa-dlg { --cd: #1f9d55; width: min(470px, calc(100vw - 2rem)); }
.wa-to { margin: 0 0 .7rem; color: var(--ink-2); font-size: .9rem; }
.wa-text, .wa-bubble { margin: 0; white-space: pre-wrap; word-break: break-word; font: inherit; font-size: .92rem; line-height: 1.75; text-align: start; }
.wa-dlg .wa-text { max-height: 40vh; overflow-y: auto; margin-bottom: 1.1rem; padding: .8rem 1rem; border-radius: 14px 14px 4px 14px;
  background: color-mix(in srgb, #1f9d55 10%, var(--surface)); border: 1px solid color-mix(in srgb, #1f9d55 25%, var(--line)); }
.wa-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .2rem 0 1rem; }
.wa-chip { font: inherit; font-size: .8rem; font-weight: 600; padding: .3rem .7rem; border-radius: var(--radius-pill); cursor: pointer;
  border: 1px dashed color-mix(in srgb, #1f9d55 45%, var(--line-2)); background: color-mix(in srgb, #1f9d55 8%, var(--surface)); color: var(--ink-2); }
.wa-chip:hover { border-style: solid; color: var(--ink); }
.wa-chip::before { content: "+ "; color: #1f9d55; font-weight: 700; }
.wa-editor textarea { font-size: .95rem; line-height: 1.7; }
.wa-phone { padding: 1rem; border-radius: var(--radius-lg); background: color-mix(in srgb, #1f9d55 6%, var(--surface-2));
  background-image: radial-gradient(color-mix(in srgb, #1f9d55 12%, transparent) 1px, transparent 1px); background-size: 14px 14px; }
.wa-bubble { max-width: 92%; padding: .75rem .95rem; border-radius: 14px 4px 14px 14px; background: color-mix(in srgb, #1f9d55 16%, var(--surface));
  box-shadow: 0 1px 1px rgba(0,0,0,.08); color: var(--ink); }
.wa-reset { margin-top: 1rem; }
/* whole money sections (the reports' tables and charts) are blurred while the money is hidden */
.money-zone { transition: filter .2s ease; }
.money-hidden .money-zone { filter: blur(7px); user-select: none; pointer-events: none; }
@media print { .money-hidden .money-zone { filter: none; } }

/* ---------- the doctor: «a patient was sent in to you» popup (app.js callsUrl) ---------- */
.call-dlg { --cd: var(--doctor); width: min(440px, calc(100vw - 2rem)); }
.call-dlg .cd-ic { width: 4.2rem; height: 4.2rem; animation: call-pulse 1.2s ease-out 3; }
.call-dlg .cd-ic svg { width: 32px; height: 32px; }
@keyframes call-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--cd) 45%, transparent); } 100% { box-shadow: 0 0 0 22px transparent; } }
.call-who { display: grid; gap: .2rem; margin: 0 0 1.3rem; }
.call-kicker { font-size: .85rem; font-weight: 700; color: var(--cd); letter-spacing: .01em; }
.call-name { font-family: var(--font-display); font-size: 1.5rem; line-height: 1.35; }
.call-meta { color: var(--muted); font-size: .9rem; }
.call-dlg .cd-actions { grid-template-columns: 1fr; }
.call-dlg .cd-ok { background: var(--doctor); border-color: var(--doctor); color: var(--surface); --b-bg: var(--doctor); --b-border: var(--doctor); min-height: 3.1rem; font-size: 1.02rem; }
@media (prefers-reduced-motion: reduce) { .call-dlg .cd-ic { animation: none; } }

/* ---------- the patient beside the exam (visit_form) ---------- */
.pt-card .pt-id { display: flex; align-items: center; gap: .75rem; margin: .1rem 0 .8rem; }
.pt-card .pt-av { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; font-weight: 800; font-size: 1.15rem;
  color: var(--doctor); background: var(--doctor-bg); }
.pt-card .pt-id strong { display: block; font-size: 1.05rem; line-height: 1.35; }
.pt-card .pt-id small { display: block; }
.pt-card .pt-dl { margin: 0; }
/* label | value, the value right beside its label (start), every row the same */
.pt-card .pt-dl { grid-template-columns: max-content 1fr; align-items: baseline; gap: .55rem 1.1rem; }
.pt-card .pt-dl dd { margin: 0; text-align: start; font-weight: 600; }
.pt-card .pt-dl bdi { unicode-bidi: isolate; }
/* a «⋯» menu inside a table floats above the page (app.js), so opening it never adds a scrollbar to the table:
   it is out of the table's flow from the start (no flash of a scrollbar), shown once placed */
.table-wrap details.more:not(.pay-more) > .menu { position: fixed; right: auto; bottom: auto; z-index: 60; visibility: hidden; }
.table-wrap details.more:not(.pay-more) > .menu.menu-float { visibility: visible; }

/* ---------- booking time as buttons (app.js draws them; lib/slots.php day_slots) ---------- */
.slot-pick { margin: -.2rem 0 1rem; padding: .8rem .9rem .6rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.slot-pick[hidden] { display: none; }
.slot-pick-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap; margin-bottom: .55rem; }
.slot-pick-head b { font-size: .92rem; }
.slot-pick-head small { font-size: .75rem; }
.slot-row { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; padding: .3rem 0; }
.slot-row + .slot-row { border-top: 1px dashed var(--line); }
.slot-hour { flex: 0 0 3.6rem; font-size: .78rem; font-weight: 700; color: var(--muted); }
.slot-btn { font: inherit; font-size: .86rem; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 5.2rem; padding: .38rem .6rem; border-radius: 10px; cursor: pointer;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line-2);
  box-shadow: inset 0 1px 0 var(--btn-shine-ghost), 0 2px 0 var(--btn-edge-ghost); transition: transform .08s ease, background-color .12s ease; }
.slot-btn:hover:not(:disabled) { background: var(--brand-soft); border-color: var(--brand); transform: translateY(-1px); }
.slot-btn.is-on { background: var(--brand); color: var(--on-brand); border-color: var(--brand); box-shadow: inset 0 1px 0 var(--btn-shine), 0 2px 0 var(--btn-edge); }
.slot-btn.is-taken { cursor: not-allowed; color: var(--muted); background: transparent; border-style: dashed; box-shadow: none; text-decoration: line-through; opacity: .7; }
@media (max-width: 520px) { .slot-hour { flex-basis: 100%; } .slot-btn { flex: 1 1 calc(25% - .4rem); min-width: 0; } }
/* the doctor's card: the one inside stands out on top, «ينتظرون بعده» under it, the day's takings last */
.monitor-card > .mon-money:last-child { margin: .8rem 0 0; }
.mon-line-title { margin: .9rem 0 .35rem; font-size: .78rem; font-weight: 700; color: var(--muted); }
.med-readonly > div { padding: .55rem .75rem; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); background: var(--surface-2); }
.med-readonly p { margin: .2rem 0 0; }
.draft-note { margin: 0 0 .9rem; padding: .55rem .8rem; border-radius: var(--radius-sm); font-size: .85rem; font-weight: 600;
  color: var(--brand-ink); background: var(--brand-soft); border: 1px solid var(--line-brand, var(--line)); }
/* the doctor's exam button before the reception sent the patient in: shown, not usable */
.btn.is-waiting-call { cursor: not-allowed; opacity: .6; filter: saturate(.4); transform: none !important; box-shadow: none; }

/* ---------- the expenses list: one line per value on a computer, a tidy card per expense on a phone ---------- */
.exp-table td { vertical-align: middle; }
.exp-table .nowrap { white-space: nowrap; }
.exp-table .exp-amount strong { font-size: .98rem; font-variant-numeric: tabular-nums; }
.exp-table .receipts { flex-wrap: nowrap; }
.exp-table td.cell-actions { width: 1%; }
@media (max-width: 720px) {
  .exp-table .cell-main { font-weight: 700; }
  .exp-table .exp-amount { text-align: end; }
  .exp-table td.cell-actions { width: auto; display: flex; justify-content: flex-end; }
  .exp-table .receipts { flex-wrap: wrap; }
}

/* ---------- money owed on the subscription (billing.php subscription_due): noticeable, never in the way ---------- */
.due-banner { --due: var(--warning); position: relative; display: flex; align-items: center; justify-content: center; gap: .65rem; flex-wrap: wrap;
  padding: .55rem 1.25rem; font-size: .95rem; color: var(--ink); text-decoration: none; overflow: hidden;
  background: color-mix(in srgb, var(--due) 13%, var(--surface)); border-bottom: 1px solid color-mix(in srgb, var(--due) 30%, var(--line)); }
.due-banner.is-late { --due: var(--danger); }
.due-banner:hover { text-decoration: none; background: color-mix(in srgb, var(--due) 18%, var(--surface)); }
/* a slow sheen crossing the strip every few seconds */
.due-banner::after { content: ""; position: absolute; inset-block: 0; width: 40%; inset-inline-start: -45%; pointer-events: none;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 55%, transparent), transparent); animation: due-sheen 7s ease-in-out infinite; }
@keyframes due-sheen { 0%, 70% { inset-inline-start: -45%; } 100% { inset-inline-start: 110%; } }
.due-pulse { position: relative; width: .7rem; height: .7rem; flex: none; border-radius: 50%; background: var(--due); }
.due-pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--due); animation: due-ping 1.8s ease-out infinite; }
@keyframes due-ping { 0% { transform: scale(1); opacity: .55; } 80%, 100% { transform: scale(2.6); opacity: 0; } }
.due-text b { color: var(--due); font-weight: 800; font-variant-numeric: tabular-nums; }
.due-go { display: inline-flex; align-items: center; gap: .2rem; padding: .18rem .7rem; border-radius: var(--radius-pill); font-size: .85rem; font-weight: 700;
  color: #fff; background: var(--due); }
.due-go .ic { width: 15px; height: 15px; }
[dir="ltr"] .due-go .ic { transform: scaleX(-1); }
/* the dot beside «اشتراكي» in the menu */
.sb-item, .more-item, .bb-item { position: relative; }
.due-dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--danger); margin-inline-start: auto; flex: none;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 55%, transparent); animation: due-dot 2s ease-out infinite; }
.more-item .due-dot { position: absolute; top: .55rem; inset-inline-end: .7rem; margin: 0; }
body.sb-collapsed .sb-item .due-dot { position: absolute; top: .35rem; inset-inline-end: .35rem; margin: 0; }
@keyframes due-dot { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }
/* «اشتراكي»: the charges that are due glow softly */
.charges tr.charge-flash > td { animation: charge-flash 2.6s ease-in-out infinite; }
@keyframes charge-flash { 0%, 100% { background: transparent; } 50% { background: color-mix(in srgb, var(--danger) 9%, transparent); } }
.charges tr.charge-flash .charge-state { animation: due-dot 2s ease-out infinite; }
@media (prefers-reduced-motion: reduce) { .due-banner::after, .due-pulse::after, .due-dot, .charges tr.charge-flash > td, .charges tr.charge-flash .charge-state { animation: none; } }
/* a demo account (admin): shown to doctors, kept out of the platform's figures */
.demo-tag { display: inline-block; padding: .05rem .5rem; border-radius: var(--radius-pill); font-size: .72rem; font-weight: 700; vertical-align: middle;
  color: var(--doctor); background: var(--doctor-bg); border: 1px dashed color-mix(in srgb, var(--doctor) 45%, transparent); }

/* ---------- new doctor (admin): one numbered card per step, so the parts stand apart ---------- */
.form-steps { display: grid; gap: 1.1rem; max-width: 980px; }
.form-steps > .form-step { margin: 0; padding: 1.15rem 1.35rem 1.25rem; border-inline-start: 4px solid var(--brand); }
.step-head { display: flex; align-items: center; gap: .75rem; margin: 0 0 1rem; padding-bottom: .8rem; border-bottom: 1px solid var(--line); }
.step-head h2 { margin: 0; font-size: 1.12rem; }
.step-head p { margin: .15rem 0 0; font-size: .86rem; }
.step-num { display: grid; place-items: center; flex: none; width: 2rem; height: 2rem; border-radius: 50%; font-weight: 800; font-size: .95rem;
  color: var(--on-brand); background: var(--brand); box-shadow: 0 2px 0 var(--btn-edge); }
.step-ic { display: grid; place-items: center; flex: none; width: 2.3rem; height: 2.3rem; border-radius: 12px; color: var(--brand-ink); background: var(--brand-soft); }
.step-ic .ic { width: 20px; height: 20px; }
.form-step .contract { display: grid; gap: .9rem; }
.form-step .staff-rows { display: grid; gap: .7rem; margin-bottom: .7rem; }
.form-step .staff-row { background: var(--surface-2); border-style: solid; border-color: var(--line); }
.form-steps > .step-finish { border-inline-start-color: var(--gold-500); }
.step-submit { display: flex; justify-content: flex-end; }
.step-submit .btn { min-width: 14rem; min-height: 3rem; font-size: 1rem; }
@media (max-width: 600px) { .step-submit .btn { width: 100%; } .step-ic { display: none; } }

/* ---------- Visit bill (appointment_bill.php) ---------- */
.bill-table .num { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bill-table td form { margin: 0; }
.bill-table tfoot th { text-align: start; font-weight: 600; color: var(--muted); }
.bill-table tfoot .bill-total th, .bill-table tfoot .bill-total td { color: var(--ink); font-weight: 700; font-size: 1.05rem; border-top: 2px solid var(--line); }
.bill-table .bill-discount td { color: var(--success); }
.bill-table tfoot .bill-due.is-due th, .bill-table tfoot .bill-due.is-due td { color: var(--danger); font-weight: 700; font-size: 1.1rem; }
.bill-pay { width: 100%; justify-content: center; margin-top: 1rem; font-size: 1.05rem; }
.bill-settled { display: flex; align-items: center; gap: .4rem; margin: 1rem 0 0; color: var(--success); font-weight: 600; }
.bill-settled .ic { width: 18px; height: 18px; }
.bill-link { font-weight: 600; text-decoration: underline dotted; text-underline-offset: 3px; }
label .hint { display: block; margin-top: .3rem; font-weight: 400; font-size: .82rem; color: var(--muted); }

/* ---------- The bill box on the exam page (lib/bill.php bill_panel) ---------- */
.bill-box { margin: 1rem 0; padding: .9rem 1rem 1rem; border: 1px solid var(--line); border-inline-start: 4px solid var(--gold-500, var(--brand)); border-radius: var(--radius); background: var(--surface-2, transparent); }
.bill-box.is-busy { opacity: .6; pointer-events: none; }
.bill-box-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.bill-box-head h2 { display: flex; align-items: center; gap: .45rem; margin: 0; font-size: 1.05rem; }
.bill-box-head h2 .ic { width: 20px; height: 20px; color: var(--gold-500, var(--brand)); }
.bill-lines { list-style: none; margin: 0; padding: 0; }
.bill-lines li { display: grid; grid-template-columns: 1fr auto 2.2rem; align-items: center; gap: .6rem; padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.bill-lines .bl-name { display: flex; flex-direction: column; min-width: 0; }
.bill-lines .bl-name small { font-size: .78rem; }
.bill-lines .bl-price { display: flex; align-items: center; gap: .3rem; margin: 0; font-weight: 600; white-space: nowrap; }
.bill-lines .is-discount .bl-name strong, .bill-lines .is-discount .bl-price { color: var(--success); }
.bill-box .bill-in { width: 6.5rem; margin: 0; padding: .35rem .5rem; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.bill-add { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .7rem; }
.bill-add select { flex: 1 1 12rem; min-width: 0; margin: 0; }
.bill-add [data-bill-name] { flex: 1 1 9rem; min-width: 0; margin: 0; }
.bill-add .btn { margin: 0; }
.bill-disc { margin-top: .4rem; }
.bill-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .9rem 0 0; }
.bill-sum > div { padding: .45rem .6rem; border-radius: var(--radius); background: var(--bg, rgba(0,0,0,.03)); border: 1px solid var(--line); }
.bill-sum dt { font-size: .8rem; color: var(--muted); }
.bill-sum dd { margin: .1rem 0 0; font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.bill-sum .is-due dd { color: var(--danger); }
.bill-sum .is-ok dd { color: var(--success); }
.bill-msg { margin: .5rem 0 0; min-height: 1.2em; font-size: .85rem; color: var(--success); }
.bill-msg.is-error { color: var(--danger); }
@media (max-width: 600px) {
  .bill-sum { grid-template-columns: 1fr 1fr 1fr; gap: .35rem; }
  .bill-sum dd { font-size: .95rem; }
  .bill-box .bill-in { width: 5.5rem; }
}

/* «خرجوا من الكشف - بانتظار الدفع» on the schedule (appointments.php) */
.appt-unpaid { border-inline-start: 4px solid var(--gold-500); }
.appt-unpaid .card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.appt-unpaid .count { background: var(--gold-100); color: var(--gold-700); }
.appt-unpaid .unpaid-sum { color: var(--danger); font-size: 1.05rem; }
.bill-what { max-width: 22rem; white-space: normal; line-height: 1.5; }
.appt-unpaid .btn-pay { background: var(--gold-500); border-color: var(--gold-600); color: #1d1608; font-weight: 700; }
.appt-unpaid .btn-pay:hover { background: var(--gold-600); color: #fff; }

/* ---------- Dental chart (lib/dental.php, assets/dental.js) ---------- */
.dc { margin: 0 0 1rem; padding: 1.1rem; border-radius: calc(var(--radius) * 1.4); border: 1px solid var(--line);
  background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--brand) 9%, var(--surface)) 0%, var(--surface) 60%); }
.dc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .6rem; }
.dc-title { margin: 0; font-size: 1.1rem; }
.dc-sub { margin: .15rem 0 0; font-size: .85rem; }
.dc-seg { display: inline-flex; padding: 3px; border-radius: var(--radius-pill); background: var(--surface-2); border: 1px solid var(--line); }
.dc-seg button { border: 0; background: none; color: var(--ink-2); font: inherit; font-size: .85rem; font-weight: 600; padding: .35rem .9rem; border-radius: var(--radius-pill); cursor: pointer; }
.dc-seg button.is-on { background: var(--brand); color: #fff; box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 40%, transparent); }
.dc-body { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 1.1rem; align-items: start; }
.dc-stage { --i: #c27610; --c: #23873a; --p: #7d2a9c; --m: #23439a; --ink-dc: #1f2b37; --halo-dc: #ffffff;
  perspective: 1600px; border-radius: var(--radius); padding: .4rem .4rem .6rem; border: 1px solid #d8e6f1;
  background: radial-gradient(90% 70% at 50% 45%, #ffffff 0%, #f3f8fc 70%, #e9f2f9 100%); box-shadow: 0 8px 26px rgba(30,60,90,.10); }
.dc-svg { display: block; width: 100%; height: auto; max-height: calc(100vh - 150px); margin: 0 auto; transform: rotateX(7deg); transform-origin: 50% 50%; }
.dc-jawshape { filter: drop-shadow(0 6px 10px rgba(90,25,35,.28)); }
.dc-jaw { fill: var(--ink-dc); font-size: 26px; font-weight: 800; paint-order: stroke; stroke: var(--halo-dc); stroke-width: 5px; stroke-linejoin: round; }
.dc-side { fill: var(--ink-dc); font-size: 25px; font-weight: 800; paint-order: stroke; stroke: var(--halo-dc); stroke-width: 5px; stroke-linejoin: round; }
/* the tooth numbers: large, bold, with a halo so they read on any background; they grow with their tooth on hover */
.dc-num { font-size: 25px; font-weight: 800; font-variant-numeric: tabular-nums; pointer-events: none;
  paint-order: stroke; stroke: var(--halo-dc); stroke-width: 5px; stroke-linejoin: round; transition: font-size .18s ease; }
.dc-tooth:hover .dc-num, .dc-tooth:focus-visible .dc-num { font-size: 34px; }
.dc-tooth.is-sel .dc-num { font-size: 31px; }
.dc-num.t-incisor, .dc-kinds .t-incisor { fill: var(--i); color: var(--i); }
.dc-num.t-canine, .dc-kinds .t-canine { fill: var(--c); color: var(--c); }
.dc-num.t-premolar, .dc-kinds .t-premolar { fill: var(--p); color: var(--p); }
.dc-num.t-molar, .dc-kinds .t-molar { fill: var(--m); color: var(--m); }
.dc-kinds { display: flex; flex-wrap: wrap; justify-content: center; gap: .3rem 1rem; font-size: .82rem; font-weight: 600; margin-top: .15rem; }
.dc-dot { fill: #14b8a6; stroke: #fff; stroke-width: 1.2; }
:root[data-theme="dark"] .dc-stage { --i: #f2a93b; --c: #4cc764; --p: #c27fe2; --m: #86a2f5; --ink-dc: #e8f1f5; --halo-dc: #0d1918;
  border-color: #23403d; background: radial-gradient(90% 70% at 50% 45%, #1a302e 0%, #12211f 70%, #0d1918 100%); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dc-stage { --i: #f2a93b; --c: #4cc764; --p: #c27fe2; --m: #86a2f5; --ink-dc: #e8f1f5; --halo-dc: #0d1918;
    border-color: #23403d; background: radial-gradient(90% 70% at 50% 45%, #1a302e 0%, #12211f 70%, #0d1918 100%); }
}
.dc-tooth { cursor: pointer; outline: none; }
.dc-tooth .dc-lift { transition: transform .18s ease, filter .18s ease; transform-box: fill-box; transform-origin: center; }
.dc-tooth:hover .dc-lift, .dc-tooth:focus-visible .dc-lift { transform: scale(1.32); filter: brightness(1.07) drop-shadow(0 4px 6px rgba(40,10,15,.35)); }
.dc-tooth.is-sel .dc-lift { transform: scale(1.22); filter: url(#dcGlow); }
.dc-tooth.is-sel:hover .dc-lift { transform: scale(1.32); }
.dc-tooth.is-sel .dc-body { stroke: #14b8a6; stroke-width: 2.2; }
.dc-tooth.is-missing .dc-num { opacity: .55; }
.dc-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: .9rem;
  position: sticky; top: .75rem; max-height: calc(100vh - 1.5rem); overflow-y: auto; }
.dc-pick { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .35rem; padding: 2rem .5rem; color: var(--muted); }
.dc-pick svg { width: 46px; height: 46px; fill: color-mix(in srgb, var(--brand) 18%, transparent); stroke: var(--brand); stroke-width: 1.3; }
.dc-pick strong { color: var(--ink); }
.dc-th { display: flex; align-items: center; gap: .65rem; margin-bottom: .4rem; }
.dc-th strong { display: block; font-size: 1rem; line-height: 1.35; }
/* the English name under the Arabic one: a clear, left-to-right label */
.dc-th .dc-en { display: inline-block; margin-top: .3rem; padding: .15rem .55rem; border-radius: 6px; direction: ltr; unicode-bidi: isolate;
  font-size: .9rem; font-weight: 600; letter-spacing: .01em; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); }
.dc-badge { display: inline-grid; place-items: center; min-width: 2.6rem; height: 2.6rem; padding: 0 .4rem; border-radius: 12px; font-weight: 800; font-size: 1.05rem; color: #fff;
  background: linear-gradient(145deg, color-mix(in srgb, var(--brand) 80%, #fff), var(--brand)); box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 35%, transparent), inset 0 1px 0 rgba(255,255,255,.35); font-variant-numeric: tabular-nums; }
.dc-badge.sm { min-width: 2rem; height: 1.7rem; font-size: .82rem; border-radius: 8px; }
.dc-last { margin: .2rem 0 .4rem; font-size: .82rem; color: var(--muted); }
.dc-panel h4 { margin: .75rem 0 .35rem; font-size: .82rem; color: var(--muted); font-weight: 700; }
.dc-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.dc-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .65rem; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: inherit; font-size: .82rem; cursor: pointer; transition: background .15s, border-color .15s, transform .1s; }
.dc-chip:hover { border-color: color-mix(in srgb, var(--c, var(--brand)) 60%, var(--line)); }
.dc-chip:active { transform: scale(.97); }
.dc-chip i { width: .7rem; height: .7rem; border-radius: 50%; background: var(--c); box-shadow: inset 0 -1px 2px rgba(0,0,0,.25); }
.dc-chip.is-on { background: color-mix(in srgb, var(--c, var(--brand)) 18%, var(--surface)); border-color: var(--c, var(--brand)); font-weight: 700; }
.dc-surf .dc-chip { font-variant-numeric: tabular-nums; }
.dc-note { margin-top: .75rem; }
.dc-note input { margin-top: .25rem; }
.dc-clear { margin-top: .6rem; }
.dc-legend { display: flex; flex-wrap: wrap; gap: .4rem .9rem; margin: .7rem 0 0; font-size: .8rem; color: var(--ink-2); }
.dc-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.dc-legend i { width: .75rem; height: .75rem; border-radius: 50%; background: var(--c); }
.dc-today { margin-top: .8rem; border-top: 1px dashed var(--line); padding-top: .6rem; }
.dc-today h4 { margin: 0 0 .4rem; font-size: .85rem; }
.dc-today ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.dc-today li { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; font-size: .85rem; }
.dc-today li button { display: inline-flex; align-items: center; gap: .45rem; border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: var(--ink); cursor: pointer; }
@media (max-width: 900px) {
  .dc-body { grid-template-columns: 1fr; }
  .dc-panel { position: static; max-height: none; }
  .dc-svg { max-height: none; }
  .dc-svg { transform: rotateX(5deg); }
}
@media (max-width: 600px) {
  .dc { padding: .7rem; margin-inline: -.25rem; }
  .dc-num { font-size: 27px; }
  .dc-side, .dc-jaw { font-size: 27px; }
}

/* the chart in the patient's file (view mode): the mouth's summary and a tooth's history */
.dc-sum h4 { margin: 0 0 .6rem; font-size: .95rem; color: var(--ink); }
.dc-sum ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.dc-sum li { display: flex; align-items: center; gap: .5rem; padding: .45rem .6rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.dc-sum li i, .dc-now i, .dc-log li::before { width: .75rem; height: .75rem; border-radius: 50%; background: var(--c); flex: none; }
.dc-sum li b { margin-inline-start: auto; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.dc-sum-hint { margin: .8rem 0 0; font-size: .85rem; }
.dc-now { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 0; padding: .5rem .65rem; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--c) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 40%, var(--line)); }
.dc-log { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.dc-log li { position: relative; padding: .15rem 0 .15rem 0; padding-inline-start: 1.3rem; font-size: .88rem; line-height: 1.5; }
.dc-log li::before { content: ""; position: absolute; inset-inline-start: 0; top: .45rem; }
.dc-log li:not(:last-child)::after { content: ""; position: absolute; inset-inline-start: .33rem; top: 1.3rem; bottom: -.55rem; width: 2px; background: var(--line); }
.dc-log-h { font-weight: 700; font-size: .82rem; }
.dc-log-h a { color: var(--brand-ink); }
.dc-view .dc-tooth { cursor: pointer; }

/* whole-mouth procedures above the chart (scaling, whitening) */
.dc-mouth { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .5rem; margin: 0 0 .8rem; padding: .55rem .7rem; border-radius: var(--radius); background: var(--surface-2); border: 1px dashed var(--line); }
.dc-mouth-l { font-size: .85rem; font-weight: 700; color: var(--ink-2); margin-inline-end: .25rem; }
.dc-mouth .dc-chip { --c: var(--brand); font-size: .9rem; padding: .35rem .8rem; }
.dc-check { width: 1rem !important; height: 1rem !important; border-radius: 5px !important; background: var(--surface) !important; border: 1.5px solid var(--line-2, var(--line)); box-shadow: none !important; position: relative; }
.dc-chip.is-on .dc-check { background: var(--brand) !important; border-color: var(--brand); }
.dc-chip.is-on .dc-check::after { content: ""; position: absolute; inset: 2px 4px 4px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.dc-badge-mouth { min-width: 2.4rem; background: linear-gradient(145deg, #c9a45c, #a57f36); }
.dc-today li > b { font-weight: 700; }
.dc-sum-mouth { margin: .7rem 0 0; font-size: .88rem; }

/* «تسليم الإيراد» (handover.php) */
.handover-math { list-style: none; margin: 0 0 .9rem; padding: 0; display: grid; gap: .35rem; }
.handover-math li { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .5rem .7rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.handover-math b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.handover-math .handover-due { background: color-mix(in srgb, var(--brand) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line)); font-size: 1.1rem; font-weight: 700; }
.handover-due b { color: var(--brand-ink); font-size: 1.3rem; }
.handover-other { font-size: .85rem; margin: 0 0 .9rem; }
.handover-form .btn { margin-top: .25rem; }
.handover-rows { margin-top: 1rem; }
.handover-rows summary { cursor: pointer; font-weight: 600; color: var(--ink-2); margin-bottom: .5rem; }
.handover-pending { padding: .9rem 1rem; border: 1px solid var(--line); border-inline-start: 4px solid var(--warning); border-radius: var(--radius); background: var(--surface); margin-top: .75rem; }
.hp-who strong { display: block; font-size: 1.05rem; }
.hp-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; margin: .7rem 0; }
.hp-sum > div { padding: .45rem .6rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.hp-sum dt { font-size: .78rem; color: var(--muted); }
.hp-sum dd { margin: .1rem 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.hp-sum .hp-handed { font-size: 1.25rem; color: var(--brand-ink); }
.hp-note { margin: 0 0 .6rem; font-size: .9rem; }
.hp-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .5rem; }
.hp-actions form { margin: 0; }
.hp-dispute > summary { list-style: none; cursor: pointer; }
.hp-dispute > summary::-webkit-details-marker { display: none; }
.hp-dispute[open] { flex-basis: 100%; }
.hp-dispute[open] form { margin-top: .6rem; }

/* the doctor's reminder: cash handed over, waiting for his confirmation (lib/handover.php handover_banner) */
.hand-banner { position: relative; display: flex; align-items: center; justify-content: center; gap: .8rem; flex-wrap: wrap; overflow: hidden;
  padding: .7rem 1rem; color: #3d2a05; text-decoration: none;
  background: linear-gradient(100deg, #f7d77c 0%, #f1c55a 45%, #e9b444 100%); border-bottom: 1px solid #c99a2e;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.06); }
.hand-banner:hover { text-decoration: none; filter: brightness(1.04); }
.hand-banner::after { content: ""; position: absolute; inset-block: 0; width: 35%; inset-inline-start: -40%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.55), transparent); animation: hand-sheen 3.2s ease-in-out infinite; }
@keyframes hand-sheen { 0% { inset-inline-start: -40%; } 60%, 100% { inset-inline-start: 110%; } }
.hand-coin { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #fff6d6, #e0a92c 70%); box-shadow: 0 0 0 0 rgba(201,140,20,.6); animation: hand-pulse 1.8s ease-out infinite; }
.hand-coin .ic { width: 20px; height: 20px; color: #6b4700; }
@keyframes hand-pulse { 0% { box-shadow: 0 0 0 0 rgba(201,140,20,.65); } 70%, 100% { box-shadow: 0 0 0 12px rgba(201,140,20,0); } }
.hand-text { display: flex; flex-direction: column; line-height: 1.35; }
.hand-text b { font-size: 1.02rem; }
.hand-text > span { font-size: .9rem; opacity: .9; }
.hand-go { display: inline-flex; align-items: center; gap: .3rem; padding: .4rem .9rem; border-radius: var(--radius-pill); font-weight: 700; font-size: .9rem;
  background: #3d2a05; color: #ffe9a8; }
.hand-go .ic { width: 16px; height: 16px; }
.hand-count { margin-inline-start: auto; min-width: 1.35rem; height: 1.35rem; padding: 0 .35rem; border-radius: var(--radius-pill); flex: none;
  display: inline-grid; place-items: center; font-size: .75rem; font-weight: 800; color: #3d2a05; background: #f1c55a;
  box-shadow: 0 0 0 0 rgba(241,197,90,.6); animation: hand-pulse 1.8s ease-out infinite; }
.more-item .hand-count { position: absolute; top: .45rem; inset-inline-end: .6rem; margin: 0; }
body.sb-collapsed .sb-item .hand-count { position: absolute; top: .2rem; inset-inline-end: .2rem; margin: 0; }
@media (prefers-reduced-motion: reduce) { .hand-banner::after, .hand-coin, .hand-count { animation: none; } }
.hand-others { margin: .8rem 0; padding: .7rem .8rem; border-radius: var(--radius); background: var(--info-bg); border: 1px solid color-mix(in srgb, var(--info) 30%, transparent); }
.hand-others h4 { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; margin: 0 0 .35rem; font-size: .92rem; color: var(--info); }
.hand-others h4 .ic { width: 18px; height: 18px; }
.hand-others h4 small { font-weight: 500; }
.hand-others-sum { margin: 0 0 .45rem; font-size: .9rem; }
.hand-others .table { background: var(--surface); border-radius: var(--radius-sm); }
.pay-chip { display: inline-block; padding: .05rem .5rem; border-radius: var(--radius-pill); background: var(--info-bg); color: var(--info); font-size: .78rem; font-weight: 700; }
.hand-cancel { margin-top: .35rem; }
.hand-cash { margin: .8rem 0; padding: .7rem .8rem; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.hand-cash h4 { display: flex; align-items: center; gap: .35rem; margin: 0 0 .45rem; font-size: .92rem; }
.hand-cash h4 .ic { width: 18px; height: 18px; color: var(--brand); }
.hand-cash .hand-out-h { margin-top: .8rem; }
.hand-cash .hand-out-h .ic { color: var(--danger); }
.hand-cash .table { background: var(--surface); border-radius: var(--radius-sm); }
/* the doctor's handover page: what each staff member holds, the record */
.held-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem; }
.held-card { padding: .8rem .9rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); display: flex; flex-direction: column; gap: .45rem; }
.held-card.has-cash { border-color: color-mix(in srgb, var(--gold-500) 60%, var(--line)); background: color-mix(in srgb, var(--gold-500) 9%, var(--surface)); }
.held-who { display: flex; align-items: center; gap: .5rem; }
.held-amount small { display: block; font-size: .78rem; color: var(--muted); }
.held-amount b { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.held-card.has-cash .held-amount b { color: var(--gold-700); }
.held-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; font-size: .84rem; }
.held-lines li { display: flex; justify-content: space-between; gap: .5rem; }
.held-last { font-size: .78rem; }
.log-sum { margin: .2rem 0 .7rem; font-size: .92rem; }
.log-table td small { font-size: .78rem; }
.log-detail-row > td { background: var(--surface-2); padding: .6rem; }
.log-detail-row .hand-cash, .log-detail-row .hand-others { margin: .3rem 0; }
:root[data-theme="dark"] .held-card.has-cash .held-amount b { color: var(--gold-300); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .held-card.has-cash .held-amount b { color: var(--gold-300); } }
.lock-mark { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 8px; color: var(--muted); background: var(--surface-2); cursor: help; }
.lock-mark .ic { width: 16px; height: 16px; }

/* the patient's prescription from a WhatsApp link (pages/tenant/rx_share.php) */
.rx-share-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: center; gap: .8rem; flex-wrap: wrap;
  padding: .7rem 1rem; background: #fff8e6; border-bottom: 1px solid #ecd9a3; color: #4a3a12; font-size: .95rem; }
.rx-share-bar p { display: flex; align-items: center; gap: .45rem; margin: 0; line-height: 1.5; }
.rx-share-bar .ic { width: 18px; height: 18px; flex: none; }
.rx-share-fit { width: 100%; max-width: 100vw; overflow: hidden; display: flex; justify-content: center; padding: 1rem 0; }
.rx-share-fit .rx-sheet { transform-origin: top center; flex: none; box-shadow: 0 6px 24px rgba(0,0,0,.12); }
@media (max-width: 820px) { .rx-share-fit { padding: .5rem 0; } }
@media print { .rx-share-fit { padding: 0; display: block; } .rx-share-fit .rx-sheet { box-shadow: none; transform: none !important; } }
.rx-share-off { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 1rem; }
.rx-off-card { max-width: 420px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 2rem 1.5rem; }
.rx-off-card h1 { font-size: 1.2rem; margin: 0 0 .8rem; }
/* was the prescription sent on WhatsApp, did the patient open it (lib/rx_share.php rx_share_badge) */
.rx-sent { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .65rem; border-radius: var(--radius-pill); font-size: .8rem; font-weight: 600; }
.rx-sent .ic { width: 15px; height: 15px; }
.rx-sent.is-opened { background: var(--success-bg); color: var(--success); }
.rx-sent.is-waiting { background: var(--warning-bg); color: var(--warning); }
.rx-sent-line { margin: 0 0 .8rem; }
.visit header .rx-sent { font-size: .75rem; }

/* ---- terms & privacy (lib/legal.php) ---- */
.legal-links { margin: .9rem 0 0; font-size: .8rem; color: var(--muted); text-align: center; }
.legal-links a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.legal-links a:hover { color: var(--brand-ink); }
.legal-links.is-start { text-align: start; font-size: .9rem; }
.rx-share-legal { margin: .5rem 0 1.2rem; text-align: center; font-size: .78rem; }
.rx-share-legal a { color: #6b7c7a; }
/* the public page: a calm reading column */
.auth-wrap:has(.legal-doc) { display: block; padding: 1.5rem 16px 3rem; }
.legal-doc { max-width: 760px; margin: 0 auto; padding: 2rem clamp(1.1rem, 4vw, 2.6rem); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); line-height: 1.85; color: var(--ink-2); }
.legal-head { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .3rem 1rem; padding-bottom: 1.2rem; border-bottom: 1px solid var(--line); }
.legal-brand .brand-logo { width: 120px; }
.legal-tools { display: flex; gap: .4rem; }
.legal-head h1 { grid-column: 1 / -1; margin: 1.2rem 0 0; font-size: clamp(1.5rem, 4vw, 2rem); color: var(--ink); }
.legal-date { grid-column: 1 / -1; margin: 0; font-size: .85rem; color: var(--muted); }
.legal-intro { grid-column: 1 / -1; margin: .6rem 0 0; }
.legal-toc { margin: 1.2rem 0 .4rem; padding: .9rem 1.1rem; padding-inline-start: 2.2rem; border-radius: var(--radius); background: var(--surface-3); columns: 2 220px; column-gap: 2rem; font-size: .9rem; }
.legal-toc a { color: var(--brand-ink); }
.legal-sec { padding-top: 1.1rem; scroll-margin-top: 1rem; }
.legal-sec h2 { display: flex; align-items: center; gap: .6rem; margin: 0 0 .35rem; font-size: 1.12rem; color: var(--ink); }
.legal-n { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 9px; background: var(--brand-soft); color: var(--brand-ink); font-size: .85rem; }
.legal-sec p { margin: .35rem 0; }
.legal-sec ul { margin: .35rem 0; padding-inline-start: 1.3rem; }
.legal-sec li { margin: .25rem 0; }
.legal-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: .85rem; color: var(--muted); }
@media print {
  .auth-wrap:has(.legal-doc) { padding: 0; }
  .legal-doc { max-width: none; padding: 0; border: 0; box-shadow: none; }
}
/* the doctor's acceptance box: covers the page until he accepts */
.legal-gate { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; background: rgba(4, 20, 19, .62); backdrop-filter: blur(4px); }
.legal-gate-card { width: min(480px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 1.8rem 1.5rem 1.5rem; border-radius: var(--radius-xl);
  background: var(--surface); box-shadow: var(--shadow-lg); text-align: center; }
.legal-gate-ic { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; color: #fff;
  background: linear-gradient(135deg, var(--teal-400), var(--teal-700)); box-shadow: 0 8px 20px rgba(8, 46, 43, .25); }
.legal-gate-ic .ic { width: 28px; height: 28px; }
.legal-gate-card h2 { margin: .9rem 0 .4rem; font-size: 1.2rem; }
.legal-gate-card p { margin: 0 0 1rem; color: var(--ink-2); line-height: 1.8; }
.legal-gate-links { display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.legal-gate-card .check { justify-content: center; margin-bottom: 1rem; text-align: start; }


/* ======================================================================
   Motion: the sidebar's items lift like the dental chart's teeth on hover, and every page settles in
   when it opens (only the first moment: the live re-renders that follow never replay it)
   ====================================================================== */
.sb-item .ic { transition: transform .18s ease, filter .18s ease; }
.sb-item:hover .nav-ic, .sb-item:focus-visible .nav-ic { transform: scale(1.16); background: rgba(255,255,255,.18); box-shadow: 0 4px 10px rgba(2, 10, 9, .32); }
.sb-item:hover .ic, .sb-item:focus-visible .ic { transform: scale(1.12); filter: brightness(1.12) drop-shadow(0 2px 3px rgba(2, 10, 9, .35)); }
.sb-item.on:hover .nav-ic, .sb-item.on:focus-visible .nav-ic { background: var(--brand-soft); box-shadow: 0 4px 10px rgba(8, 46, 43, .22); }
.sb-item:active .nav-ic { transform: scale(1.05); }
.more-item .nav-ic { transition: transform .18s ease, box-shadow .18s ease; }
.more-item:hover .nav-ic, .more-item:focus-visible .nav-ic { transform: scale(1.12); box-shadow: 0 4px 10px rgba(8, 46, 43, .18); }

@keyframes page-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes card-in { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: none; } }
html.page-enter .app-main > .container > * { animation: page-in .6s cubic-bezier(.22, .8, .36, 1) both; }
html.page-enter .app-main > .container > :nth-child(2) { animation-delay: .08s; }
html.page-enter .app-main > .container > :nth-child(3) { animation-delay: .16s; }
html.page-enter .app-main > .container > :nth-child(4) { animation-delay: .24s; }
html.page-enter .app-main > .container > :nth-child(5) { animation-delay: .32s; }
html.page-enter .app-main > .container > :nth-child(n+6) { animation-delay: .4s; }
html.page-enter .auth-card { animation: card-in .65s cubic-bezier(.22, .8, .36, 1) both; }

@media (prefers-reduced-motion: reduce) {
  .sb-item .nav-ic, .sb-item .ic, .more-item .nav-ic { transition: none; }
  .sb-item:hover .nav-ic, .sb-item:hover .ic, .sb-item:focus-visible .nav-ic, .sb-item:focus-visible .ic, .more-item:hover .nav-ic { transform: none; }
  html.page-enter .app-main > .container > *, html.page-enter .auth-card { animation: none; }
}
