@font-face { font-family: 'Geist'; src: url('/fonts/geist.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Bricolage'; src: url('/fonts/bricolage.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }
/* Arabic letters only: downloaded the first time Arabic text appears. Latin keeps Geist and Bricolage. */
@font-face { font-family: 'Cairo'; src: url('/fonts/cairo-arabic.woff2') format('woff2'); font-weight: 200 1000; font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }

/* ---------- Tokens ---------- */
:root {
  --bg: #F3F1EA; --surface: #FFFFFF; --surface-2: #F9F7F2; --surface-3: #EFECE3;
  --ink: #12211E; --ink-2: #47564F; --ink-3: #66736E;
  --line: #E3DFD4; --line-strong: #CFCABC;
  --brand: #0B5A50; --brand-ink: #FFFFFF; --brand-soft: #DCEFE9; --brand-text: #0B5A50;
  --accent: #C94F1B; --accent-soft: #FCE9DF; --accent-text: #A83F12;
  --good: #1B7F5C; --good-soft: #DDF3E9; --warn: #9A6B00; --warn-soft: #FBF0CF;
  --danger: #B3261E; --danger-soft: #FBE4E2; --info: #2B6399; --info-soft: #E0ECF7;
  --mute-soft: #ECE9E0;
  --rail: #0B2B27; --rail-2: #123B35; --rail-ink: #CFE3DD; --rail-mute: #84A69E; --mint: #7FE3CF; --coral: #F08A5D;
  --c0: #008A7C; --c1: #D9622B; --c2: #5B5FC7; --c3: #B8860B; --c4: #B5397A; --c5: #2E7FB8;
  --shadow-sm: 0 1px 2px rgb(18 33 30 / .05);
  --shadow: 0 1px 2px rgb(18 33 30 / .04), 0 8px 24px -12px rgb(18 33 30 / .14);
  --shadow-lg: 0 24px 64px -16px rgb(10 30 26 / .35);
  --r-s: 8px; --r: 12px; --r-l: 18px;
  --display: 'Bricolage', 'Cairo', 'Segoe UI', system-ui, sans-serif;
  --body: 'Geist', 'Cairo', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --dark: 1;
  --bg: #0C1615; --surface: #14201F; --surface-2: #1A2827; --surface-3: #213230;
  --ink: #E8EFEC; --ink-2: #AEBDB8; --ink-3: #8D9D98;
  --line: #263634; --line-strong: #3A4D4A;
  --brand: #5CD4BE; --brand-ink: #06231F; --brand-soft: #143B35; --brand-text: #7FE3CF;
  --accent: #F08A5D; --accent-soft: #3C2317; --accent-text: #F6AC88;
  --good: #5FD0A4; --good-soft: #12352A; --warn: #E2BC57; --warn-soft: #362C10;
  --danger: #F2938C; --danger-soft: #3D1D1B; --info: #8DBDE8; --info-soft: #172D42;
  --mute-soft: #223230;
  --rail: #0A1312; --rail-2: #16302C;
  --c0: #2A9D8C; --c1: #D96F42; --c2: #7B80E0; --c3: #B58D28; --c4: #CF629C; --c5: #4A96CC;
  --shadow-sm: none; --shadow: 0 1px 0 rgb(255 255 255 / .02), 0 12px 28px -18px #000; --shadow-lg: 0 24px 64px -16px #000;
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #0C1615; --surface: #14201F; --surface-2: #1A2827; --surface-3: #213230;
  --ink: #E8EFEC; --ink-2: #AEBDB8; --ink-3: #8D9D98;
  --line: #263634; --line-strong: #3A4D4A;
  --brand: #5CD4BE; --brand-ink: #06231F; --brand-soft: #143B35; --brand-text: #7FE3CF;
  --accent: #F08A5D; --accent-soft: #3C2317; --accent-text: #F6AC88;
  --good: #5FD0A4; --good-soft: #12352A; --warn: #E2BC57; --warn-soft: #362C10;
  --danger: #F2938C; --danger-soft: #3D1D1B; --info: #8DBDE8; --info-soft: #172D42;
  --mute-soft: #223230;
  --rail: #0A1312; --rail-2: #16302C;
  --c0: #2A9D8C; --c1: #D96F42; --c2: #7B80E0; --c3: #B58D28; --c4: #CF629C; --c5: #4A96CC;
  --shadow-sm: none; --shadow: 0 1px 0 rgb(255 255 255 / .02), 0 12px 28px -18px #000; --shadow-lg: 0 24px 64px -16px #000;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.015em; line-height: 1.15; }
h1 { font-size: 30px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); } .small { font-size: 12.5px; } .strong { font-weight: 600; }
.link { color: var(--brand-text); font-weight: 500; } .link:hover { text-decoration: underline; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 16px; } .stack-s { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; } .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pre { white-space: pre-wrap; }

/* ---------- Right-to-left (Arabic) ---------- */
/* Letter-spacing breaks the joins between Arabic letters, and Arabic reads better a touch larger. */
[dir="rtl"] body { font-size: 14.5px; line-height: 1.65; }
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] .kpi .value, [dir="rtl"] .hero h1, [dir="rtl"] .login-art h1 { letter-spacing: 0; line-height: 1.3; }
[dir="rtl"] svg.i.dir { transform: scaleX(-1); }
/* Typed values that are inherently left-to-right. */
[dir="rtl"] input[type="email"], [dir="rtl"] input[type="tel"], [dir="rtl"] input[type="number"] { direction: ltr; text-align: end; }
/* Time runs left to right on the day ribbon and in charts, as in most Arabic scheduling software. */
.ribbon-scroll, .chart { direction: ltr; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column; padding: 18px 12px; z-index: 30; overflow-y: auto; }
.brandmark { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brandmark svg { width: 32px; height: 32px; flex: none; }
.brandmark b { display: block; font: 600 17px/1.1 var(--display); color: #fff; letter-spacing: -.01em; }
.brandmark span { display: block; font-size: 11.5px; color: var(--rail-mute); max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px; font-weight: 500; color: var(--rail-ink); transition: background .15s, color .15s; }
.nav a:hover { background: var(--rail-2); color: #fff; }
.nav a.on { background: var(--rail-2); color: #fff; }
.nav a.on::before { content: ''; position: absolute; inset-inline-start: -12px; top: 9px; bottom: 9px; width: 3px; border-start-end-radius: 3px; border-end-end-radius: 3px; background: var(--mint); }
.nav a.on svg { color: var(--mint); }
.nav .badge { margin-inline-start: auto; background: var(--coral); color: #2A1208; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; }
.nav :focus-visible, .rail-user:focus-visible { outline-color: var(--mint); }
.rail-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; width: 100%; text-align: start; color: #fff; }
.rail-user:hover { background: var(--rail-2); }
.rail-user small { display: block; color: var(--rail-mute); font-size: 11.5px; text-transform: capitalize; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); }
.searchbtn { flex: 1; max-width: 420px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-3); transition: border-color .15s; }
.searchbtn:hover { border-color: var(--line-strong); }
kbd { margin-inline-start: auto; font: 500 11px var(--body); padding: 2px 6px; border-radius: 5px; background: var(--surface-3); color: var(--ink-2); }
.topbar .spacer { flex: 1; }
.iconbtn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--ink-2); flex: none; }
.iconbtn:hover { background: var(--surface-3); color: var(--ink); }
.menu-toggle { display: none; }
.view { padding: 8px 28px 48px; max-width: 1480px; width: 100%; animation: rise .28s cubic-bezier(.2,.7,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.pagehead p { color: var(--ink-3); margin-top: 4px; }
.scrim { display: none; }
.demo-bar { display: flex; align-items: center; gap: 10px; margin: 0 28px 12px; padding-block: 6px; padding-inline: 14px 6px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 13px; font-weight: 500; }
.demo-bar .iconbtn { width: 28px; height: 28px; color: inherit; }
@media (max-width: 860px) { .demo-bar { margin: 0 16px 10px; } }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 10px; font-weight: 550; white-space: nowrap; border: 1px solid var(--line-strong); background: var(--surface); transition: background .15s, transform .05s, border-color .15s; }
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--brand) 88%, var(--ink)); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); color: var(--surface); border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.seg { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 10px; gap: 2px; flex-wrap: wrap; }
.seg button, .seg a { padding: 5px 12px; border-radius: 8px; font-weight: 500; color: var(--ink-2); font-size: 13px; }
.seg .on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg button:hover:not(.on), .seg a:hover:not(.on) { color: var(--ink); }

/* ---------- Cards, KPIs ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-sm); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 0; }
.card-b { padding: 14px 18px 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); align-items: start; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--ink-2); font-size: 13px; display: flex; align-items: center; gap: 7px; }
.kpi .value { font: 600 30px/1.15 var(--display); letter-spacing: -.02em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi .foot { color: var(--ink-3); font-size: 12.5px; margin-top: 4px; }
.delta { font-weight: 600; } .delta.up { color: var(--good); } .delta.down { color: var(--danger); }

/* ---------- Dashboard hero and day ribbon ---------- */
.hero { position: relative; overflow: hidden; background: var(--rail); color: #fff; border-radius: 22px; padding: 26px 28px 22px; margin-bottom: 16px; isolation: isolate; }
.hero::before { content: ''; position: absolute; inset: 0; z-index: -1; background:
  radial-gradient(600px 300px at 88% -20%, rgb(127 227 207 / .22), transparent 70%),
  radial-gradient(420px 240px at 4% 120%, rgb(240 138 93 / .16), transparent 70%); }
.hero h1 { font-size: 34px; color: #fff; font-weight: 500; }
.hero h1 em { font-style: normal; color: var(--mint); }
.hero .sub { color: var(--rail-ink); margin-top: 6px; }
.hero-stats { display: flex; gap: 30px; flex-wrap: wrap; }
.hero-stats div b { display: block; font: 600 28px/1 var(--display); font-variant-numeric: tabular-nums; }
.hero-stats div span { font-size: 12px; color: var(--rail-mute); }
.ribbon { margin-top: 22px; --lane-h: 34px; }
.ribbon-scroll { overflow: auto hidden; padding-bottom: 2px; scrollbar-width: thin; scrollbar-color: var(--rail-2) transparent; }
.ribbon-inner { min-width: 760px; display: grid; grid-template-columns: 120px minmax(0, 1fr); column-gap: 10px; }
.ribbon-hours { position: relative; height: 18px; grid-column: 2; font-size: 11px; color: var(--rail-mute); }
.ribbon-hours span { position: absolute; transform: translateX(-50%); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ribbon-name { font-size: 12.5px; color: var(--rail-ink); align-self: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ribbon-lane { position: relative; height: var(--lane-h); background: rgb(255 255 255 / .05); border-radius: 8px; margin-bottom: 5px; }
.rb { position: absolute; top: 3px; bottom: 3px; border-radius: 5px; background: rgb(255 255 255 / .18); transition: filter .12s, transform .12s; display: block; min-width: 4px; }
.rb:hover { filter: brightness(1.25); transform: scaleY(1.1); }
.rb.scheduled { background: rgb(255 255 255 / .2); }
.rb.arrived { background: #F2C14E; }
.rb.in_consult { background: var(--mint); box-shadow: 0 0 12px rgb(127 227 207 / .55); }
.rb.completed { background: #3C8A7C; }
.rb.cancelled, .rb.no_show { background: repeating-linear-gradient(135deg, rgb(255 255 255 / .16) 0 3px, transparent 3px 6px); }
.rb.no_show { outline: 1px solid var(--coral); outline-offset: -1px; }
.now-line { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--coral); border-radius: 2px; z-index: 2; pointer-events: none; }
.ribbon-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; padding-inline-start: 130px; font-size: 11.5px; color: var(--rail-ink); }
.ribbon-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -1px; }

/* ---------- Status pills, avatars ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding-block: 2px; padding-inline: 7px 9px; border-radius: 99px; font-size: 12px; font-weight: 550; white-space: nowrap; }
.pill svg.i { width: 12px; height: 12px; stroke-width: 2.4; }
.st-scheduled { background: var(--info-soft); color: var(--info); }
.st-arrived, .st-partial, .st-warn { background: var(--warn-soft); color: var(--warn); }
.st-in_consult, .st-good, .st-paid, .st-signed { background: var(--good-soft); color: var(--good); }
.st-completed, .st-void, .st-draft, .st-mute { background: var(--mute-soft); color: var(--ink-2); }
.st-cancelled { background: var(--mute-soft); color: var(--ink-3); text-decoration: line-through; }
.st-no_show, .st-unpaid, .st-danger { background: var(--danger-soft); color: var(--danger); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; margin: 0 1px; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.avatar { --h: 170; width: 34px; height: 34px; border-radius: 11px; flex: none; display: grid; place-items: center; font: 600 12.5px var(--display); background: hsl(var(--h) 45% 88%); color: hsl(var(--h) 55% 24%); }
:root[data-theme="dark"] .avatar { background: hsl(var(--h) 30% 22%); color: hsl(var(--h) 60% 82%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { background: hsl(var(--h) 30% 22%); color: hsl(var(--h) 60% 82%); } }
.avatar.lg { width: 64px; height: 64px; border-radius: 20px; font-size: 22px; }
.rail-user .avatar { background: var(--rail-2); color: var(--mint); }
.allergy { display: inline-flex; align-items: center; gap: 5px; color: var(--accent-text); background: var(--accent-soft); padding-block: 1px; padding-inline: 6px 8px; border-radius: 6px; font-size: 12px; font-weight: 550; max-width: 100%; }
.allergy svg.i { width: 13px; height: 13px; }
.banner { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: 12px; font-weight: 500; }
.banner.alert { background: var(--accent-soft); color: var(--accent-text); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--brand-soft); color: var(--brand-text); }
.banner.demo { background: var(--warn-soft); color: var(--warn); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: start; font-size: 12px; font-weight: 500; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t th.r, .t td.r { text-align: end; }
.t tbody tr.click { cursor: pointer; transition: background .1s; }
.t tbody tr.click:hover { background: var(--surface-2); }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.search svg { position: absolute; inset-inline-start: 11px; top: 50%; translate: 0 -50%; color: var(--ink-3); pointer-events: none; }
.search input.input { padding-inline-start: 34px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; color: var(--ink-3); font-size: 13px; border-top: 1px solid var(--line); }
.empty { text-align: center; padding: 44px 20px; color: var(--ink-3); }
.empty svg.i { width: 28px; height: 28px; margin-bottom: 8px; }
.empty b { display: block; color: var(--ink); font: 600 15px var(--display); margin-bottom: 2px; }
.loading { display: grid; place-items: center; padding: 80px 0; color: var(--ink-3); }
.spinner { width: 26px; height: 26px; border: 2.5px solid var(--line-strong); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.span { grid-column: 1 / -1; }
.field > label, .label-s { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.input, input.input, select.input, textarea.input { width: 100%; padding: 8px 11px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); transition: border-color .12s, box-shadow .12s; min-height: 37px; }
.input:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
textarea.input { resize: vertical; min-height: 84px; line-height: 1.5; }
.form-section { grid-column: 1 / -1; font: 600 13.5px var(--display); padding-top: 8px; margin-bottom: -4px; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 14px; }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 8px 12px; border-radius: 9px; font-weight: 500; font-size: 13px; }

/* ---------- Dialogs ---------- */
dialog.dlg { border: 0; padding: 0; color: inherit; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); overflow: hidden; }
dialog.dlg[open] { display: flex; flex-direction: column; animation: pop .2s cubic-bezier(.2,.8,.2,1); }
dialog.dlg.wide { width: min(820px, calc(100vw - 24px)); }
dialog.dlg::backdrop { background: rgb(6 20 18 / .5); backdrop-filter: blur(3px); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
dialog.dlg.side { margin-block: 0; margin-inline: auto 0; height: 100dvh; max-height: 100dvh; border-radius: 0; border-start-start-radius: 22px; border-end-start-radius: 22px; width: min(460px, 100vw); --slide: 40px; }
[dir="rtl"] dialog.dlg.side { --slide: -40px; }
dialog.dlg.side[open] { animation: slidein .24s cubic-bezier(.2,.8,.2,1); }
@keyframes slidein { from { transform: translateX(var(--slide)); opacity: 0; } to { transform: none; opacity: 1; } }
.dlg-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; }
.dlg-h p { color: var(--ink-3); font-size: 13px; margin-top: 3px; }
.dlg-b { padding: 4px 20px 18px; overflow-y: auto; flex: 1; }
.dlg-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.dlg form { display: contents; }
.kv { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px 12px; }
.kv dt { color: var(--ink-3); font-size: 13px; } .kv dd { margin: 0; }
.action-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pp-results { border: 1px solid var(--line); border-radius: 10px; margin-top: 4px; max-height: 210px; overflow-y: auto; }
.pp-results button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; text-align: start; }
.pp-results button:hover, .pp-results button:focus-visible { background: var(--surface-2); outline: 0; }
.pp-chosen { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-2); }

/* ---------- Toasts and tooltip ---------- */
#toasts { position: fixed; bottom: 20px; left: 50%; translate: -50% 0; z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--surface); padding: 9px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 500; animation: rise .2s; display: flex; gap: 8px; align-items: center; max-width: calc(100vw - 32px); }
.toast.err { background: var(--danger); color: #fff; }
:root[data-theme="dark"] .toast.err { color: #2b0d0b; }
#tip { position: fixed; z-index: 9998; pointer-events: none; background: var(--ink); color: var(--surface); font-size: 12.5px; padding: 6px 10px; border-radius: 8px; max-width: 280px; box-shadow: var(--shadow-lg); white-space: pre-line; font-variant-numeric: tabular-nums; }

/* ---------- Command palette ---------- */
dialog.palette { margin-top: 12vh; width: min(600px, calc(100vw - 24px)); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.palette-input input { flex: 1; border: 0; background: none; outline: 0; font-size: 16px; min-width: 0; }
.palette-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 10px; width: 100%; text-align: start; }
.palette-item.on { background: var(--brand-soft); }
.palette-group { font-size: 11.5px; color: var(--ink-3); padding: 8px 10px 4px; }

/* ---------- Charts ---------- */
.chart { position: relative; height: 190px; display: flex; padding-left: 44px; padding-bottom: 22px; }
.chart .gridline { position: absolute; left: 44px; right: 0; height: 1px; background: var(--line); }
.chart .ylabel { position: absolute; left: 0; width: 38px; text-align: right; font-size: 11px; color: var(--ink-3); translate: 0 -50%; font-variant-numeric: tabular-nums; }
.chart .bars { position: relative; flex: 1; display: flex; align-items: flex-end; min-width: 0; }
.chart .col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; padding: 0 1px; min-width: 0; position: relative; }
.chart .bar { width: 100%; max-width: 26px; background: var(--c0); border-radius: 4px 4px 0 0; min-height: 0; transition: opacity .12s; }
.chart:hover .bar { opacity: .5; } .chart .col:hover .bar { opacity: 1; }
.chart .xlabel { position: absolute; bottom: -20px; left: 50%; translate: -50% 0; font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.chart.single-color-2 .bar { background: var(--c2); }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar .top { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin-bottom: 4px; }
.hbar .track { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--c0); border-start-end-radius: 4px; border-end-end-radius: 4px; }
.spark { width: 100%; height: 34px; display: block; overflow: visible; }
.spark polyline { fill: none; stroke: var(--c0); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.datatable { margin-top: 12px; font-size: 13px; }
.datatable summary { cursor: pointer; color: var(--ink-3); font-size: 12.5px; }
.datatable .t td, .datatable .t th { padding: 6px 10px; }

/* ---------- Schedule ---------- */
.cal { --ppm: 2px; display: grid; overflow: auto; max-height: calc(100vh - 190px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.cal-grid { display: grid; min-width: fit-content; }
.cal-head { position: sticky; top: 0; z-index: 6; background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 12px; min-width: 170px; border-inline-start: 1px solid var(--line); display: flex; align-items: center; gap: 9px; }
.cal-head.corner { inset-inline-start: 0; z-index: 7; min-width: 58px; width: 58px; border-inline-start: 0; padding: 0; }
.cal-head.today b { color: var(--brand-text); }
.cal-head .dot { width: 9px; height: 9px; border-radius: 3px; background: var(--dc, var(--c0)); flex: none; }
.cal-gutter { position: sticky; inset-inline-start: 0; z-index: 5; background: var(--surface); width: 58px; }
.cal-gutter span { position: absolute; inset-inline-end: 8px; font-size: 11px; color: var(--ink-3); translate: 0 -50%; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cal-col { position: relative; border-inline-start: 1px solid var(--line); min-width: 170px; cursor: copy; background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px calc(var(--ppm) * 60)), repeating-linear-gradient(to bottom, color-mix(in srgb, var(--line) 45%, transparent) 0 1px, transparent 1px calc(var(--ppm) * 30)); }
.cal-col.drop { background-color: var(--brand-soft); }
.cal-col .ghost { position: absolute; left: 4px; right: 4px; border-radius: 8px; border: 1.5px dashed var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); pointer-events: none; font-size: 11.5px; padding: 2px 7px; color: var(--brand-text); font-weight: 600; }
.ev { position: absolute; left: 4px; right: 4px; border-radius: 8px; padding: 3px 8px; overflow: hidden; cursor: pointer; font-size: 12px; line-height: 1.3; border-inline-start: 3px solid var(--dc, var(--c0)); background: color-mix(in srgb, var(--dc, var(--c0)) 14%, var(--surface)); transition: box-shadow .12s, transform .12s; text-align: start; display: block; }
.ev:hover { box-shadow: var(--shadow); z-index: 3; transform: translateY(-1px); }
.ev b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev span { color: var(--ink-2); white-space: nowrap; display: block; overflow: hidden; text-overflow: ellipsis; }
.ev.compact { padding: 0 7px; } .ev.compact b { display: inline; font-size: 11.5px; }
.ev.completed { opacity: .62; }
.ev.cancelled, .ev.no_show { opacity: .55; background: repeating-linear-gradient(135deg, var(--surface-3) 0 4px, var(--surface) 4px 8px); }
.ev.cancelled b { text-decoration: line-through; }
.ev.arrived { box-shadow: inset 0 0 0 1.5px var(--warn); }
.ev.in_consult { box-shadow: inset 0 0 0 1.5px var(--good); }
.ev[draggable="true"] { cursor: grab; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--accent); z-index: 4; pointer-events: none; }
.cal-now::before { content: ''; position: absolute; inset-inline-start: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* ---------- Queue board ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.lane { background: var(--surface-3); border-radius: var(--r-l); padding: 12px; min-height: 280px; }
.lane-h { display: flex; align-items: center; gap: 8px; padding: 2px 4px 12px; font: 600 14px var(--display); }
.lane-h .count { margin-inline-start: auto; font: 600 12px var(--body); background: var(--surface); padding: 1px 8px; border-radius: 99px; color: var(--ink-2); }
.qcard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 9px; box-shadow: var(--shadow-sm); animation: rise .2s; }
.qcard .who { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.qcard .meta { font-size: 12.5px; color: var(--ink-3); margin-top: 8px; display: flex; gap: 4px 10px; flex-wrap: wrap; }
.qcard .acts { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.wait { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.wait.ok { color: var(--ink-2); } .wait.warn { color: var(--warn); } .wait.late { color: var(--danger); }
.vitalstrip { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--ink-2); background: var(--surface-2); border-radius: 8px; padding: 5px 8px; margin-top: 8px; font-variant-numeric: tabular-nums; }

/* ---------- Agenda rows ---------- */
.agenda-row { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 10px; width: 100%; text-align: start; }
.agenda-row:hover { background: var(--surface-2); }
.agenda-row time { width: 62px; flex: none; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 500; }

/* ---------- Patient chart ---------- */
.chart-head { display: flex; gap: 18px; padding: 20px; align-items: center; flex-wrap: wrap; }
.chart-head h1 { font-size: 28px; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--ink-2); margin-top: 6px; font-size: 13.5px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 18px 0 16px; overflow: auto hidden; scrollbar-width: none; }
.tabs button { padding: 9px 14px; font-weight: 500; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--brand-text); border-color: var(--brand); }
.timeline { position: relative; padding-inline-start: 20px; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 5px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.tl-item { position: relative; margin-bottom: 12px; }
.tl-item::before { content: ''; position: absolute; inset-inline-start: -20px; top: 18px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand); }
.tl-item details { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.tl-item summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.tl-item summary::-webkit-details-marker { display: none; }
.soap { padding: 0 14px 14px; display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.soap h4 { font: 500 12px var(--body); color: var(--ink-3); margin-bottom: 2px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--surface); }
.tile .k { font-size: 12.5px; color: var(--ink-3); }
.tile .v { font: 600 22px var(--display); font-variant-numeric: tabular-nums; }
.tile .v small { font: 400 12px var(--body); color: var(--ink-3); }

/* ---------- Visit editor ---------- */
.visit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.visit-side { position: sticky; top: 68px; display: flex; flex-direction: column; gap: 16px; }
.soap-field { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.soap-field:last-child { border-bottom: 0; }
.soap-letter { width: 34px; height: 34px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-text); font: 700 16px var(--display); display: grid; place-items: center; }
.soap-field label { font-weight: 600; font-size: 13.5px; display: block; }
.soap-field .sub { font-size: 12.5px; color: var(--ink-3); margin-bottom: 6px; }
.vitals-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.rx-row { display: grid; grid-template-columns: minmax(160px, 2fr) repeat(3, minmax(90px, 1fr)) 64px 34px; gap: 8px; align-items: center; margin-bottom: 8px; }
.rx-row.head { color: var(--ink-3); font-size: 12px; margin-bottom: 4px; }
.savestate { font-size: 12.5px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 5px; }
.stickybar { position: sticky; top: 60px; z-index: 10; }

/* ---------- Invoice paper ---------- */
.paper { padding: 34px 38px; }
.paper-h { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-bottom: 20px; border-bottom: 2px solid var(--ink); margin-bottom: 20px; }
.paper-h h2 { font-size: 22px; }
.totals { margin-inline-start: auto; width: min(300px, 100%); margin-top: 14px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.totals .grand { font: 600 20px var(--display); border-top: 1px solid var(--line-strong); margin-top: 6px; padding-top: 10px; }
.line-row { display: grid; grid-template-columns: minmax(0, 1fr) 64px 100px 90px 34px; gap: 8px; align-items: center; margin-bottom: 8px; }
.stockbar { height: 6px; width: 110px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.stockbar i { display: block; height: 100%; border-radius: 3px; background: var(--good); }
.stockbar.low i { background: var(--warn); } .stockbar.out i { background: var(--danger); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, 1fr); }
.login-art { position: relative; overflow: hidden; background: var(--rail); color: #fff; padding: 44px; display: flex; flex-direction: column; justify-content: space-between; isolation: isolate; }
.login-art svg.globe { position: absolute; inset-inline-end: -180px; top: 50%; translate: 0 -50%; width: 720px; height: 720px; z-index: -1; opacity: .9; }
.login-art svg.globe .m { fill: none; stroke: var(--mint); stroke-width: 1; opacity: .4; }
.login-art svg.globe .pulse-line { fill: none; stroke: var(--coral); stroke-width: 2.2; stroke-dasharray: 900; animation: draw 5s ease-in-out infinite; }
@keyframes draw { 0% { stroke-dashoffset: 900; } 55%, 100% { stroke-dashoffset: 0; } }
.login-art h1 { font-size: clamp(38px, 4.4vw, 62px); font-weight: 500; letter-spacing: -.03em; line-height: 1.04; max-width: 13ch; color: #fff; }
.login-art h1 em { font-style: normal; color: var(--mint); }
.login-art p { max-width: 42ch; color: var(--rail-ink); margin-top: 14px; font-size: 15px; }
.login-form { position: relative; display: flex; align-items: center; justify-content: center; padding: 32px 24px; background: var(--surface); }
.login-lang { position: absolute; top: 18px; inset-inline-end: 18px; }
.lang-btn { font-family: 'Cairo', var(--body); font-weight: 600; }
.login-form form { width: min(370px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-form h2 { font-size: 26px; }
.demo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.demo-grid button { display: flex; gap: 9px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 11px; text-align: start; min-width: 0; }
.demo-grid button:hover { border-color: var(--brand); background: var(--surface-2); }
.demo-grid small { display: block; color: var(--ink-3); text-transform: capitalize; font-size: 11.5px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main, .visit-grid { grid-template-columns: minmax(0, 1fr); }
  .visit-side { position: static; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; inset-inline-start: 0; top: 0; width: 248px; transform: translateX(-100%); transition: transform .22s; }
  [dir="rtl"] .rail { transform: translateX(100%); }
  [dir="rtl"] .shell.menu-open .rail { transform: none; }
  .shell.menu-open .rail { transform: none; box-shadow: var(--shadow-lg); }
  .shell.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgb(6 20 18 / .45); z-index: 25; }
  .menu-toggle { display: grid; }
  .topbar { padding: 10px 16px; }
  .view { padding: 6px 16px 36px; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-art { padding: 28px 24px; min-height: 240px; }
  .login-art svg.globe { width: 420px; height: 420px; inset-inline-end: -160px; }
  kbd { display: none; }
  .searchbtn { min-width: 0; }
  .topbar .spacer { display: none; }
  .topbar [data-book] { padding: 8px 10px; flex: none; }
  .topbar [data-book] span { display: none; }
  h1 { font-size: 25px; } .hero h1 { font-size: 26px; } .hero { padding: 20px; }
  .ribbon-legend { padding-inline-start: 0; }
  .paper { padding: 22px 18px; }
  .rx-row { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-bottom: 12px; border-bottom: 1px solid var(--line); }
  .rx-row.head { display: none; }
  .rx-row > :first-child { grid-column: 1 / -1; }
  .line-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .line-row > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 540px) {
  .g4 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .soap { grid-template-columns: minmax(0, 1fr); }
  .demo-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi .value { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Print: only the document ---------- */
.print-only { display: none; }
@media print {
  :root { --bg: #fff; --surface: #fff; --ink: #000; --ink-2: #222; --ink-3: #444; --line: #bbb; --line-strong: #888; --surface-2: #fff; --surface-3: #eee; }
  body { background: #fff; }
  .rail, .topbar, .no-print, #toasts, #tip { display: none !important; }
  .shell { display: block; }
  .view { padding: 0; max-width: none; animation: none; }
  .card { border: 0; box-shadow: none; }
  .print-only { display: block; }
  .paper { padding: 0; }
  .pill { border: 1px solid #888; background: none; color: #000; }
}
