/* ============================================================
   OnCallat 2.0 — "White Coat" (judged design direction, 2026-08-18)
   One superfamily: IBM Plex Sans Arabic + IBM Plex Sans.
   HARD RULE: logical properties only — no left/right anywhere,
   which is what makes flawless RTL enforceable, not aspirational.
   Structure comes from hairlines + whitespace; shadows only on
   floating layers. Indigo belongs to AI moments ONLY.
   ============================================================ */

:root {
  --bg:       #F6F8F9;
  --surface:  #FFFFFF;
  --text:     #13252E;
  --muted:    #5C6B73;
  --primary:  #0B6B62;
  --accent:   #5257C5;
  --success:  #178A50;
  --warning:  #B45309;
  --danger:   #B42318;
  --border:   #E3E9EB;

  --primary-contrast: #FFFFFF;
  --primary-tonal: rgba(11,107,98,.10);
  --focus-ring: rgba(11,107,98,.40);
  --ai-wash:   rgba(82,87,197,.06);
  --ai-border: rgba(82,87,197,.35);
  --today-wash:   rgba(11,107,98,.05);
  --weekend-wash: rgba(19,37,46,.035);
  --danger-tonal: rgba(180,35,24,.08);
  --warning-tonal: rgba(180,83,9,.10);
  --success-tonal: rgba(23,138,80,.10);

  /* Khatm brand (the OnCall@ seal) */
  --paper: #F7F5F0;
  --seal-ink: #084A44;
  --seal-wash: rgba(11,107,98,.06);
  --seal-line: rgba(11,107,98,.28);
  --seal-ghost: .05;

  --shift-morning: #B45309;  --shift-morning-tint: rgba(180,83,9,.14);
  --shift-evening: #C2573F;  --shift-evening-tint: rgba(194,87,63,.14);
  --shift-night:   #4A4FB5;  --shift-night-tint:   rgba(74,79,181,.14);
  --shift-24h:     #0B6B62;  --shift-24h-tint:     rgba(11,107,98,.10);
  /* slate, not red: colour-deficient eyes kept collapsing a red standby
     into the evening salmon — the dashed border stays as the second cue */
  --shift-standby: #526070;  --shift-standby-tint: rgba(82,96,112,.12);
  --shift-day:     #1D6FB8;  --shift-day-tint:     rgba(29,111,184,.12);
  --shift-oncall:  #7A3FB2;  --shift-oncall-tint:  rgba(122,63,178,.11);

  /* quiet-luxury depth: a hairline-soft resting shadow, a plush floating one */
  --shadow-1: 0 1px 2px rgba(19,37,46,.04), 0 4px 12px rgba(19,37,46,.05);
  --shadow-float: 0 24px 48px -12px rgba(19,37,46,.22), 0 2px 8px rgba(19,37,46,.06);

  --r-input: 10px;  --r-btn: 12px;  --r-card: 16px;  --r-sheet: 22px;  --r-pill: 999px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 48px;
  --gutter: 16px;
  --tap-min: 44px;

  /* iPhones get Apple's own SF Pro + SF Arabic (the native iOS voice);
     everyone else falls to the Plex superfamily */
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, "Segoe UI", sans-serif;
  /* display voice: Plex Serif carries Latin, Amiri (the same face as the PDF
     export) carries Arabic through the fallback chain — one token, bilingual */
  --font-display: "IBM Plex Serif", "Amiri", ui-serif, Georgia, serif;
  --fs-overline: 12px;
  --fs-meta: 13px;
  --fs-grid: 13px;
  --fs-body: 15px;
  --fs-title: 17px;
  --fs-page: 22px;
  --fs-display: 28px;
  --lh-body: 1.5;
  --lh-heading: 1.3;

  --ease: cubic-bezier(0.2, 0, 0, 1);
  --dur: 180ms;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg:       #0C1518;
  --surface:  #132024;
  --text:     #E9EFF1;
  --muted:    #92A5AC;
  --primary:  #2EC9A8;
  --accent:   #A0A8F0;
  --success:  #4CC38A;
  --warning:  #E2A33C;
  --danger:   #EC6A5E;
  --border:   #24363C;
  --primary-contrast: #0C1518;
  --primary-tonal: rgba(46,201,168,.14);
  --focus-ring: rgba(46,201,168,.45);
  --ai-wash:   rgba(160,168,240,.08);
  --ai-border: rgba(160,168,240,.35);
  --today-wash:   rgba(46,201,168,.07);
  --weekend-wash: rgba(233,239,241,.05);
  --danger-tonal: rgba(236,106,94,.12);
  --warning-tonal: rgba(226,163,60,.12);
  --success-tonal: rgba(76,195,138,.12);
  --paper: #F7F5F0;
  --seal-ink: #5FD9BC;
  --seal-wash: rgba(46,201,168,.08);
  --seal-line: rgba(46,201,168,.32);
  --seal-ghost: .08;
  --shift-morning: #E2A33C;  --shift-morning-tint: rgba(226,163,60,.16);
  --shift-evening: #E88A70;  --shift-evening-tint: rgba(232,138,112,.16);
  --shift-night:   #A0A8F0;  --shift-night-tint:   rgba(160,168,240,.16);
  --shift-24h:     #2EC9A8;  --shift-24h-tint:     rgba(46,201,168,.12);
  --shift-standby: #9FB3C8;  --shift-standby-tint: rgba(159,179,200,.14);
  --shift-day:     #7FB8EA;  --shift-day-tint:     rgba(127,184,234,.15);
  --shift-oncall:  #C99DEE;  --shift-oncall-tint:  rgba(201,157,238,.15);
  --shadow-float: 0 8px 24px rgba(0,0,0,.5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #0C1518; --surface: #132024; --text: #E9EFF1; --muted: #92A5AC;
    --primary: #2EC9A8; --accent: #A0A8F0; --success: #4CC38A;
    --warning: #E2A33C; --danger: #EC6A5E; --border: #24363C;
    --primary-contrast: #0C1518; --primary-tonal: rgba(46,201,168,.14);
    --focus-ring: rgba(46,201,168,.45);
    --ai-wash: rgba(160,168,240,.08); --ai-border: rgba(160,168,240,.35);
    --today-wash: rgba(46,201,168,.07); --weekend-wash: rgba(233,239,241,.05);
    --danger-tonal: rgba(236,106,94,.12); --warning-tonal: rgba(226,163,60,.12);
    --success-tonal: rgba(76,195,138,.12);
    --paper: #F7F5F0; --seal-ink: #5FD9BC;
    --seal-wash: rgba(46,201,168,.08); --seal-line: rgba(46,201,168,.32);
    --seal-ghost: .08;
    --shift-morning: #E2A33C; --shift-morning-tint: rgba(226,163,60,.16);
    --shift-evening: #E88A70; --shift-evening-tint: rgba(232,138,112,.16);
    --shift-night:   #A0A8F0; --shift-night-tint:   rgba(160,168,240,.16);
    --shift-24h:     #2EC9A8; --shift-24h-tint:     rgba(46,201,168,.12);
    --shift-standby: #9FB3C8; --shift-standby-tint: rgba(159,179,200,.14);
    --shift-day:     #7FB8EA; --shift-day-tint:     rgba(127,184,234,.15);
    --shift-oncall:  #C99DEE; --shift-oncall-tint:  rgba(201,157,238,.15);
    --shadow-float: 0 8px 24px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

/* ---- base ---- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-family: var(--font-ui); -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-size: var(--fs-body); line-height: var(--lh-body);
  min-height: 100vh; min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
html[lang="ar"] body { font-size: 16px; line-height: 1.7; letter-spacing: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
a { color: var(--primary); }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.num, .price { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
[hidden] { display: none !important; }

/* ---- type helpers ---- */
.overline {
  font-size: var(--fs-overline); font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
}
html[lang="ar"] .overline { font-size: 13px; letter-spacing: 0; text-transform: none; }
.page-title {
  font-family: var(--font-display); font-size: var(--fs-page); font-weight: 700;
  line-height: var(--lh-heading); letter-spacing: -.01em;
}
html[lang="ar"] .page-title { letter-spacing: 0; }
.section-title { font-size: var(--fs-title); font-weight: 600; line-height: var(--lh-heading); }
.meta { font-size: var(--fs-meta); color: var(--muted); }

/* ---- layout ---- */
.screen { display: none; min-height: 100vh; min-height: 100dvh; }
.screen.active { display: block; }
.page {
  max-width: 960px; margin-inline: auto;
  padding: var(--s5) var(--gutter) calc(76px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 768px) { :root { --gutter: 24px; } }
@media (min-width: 960px) {
  .page { padding-block-end: var(--s7); padding-inline-start: calc(72px + var(--gutter)); }
}

/* ---- cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); padding: var(--s5);
  box-shadow: var(--shadow-1);
}
.card + .card, .stack > * + * { margin-block-start: var(--s4); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 48px; padding: 0 var(--s5);
  border-radius: var(--r-btn); border: 1px solid transparent;
  font-weight: 600; font-size: var(--fs-body); cursor: pointer;
  background: none; text-decoration: none;
  transition: opacity var(--dur) var(--ease), transform 120ms var(--ease),
    background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary), #fff 9%), var(--primary));
  color: var(--primary-contrast);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--primary) 40%, transparent),
    inset 0 1px 0 rgba(255,255,255,.14);
}
.btn-tonal { background: var(--primary-tonal); color: var(--primary); }
.btn-outline { border-color: var(--border); color: var(--text); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-ai { background: var(--accent); color: #fff; }
.btn-full { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 var(--s3); font-size: var(--fs-meta); border-radius: var(--r-input); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap-min); height: var(--tap-min); border-radius: var(--r-btn);
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  color: var(--text);
}

/* ---- inputs ---- */
.field { display: block; }
.field + .field { margin-block-start: var(--s4); }
.field-label {
  display: block; font-size: var(--fs-meta); font-weight: 600;
  margin-block-end: var(--s2); color: var(--text);
}
.input, .select, .textarea {
  width: 100%; min-height: 48px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-input); padding: var(--s2) var(--s3);
  font-size: max(16px, 1em); /* under 16px, iOS Safari zooms the page on focus */
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary); outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus-ring) 35%, transparent);
}
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .8; }
.textarea { min-height: 92px; resize: vertical; }
.hint { font-size: var(--fs-meta); color: var(--muted); margin-block-start: var(--s2); }

