/* ==========================================================================
   Pharmacy Digital Hub — Design System
   Premium Enterprise Healthcare SaaS: modern, minimal, fast over flashy.
   ========================================================================== */

/* Cairo — self-hosted (SIL OFL), variable weight 400–800, Arabic + Latin in one family
   so a single font powers both languages with no CDN dependency (CSP-friendly, works offline/PWA). */
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fonts/cairo/cairo-arabic.woff2') format('woff2');
  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;
}
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fonts/cairo/cairo-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fonts/cairo/cairo-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1EFF, U+2020, U+20A0-20AB;
}

:root {
  /* §10 brand colors — overridable at runtime via CSS custom properties written by admin settings.
     Official brand blues (#15508A / #1691D0 / #2FA9E0) — these are also the settings table's
     seeded defaults, kept in sync intentionally. */
  --color-primary: #15508A;
  --color-primary-600: #114271;
  --color-secondary: #1691D0;
  --color-accent: #2FA9E0;
  --color-bg: #F5F9FC;
  --color-dark: #114271;

  --color-surface: #FFFFFF;
  --color-surface-2: #F1F5F9;
  --color-border: #E2E8F0;
  --color-text: #0F172A;
  --color-text-muted: #5A687D;
  --color-success: #117A38;
  --color-warning: #A35905;
  --color-danger: #C62222;
  --color-neutral: #94A3B8;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --font-primary: 'Cairo', 'Segoe UI', Tahoma, system-ui, sans-serif;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;

  --header-h: 72px;
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --color-bg: #0B1220;
  --color-surface: #111827;
  --color-surface-2: #0F172A;
  --color-border: #1F2937;
  --color-text: #F1F5F9;
  --color-text-muted: #94A3B8;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

* { box-sizing: border-box; }
/* NOTE: do not give `html` a non-visible overflow-x to "fix" the mobile off-canvas-sidebar overflow
   below — that was tried and reverted. Any non-visible overflow-x on `html` (hidden OR clip) turns
   it into a scrolling container in its own right, which silently breaks `position: sticky` on
   `.admin-sidebar` (caught by actually scrolling the rendered admin page, not just reading the CSS —
   the sticky sidebar stopped sticking, a much worse regression than the thing being "fixed"). The
   real fix is on `body` below via `contain: paint`. */
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-primary);
  line-height: 1.7;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

.container { width: 100%; max-width: 1280px; margin-inline: auto; padding-inline: var(--space-5); }

h1, h2, h3, h4 { font-weight: 700; margin: 0 0 var(--space-3); line-height: 1.3; }
p { margin: 0 0 var(--space-3); color: var(--color-text-muted); }

:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Skip link (a11y §52) ---------- */
.skip-link {
  position: absolute; inset-inline-start: -999px; top: 0; z-index: 200;
  background: var(--color-primary); color: #fff; padding: var(--space-3) var(--space-4);
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { inset-inline-start: 0; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100; height: var(--header-h);
  background: color-mix(in srgb, var(--color-surface) 88%, transparent);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border-bottom: 1px solid var(--color-border);
  /* §48 PWA standalone launches (installed on iPhone/Android) draw under the status bar/notch —
     a plain browser tab already reserves that space itself, so this only fires when installed. */
  padding-top: env(safe-area-inset-top);
  height: calc(var(--header-h) + env(safe-area-inset-top));
}
.site-header .container { height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); }
.brand { display: flex; align-items: center; gap: var(--space-3); font-weight: 700; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 20px; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-text span { font-size: 12px; color: var(--color-text-muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main-nav { display: flex; align-items: center; gap: var(--space-6); }
.main-nav a { font-size: 14px; font-weight: 600; color: var(--color-text-muted); transition: color var(--transition); }
.main-nav a:hover, .main-nav a:focus-visible { color: var(--color-primary); }

.header-actions { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
/* Every control in this row reads as one toolbar, not a pill next to two mismatched circles —
   the login link is a .btn-sm (~34px tall) sitting beside 40px .icon-btn circles by default. */
.header-actions .admin-login-link { height: 40px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--color-border);
  background: var(--color-surface); display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--color-text); transition: transform var(--transition), border-color var(--transition);
}
.icon-btn:hover { transform: translateY(-2px); border-color: var(--color-primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: 12px 22px; border-radius: 999px; font-weight: 700; font-size: 14px; border: 1px solid transparent;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--color-primary); color: #fff; box-shadow: var(--shadow-md); }
.btn-primary:hover { background: var(--color-primary-600); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-ghost { background: transparent; color: var(--color-primary); border-color: color-mix(in srgb, var(--color-primary) 30%, transparent); }
.btn-sm { padding: 8px 16px; font-size: 13px; }

.mobile-menu-btn { display: none; }

/* Mobile dropdown nav panel — deliberately NOT reusing .container (it lives inside .site-header
   .container, whose descendant selector forces display:flex and would defeat [hidden] entirely). */
.mobile-menu-panel {
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: var(--space-5);
  padding-block: var(--space-4);
  flex-direction: column;
  gap: var(--space-3);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}
.mobile-menu-panel:not([hidden]) { display: flex; }
.mobile-menu-panel a { font-size: 14px; font-weight: 600; color: var(--color-text); }

/* ---------- Hero ----------
   Layered like a product-launch hero rather than a flat tint: a soft brand-color bloom top-inline-start
   (the reading start in both directions) balanced by a cooler bloom at the far side, a fine dot grid
   for texture/depth (masked to fade out before the actions row so it never competes with the CTAs),
   and a hairline bottom edge that seats the section against what follows instead of just stopping. */
.hero {
  /* z-index:0 (not just position:relative) is load-bearing: it makes .hero its own stacking
     context, which is what keeps ::before's z-index:-1 painting ABOVE .hero's own background
     instead of behind it. Without it, a negative-z-index child of a non-stacking-context ancestor
     escapes to the grandparent's stacking order and paints under the parent's own background —
     which is exactly what silently hid the dot grid entirely (found by comparing a real screenshot
     against the CSS, not by reading the CSS alone). */
  position: relative; z-index: 0; overflow: hidden;
  padding-block: clamp(56px, 8vw, 96px) clamp(40px, 6vw, 64px);
  background: var(--color-bg);
  border-bottom: 1px solid color-mix(in srgb, var(--color-border) 60%, transparent);
}
/* The gradient blooms live on their own layer (not .hero's own background) so they can drift —
   a static hero reads as a poster; a slow 22s bloom drift plus a breathing dot grid reads as a
   system quietly doing something, which is the point when the "something" is AI analysis. */
.hero::after {
  content: ''; position: absolute; inset: -10%; z-index: -2; pointer-events: none;
  background:
    radial-gradient(55% 70% at 10% -5%, color-mix(in srgb, var(--color-primary) 30%, transparent), transparent),
    radial-gradient(48% 60% at 100% 10%, color-mix(in srgb, var(--color-accent) 26%, transparent), transparent),
    radial-gradient(60% 50% at 50% 100%, color-mix(in srgb, var(--color-secondary) 14%, transparent), transparent);
  animation: hero-drift 22s ease-in-out infinite;
}
.hero::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(circle, color-mix(in srgb, var(--color-primary) 35%, transparent) 1.5px, transparent 1.5px);
  background-size: 24px 24px;
  -webkit-mask-image: linear-gradient(180deg, black, transparent 85%);
  mask-image: linear-gradient(180deg, black, transparent 85%);
  animation: hero-pulse 5s ease-in-out infinite;
}
@keyframes hero-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(2%, 1.5%) scale(1.04); }
  66% { transform: translate(-1.5%, 2%) scale(1.02); }
}
@keyframes hero-pulse {
  0%, 100% { opacity: .75; }
  50% { opacity: 1; }
}

/* ---------- Hero orbs — pharmacy + AI motifs (pill/stethoscope for the department, a bot glyph
   for the AI analyzer feature) drifting slowly across the bloom layer. Purely decorative
   (aria-hidden), low-opacity so they read as ambient texture, never compete with the headline. */
.hero-orbs { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.hero-orb {
  position: absolute; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; color: var(--color-primary);
  background: color-mix(in srgb, var(--color-surface) 55%, transparent);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--color-primary) 12%, transparent);
  backdrop-filter: blur(1px);
  animation: hero-orb-float 9s ease-in-out infinite;
}
.hero-orb svg { opacity: .8; }
.hero-orb:nth-child(1) { width: 76px; height: 76px; top: 8%; inset-inline-end: 6%; animation-duration: 10s; }
.hero-orb:nth-child(2) { width: 56px; height: 56px; top: 55%; inset-inline-end: 18%; animation-duration: 8s; animation-delay: 1.5s; color: var(--color-secondary); }
.hero-orb:nth-child(3) { width: 46px; height: 46px; top: 28%; inset-inline-start: 6%; animation-duration: 11s; animation-delay: .7s; color: var(--color-accent); }
@keyframes hero-orb-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-16px) rotate(4deg); }
}
.hero-badge {
  display: inline-flex; align-items: center; gap: var(--space-2); padding: 8px 16px; border-radius: 999px;
  background: color-mix(in srgb, var(--color-primary) 10%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--color-primary) 20%, transparent);
  color: var(--color-primary); font-size: 13px; font-weight: 700; margin-bottom: var(--space-5);
}
.hero h1 {
  font-size: clamp(30px, 5vw, 54px); max-width: 18ch; letter-spacing: -0.01em;
  background: linear-gradient(90deg, var(--color-text), var(--color-primary) 70%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p.lead { font-size: clamp(16px, 2vw, 19px); max-width: 62ch; margin-bottom: var(--space-6); }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.hero-stats { display: flex; align-items: center; gap: var(--space-5); margin-top: var(--space-6); }
.hero-stats div:not(.hero-stats-sep) { display: flex; align-items: baseline; gap: 8px; }
.hero-stats strong { font-size: 22px; font-weight: 800; color: var(--color-primary); font-variant-numeric: tabular-nums; }
.hero-stats span { font-size: 13px; color: var(--color-text-muted); font-weight: 600; }
.hero-stats-sep { width: 1px; height: 24px; background: var(--color-border); }
@media (max-width: 640px) { .hero-stats { gap: var(--space-4); flex-wrap: wrap; } }

/* ---------- Section shells ---------- */
.section { padding-block: clamp(36px, 4.5vw, 56px); }
.section-alt { background: var(--color-surface-2); }
/* Brand-tinted section grounds — each section reads as belonging to the same identity via a very
   light wash of one of the three official brand colors, rotating through them, instead of every
   other section defaulting to the same neutral gray. Kept subtle (4-6% mix) on purpose: enough to
   read as "this section is tinted" without fighting card borders or body-text contrast. */
.section-tint-primary { background: color-mix(in srgb, var(--color-primary) 5%, var(--color-bg)); }
.section-tint-secondary { background: color-mix(in srgb, var(--color-secondary) 6%, var(--color-bg)); }
.section-tint-accent { background: color-mix(in srgb, var(--color-accent) 7%, var(--color-bg)); }
.section-head { max-width: 720px; margin-inline: auto; text-align: center; margin-bottom: var(--space-6); }
.section-head .eyebrow {
  /* color-mix (not the raw brand var) so small bold text stays WCAG AA against light section
     backgrounds even if an admin picks a lighter secondary brand color later — §Lighthouse a11y pass
     found the raw --color-secondary here at 3.3:1, short of the 4.5:1 small-text requirement. */
  display: inline-block; color: color-mix(in srgb, var(--color-secondary) 70%, black); font-weight: 700; font-size: 13px;
  letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: var(--space-2);
}
.section-head h2 { font-size: clamp(24px, 3.4vw, 36px); }

/* ---------- Grids & cards ---------- */
.grid { display: grid; gap: var(--space-5); }
.grid-services { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
/* Services are purely informational cards (no per-card status/category badges the way platforms
   have), so without some variation the grid reads as one repeated block. A rotating top accent —
   cycling the three official brand colors instead of inventing off-brand ones — and a matching
   icon tint give each card a distinct identity while the palette stays exactly on-brand. */
.grid-services .card { border-top: 3px solid var(--color-primary); }
.grid-services .card:nth-child(3n+2) { border-top-color: var(--color-secondary); }
.grid-services .card:nth-child(3n+2) .card-icon { background: color-mix(in srgb, var(--color-secondary) 10%, var(--color-surface)); color: var(--color-secondary); }
.grid-services .card:nth-child(3n+3) { border-top-color: var(--color-accent); }
.grid-services .card:nth-child(3n+3) .card-icon { background: color-mix(in srgb, var(--color-accent) 12%, var(--color-surface)); color: var(--color-accent); }
.grid-platforms { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
/* Platform cards already carry real semantic data (their live status) — the top accent should say
   that, not a decorative color rotation the way service cards use, which would just fight the
   status badge's own success/danger/warning meaning with a second, unrelated color system. */
.platform-card-success { border-top: 3px solid var(--color-success); }
.platform-card-danger { border-top: 3px solid var(--color-danger); }
.platform-card-warning { border-top: 3px solid var(--color-warning); }
.platform-card-neutral { border-top: 3px solid var(--color-neutral); }
.platform-card-success:hover { box-shadow: 0 8px 24px color-mix(in srgb, var(--color-success) 16%, transparent); }
.platform-card-danger:hover { box-shadow: 0 8px 24px color-mix(in srgb, var(--color-danger) 14%, transparent); }
.platform-card-warning:hover { box-shadow: 0 8px 24px color-mix(in srgb, var(--color-warning) 16%, transparent); }

/* ---------- Marquee (Quick Access) — a continuous conveyor instead of a static grid, since this
   section is specifically "recently used" and reads better as motion than as a fixed list. Content
   is rendered twice back-to-back so translating exactly -50% loops seamlessly; edge fades hide the
   hard cut where cards enter/exit instead of a visible clipped edge. Pausing on hover/focus lets a
   visitor actually read a card instead of chasing a moving target. */
.marquee { position: relative; overflow: hidden; margin-inline: calc(var(--space-5) * -1); }
.marquee-track {
  /* No flex `gap` here on purpose: each card carries its own trailing margin instead (below), so
     "one set of cards" is a fixed, self-contained width including its own spacing. That's what
     makes translateX(-50%) land exactly at the seam between the two duplicated sets — with `gap`
     on the container instead, the lone gap connecting the two sets is indistinguishable from the
     inter-card gaps and the halfway point lands mid-gap, not on the seam, so the loop visibly hitches. */
  display: flex; width: max-content;
  animation: marquee-scroll 38s linear infinite;
}
.marquee:hover .marquee-track, .marquee:focus-within .marquee-track { animation-play-state: paused; }
.marquee-track .card { width: 300px; flex-shrink: 0; margin-inline-end: var(--space-5);
  /* .card's own `height:100%` (written for CSS Grid rows, where it works) resolves to `auto` inside
     a flex container whose own height is content-derived — an explicit height wins over the
     default stretch, so every card fell back to ITS OWN content height instead of matching its
     tallest neighbor (measured: 424px vs 312px next to each other, not a design choice). Overriding
     back to auto + explicit stretch restores the intended uniform row height. */
  height: auto; align-self: stretch;
}
@keyframes marquee-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
.grid-categories { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.card {
  background: var(--color-surface); border: 1px solid color-mix(in srgb, var(--color-border) 70%, transparent);
  border-radius: var(--radius-md); padding: var(--space-6) var(--space-5); box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  display: flex; flex-direction: column; height: 100%;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--color-primary) 22%, var(--color-border)); }

.card-icon {
  width: 44px; height: 44px; border-radius: 12px; font-size: 22px;
  display: flex; align-items: center; justify-content: center; margin-bottom: var(--space-4);
  background: color-mix(in srgb, var(--color-primary) 8%, var(--color-surface));
  color: var(--color-primary); transition: transform var(--transition);
}
.card:hover .card-icon { transform: scale(1.05); }
.card h3 { font-size: 16.5px; margin-bottom: var(--space-2); letter-spacing: -0.01em; }
.card p { font-size: 13.5px; line-height: 1.65; flex: 1; }
.card-meta { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-block: var(--space-3); }
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px; background: var(--color-surface-2); color: var(--color-text-muted);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge .dot-pulse { animation: dot-pulse 2s ease-in-out infinite; }
@keyframes dot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.badge-success { color: var(--color-success); }
.badge-warning { color: var(--color-warning); }
.badge-danger { color: var(--color-danger); }
.badge-neutral { color: var(--color-neutral); }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-3); }

.card-featured { border-color: color-mix(in srgb, var(--color-accent) 45%, var(--color-border)); }
.badge-featured { background: color-mix(in srgb, var(--color-accent) 16%, var(--color-surface)); color: var(--color-primary); }

.favorite-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--color-border); background: var(--color-surface);
  display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0;
  transition: transform var(--transition), border-color var(--transition), color var(--transition);
}
.favorite-btn:hover { transform: scale(1.08); }
.favorite-btn[aria-pressed="true"] { color: #F59E0B; border-color: #F59E0B; }

/* ---------- Search ---------- */
.search-box {
  position: relative; max-width: 640px; margin-inline: auto;
}
.search-box input {
  width: 100%; padding: 16px 52px; border-radius: 999px; border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text); font-size: 15px; box-shadow: var(--shadow-sm);
}
.search-box .search-icon { position: absolute; inset-inline-start: 20px; top: 50%; translate: 0 -50%; opacity: 0.6; }
.search-results {
  margin-top: var(--space-4); display: grid; gap: var(--space-3); text-align: start;
}
.search-result-item {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm);
}
.search-empty { text-align: center; color: var(--color-text-muted); padding: var(--space-4); display: none; }