/* ---- chips / pills / badges ---- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--r-pill); border: 1px solid var(--border);
  padding: 3px 12px; font-size: var(--fs-meta); background: var(--surface);
}
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-overline); font-weight: 600;
  border-radius: var(--r-pill); padding: 2px 10px;
}
.badge-draft { background: var(--warning-tonal); color: var(--warning); }
.badge-confirmed { background: var(--success-tonal); color: var(--success); }
.badge-ai {
  background: var(--ai-wash); color: var(--accent);
  border: 1px solid var(--ai-border);
}

/* ---- shift chips: tint + bar + text, never color alone ---- */
.shift-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-grid); font-weight: 600; line-height: 1.4;
  border-radius: 6px; padding: 2px 8px;
  border-inline-start: 2px solid currentColor;
}
.sc-morning { background: var(--shift-morning-tint); color: var(--shift-morning); }
.sc-evening { background: var(--shift-evening-tint); color: var(--shift-evening); }
.sc-night   { background: var(--shift-night-tint);   color: var(--shift-night); }
.sc-24h     { background: var(--shift-24h-tint);     color: var(--shift-24h); border-inline-start-width: 4px; border-inline-start-style: double; }
.sc-standby { background: var(--shift-standby-tint); color: var(--shift-standby); border-inline-start-style: dashed; }
.sc-day     { background: var(--shift-day-tint);     color: var(--shift-day); }
.sc-oncall  { background: var(--shift-oncall-tint);  color: var(--shift-oncall); border-inline-start-style: dotted; }
#dutyNote { white-space: pre-line; }
.wordmark .at { color: var(--primary); }

/* ---- drawn icons: one stroke voice everywhere, no emojis ---- */
.ic { width: 1.15em; height: 1.15em; vertical-align: -0.18em; flex-shrink: 0; }
.pref-toggle .ic { width: 17px; height: 17px; }
.drop-ic .ic { width: 34px; height: 34px; color: var(--accent); }
.role-icon .ic { width: 30px; height: 30px; color: var(--accent); }
.dept-logo > .at, .dept-logo > .at-logo { width: 62%; height: 62%; }
.notice > span:first-child .ic, .notice > .ic { width: 20px; height: 20px; color: var(--accent); }
.btn .ic { width: 1.05em; height: 1.05em; }

/* ---- rules center ---- */
.badge-src {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 600;
}
.ov-row {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding-block: 8px; border-block-end: 1px solid var(--border);
  font-size: var(--fs-meta);
}
.ov-row:last-child { border-block-end: none; }
.ov-name { cursor: pointer; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.rp-row { transition: transform .12s ease; }
.rp-row:active { transform: scale(.985); }
#limitsList .icon-btn { min-width: 34px; min-height: 34px; font-size: 15px; }
.pdf-theme-row { display: flex; align-items: center; gap: 10px; }
.pdf-theme-row.on { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.theme-dot { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; border: 1px solid var(--border); }
.th-brand  { background: #0B6B62; }
.th-big    { background: var(--surface); position: relative; }
.th-big::after { content: "A"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: var(--text); }
.th-formal { background: #fff; border-color: #666; }
.th-color  { background: #0E1821; }
.th-logo   { background: var(--accent); }

/* ---- notices ---- */
.notice {
  display: flex; gap: var(--s3); align-items: flex-start;
  border-radius: var(--r-card); padding: var(--s3) var(--s4);
  font-size: var(--fs-meta); border: 1px solid var(--border);
}
.notice-warn { background: var(--warning-tonal); border-color: transparent; color: var(--text); }
.notice-warn > .ic { color: var(--warning); }
.notice-ok { background: var(--success-tonal); border-color: transparent; }
.notice-ai { background: var(--ai-wash); border: 1px solid var(--ai-border); }

/* ============================================================
   AUTH
   ============================================================ */
.auth-wrap {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: var(--s6) var(--gutter);
  position: relative; overflow: hidden;
}
/* an oversized, whisper-faint mark bleeding off the corner — brand depth
   without competing with the content */
.auth-wash {
  position: absolute; inset-block-start: -22%; inset-inline-end: -26%;
  width: 64vmin; height: 64vmin; color: var(--primary); opacity: .035;
  pointer-events: none;
}
.auth-wash svg { width: 100%; height: 100%; }
.auth-card { width: 100%; max-width: 400px; position: relative; }
.auth-brand { text-align: center; margin-block-end: var(--s6); }
.auth-name { font-size: 34px; font-weight: 600; letter-spacing: -.01em; }
.auth-tag { color: var(--muted); margin-block-start: var(--s2); font-family: var(--font-display); font-style: italic; }
html[lang="ar"] .auth-tag { font-style: normal; }
.otp-row { display: flex; gap: var(--s2); justify-content: space-between; direction: ltr; }
.otp-cell {
  width: 48px; height: 56px; text-align: center; font-size: 22px; font-weight: 600;
  border: 1px solid var(--border); border-radius: var(--r-input);
  background: var(--surface); font-variant-numeric: tabular-nums;
}
.otp-cell:focus { border-color: var(--primary); outline: none; }
.auth-alt { text-align: center; margin-block-start: var(--s4); }
.auth-alt button { background: none; border: none; color: var(--primary); font-weight: 600; cursor: pointer; padding: var(--s2); }
.auth-foot { text-align: center; color: var(--muted); font-size: var(--fs-meta); margin-block-start: var(--s6); }
.auth-msg { margin-block-start: var(--s4); }

/* ---- Khatm wordmark + seal ---- */
.wordmark {
  font-family: var(--font-ui); font-weight: 600; letter-spacing: -.01em;
  line-height: 1; color: var(--text); display: inline-flex; align-items: baseline;
}
.wordmark .at {
  width: 1.06em; height: 1.06em; transform: translateY(.15em);
  margin-inline-start: -.11em; color: var(--primary); flex: none;
}
.wordmark-sub {
  display: block; font-weight: 500; font-size: .62em; letter-spacing: 0;
  color: var(--muted); margin-block-start: 4px;
}
/* the sub-lockup's mark speaks in the sub's own muted ink */
.wordmark-sub .at-sub {
  width: 1em; height: 1em; display: inline-block; vertical-align: -.18em;
  margin-inline-start: -.06em; color: currentColor;
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
/* both app stores require the privacy policy reachable from inside the app */
.legal-links { font-size: var(--fs-meta); color: var(--muted); }
.legal-links a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.legal-links a:hover { color: var(--primary); }
/* the Arabic ending: the mark plays ات after مناوبـ, sitting on the
   baseline like a letter — kashida from the ب reaches toward it */
.wordmark .at-ar {
  width: 1.14em; height: 1.14em; transform: translateY(.22em);
  /* pull the mark into the kashida so بـ and the alef physically join —
     the glyph's own right-side padding would otherwise read as a word gap */
  margin-inline-start: -.18em;
}
.at-slot { display: inline-flex; }
.at-mini { width: 17px; height: 17px; color: var(--primary); flex: none; align-self: center; }
.at-logo { width: 22px; height: 22px; color: var(--primary); }
/* the kashida bridge lives only inside the Arabic wordmark, in text ink —
   it is the word reaching for its mark, not part of the mark itself */
svg .join { display: none; }
.wordmark .at-ar .join { display: inline; stroke: var(--text); }

/* ---- motion: one pen, one vocabulary ----
   Every stroke has pathLength=100, so dasharray 101 fits them all and the
   timeline reads in percentages of the stroke, not pixels. */
@keyframes seal-draw { to { stroke-dashoffset: 0; } }
@keyframes dot-land {
  0%   { opacity: 0; transform: translateY(-9px) scale(.6); }
  60%  { opacity: 1; transform: translateY(1.5px) scale(1.08); }
  80%  { transform: translateY(-.5px) scale(.97); }
  100% { opacity: 1; transform: none; }
}
/* The wordmark's @ writes itself like a pen: bowl, a quick stem, then the
   long swash sweep — dots dropped onto the page last, with real weight. */
.auth-name .s-bowl, .auth-name .s-stem, .auth-name .s-swash {
  stroke-dasharray: 101; stroke-dashoffset: 101;
}
.auth-name .s-bowl  { animation: seal-draw 560ms cubic-bezier(.42,0,.26,1) 150ms forwards; }
.auth-name .s-stem  { animation: seal-draw 300ms cubic-bezier(.55,.06,.25,1) 800ms forwards; }
.auth-name .s-swash { animation: seal-draw 880ms cubic-bezier(.44,.05,.55,1) 1170ms forwards; }
.auth-name .dot, .auth-name .dot2 {
  opacity: 0; transform-origin: center; transform-box: fill-box;
  animation: dot-land 340ms cubic-bezier(.3,.1,.4,1) 2130ms forwards;
}
.auth-name .dot2 { animation-delay: 2270ms; }
/* Arabic writes in Arabic order: the alef rises first, then the bowl, then
   the swash — and the ت's right dot lands before its twin. */
.auth-name .at-ar .s-stem  { animation-delay: 150ms; animation-duration: 420ms; }
.auth-name .at-ar .s-bowl  { animation-delay: 640ms; }
.auth-name .at-ar .s-swash { animation-delay: 1240ms; }
/* while the AI works, the mark writes and unwrites itself — unhurried,
   one shared 3.2s clock so the strokes hand off without drifting */
.at-think { width: 18px; height: 18px; color: var(--primary); flex: none; align-self: center; }
.at-think .s-bowl, .at-think .s-stem, .at-think .s-swash {
  stroke-dasharray: 101; stroke-dashoffset: 101;
}
@keyframes think-bowl {
  0% { stroke-dashoffset: 101; } 18% { stroke-dashoffset: 0; }
  72% { stroke-dashoffset: 0; } 90%, 100% { stroke-dashoffset: -101; }
}
@keyframes think-stem {
  0%, 14% { stroke-dashoffset: 101; } 26% { stroke-dashoffset: 0; }
  76% { stroke-dashoffset: 0; } 92%, 100% { stroke-dashoffset: -101; }
}
@keyframes think-swash {
  0%, 24% { stroke-dashoffset: 101; } 52% { stroke-dashoffset: 0; }
  80% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -101; }
}
@keyframes think-dots {
  0%, 50% { opacity: 0; } 58%, 78% { opacity: 1; } 88%, 100% { opacity: 0; }
}
.at-think .s-bowl  { animation: think-bowl 3200ms cubic-bezier(.45,.05,.55,.95) infinite; }
.at-think .s-stem  { animation: think-stem 3200ms cubic-bezier(.45,.05,.55,.95) infinite; }
.at-think .s-swash { animation: think-swash 3200ms cubic-bezier(.45,.05,.55,.95) infinite; }
.at-think .dot, .at-think .dot2 { animation: think-dots 3200ms ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .s-bowl, .s-stem, .s-swash, .auth-name .dot, .auth-name .dot2, .at-think .dot, .at-think .dot2 {
    animation: none !important; stroke-dashoffset: 0 !important;
    animation-delay: 0s !important; animation-iteration-count: 1 !important;
    opacity: 1 !important; transform: none !important;
  }
}
.seal-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-overline); font-weight: 600;
  border-radius: var(--r-pill); padding: 3px 12px;
  background: var(--seal-wash); color: var(--seal-ink);
  border: 1px solid var(--seal-line);
  box-shadow: 0 0 0 3px var(--seal-wash);
}
.seal-badge svg { width: 15px; height: 15px; flex: none; }
/* the empty month is sealed territory waiting for its stamp: the mark
   bleeds off the card's corner like an embossing die, not a watermark
   hiding behind the text */
.empty-seal {
  position: absolute; inset-block-end: -21%; inset-inline-end: -9%;
  width: 215px; height: 215px; opacity: var(--seal-ghost);
  color: var(--primary); pointer-events: none; transform: rotate(-6deg);
}
html[dir="rtl"] .empty-seal { transform: rotate(6deg); }

/* ---- the confirm ceremony: a month is stamped, not saved ---- */
.seal-moment {
  position: fixed; inset: 0; z-index: 220; display: flex;
  align-items: center; justify-content: center;
  background: rgba(8, 20, 18, .34); backdrop-filter: blur(3px);
  pointer-events: none; transition: opacity .38s ease;
}
.seal-moment.out { opacity: 0; }
.seal-moment-mark { position: relative; display: flex; align-items: center; justify-content: center; }
.seal-moment svg.at {
  width: 132px; height: 132px; color: #fff;
  filter: drop-shadow(0 14px 34px rgba(0, 0, 0, .35));
  animation: seal-stamp 620ms cubic-bezier(.3,.1,.35,1) 60ms both;
}
@keyframes seal-stamp {
  0%   { opacity: 0; transform: scale(2.1) rotate(-7deg); }
  55%  { opacity: 1; transform: scale(.94) rotate(0deg); }
  76%  { transform: scale(1.045); }
  100% { opacity: 1; transform: scale(1); }
}
.seal-halo {
  position: absolute; inset: -26px; border: 2px solid #fff;
  border-radius: 50%; opacity: 0; pointer-events: none;
  animation: seal-halo 900ms cubic-bezier(.2,.5,.3,1) 460ms both;
}
@keyframes seal-halo {
  0%   { opacity: .5; transform: scale(.68); }
  100% { opacity: 0; transform: scale(1.4); }
}
/* first time the owner of a month sees it sealed, the badge stamps once */
.seal-badge.just-sealed svg { animation: seal-stamp 560ms cubic-bezier(.3,.1,.35,1) 200ms both; }
@media (prefers-reduced-motion: reduce) {
  .seal-moment { display: none; }
  .seal-badge.just-sealed svg { animation: none; }
}

/* role cards */
.role-card {
  display: flex; gap: var(--s4); align-items: center; text-align: start;
  width: 100%; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); padding: var(--s5);
  transition: border-color var(--dur) var(--ease);
}
.role-card:hover { border-color: var(--primary); }
.role-icon {
  width: 48px; height: 48px; border-radius: var(--r-card); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
  background: var(--primary-tonal);
}
.role-title { font-weight: 600; }
.role-desc { font-size: var(--fs-meta); color: var(--muted); margin-block-start: 2px; }

/* ============================================================
   APP CHROME
   ============================================================ */
.topbar {
  position: sticky; inset-block-start: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  backdrop-filter: blur(24px) saturate(1.8);
  border-block-end: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  padding-block-start: env(safe-area-inset-top, 0px);
}
@supports not (backdrop-filter: blur(1px)) { .topbar { background: var(--bg); } }
.topbar-inner {
  max-width: 960px; margin-inline: auto;
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--gutter);
}
@media (min-width: 960px) { .topbar-inner { padding-inline-start: calc(72px + var(--gutter)); } }
.dept-logo { display: flex; align-items: center; justify-content: center; }
.dept-logo {
  width: 36px; height: 36px; border-radius: 10px; object-fit: cover;
  border: 1px solid var(--border); background: var(--surface);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  overflow: hidden; flex-shrink: 0;
}
.topbar-titles { min-width: 0; flex: 1; }
.topbar-dept { font-weight: 600; font-size: var(--fs-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub { font-size: var(--fs-overline); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ver-chip {
  font-size: 11px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--border); border-radius: var(--r-pill); padding: 1px 8px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.sync-dot.busy { background: var(--warning); }
.sync-dot.error { background: var(--danger); }
.sync-dot.off { background: var(--border); }

/* bottom tabs (mobile) / icon rail (desktop) */
.tabbar {
  position: fixed; inset-block-end: 0; inset-inline: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  backdrop-filter: blur(24px) saturate(1.8);
  border-block-start: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  display: flex; padding-block-end: env(safe-area-inset-bottom, 0px);
}
@supports not (backdrop-filter: blur(1px)) { .tabbar { background: var(--surface); } }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: var(--s2) 0 var(--s2); min-height: 56px; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 11px; font-weight: 600;
  position: relative; transition: color var(--dur) var(--ease), transform 120ms var(--ease);
}
.tab:active { transform: scale(.94); }
/* the active tab gets a soft tonal pill behind its icon — chrome that feels
   native on a phone, quieter than an edge bar */
.tab::before {
  content: ""; position: absolute; inset-block-start: 6px;
  inset-inline-start: 50%; translate: -50% 0;
  width: 52px; height: 28px; border-radius: var(--r-pill);
  background: transparent; transition: background var(--dur) var(--ease);
}
html[dir="rtl"] .tab::before { translate: 50% 0; }
.tab .t-icon { font-size: 21px; line-height: 1; position: relative; }
.tab .t-svg { width: 22px; height: 22px; display: block; }
.tab span:last-child { position: relative; }
.tab.active { color: var(--primary); }
.tab.active::before { background: var(--primary-tonal); }
@media (min-width: 960px) {
  .tabbar {
    inset-inline-end: auto; inset-block: 0; width: 72px;
    flex-direction: column; justify-content: flex-start; gap: var(--s2);
    border-block-start: none; border-inline-end: 1px solid var(--border);
    padding-block-start: var(--s6);
  }
  .tab { flex: 0 0 auto; width: 100%; }
}

/* ============================================================
   SCHEDULE — the roster as a document
   ============================================================ */
.month-nav { display: flex; align-items: center; gap: var(--s3); }
.month-nav .page-title { flex: 1; }
.sheet-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); padding: var(--s4);
  overflow-x: auto;
}
.roster { border-collapse: collapse; width: 100%; font-size: var(--fs-grid); line-height: 1.4; }
.roster th, .roster td { border: 1px solid var(--border); padding: 6px 8px; text-align: start; vertical-align: top; }
.roster thead th {
  font-size: var(--fs-overline); font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); background: var(--bg);
  position: sticky; inset-block-start: 0;
}
html[lang="ar"] .roster thead th { letter-spacing: 0; text-transform: none; font-size: 13px; }
.roster .day-cell {
  width: 52px; font-variant-numeric: tabular-nums; white-space: nowrap;
  position: sticky; inset-inline-start: 0; z-index: 1; background: var(--surface);
}
.roster tr.is-we .day-cell { background: color-mix(in srgb, var(--surface), var(--text) 4%); }
.roster tr.is-today .day-cell { background: color-mix(in srgb, var(--surface), var(--primary) 6%); }
.roster thead th:first-child { position: sticky; inset-inline-start: 0; z-index: 2; }
.roster .day-num { font-weight: 600; }
.roster .day-name { font-size: 11px; color: var(--muted); }
.roster .th-time { font-size: 10px; font-weight: 400; color: var(--muted); letter-spacing: 0; text-transform: none; white-space: nowrap; }
.roster tr.is-we td { background: var(--weekend-wash); }
.roster tr.is-today td { background: var(--today-wash); }
.roster td.slot-cell { cursor: pointer; }
.roster td.slot-cell:hover { background: var(--primary-tonal); }
.cell-people { display: flex; flex-wrap: wrap; gap: 4px; }
.person-chip {
  display: inline-flex; align-items: center; white-space: nowrap;
  border-radius: 6px; padding: 2px 8px; font-size: var(--fs-grid); font-weight: 700;
  border-inline-start: 2.5px solid currentColor; letter-spacing: .01em;
}
html[lang="ar"] .person-chip { letter-spacing: 0; }
.person-chip.me { outline: 2px solid currentColor; outline-offset: 0; }
.person-chip.dim { opacity: .6; font-weight: 400; }
.empty-slot { color: var(--muted); opacity: .6; }