/* ---------- Categories ---------- */
.category-chip {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: var(--space-5) var(--space-4); border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--color-border) 70%, transparent);
  background: var(--color-surface); text-align: center; transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.category-chip:hover {
  border-color: color-mix(in srgb, var(--color-primary) 30%, var(--color-border));
  transform: translateY(-3px); box-shadow: var(--shadow-md);
}
.category-chip .count { font-size: 12px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

/* ---------- Stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-5); text-align: center; }
.stat-item {
  padding: var(--space-5); border-radius: var(--radius-md); background: var(--color-surface);
  border: 1px solid var(--color-border); transition: transform var(--transition), box-shadow var(--transition);
}
.stat-item:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-value { font-size: clamp(28px, 4vw, 42px); font-weight: 800; color: var(--color-primary); }
.stat-label { font-size: 13px; color: var(--color-text-muted); font-weight: 600; }

/* ---------- Footer ---------- */
.site-footer { background: var(--color-dark); color: #CBD5E1; padding-block: var(--space-8) var(--space-6); }
.site-footer a { color: #CBD5E1; }
.site-footer a:hover { color: #fff; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-6); margin-bottom: var(--space-6); }
.footer-links { display: flex; flex-direction: column; gap: var(--space-2); font-size: 14px; }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1); padding-top: var(--space-5);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-3);
  font-size: 13px; color: #A9B5C6;
}

/* ---------- Skeleton loading (§55) ---------- */
.skeleton { position: relative; overflow: hidden; background: var(--color-surface-2); border-radius: var(--radius-sm); }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--color-surface) 60%, transparent), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { translate: -100% 0; } to { translate: 100% 0; } }