/* stats row */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  padding: var(--s3) var(--s4); text-align: center;
}
.stat b { display: block; font-family: var(--font-display); font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat span { font-size: var(--fs-overline); color: var(--muted); }

/* ============================================================
   AI LEDGER — the thought process, on the indigo wash
   ============================================================ */
.ai-panel {
  background: var(--ai-wash); border: 1px solid var(--ai-border);
  border-radius: var(--r-card); padding: var(--s5);
}
.ai-panel-head { display: flex; align-items: center; gap: var(--s2); margin-block-end: var(--s3); }
.ai-panel .row { flex-wrap: wrap; }
.ledger-row {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s2) 0; border-block-start: 1px solid var(--ai-border);
  font-size: var(--fs-meta);
}
.ledger-row:first-of-type { border-block-start: none; }
.ledger-ic { flex-shrink: 0; }
.ledger-ok .ledger-ic { color: var(--success); }
.ledger-warn { color: var(--text); }
.ledger-warn .ledger-ic { color: var(--warning); }
.ledger-fail { color: var(--text); }
.ledger-fail .ledger-ic { color: var(--danger); }

/* view switcher — iOS segmented control */
.view-seg {
  display: flex; gap: 2px; padding: 3px; margin-block-end: var(--s4);
  background: color-mix(in srgb, var(--text) 7%, transparent);
  border-radius: 10px;
}
.view-seg button {
  flex: 1; min-height: 34px; border: none; background: none; cursor: pointer;
  border-radius: 8px; font-weight: 600; font-size: var(--fs-meta); color: var(--muted);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform 120ms var(--ease);
}
.view-seg button:active { transform: scale(.97); }
.view-seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(19,37,46,.14); }