/* ---------- Mobile bottom nav (§50) ---------- */
.bottom-nav { display: none; }

@media (max-width: 900px) {
  .main-nav { display: none; }
  .mobile-menu-btn { display: flex; }
}

/* ---------- Tablet (iPad portrait/landscape, Android tablets) ----------
   Neither the desktop nor the phone rules fit a tablet well on their own: desktop grids stay too
   wide (2 giant columns look sparse), phone rules collapse to single-column when there's clearly
   room for two. This band pins a deliberate 2-column rhythm instead of leaving it to auto-fit. */
@media (min-width: 641px) and (max-width: 1024px) {
  .grid-platforms, .grid-services { grid-template-columns: repeat(2, 1fr); }
  .grid-categories { grid-template-columns: repeat(4, 1fr); }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .container { padding-inline: var(--space-4); }
  /* No fixed max-width here on purpose: .brand already has min-width:0 inside the header's flex
     row, so the browser sizes it to whatever space is actually left after .header-actions' fixed
     width — a guessed vw cap (previously 46vw ≈ 172px on a 375px phone) truncated the real site
     name ("البوابة الرقمية لقسم الرعاية الصيدلية") to a few words with "..." even when far more
     room was available, which is what was actually happening (confirmed via a live screenshot,
     not just reading the CSS). */
  .brand-text span { display: none; }
  .header-actions .admin-login-link { display: none; }
}