/* staff × days matrix — the classic hospital wall sheet */
.roster.matrix th, .roster.matrix td { padding: 3px 4px; text-align: center; font-size: 11px; }
.roster.matrix .m-name {
  text-align: start; font-weight: 700; white-space: nowrap; max-width: 110px;
  overflow: hidden; text-overflow: ellipsis;
  position: sticky; inset-inline-start: 0; z-index: 1; background: var(--surface);
}
.roster.matrix td.is-we { background: var(--weekend-wash); }
.roster.matrix td.m-tot { font-weight: 700; font-variant-numeric: tabular-nums; }
.mchip {
  display: inline-block; min-width: 16px; border-radius: 4px; padding: 0 3px;
  font-size: 10px; font-weight: 700; line-height: 1.5;
}

/* day list — announcement style, phone-first */
.dl-day {
  display: flex; align-items: baseline; gap: var(--s2);
  padding: var(--s2) var(--s3); margin-block-start: var(--s3);
  background: color-mix(in srgb, var(--text) 5%, transparent);
  border-radius: 8px; font-weight: 700;
}
.dl-day.is-we { background: var(--primary-tonal); }
.dl-day .dl-num { font-family: var(--font-display); font-size: 18px; }
.dl-row { display: flex; gap: var(--s2); padding: var(--s2) var(--s3); align-items: baseline; flex-wrap: wrap; }
.dl-row .dl-shift { font-size: var(--fs-overline); font-weight: 700; min-width: 64px; }