/* Even with the subtitle already hidden and no artificial cap, the topbar's icon cluster
   (language switch + dark mode + hamburger) plus the logo mark leaves so little room on a
   real phone (measured: 129px available vs 255px needed for the full official name) that the
   title still gets ellipsis-truncated down to a couple of words — technically not overflowing,
   but reads worse than just showing the icon alone, which is what most sites do at this width. */
@media (max-width: 480px) {
  .brand-text { display: none; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset-inline: 0; bottom: 0; z-index: 100;
    background: color-mix(in srgb, var(--color-surface) 96%, transparent); backdrop-filter: blur(10px);
    border-top: 1px solid var(--color-border); padding-block: 6px; padding-bottom: max(6px, env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; font-weight: 700;
    color: var(--color-text-muted); padding: 6px 0;
  }
  .bottom-nav a.active { color: var(--color-primary); }
  .bottom-nav .bn-icon { font-size: 18px; }
  body { padding-bottom: 64px; }
  /* Clear the fixed bottom-nav bar instead of sitting on top of it. */
  .back-to-top { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* ---------- Back to top ---------- */
.back-to-top {
  position: fixed; inset-inline-end: var(--space-5); bottom: var(--space-5); z-index: 90;
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-primary); box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transform: translateY(12px);
  transition: opacity var(--transition), transform var(--transition), visibility var(--transition), border-color var(--transition);
}
.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { border-color: var(--color-primary); transform: translateY(-2px); }