/* fairness table */
.fair-table { width: 100%; border-collapse: collapse; font-size: var(--fs-meta); }
.fair-table th, .fair-table td { border-block-end: 1px solid var(--border); padding: 6px 8px; text-align: start; }
.fair-table td.num, .fair-table th.num { text-align: end; font-variant-numeric: tabular-nums; }

/* ============================================================
   STAFF
   ============================================================ */
.staff-card { display: flex; align-items: center; gap: var(--s4); }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; color: var(--primary); background: var(--primary-tonal);
}
.staff-main { flex: 1; min-width: 0; }
.staff-name { font-weight: 600; }
.staff-meta { font-size: var(--fs-meta); color: var(--muted); }
.pref-grid { display: flex; flex-wrap: wrap; gap: var(--s2); }
.pref-toggle {
  border: 1px solid var(--border); border-radius: var(--r-pill);
  min-height: 36px; padding: 0 var(--s4); background: var(--surface); cursor: pointer;
  font-size: var(--fs-meta); font-weight: 600; color: var(--muted);
}
.pref-toggle.on { background: var(--primary-tonal); color: var(--primary); border-color: var(--primary); }

/* upload drop card */
.drop-card {
  border: 2px dashed var(--border); border-radius: var(--r-card);
  padding: var(--s7) var(--s5); text-align: center; cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  background: var(--surface);
}
.drop-card.over, .drop-card:hover { border-color: var(--primary); background: var(--primary-tonal); }
.drop-ic { font-size: 34px; margin-block-end: var(--s2); }

/* ============================================================
   SHEETS (bottom sheets / dialogs) + toast
   ============================================================ */
.scrim {
  position: fixed; inset: 0; z-index: 60; background: rgba(10,20,24,.52);
  opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease);
}
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 70;
  background: var(--surface); border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  border: 1px solid var(--border); border-block-end: none;
  max-height: 88vh; max-height: 88dvh; display: flex; flex-direction: column;
  /* Apple's sheet curve — settles with a hint of spring */
  transform: translateY(105%); transition: transform 340ms cubic-bezier(.32,.72,0,1);
  box-shadow: var(--shadow-float);
  padding-block-end: env(safe-area-inset-bottom, 0px);
}
.sheet::before {
  content: ""; display: block; flex: none;
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 8px auto 0;
}
.sheet.open { transform: translateY(0); }
@media (min-width: 768px) {
  .sheet {
    inset-inline: auto; inset-block: auto;
    inset-block-start: 50%; inset-inline-start: 50%;
    transform: translate(-50%, -46%); opacity: 0; pointer-events: none;
    width: min(560px, calc(100vw - 48px)); border-radius: var(--r-sheet);
    border-block-end: 1px solid var(--border); max-height: 84vh;
    transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  }
  /* inset-inline-start already mirrors in RTL (it becomes right:50%); only
     the physical translate needs flipping — overriding the inset too pushed
     the dialog off-screen. */
  html[dir="rtl"] .sheet { transform: translate(50%, -46%); }
  .sheet.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }
  html[dir="rtl"] .sheet.open { transform: translate(50%, -50%); }
  .sheet::before { display: none; } /* grabbers belong to bottom sheets, not dialogs */
}
.sheet-head {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s5) var(--s5) var(--s3); flex-shrink: 0;
}
.sheet-head .section-title { flex: 1; }
.sheet-body { padding: 0 var(--s5) var(--s5); overflow-y: auto; }
.sheet-foot {
  padding: var(--s3) var(--s5) var(--s5); flex-shrink: 0;
  display: flex; gap: var(--s3); border-block-start: 1px solid var(--border);
}
.toast {
  position: fixed; inset-block-end: calc(76px + env(safe-area-inset-bottom, 0px));
  inset-inline: var(--s4); z-index: 90; margin-inline: auto; width: fit-content; max-width: 92vw;
  background: var(--text); color: var(--bg);
  border-radius: var(--r-btn); padding: var(--s3) var(--s5);
  font-size: var(--fs-meta); font-weight: 600; box-shadow: var(--shadow-float);
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast.show { opacity: 1; transform: none; }

/* pricing sheet */
.check-list { list-style: none; }
.check-list li { display: flex; gap: var(--s2); padding-block: var(--s1); font-size: var(--fs-meta); }
.check-list li::before { content: "✓"; color: var(--success); font-weight: 700; }
.trust-line { text-align: center; font-size: var(--fs-overline); color: var(--muted); margin-block-start: var(--s3); }

/* demo banner */
.demo-banner {
  background: var(--warning-tonal); color: var(--text);
  font-size: var(--fs-meta); padding: var(--s2) var(--s3);
  display: flex; align-items: center; justify-content: center;
  gap: var(--s2) var(--s3); flex-wrap: wrap;
}
/* the label owns its line in both languages; the pills wrap as one row */
.demo-banner .small { flex-basis: 100%; text-align: center; }
/* the tan wash goes muddy over near-black — dark gets a quiet slate wash */
:root[data-theme="dark"] .demo-banner { background: rgba(233,239,241,.07); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .demo-banner { background: rgba(233,239,241,.07); }
}
.demo-seg { display: inline-flex; gap: 4px; }
.demo-seg .pref-toggle { min-height: 30px; padding: 0 10px; font-size: 12px; background: var(--surface); }

/* the raw text an import sent to the AI — monospace, scrollable, selectable */
.read-dump {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px;
  white-space: pre-wrap; word-break: break-word; max-height: 40vh; overflow: auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: var(--s3); user-select: text; -webkit-user-select: text;
}

/* skeleton shimmer for loading */
@keyframes pulse { 50% { opacity: .4; } }
.skeleton { animation: pulse 1.2s ease-in-out infinite; background: var(--border); border-radius: 6px; color: transparent; }

/* utility */
.row { display: flex; align-items: center; gap: var(--s3); }
.btn-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); align-items: stretch; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.mt2 { margin-block-start: var(--s2); } .mt4 { margin-block-start: var(--s4); } .mt6 { margin-block-start: var(--s6); }
.mb4 { margin-block-end: var(--s4); }
.muted { color: var(--muted); }
.small { font-size: var(--fs-meta); }
.divider { border: none; border-block-start: 1px solid var(--border); margin-block: var(--s4); }

/* ---- print: the roster survives a hospital photocopier ---- */
@media print {
  /* Paper is always light — override every theme state, dark included. */
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #fff; --surface: #fff; --text: #000; --muted: #555; --border: #bbb;
    --weekend-wash: rgba(0,0,0,.05); --today-wash: transparent;
    color-scheme: light;
  }
  body { background: #fff; }
  .topbar, .tabbar, .no-print, .toast, .demo-banner, .month-nav, .ai-panel,
  .stat-row, #fairCard, #noSched, .scrim, .sheet, .badge { display: none !important; }
  .page { padding: 0; max-width: none; }
  .sheet-card { border: none; padding: 0; overflow: visible; }
  .person-chip, .shift-chip { background: #fff !important; color: #000 !important; border: 1px solid #000 !important; }
  .print-footer { display: block; font-size: 8px; color: #777; margin-block-start: 8px; text-align: center; }
  #rosterWrap[data-draft]::after {
    content: attr(data-draft);
    position: absolute; inset-block-start: 42%; inset-inline-start: 50%;
    transform: translate(-50%, -50%) rotate(-24deg);
    font-size: 42px; font-weight: 600; color: rgba(0,0,0,.10); white-space: nowrap;
  }
html[dir="rtl"] #rosterWrap[data-draft]::after { transform: translate(50%, -50%) rotate(-18deg); }
  #rosterWrap { position: relative; }
}
.print-footer { display: none; }
