/* =========================================================
   CareurPatients — Design System
   ========================================================= */
/* ---------- Themes ----------
   Switch with <html data-theme="…">; the list lives in THEMES in app.js.
   Each palette sets raw --t-* colours: a deep brand colour for the gradient
   sidebar and tinted text, plus a contrasting accent for buttons and the active
   menu item. The :root block below maps them onto the design tokens.
   Classic Navy is the default. */
:root {
  --primary: var(--t-accent);
  --primary-600: var(--t-accent-dark);
  --primary-700: var(--t-accent-dark);
  --primary-50: var(--t-accent-soft);
  --primary-100: color-mix(in srgb, var(--t-accent) 16%, #fff);
  --primary-200: color-mix(in srgb, var(--t-accent) 32%, #fff);
  --primary-rgb: var(--t-accent-rgb);
  --primary-2: color-mix(in srgb, var(--t-accent) 62%, #fff);

  --bg: var(--t-surface);
  --text: var(--t-ink);
  --text-2: var(--t-ink-soft);
  --muted: var(--t-ink-mute);
  --border: color-mix(in srgb, var(--t-brand) 9%, #fff);
  --border-strong: color-mix(in srgb, var(--t-brand) 16%, #fff);
  --info: var(--t-brand-mid);
  --info-50: var(--t-info-soft);

  --hero-bg: linear-gradient(100deg, #fff 0%, #fff 45%, var(--t-surface-2) 100%);
  --upcoming-bg: linear-gradient(115deg, var(--t-accent-soft) 0%, #fff 55%, var(--t-info-soft) 100%);
  --upcoming-border: color-mix(in srgb, var(--t-accent) 18%, #fff);
  --auth-bg: linear-gradient(150deg, var(--t-sb-2) 0%, var(--t-sb-1) 55%, var(--t-sb-deep) 100%);

  --sb-bg: linear-gradient(180deg, var(--t-sb-0) 0%, var(--t-sb-1) 55%, var(--t-sb-2) 100%);
  --sb-footer: var(--t-sb-0);
  --sb-border: transparent;
  --sb-text: rgba(255, 255, 255, .72);
  --sb-section: rgba(255, 255, 255, .5);
  --sb-hover-bg: rgba(255, 255, 255, .1);
  --sb-hover-text: #fff;
  --sb-active-bg: var(--t-accent);
  --sb-active-text: #fff;
  --sb-active-shadow: 0 6px 16px rgba(var(--t-accent-rgb), .38);
  --sb-indicator: var(--t-accent);
  --sb-divider: rgba(255, 255, 255, .12);
  --sb-brand: #fff;
  --sb-accent: color-mix(in srgb, var(--t-accent) 55%, #fff);
}

:root,
[data-theme="classic"] {
  --t-accent: #d4145a; --t-accent-dark: #c8102e; --t-accent-rgb: 212, 20, 90; --t-accent-soft: #fce4ec;
  --t-brand: #0a2a5c; --t-brand-mid: #1a4a8c; --t-info-soft: #e4eef9;
  --t-sb-0: #0a2a5c; --t-sb-1: #123a72; --t-sb-2: #1a4a8c; --t-sb-deep: #061a3a;
  --t-surface: #f3f6fb; --t-surface-2: #e7edf6;
  --t-ink: #0a2a5c; --t-ink-soft: #4a5d7a; --t-ink-mute: #7a8ba3;
}
[data-theme="graphite"] {
  --t-accent: #d97706; --t-accent-dark: #b45309; --t-accent-rgb: 217, 119, 6; --t-accent-soft: #fef3c7;
  --t-brand: #1f2937; --t-brand-mid: #374151; --t-info-soft: #e5e7eb;
  --t-sb-0: #111827; --t-sb-1: #1f2937; --t-sb-2: #374151; --t-sb-deep: #030712;
  --t-surface: #f4f5f7; --t-surface-2: #e5e7eb;
  --t-ink: #1f2937; --t-ink-soft: #4b5563; --t-ink-mute: #6b7280;
}
[data-theme="forest"] {
  --t-accent: #ca8a04; --t-accent-dark: #a16207; --t-accent-rgb: 202, 138, 4; --t-accent-soft: #fef9c3;
  --t-brand: #14532d; --t-brand-mid: #166534; --t-info-soft: #dcfce7;
  --t-sb-0: #0f3d22; --t-sb-1: #14532d; --t-sb-2: #166534; --t-sb-deep: #052e16;
  --t-surface: #f3f7f4; --t-surface-2: #e4ede6;
  --t-ink: #14532d; --t-ink-soft: #3f6b4f; --t-ink-mute: #6b8a75;
}
[data-theme="steel"] {
  --t-accent: #2563eb; --t-accent-dark: #1d4ed8; --t-accent-rgb: 37, 99, 235; --t-accent-soft: #dbeafe;
  --t-brand: #243447; --t-brand-mid: #334155; --t-info-soft: #e2e8f0;
  --t-sb-0: #1a2736; --t-sb-1: #243447; --t-sb-2: #334155; --t-sb-deep: #0f172a;
  --t-surface: #f4f6f9; --t-surface-2: #e8edf3;
  --t-ink: #243447; --t-ink-soft: #475569; --t-ink-mute: #64748b;
}
[data-theme="crimson"] {
  --t-accent: #e11d48; --t-accent-dark: #9f1239; --t-accent-rgb: 225, 29, 72; --t-accent-soft: #ffe4e6;
  --t-brand: #4a0e1f; --t-brand-mid: #7f1d35; --t-info-soft: #fce7f3;
  --t-sb-0: #3b0a18; --t-sb-1: #4a0e1f; --t-sb-2: #7f1d35; --t-sb-deep: #1f040c;
  --t-surface: #faf4f6; --t-surface-2: #f1e4e8;
  --t-ink: #4a0e1f; --t-ink-soft: #6b3a48; --t-ink-mute: #94707a;
}
[data-theme="copper"] {
  --t-accent: #ea580c; --t-accent-dark: #c2410c; --t-accent-rgb: 234, 88, 12; --t-accent-soft: #ffedd5;
  --t-brand: #2c1810; --t-brand-mid: #5c3420; --t-info-soft: #ffedd5;
  --t-sb-0: #1c100a; --t-sb-1: #2c1810; --t-sb-2: #5c3420; --t-sb-deep: #120a06;
  --t-surface: #f7f3f0; --t-surface-2: #ebe3dc;
  --t-ink: #2c1810; --t-ink-soft: #6b4a3a; --t-ink-mute: #9a7d6c;
}
[data-theme="azure"] {
  --t-accent: #0284c7; --t-accent-dark: #0369a1; --t-accent-rgb: 2, 132, 199; --t-accent-soft: #e0f2fe;
  --t-brand: #0c4a6e; --t-brand-mid: #0369a1; --t-info-soft: #e0f2fe;
  --t-sb-0: #0a3a57; --t-sb-1: #0c4a6e; --t-sb-2: #0369a1; --t-sb-deep: #082f49;
  --t-surface: #f0f9ff; --t-surface-2: #e0f2fe;
  --t-ink: #0c4a6e; --t-ink-soft: #3d6f8c; --t-ink-mute: #6b93a8;
}
[data-theme="orchid"] {
  --t-accent: #db2777; --t-accent-dark: #9d174d; --t-accent-rgb: 219, 39, 119; --t-accent-soft: #fce7f3;
  --t-brand: #4c1d55; --t-brand-mid: #6b2d77; --t-info-soft: #fae8ff;
  --t-sb-0: #3b1643; --t-sb-1: #4c1d55; --t-sb-2: #6b2d77; --t-sb-deep: #2a0f30;
  --t-surface: #faf5f8; --t-surface-2: #f3e8ef;
  --t-ink: #4c1d55; --t-ink-soft: #6b4a72; --t-ink-mute: #947a99;
}
[data-theme="glacier"] {
  --t-accent: #4f46e5; --t-accent-dark: #4338ca; --t-accent-rgb: 79, 70, 229; --t-accent-soft: #e0e7ff;
  --t-brand: #1e3a5f; --t-brand-mid: #2a4a73; --t-info-soft: #dbeafe;
  --t-sb-0: #162c4a; --t-sb-1: #1e3a5f; --t-sb-2: #2a4a73; --t-sb-deep: #0f2038;
  --t-surface: #f4f7fb; --t-surface-2: #e6eef7;
  --t-ink: #1e3a5f; --t-ink-soft: #4a6280; --t-ink-mute: #7a8fa8;
}
[data-theme="olive"] {
  --t-accent: #65a30d; --t-accent-dark: #4d7c0f; --t-accent-rgb: 101, 163, 13; --t-accent-soft: #ecfccb;
  --t-brand: #3f4a2e; --t-brand-mid: #55633d; --t-info-soft: #f0f4e8;
  --t-sb-0: #303824; --t-sb-1: #3f4a2e; --t-sb-2: #55633d; --t-sb-deep: #1f2616;
  --t-surface: #f5f6f1; --t-surface-2: #e8ebe1;
  --t-ink: #3f4a2e; --t-ink-soft: #5c6750; --t-ink-mute: #848c78;
}
[data-theme="sandstone"] {
  --t-accent: #c2410c; --t-accent-dark: #9a3412; --t-accent-rgb: 194, 65, 12; --t-accent-soft: #ffedd5;
  --t-brand: #5c4033; --t-brand-mid: #7a5645; --t-info-soft: #f5ebe3;
  --t-sb-0: #463027; --t-sb-1: #5c4033; --t-sb-2: #7a5645; --t-sb-deep: #2e1f18;
  --t-surface: #f7f3ef; --t-surface-2: #ebe3db;
  --t-ink: #5c4033; --t-ink-soft: #7a5e50; --t-ink-mute: #a0897c;
}
[data-theme="mulberry"] {
  --t-accent: #be185d; --t-accent-dark: #9d174d; --t-accent-rgb: 190, 24, 93; --t-accent-soft: #fce7f3;
  --t-brand: #3b0a2a; --t-brand-mid: #5b1340; --t-info-soft: #fce7f3;
  --t-sb-0: #2a071e; --t-sb-1: #3b0a2a; --t-sb-2: #5b1340; --t-sb-deep: #1a0412;
  --t-surface: #faf4f7; --t-surface-2: #f1e4eb;
  --t-ink: #3b0a2a; --t-ink-soft: #6b3a55; --t-ink-mute: #987088;
}
[data-theme="slate-mint"] {
  --t-accent: #10b981; --t-accent-dark: #047857; --t-accent-rgb: 16, 185, 129; --t-accent-soft: #d1fae5;
  --t-brand: #1f2a37; --t-brand-mid: #334155; --t-info-soft: #e2e8f0;
  --t-sb-0: #15202b; --t-sb-1: #1f2a37; --t-sb-2: #334155; --t-sb-deep: #0b1219;
  --t-surface: #f4f7f6; --t-surface-2: #e5ece9;
  --t-ink: #1f2a37; --t-ink-soft: #475569; --t-ink-mute: #64748b;
}

:root {
  --danger: #e5484d;
  --danger-50: #fff0f0;

  --surface: #ffffff;

  --success: #16a34a;
  --success-50: #e9f9ef;
  --warning: #f59e0b;
  --warning-50: #fff6e6;
  --purple: #8b5cf6;
  --purple-50: #f3eeff;
  --teal: #14b8a6;
  --teal-50: #e6fbf8;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow: 0 4px 16px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 20px 48px rgba(16, 24, 40, 0.14);

  --sidebar-w: 76px;
  --sidebar-w-open: 232px;
  --topbar-h: 68px;
  --footer-h: 44px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
svg.lucide { width: 18px; height: 18px; stroke-width: 1.75; flex-shrink: 0; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex; flex-direction: column; align-items: stretch;
  padding: 16px 12px;
  z-index: 40;
  transition: width .25s ease;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 6px; margin-bottom: 22px;
  white-space: nowrap; overflow: hidden;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 6px 14px rgba(var(--primary-rgb), .3);
}
.brand-mark svg { width: 20px; height: 20px; stroke-width: 2.25; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.2px; }
.brand-name span { color: var(--primary); }
.sidebar .brand-name { opacity: 0; transition: opacity .2s; color: var(--sb-brand); }
.sidebar .brand-name span { color: var(--sb-accent); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-section {
  font-size: 0; height: 1px; margin: 8px 12px; background: var(--sb-divider);
  text-transform: uppercase; letter-spacing: .8px; color: var(--sb-section); white-space: nowrap; overflow: hidden;
}
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  height: 42px; padding: 0 13px; border-radius: 10px;
  color: var(--sb-text); white-space: nowrap; overflow: visible;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--sb-hover-bg); color: var(--sb-hover-text); }
.nav a.active { background: var(--sb-active-bg); color: var(--sb-active-text); box-shadow: var(--sb-active-shadow, none); }
.nav a.active::before {
  content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--sb-indicator);
}
.nav a .label { opacity: 0; transition: opacity .15s; font-weight: 500; }
.nav a .tip {
  position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  background: var(--text); color: #fff; font-size: 11px; padding: 5px 9px; border-radius: 6px;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.nav a:hover .tip { opacity: 1; }
.nav .badge-dot {
  position: absolute; top: 9px; left: 28px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--danger); border: 2px solid var(--sb-bg);
}

.sidebar-footer { display: flex; flex-direction: column; gap: 4px; }

/* Sits on the sidebar's right edge, vertically centred on the topbar. */
.sidebar-toggle {
  position: absolute; right: -13px; top: calc(var(--topbar-h) / 2 - 13px); z-index: 45;
  width: 26px; height: 26px; border-radius: 50%; padding: 0;
  display: grid; place-items: center;
  background: #fff; color: var(--text-2); border: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(15, 23, 42, .12);
  cursor: pointer; transition: background .15s, color .15s, border-color .15s, transform .15s;
}
.sidebar-toggle:hover { background: var(--primary); border-color: var(--primary); color: #fff; transform: scale(1.08); }
.sidebar-toggle:focus-visible { outline: 2px solid rgba(var(--primary-rgb), .45); outline-offset: 2px; }
.sidebar-toggle svg { width: 15px; height: 15px; stroke-width: 2.25; }
.sidebar-toggle .when-open, body.sidebar-open .sidebar-toggle .when-closed { display: none; }
body.sidebar-open .sidebar-toggle .when-open { display: block; }
.sidebar-toggle .tip {
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: var(--text); color: #fff; font-size: 11px; font-weight: 500; padding: 5px 9px; border-radius: 6px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.sidebar-toggle .tip::after { content: "Expand menu"; }
body.sidebar-open .sidebar-toggle .tip::after { content: "Collapse menu"; }
.sidebar-toggle:hover .tip { opacity: 1; }

/* Grouped navigation: accordion when the sidebar is open, flyout when collapsed.
   The negative margin keeps the active indicator inside the scroll container. */
.sidebar-body { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0 -12px; padding: 0 12px 4px; }
.sidebar-body > .nav { flex: 0 0 auto; }
.sidebar-body > .sidebar-footer { flex: 0 0 auto; margin-top: auto; padding-top: 12px; }
/* Collapsed tooltips sit outside the sidebar, so only the expanded menu may clip and scroll. */
body.sidebar-open .sidebar-body { overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--sb-divider) transparent; }
body.sidebar-open .sidebar-body::-webkit-scrollbar { width: 4px; }
body.sidebar-open .sidebar-body::-webkit-scrollbar-thumb { background: var(--sb-divider); border-radius: 4px; }
.nav-group { display: flex; flex-direction: column; }
.nav .nav-parent .chev { margin-left: auto; width: 15px; height: 15px; opacity: 0; transition: transform .2s, opacity .15s; }
.nav-group.open > .nav-parent .chev { transform: rotate(180deg); }
.nav-sub { display: none; }
.nav-sub-title { display: none; }
.nav .nav-sub a { height: 34px; padding: 0 10px 0 14px; gap: 8px; font-size: 12.5px; border-radius: 8px; }
.nav-badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 6px; border-radius: 9px;
  display: grid; place-items: center; font-size: 10px; font-weight: 600; background: var(--primary); color: #fff;
}
.nav-badge.red { background: var(--danger); }
.nav-badge.soon { background: rgba(148, 163, 184, .22); color: inherit; font-weight: 500; letter-spacing: .2px; }
.nav a.soon { opacity: .72; }

body.sidebar-open .nav .nav-parent .chev { opacity: .7; }
body.sidebar-open .nav-group > .nav-parent.active { background: transparent; box-shadow: none; }
body.sidebar-open .nav-group > .nav-parent.active::before { display: none; }
body.sidebar-open .nav-group.open > .nav-sub { display: block; margin: 2px 0 6px 22px; padding-left: 8px; border-left: 1px solid var(--sb-divider); }
body.sidebar-open .nav .nav-sub a.active { background: var(--sb-active-bg); color: var(--sb-active-text); font-weight: 500; box-shadow: var(--sb-active-shadow, none); }
body.sidebar-open .nav .nav-sub a.active::before { left: -9px; top: 9px; bottom: 9px; width: 2px; border-radius: 2px; }
body.sidebar-open .nav-group .badge-dot { display: none; }

body:not(.sidebar-open) .nav-group > .nav-sub {
  position: fixed; left: calc(var(--sidebar-w) + 6px); z-index: 70; min-width: 230px;
  background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px;
}
body:not(.sidebar-open) .nav-group > .nav-sub::before { content: ""; position: absolute; left: -22px; top: 0; width: 22px; height: 100%; }
body:not(.sidebar-open) .nav-group:hover > .nav-sub { display: block; animation: pop .12s ease; }
body:not(.sidebar-open) .nav-sub-title {
  display: block; padding: 8px 10px 6px; font-size: 10.5px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--muted);
}
body:not(.sidebar-open) .nav .nav-sub a { color: var(--text-2); }
body:not(.sidebar-open) .nav .nav-sub a:hover,
body:not(.sidebar-open) .nav .nav-sub a.active { background: var(--primary-50); color: var(--primary); }
body:not(.sidebar-open) .nav .nav-sub a.active { font-weight: 500; }
body:not(.sidebar-open) .nav .nav-sub a.active::before { display: none; }

body.sidebar-open .sidebar { width: var(--sidebar-w-open); }
body.sidebar-open .sidebar .brand-name,
body.sidebar-open .nav a .label { opacity: 1; }
body.sidebar-open .nav-section { font-size: 10px; height: auto; margin: 0; padding: 12px 10px 4px; background: none; }
body.sidebar-open .nav a .tip { display: none; }
body.sidebar-open .main { margin-left: var(--sidebar-w-open); }

.main {
  flex: 1; min-width: 0; overflow-x: clip;
  margin-left: var(--sidebar-w);
  transition: margin-left .25s ease;
}

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .page-title { font-size: 17px; font-weight: 600; }
.topbar .crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; min-width: 0; overflow: hidden; }
.topbar .crumbs b { overflow: hidden; text-overflow: ellipsis; }
.topbar .crumbs svg { width: 15px; height: 15px; }
.topbar .crumbs svg.lucide-chevron-right { width: 13px; height: 13px; color: #c3c8d1; }
.topbar .crumbs a:hover { color: var(--primary); }
.topbar .crumbs b { color: var(--text); font-weight: 500; }
.topbar .spacer { flex: 1; }
.topbar .menu-btn, .m-title, .nav-backdrop { display: none; }

.search {
  display: flex; align-items: center; gap: 8px;
  height: 38px; width: 300px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: #fff;
  color: var(--muted);
}
.search input { border: 0; outline: 0; flex: 1; background: transparent; font-size: 12.5px; color: var(--text); }
.search kbd {
  font-family: inherit; font-size: 10.5px; color: var(--muted);
  border: 1px solid var(--border-strong); border-radius: 5px; padding: 1px 6px;
}

.icon-btn {
  position: relative;
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--primary-50); color: var(--primary); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 2px solid #fff;
}
.lang {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  font-size: 12px; background: #fff;
}
.flag-in {
  width: 18px; height: 12px; border-radius: 2px; overflow: hidden;
  background: linear-gradient(#ff9933 0 33.3%, #fff 33.3% 66.6%, #138808 66.6% 100%);
  position: relative;
}
.flag-in::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 4px; height: 4px;
  border-radius: 50%; border: 1px solid #000080;
}
.branch-btn {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px 0 6px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: #fff; text-align: left; line-height: 1.15;
}
.branch-btn:hover { border-color: var(--primary-200); }
.branch-btn .bi { width: 26px; height: 26px; border-radius: 7px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; }
.branch-btn .bi svg { width: 15px; height: 15px; }
.branch-btn small { display: block; font-size: 10px; color: var(--muted); }
.branch-btn b { display: block; font-size: 12px; font-weight: 600; white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 6px; }
.user-chip .meta { line-height: 1.2; text-align: left; white-space: nowrap; }
.user-chip .meta b { font-size: 12.5px; font-weight: 600; display: block; }
.user-chip .meta small { font-size: 11px; color: var(--muted); }

.content { padding: 24px 28px calc(var(--footer-h) + 32px); }

.app-footer {
  position: fixed; bottom: 0; right: 0; left: var(--sidebar-w); z-index: 30;
  height: var(--footer-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 28px;
  /* Uses the sidebar tokens so the footer follows each theme's menu colour. */
  background: var(--sb-footer, var(--sb-bg));
  border-top: 1px solid var(--sb-border);
  font-size: 11.5px; color: var(--sb-text); white-space: nowrap;
  transition: left .25s ease;
}
body.sidebar-open .app-footer { left: var(--sidebar-w-open); }
.app-footer b { font-weight: 600; color: var(--sb-brand); }
.app-footer b span { color: var(--sb-accent); }
.app-footer svg { width: 14px; height: 14px; }
.foot-left, .foot-status, .foot-links { display: flex; align-items: center; gap: 10px; }
.foot-sep { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .45; }
.foot-status { color: var(--sb-text); }
.foot-status svg { color: var(--sb-accent); }
.pulse { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.pulse::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--success); opacity: 0; animation: pulse 2s ease-out infinite;
}
@keyframes pulse { 0% { transform: scale(.5); opacity: .6; } 100% { transform: scale(1.3); opacity: 0; } }
.foot-links { gap: 18px; }
.foot-links a { display: inline-flex; align-items: center; gap: 5px; transition: color .15s; }
.foot-links a:hover { color: var(--sb-hover-text); }

/* ---------- Generic UI ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-head h3 svg { color: var(--primary); width: 17px; height: 17px; }
.card-body { padding: 16px 20px; }
.card-sub { font-size: 11.5px; color: var(--muted); font-weight: 400; }

.grid { display: grid; gap: 20px; }
.split { grid-template-columns: 1.2fr 1fr; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.fw-600 { font-weight: 600; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; }
.small { font-size: 11.5px; }
.xs { font-size: 10.5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  font-size: 12.5px; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent; transition: all .15s;
}
.btn svg { width: 15px; height: 15px; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 11.5px; border-radius: 6px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 13.5px; border-radius: 10px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(var(--primary-rgb), .22); }
.btn-primary:hover { background: var(--primary-600); }
.btn-outline { background: #fff; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { border-color: var(--primary-200); color: var(--primary); }
.btn-soft { background: var(--primary-50); color: var(--primary); }
.btn-soft:hover { background: var(--primary-100); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--primary-50); color: var(--primary); }
.btn-block { width: 100%; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
  background: #fde8c8; color: #9a5b00; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 30px; height: 30px; font-size: 11.5px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar.xl { width: 88px; height: 88px; font-size: 30px; }
.av-amber { background: #fdecc8; color: #a35f00; }
.av-green { background: #d9f6e3; color: #138a42; }
.av-cyan { background: #d4f4fb; color: #0b7c94; }
.av-blue { background: #dfe8ff; color: #3456c9; }
.av-pink { background: #ffe1e6; color: #c8102e; }
.av-purple { background: #ece3ff; color: #6d3fd8; }
.av-peach { background: #ffe4d6; color: #c2531b; }
.av-gray { background: #eceef2; color: #6b7280; }

.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person .name { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .sub { font-size: 11px; color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: 6px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.pill svg { width: 12px; height: 12px; }
.pill-brand { background: var(--primary-50); color: var(--primary-600); }
.pill-solid { background: var(--primary); color: #fff; }
.pill-red { background: var(--danger-50); color: var(--danger); }
.pill-solid-red { background: var(--danger); color: #fff; }
.pill-green { background: var(--success-50); color: var(--success); }
.pill-amber { background: var(--warning-50); color: #c27803; }
.pill-blue { background: var(--info-50); color: var(--info); }
.pill-purple { background: var(--purple-50); color: var(--purple); }
.pill-gray { background: #f2f4f7; color: #667085; }
.pill-teal { background: var(--teal-50); color: #0f8f80; }
.dot-status { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 7px;
  font-size: 11.5px; background: #fff;
}
button.chip:hover { border-color: var(--primary-200); }
.chip.active { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
input[type=checkbox] { accent-color: var(--primary); }
.chip .count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 4px;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 600; color: #fff;
}
.count-dark { background: var(--text); }
.count-red { background: var(--danger); }
.count-blue { background: #29a8e0; }
.count-green { background: var(--success); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tabs button {
  position: relative; padding: 10px 16px; font-size: 12.5px; color: var(--muted); font-weight: 500;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--primary); }
.tabs button.active::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--primary);
}
.tabs.filled { background: var(--primary-50); border-bottom: 0; border-radius: 8px 8px 0 0; padding: 0 8px; }
.tabs.center { justify-content: center; }
.tabs .tab-count {
  margin-left: 6px; font-size: 10.5px; padding: 1px 6px; border-radius: 10px; background: #f2f4f7; color: var(--muted);
}
.tabs button.active .tab-count { background: var(--primary-100); color: var(--primary); }

.segmented { display: inline-flex; background: #f3f4f6; border-radius: 8px; padding: 3px; }
.segmented button { height: 28px; padding: 0 12px; border-radius: 6px; font-size: 12px; color: var(--text-2); font-weight: 500; }
.segmented button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }

.select, .input, .textarea {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; outline: 0;
  font-size: 12.5px; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.select { appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a93a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.select-sm { height: 30px; font-size: 12px; width: auto; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary-200); box-shadow: 0 0 0 3px var(--primary-50); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.field label .req { color: var(--primary); }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.input-icon .input { padding-left: 34px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.form-grid .span-2 { grid-column: span 2; }

.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; }
.checkbox input { accent-color: var(--primary); width: 15px; height: 15px; }

.switch { position: relative; width: 36px; height: 20px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 20px; background: #d6dae1; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; top: 2px; left: 2px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(16px); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 500; color: var(--muted);
  padding: 11px 16px; background: #fbfbfc; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 12.5px; vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #fffafb; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .actions { display: flex; gap: 4px; justify-content: flex-end; }

.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-top: 1px solid var(--border); }
.pager { display: flex; gap: 4px; }
.pager button {
  min-width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border-strong); background: #fff; font-size: 12px;
  display: grid; place-items: center;
}
.pager button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager svg { width: 14px; height: 14px; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; font-weight: 600; letter-spacing: -.2px; }
.page-head p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Dashboard: hero ---------- */
.hero-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; }
.hero {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 20px;
  padding: 20px 24px; min-height: 132px;
  border: 1.5px solid var(--primary-200);
  border-radius: var(--radius-lg);
  background: var(--hero-bg);
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--primary-rgb), .07), transparent 70%);
}
.hero .doc-photo {
  width: 92px; height: 92px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  background: linear-gradient(160deg, var(--primary-100), #fff);
  border: 3px solid #fff; box-shadow: 0 6px 18px rgba(var(--primary-rgb), .15);
}
.hero .doc-photo img { width: 100%; height: 100%; object-fit: cover; }
.hero h2 { font-size: 21px; font-weight: 600; letter-spacing: -.3px; }
.hero .welcome { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.hero .meta { display: flex; gap: 16px; margin-top: 12px; color: var(--primary); font-size: 11.5px; }
.hero .meta span { display: inline-flex; align-items: center; gap: 5px; }
.hero .meta svg { width: 14px; height: 14px; }
.hero .clock { margin-left: auto; position: relative; z-index: 1; }

.clock-face {
  position: relative; width: 96px; height: 96px; border-radius: 50%;
  background: #fff; border: 5px solid var(--primary);
  box-shadow: 0 8px 22px rgba(var(--primary-rgb), .25), inset 0 0 0 2px #fff, inset 0 0 0 3px var(--primary-100);
}
.clock-face .tick { position: absolute; left: 50%; top: 4px; width: 2px; height: 7px; background: #333; transform-origin: 50% 39px; margin-left: -1px; border-radius: 1px; }
.clock-face .tick.minor { height: 4px; width: 1px; background: #bbb; }
.clock-face .hand { position: absolute; left: 50%; bottom: 50%; transform-origin: 50% 100%; border-radius: 2px; }
.clock-face .h { width: 3px; height: 22px; margin-left: -1.5px; background: #111; }
.clock-face .m { width: 2px; height: 31px; margin-left: -1px; background: #111; }
.clock-face .s { width: 1px; height: 34px; margin-left: -.5px; background: var(--primary); }
.clock-face .pin { position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--primary); }

.upcoming {
  position: relative; overflow: hidden;
  padding: 16px 20px; border-radius: var(--radius-lg);
  background: var(--upcoming-bg);
  border: 1px solid var(--upcoming-border);
}
.upcoming h3 { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.upcoming h3 svg { width: 16px; height: 16px; }
.upcoming .body { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.upcoming .divider { width: 1px; height: 38px; background: rgba(29, 36, 51, .12); margin: 0 6px; }
.upcoming .visit b { font-size: 14px; font-weight: 500; }
.upcoming .visit .small { display: flex; gap: 10px; margin-top: 3px; color: var(--text-2); }
.upcoming .visit .small span { display: inline-flex; align-items: center; gap: 4px; }
.upcoming .visit svg { width: 13px; height: 13px; }
.upcoming .actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.upcoming .actions .btn-outline { border-color: transparent; }
.upcoming .bg-icon { position: absolute; color: rgba(var(--primary-rgb), .14); }
.upcoming .bg-icon svg { width: 54px; height: 54px; stroke-width: 1.2; }

/* KPI strip */
.kpi-strip { position: relative; margin-top: 20px; }
.kpi-track { display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 5 * 14px) / 6); gap: 14px; overflow-x: auto; scroll-behavior: smooth; scrollbar-width: none; padding-right: 24px; }
.kpi-track::-webkit-scrollbar { display: none; }
.kpi {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; position: relative; min-width: 168px;
  transition: box-shadow .15s, border-color .15s;
}
.kpi:hover { border-color: var(--primary-100); box-shadow: var(--shadow); }
.kpi .label { color: var(--text-2); font-size: 12px; line-height: 1.3; max-width: 120px; }
.kpi .value { font-size: 20px; font-weight: 600; margin-top: 4px; }
.kpi .trend { font-size: 10.5px; margin-top: 6px; display: flex; align-items: center; gap: 3px; }
.kpi .trend svg { width: 12px; height: 12px; }
.kpi .trend.up { color: var(--success); }
.kpi .trend.down { color: var(--danger); }
.kpi .ico { position: absolute; right: 14px; top: 14px; color: var(--primary-200); }
.kpi .ico svg { width: 30px; height: 30px; stroke-width: 1.3; }
.kpi-next {
  position: absolute; right: -14px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff;
  display: grid; place-items: center; box-shadow: 0 6px 14px rgba(var(--primary-rgb), .35); z-index: 2;
}

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: 20px; margin-top: 20px; align-items: start; }

/* Calendar */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
.cal-nav { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.cal-nav .month { display: inline-flex; align-items: center; gap: 6px; }
.cal-nav .month svg { color: var(--primary); width: 15px; height: 15px; }
.cal-nav button { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; color: var(--text-2); }
.cal-nav button:hover { background: var(--primary-50); color: var(--primary); }
.cal-nav button svg { width: 15px; height: 15px; }
.calendar { padding: 0 16px 16px; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--primary-50); border-radius: 8px 8px 0 0; }
.cal-head div { text-align: center; padding: 10px 0; font-size: 11px; font-weight: 500; color: var(--primary); letter-spacing: .4px; }
.cal-body { display: grid; grid-template-columns: repeat(7, 1fr); border-left: 1px solid var(--border); border-top: 1px solid var(--border); }
.cal-cell {
  position: relative; height: 72px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  display: grid; place-items: center; font-size: 13px; cursor: pointer; transition: background .12s;
}
.cal-cell:hover { background: var(--primary-50); }
.cal-cell.muted { background: #f6f7f9; color: #c3c8d1; cursor: default; }
.cal-cell.today { background: var(--primary); color: #fff; font-weight: 600; }
.cal-cell.selected:not(.today) { box-shadow: inset 0 0 0 2px var(--primary); color: var(--primary); font-weight: 600; }
.cal-cell .mark { position: absolute; left: 6px; top: 50%; width: 2px; height: 14px; margin-top: -7px; border-radius: 2px; background: var(--primary); }
.cal-cell .count { position: absolute; right: 6px; bottom: 6px; font-size: 9.5px; color: var(--muted); }
.cal-cell.today .count { color: rgba(255, 255, 255, .75); }

/* Appointment day list */
.appt-list { max-height: 330px; overflow-y: auto; }
.appt-item { display: flex; align-items: center; gap: 10px; padding: 11px 20px; border-bottom: 1px solid var(--border); }
.appt-item:last-child { border-bottom: 0; }
.appt-item .person { flex: 1; }
.appt-item .status { width: 128px; display: flex; align-items: center; gap: 6px; font-size: 11px; }
.appt-item .tools { display: flex; align-items: center; gap: 2px; color: var(--text-2); }
.appt-item .tools .icon-btn { width: 30px; height: 30px; }
.appt-item .tools svg { width: 16px; height: 16px; }

.sched-item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border: 1px solid var(--border); border-radius: 10px; }
.sched-item + .sched-item { margin-top: 8px; }
.sched-item .time { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-2); }
.sched-item .time svg { width: 14px; height: 14px; }

/* Bar chart */
.chart { position: relative; height: 230px; display: grid; grid-template-columns: 40px 1fr; padding: 18px 16px 0 6px; }
.chart .y-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: 10.5px; color: var(--muted); text-align: right; padding: 0 8px 26px 0; }
.chart .plot { position: relative; display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; padding-bottom: 26px; }
.chart .grid-lines { position: absolute; inset: 0 0 26px 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.chart .grid-lines span { border-top: 1px dashed #edf0f4; }
.chart .bar-col { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.chart .bar {
  width: 8px; border-radius: 4px 4px 0 0; background: var(--primary);
  transition: height .6s cubic-bezier(.2, .8, .2, 1), width .15s;
}
.chart .bar-col:hover .bar { width: 12px; background: var(--primary-600); }
.chart .bar-col .lbl { position: absolute; bottom: -22px; font-size: 11px; color: var(--muted); }
.chart .bar-col .tt {
  position: absolute; bottom: calc(var(--h) + 8px); background: var(--text); color: #fff; font-size: 10.5px;
  padding: 4px 8px; border-radius: 6px; opacity: 0; transition: opacity .15s; white-space: nowrap; pointer-events: none;
}
.chart .bar-col:hover .tt { opacity: 1; }
.chart-frame { margin: 14px 16px 16px; border: 1px solid var(--border); border-radius: 10px; padding-bottom: 12px; }

/* Invoice row */
.inv-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--border); }
.inv-row:last-child { border-bottom: 0; }
.inv-row .date, .inv-row .amt { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.inv-row .date svg { width: 14px; height: 14px; }

/* Clinics accordion */
.acc { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.acc + .acc { margin-top: 12px; }
.acc-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.acc-head .thumb { width: 44px; height: 44px; border-radius: 8px; background: linear-gradient(135deg, var(--info-50), var(--primary-100)); display: grid; place-items: center; color: var(--info); flex-shrink: 0; }
.acc-head .fee { margin-left: auto; color: var(--primary); font-weight: 600; font-size: 13px; white-space: nowrap; }
.acc-head .chev { transition: transform .2s; color: var(--text-2); }
.acc.open .acc-head .chev { transform: rotate(180deg); }
.acc-body { display: none; padding: 4px 14px 14px; border-top: 1px dashed var(--border); }
.acc.open .acc-body { display: block; }
.hours-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; font-size: 12px; }
.hours-row b { font-weight: 500; }
.hours-row .t { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.hours-row .t svg { width: 14px; height: 14px; color: var(--muted); }
.hours-row.closed b, .hours-row.closed .t { color: var(--danger); font-weight: 500; }

/* ---------- Stat cards (other pages) ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat { display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
.stat .ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.stat .ic svg { width: 22px; height: 22px; }
.stat .v { font-size: 20px; font-weight: 600; line-height: 1.2; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat .delta { font-size: 10.5px; margin-left: 6px; font-weight: 500; }
.ic-red { background: var(--primary-50); color: var(--primary); }
.ic-green { background: var(--success-50); color: var(--success); }
.ic-blue { background: var(--info-50); color: var(--info); }
.ic-amber { background: var(--warning-50); color: #d98a04; }
.ic-purple { background: var(--purple-50); color: var(--purple); }
.ic-teal { background: var(--teal-50); color: var(--teal); }

/* ---------- Patient profile ---------- */
.profile-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.profile-card { text-align: center; padding: 24px 20px 20px; }
.profile-card .avatar { margin: 0 auto; border: 4px solid #fff; box-shadow: 0 0 0 2px var(--primary-100); }
.profile-card h2 { font-size: 17px; font-weight: 600; margin-top: 12px; }
.profile-card .pid { color: var(--muted); font-size: 12px; }
.profile-card .quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0; }
.profile-card .quick div { background: var(--primary-50); border-radius: 10px; padding: 10px 4px; }
.profile-card .quick b { display: block; font-size: 14px; font-weight: 600; }
.profile-card .quick span { font-size: 10.5px; color: var(--muted); }
.info-list { text-align: left; border-top: 1px solid var(--border); padding-top: 14px; }
.info-list .it { display: flex; gap: 10px; padding: 7px 0; font-size: 12px; }
.info-list .it svg { color: var(--muted); width: 15px; height: 15px; margin-top: 1px; }
.info-list .it .k { color: var(--muted); font-size: 10.5px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

.vitals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.vital { padding: 14px 16px; border-radius: 12px; border: 1px solid var(--border); background: #fff; }
.vital .top { display: flex; align-items: center; justify-content: space-between; }
.vital .top .ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; }
.vital .top .ic svg { width: 17px; height: 17px; }
.vital .v { font-size: 20px; font-weight: 600; margin-top: 10px; }
.vital .v small { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.vital .l { font-size: 11.5px; color: var(--muted); }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 26px; }
.spark i { width: 4px; border-radius: 2px; background: currentColor; opacity: .5; }
.spark i:last-child { opacity: 1; }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -21px; top: 4px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary);
}
.tl-item.gray::before { border-color: #c7ccd5; }
.tl-item .when { font-size: 11px; color: var(--muted); }
.tl-item .what { font-weight: 500; margin-top: 2px; }
.tl-item .desc { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.file { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.file + .file { margin-top: 8px; }
.grid > .file + .file { margin-top: 0; }
.file .fi { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; }
.file .grow { flex: 1; min-width: 0; }

/* ---------- Prescription ---------- */
.rx-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(340px, 1fr); gap: 20px; align-items: start; }
.patient-summary { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
.ps-left {
  background: linear-gradient(160deg, var(--primary-50), #fff); border: 1px solid var(--primary-100);
  border-radius: 12px; padding: 16px; position: relative;
}
.ps-right { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.ps-right .kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 10px; }
.kv-item { display: flex; gap: 8px; }
.kv-item svg { width: 15px; height: 15px; color: var(--muted); margin-top: 2px; }
.kv-item .k { font-size: 10.5px; color: var(--muted); }
.kv-item .v { font-size: 12px; font-weight: 500; }

.med-table td { padding: 8px 10px; }
.med-table th { padding: 10px; }
.med-table .input, .med-table .select { height: 34px; font-size: 12px; }
.freq { display: flex; gap: 4px; }
.freq label { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--border-strong); font-size: 11px; cursor: pointer; font-weight: 500; color: var(--muted); }
.freq input { display: none; }
.freq input:checked + label { background: var(--primary); border-color: var(--primary); color: #fff; }

.tag-input { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: 8px; min-height: 38px; align-items: center; }
.tag-input .pill { height: 24px; }
.tag-input .pill button { display: grid; place-items: center; color: inherit; }
.tag-input .pill button svg { width: 11px; height: 11px; }
.tag-input input { border: 0; outline: 0; flex: 1; min-width: 100px; font-size: 12.5px; }

.rx-paper {
  background: #fff; border-radius: 12px; border: 1px solid var(--border); overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 11.5px;
}
.rx-paper .rx-top { padding: 18px 20px; display: flex; justify-content: space-between; gap: 12px; border-bottom: 3px solid var(--primary); }
.rx-paper .rx-top h4 { font-size: 15px; font-weight: 600; color: var(--primary); }
.rx-paper .rx-top .clinic { text-align: right; color: var(--text-2); font-size: 10.5px; line-height: 1.5; }
.rx-paper .rx-pt { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px 20px; background: #fbfbfc; border-bottom: 1px solid var(--border); font-size: 10.5px; }
.rx-paper .rx-pt b { display: block; font-size: 11.5px; font-weight: 500; color: var(--text); }
.rx-paper .rx-body { padding: 16px 20px; min-height: 280px; }
.rx-symbol { font-family: Georgia, serif; font-size: 30px; font-weight: 700; color: var(--primary); line-height: 1; }
.rx-med { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.rx-med b { font-weight: 500; }
.rx-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-end; font-size: 10.5px; color: var(--text-2); }
.rx-foot .sign { text-align: center; }
.rx-foot .sign .line { font-family: "Brush Script MT", cursive; font-size: 20px; color: var(--text); border-bottom: 1px solid var(--text-2); padding: 0 16px 2px; }
.rx-ribbon { display: inline-block; background: var(--primary); color: #fff; font-size: 9.5px; padding: 3px 14px; border-radius: 0 0 8px 8px; }

/* Template wizard */
.choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; max-width: 640px; margin: 24px auto 0; }
.choice {
  position: relative; padding: 24px; border-radius: 14px; border: 1.5px solid var(--border-strong); background: #fff;
  text-align: center; cursor: pointer; transition: all .15s;
}
.choice:hover { border-color: var(--primary-200); }
.choice.active { border-color: var(--success); box-shadow: 0 0 0 4px var(--success-50); }
.choice .check { position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; border-radius: 50%; display: none; place-items: center; background: var(--success); color: #fff; }
.choice.active .check { display: grid; }
.choice .check svg { width: 13px; height: 13px; stroke-width: 3; }
.choice .art { height: 110px; display: grid; place-items: center; color: var(--primary); }
.choice .art svg { width: 72px; height: 72px; stroke-width: 1.1; }
.choice h4 { font-size: 14px; font-weight: 600; margin-top: 8px; }
.choice p { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }

.sec-acc { position: relative; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.sec-acc + .sec-acc { margin-top: 12px; }
.sec-acc.done { border-color: #c9efd7; }
.sec-acc .head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; }
.sec-acc .head .ic { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.sec-acc .head .t { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.sec-acc .head .d { font-size: 11px; color: var(--muted); margin-top: 1px; }
.sec-acc .head .chev { margin-left: auto; transition: transform .2s; color: var(--text-2); }
.sec-acc.open .head .chev { transform: rotate(180deg); }
.sec-acc .done-badge { position: absolute; right: 14px; top: -10px; width: 20px; height: 20px; border-radius: 50%; background: var(--success); color: #fff; display: none; place-items: center; }
.sec-acc.done .done-badge { display: grid; }
.sec-acc .done-badge svg { width: 12px; height: 12px; stroke-width: 3; }
.sec-acc .body { display: none; padding: 4px 16px 16px 64px; }
.sec-acc.open .body { display: block; }
.color-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; }
.color-row + .color-row { margin-top: 8px; }
.color-row input[type=color] { width: 26px; height: 26px; border: 0; border-radius: 50%; padding: 0; background: none; cursor: pointer; }
.color-row input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.color-row input[type=color]::-webkit-color-swatch { border: 0; border-radius: 50%; }
.upload {
  border: 1.5px dashed var(--border-strong); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); font-size: 11.5px;
  transition: border-color .15s, background .15s; cursor: pointer;
}
.upload:hover { border-color: var(--primary-200); background: var(--primary-50); }
.upload svg { width: 22px; height: 22px; margin: 0 auto 6px; color: var(--primary); }
.tpl-grid { grid-template-columns: minmax(300px, 420px) 1fr; align-items: start; }
.steps { display: flex; align-items: center; gap: 8px; }
.step { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.step .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--border-strong); font-size: 11px; font-weight: 600; }
.step.active { color: var(--text); font-weight: 500; }
.step.active .n { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.done .n { background: var(--success); border-color: var(--success); color: #fff; }
.step-line { width: 40px; height: 1.5px; background: var(--border-strong); }

/* ---------- Modal / Drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 80; display: none; align-items: center; justify-content: center; padding: 20px; }
.overlay.open { display: flex; animation: fade .15s ease; }
.modal { width: 100%; max-width: 620px; max-height: calc(100vh - 40px); overflow: auto; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); animation: pop .2s ease; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: #fbfbfc; border-radius: 0 0 16px 16px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 60;
}
.dropdown.open .dropdown-menu { display: block; animation: pop .15s ease; }
.dropdown-menu a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; font-size: 12.5px; color: var(--text-2); }
.dropdown-menu a:hover, .dropdown-menu a.active { background: var(--primary-50); color: var(--primary); }
.dropdown-menu.left { left: 0; right: auto; }
.dropdown-menu .menu-title { padding: 8px 10px 4px; font-size: 10.5px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.theme-menu { max-height: calc(100vh - var(--topbar-h) - 24px); overflow-y: auto; }
.theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0 2px 4px; }
.theme-menu .menu-title { padding: 10px 6px 6px; }
.dropdown-menu .theme-tile {
  position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  padding: 6px; border-radius: 10px; border: 1.5px solid transparent;
  font-size: 11px; color: var(--text-2); text-align: center;
}
.dropdown-menu .theme-tile:hover { background: #f6f7f9; color: var(--text); }
.dropdown-menu .theme-tile.active { border-color: var(--primary); background: var(--primary-50); color: var(--primary-600); font-weight: 500; }
.theme-tile .preview {
  height: 46px; border-radius: 7px; overflow: hidden; display: grid; grid-template-columns: 12px 1fr;
  box-shadow: inset 0 0 0 1px rgba(16, 24, 40, .08); background: #fafafb;
}
.theme-tile .preview .sb { background: var(--b); border-right: 1px solid rgba(16, 24, 40, .06); }
.theme-tile .pv-body { display: flex; flex-direction: column; gap: 4px; padding: 7px 6px; }
.theme-tile .pv-body i { display: block; border-radius: 3px; }
.theme-tile .pv-body .bar { height: 9px; width: 60%; background: var(--a); }
.theme-tile .pv-body .line { height: 5px; background: var(--c); }
.theme-tile .pv-body .line.short { width: 70%; }
.theme-tile .tick {
  position: absolute; top: 2px; right: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary); color: #fff; display: none; place-items: center;
}
.theme-tile .tick svg { width: 10px; height: 10px; stroke-width: 3; }
.theme-tile.active .tick { display: grid; }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.notif { display: flex; gap: 10px; padding: 10px; border-radius: 8px; }
.notif:hover { background: #fafafb; }
.notif .ic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.notif .ic svg { width: 15px; height: 15px; }

.toast {
  position: fixed; right: 24px; bottom: calc(var(--footer-h) + 16px); z-index: 100;
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px;
  background: var(--text); color: #fff; font-size: 12.5px; box-shadow: var(--shadow-lg);
  transform: translateY(20px); opacity: 0; pointer-events: none; transition: all .25s ease;
}
.toast.show { transform: none; opacity: 1; }
.toast svg { color: #4ade80; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: #fff; }
.auth-art {
  position: relative; overflow: hidden; padding: 40px 48px; color: #fff;
  background: var(--auth-bg);
  display: flex; flex-direction: column;
}
.auth-art::before, .auth-art::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .07); }
.auth-art::before { width: 520px; height: 520px; right: -180px; top: -160px; }
.auth-art::after { width: 380px; height: 380px; left: -140px; bottom: -140px; }
.auth-art .brand-mark { background: #fff; color: var(--primary); box-shadow: none; }
.auth-art h1 { font-size: 34px; font-weight: 600; line-height: 1.25; letter-spacing: -.5px; margin-top: auto; position: relative; z-index: 1; }
.auth-art p { opacity: .85; margin-top: 12px; font-size: 14px; max-width: 440px; line-height: 1.6; position: relative; z-index: 1; }
.auth-mock {
  position: relative; z-index: 1; margin-top: 32px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 16px; padding: 16px; backdrop-filter: blur(6px); max-width: 460px;
}
.auth-mock .row-between + .row-between { margin-top: 10px; }
.auth-mock .glass { background: #fff; color: var(--text); border-radius: 10px; padding: 10px 12px; flex: 1; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-form .box { width: 100%; max-width: 380px; }
.auth-form h2 { font-size: 24px; font-weight: 600; letter-spacing: -.3px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 11.5px; margin: 18px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* =========================================================
   Phase 1 module components
   ========================================================= */
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.stats.three { grid-template-columns: repeat(3, 1fr); }
.stats.five { grid-template-columns: repeat(5, 1fr); }
.mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; }
.ml-auto { margin-left: auto; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }
.text-warning { color: #c27803; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger:hover, .btn-success:hover { filter: brightness(.94); }
.btn-outline-danger { background: #fff; border-color: #f5c2c4; color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger-50); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm svg { width: 16px; height: 16px; }

.tabs.scroll { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
.tabs.scroll::-webkit-scrollbar { display: none; }
.tabs.scroll button { white-space: nowrap; flex-shrink: 0; }
.tabs.scroll button.active::after { bottom: 0; }

/* Inline alerts */
.alert { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid; border-radius: 10px; font-size: 12.5px; }
.alert > svg { width: 18px; height: 18px; margin-top: 1px; }
.alert b { font-weight: 600; }
.alert .grow { flex: 1; min-width: 0; }
.alert-info { background: var(--info-50); border-color: #cfe2fd; color: #1d4f91; }
.alert-warn { background: var(--warning-50); border-color: #fde3b0; color: #8a5300; }
.alert-danger { background: var(--danger-50); border-color: #fbd0d2; color: #a3262a; }
.alert-success { background: var(--success-50); border-color: #c6efd5; color: #11692f; }

/* Allergy banner — shown on every clinical screen */
.allergy-banner { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 9px 14px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 12.5px; }
.allergy-banner svg { width: 17px; height: 17px; }
.allergy-banner b { font-weight: 600; }
.allergy-banner .pill { background: rgba(255, 255, 255, .18); color: #fff; }

/* Key/value details */
.kv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 20px; }
.kv-grid.three { grid-template-columns: repeat(3, 1fr); }
.kv-grid.four { grid-template-columns: repeat(4, 1fr); }
.kv-grid .k { font-size: 10.5px; color: var(--muted); }
.kv-grid .v { font-size: 12.5px; font-weight: 500; margin-top: 2px; }

.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 20px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }

.empty { text-align: center; padding: 36px 20px; color: var(--muted); font-size: 12.5px; }
.empty svg { width: 36px; height: 36px; margin: 0 auto 10px; color: var(--primary-200); }

/* Progress, donut, line chart */
.progress { height: 6px; border-radius: 6px; background: #eef0f3; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.progress.green > i { background: var(--success); }
.progress.amber > i { background: var(--warning); }
.progress.red > i { background: var(--danger); }

.donut { --size: 132px; position: relative; width: var(--size); height: var(--size); border-radius: 50%; flex-shrink: 0; }
.donut::after { content: ""; position: absolute; inset: 18px; border-radius: 50%; background: #fff; }
.donut .center { position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; text-align: center; font-size: 11px; color: var(--muted); }
.donut .center b { display: block; font-size: 18px; font-weight: 600; color: var(--text); }
.legend { display: flex; flex-direction: column; gap: 8px; font-size: 12px; flex: 1; }
.legend .li { display: flex; align-items: center; gap: 8px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend .li b { margin-left: auto; font-weight: 600; }

.line-chart { position: relative; min-height: 120px; }
.line-chart svg { display: block; overflow: visible; }
.lc-legend { display: flex; gap: 16px; padding: 0 4px 8px; font-size: 11.5px; color: var(--text-2); }
.lc-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lc-legend i { width: 12px; height: 3px; border-radius: 2px; }

/* Settings layout with vertical tab nav (.vnav[data-tabs="#panes"]) */
.settings-grid { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; }
.vnav { display: flex; flex-direction: column; gap: 2px; padding: 8px; position: sticky; top: calc(var(--topbar-h) + 20px); }
.vnav > button, .vnav > a { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; border-radius: 8px; font-size: 12.5px; color: var(--text-2); text-align: left; }
.vnav > button:hover, .vnav > a:hover { background: #f6f7f9; color: var(--text); }
.vnav > button.active, .vnav > a.active { background: var(--primary-50); color: var(--primary); font-weight: 500; }
.vnav svg { width: 16px; height: 16px; }
.vnav .count { margin-left: auto; font-size: 10.5px; color: var(--muted); }
.vnav-title { padding: 10px 12px 4px; font-size: 10.5px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }

/* Permission matrix */
.matrix th, .matrix td { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix tr.group td { background: #fbfbfc; font-size: 11px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--text-2); }

/* Queue / token board */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 16px; align-items: start; overflow-x: auto; }
.k-col { background: #f4f6f9; border-radius: 14px; padding: 12px; min-height: 220px; }
.k-col-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 12px; font-size: 12.5px; font-weight: 600; }
.k-col-head .count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #fff; display: grid; place-items: center; font-size: 11px; color: var(--text-2); }
.token-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px; box-shadow: var(--shadow-sm); }
.token-card + .token-card { margin-top: 10px; }
.token-card.called { border-color: var(--primary-200); box-shadow: 0 0 0 3px var(--primary-50); }
.token { min-width: 46px; height: 46px; padding: 0 8px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); font-size: 16px; font-weight: 700; flex-shrink: 0; }
.token.lg { min-width: 64px; height: 64px; border-radius: 14px; font-size: 24px; }
.token.solid { background: var(--primary); color: #fff; }

/* Week / resource calendar: 56px per hour */
.wk-cal { display: grid; grid-template-columns: 60px repeat(var(--cols, 7), minmax(130px, 1fr)); overflow-x: auto; }
.wk-h { padding: 10px 8px; text-align: center; font-size: 11.5px; color: var(--muted); background: #fbfbfc; border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); }
.wk-h:first-child { border-left: 0; }
.wk-h b { display: block; font-size: 14px; font-weight: 600; color: var(--text); }
.wk-h.today b { color: var(--primary); }
.wk-times { display: flex; flex-direction: column; }
.wk-time { height: 56px; padding: 0 8px; text-align: right; font-size: 10.5px; color: var(--muted); transform: translateY(-7px); }
.wk-col { position: relative; border-left: 1px solid var(--border); background-image: repeating-linear-gradient(to bottom, transparent 0 55px, var(--border) 55px 56px); }
.wk-col.off { background-color: #f8f9fb; }
.wk-ev { position: absolute; left: 4px; right: 4px; padding: 5px 8px; border-left: 3px solid; border-radius: 8px; font-size: 10.5px; line-height: 1.3; overflow: hidden; cursor: pointer; }
.wk-ev b { display: block; font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-now { position: absolute; left: 0; right: 0; z-index: 2; height: 2px; background: var(--danger); }
.wk-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.ev-brand { background: var(--primary-50); border-color: var(--primary); color: var(--primary-700); }
.ev-green { background: var(--success-50); border-color: var(--success); color: #11692f; }
.ev-amber { background: var(--warning-50); border-color: var(--warning); color: #8a5300; }
.ev-purple { background: var(--purple-50); border-color: var(--purple); color: #5b32b5; }
.ev-red { background: var(--danger-50); border-color: var(--danger); color: #a3262a; }
.ev-gray { background: #f2f4f7; border-color: #98a2b3; color: #475467; }

/* Slot picker */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.slot-grid .chip { justify-content: center; height: 34px; }
.chip.booked { opacity: .45; text-decoration: line-through; pointer-events: none; }
.chip:disabled { opacity: .45; cursor: not-allowed; }

/* Consultation workspace (EMR) */
.pt-header { display: flex; align-items: center; flex-wrap: wrap; gap: 14px 18px; padding: 14px 18px; }
.pt-header .meta { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: var(--text-2); }
.pt-header .meta span { display: inline-flex; align-items: center; gap: 5px; }
.pt-header .meta svg { width: 14px; height: 14px; color: var(--muted); }
.visit-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; padding: 10px 18px; border-top: 1px solid var(--border); background: #fbfbfc; border-radius: 0 0 var(--radius-lg) var(--radius-lg); font-size: 12px; color: var(--text-2); }
.visit-bar span { display: inline-flex; align-items: center; gap: 5px; }
.visit-bar svg { width: 14px; height: 14px; color: var(--muted); }
.ws-grid { display: grid; grid-template-columns: 250px minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
.ws-side { position: sticky; top: calc(var(--topbar-h) + 20px); display: flex; flex-direction: column; gap: 16px; }
.ws-sec { scroll-margin-top: calc(var(--topbar-h) + 20px); }
.sec-num { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--primary); color: #fff; font-size: 11px; font-weight: 600; }
.ws-actions {
  position: sticky; bottom: calc(var(--footer-h) + 12px); z-index: 5; margin-top: 20px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 16px;
  background: rgba(255, 255, 255, .95); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.mini-vitals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.mv { padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
.mv .k { font-size: 10.5px; color: var(--muted); }
.mv .v { font-size: 14px; font-weight: 600; }
.mv .v small { font-size: 10.5px; font-weight: 400; color: var(--muted); }
.mv.abn { border-color: #fbd0d2; background: var(--danger-50); }
.mv.abn .v { color: var(--danger); }
.suggest-wrap { position: relative; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; display: none; padding: 6px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); }
.suggest.open { display: block; }
.suggest button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; text-align: left; font-size: 12.5px; }
.suggest button:hover { background: var(--primary-50); color: var(--primary); }
.locked { pointer-events: none; opacity: .65; }

/* Billing */
.sum-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; font-size: 12.5px; color: var(--text-2); }
.sum-row b { font-weight: 500; color: var(--text); }
.sum-row.total { margin-top: 6px; padding-top: 12px; border-top: 1px dashed var(--border-strong); font-size: 14px; font-weight: 600; color: var(--text); }
.sum-row.total b { font-size: 18px; font-weight: 700; color: var(--primary); }
.pay-modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pay-mode { padding: 10px 6px; border: 1.5px solid var(--border-strong); border-radius: 10px; text-align: center; font-size: 11.5px; color: var(--text-2); }
.pay-mode svg { display: block; width: 20px; height: 20px; margin: 0 auto 4px; }
.pay-mode.active { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }

/* Reports catalogue */
.report-tile { display: flex; gap: 12px; padding: 14px; background: #fff; border: 1px solid var(--border); border-radius: 12px; transition: border-color .15s, box-shadow .15s; }
.report-tile:hover { border-color: var(--primary-200); box-shadow: var(--shadow); }
.report-tile .ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.report-tile .ic svg { width: 18px; height: 18px; }
.report-tile h4 { font-size: 13px; font-weight: 600; }
.report-tile p { margin-top: 2px; font-size: 11.5px; line-height: 1.45; color: var(--muted); }

/* Right-side drawer: <div class="overlay drawer-wrap" id="…"><div class="drawer">…</div></div> */
.overlay.drawer-wrap { justify-content: flex-end; padding: 0; }
.drawer { display: flex; flex-direction: column; width: 100%; max-width: 520px; height: 100%; background: #fff; box-shadow: var(--shadow-lg); animation: slide-in .22s ease; }
.drawer .modal-body { flex: 1; overflow: auto; }
.drawer .modal-foot { border-radius: 0; }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Prototype busy state on action buttons */
@keyframes td-spin { to { transform: rotate(360deg); } }
.spin, i.spin, .btn .spin { animation: td-spin .7s linear infinite; display: inline-block; }
button.btn:disabled { opacity: .72; cursor: wait; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .kpi-track { grid-auto-columns: 180px; }
  .vitals { grid-template-columns: repeat(2, 1fr); }
  .ws-grid { grid-template-columns: 220px minmax(0, 1fr); }
  .ws-grid > .ws-right { grid-column: 1 / -1; position: static; display: grid; grid-template-columns: repeat(2, 1fr); }
  .stats.five { grid-template-columns: repeat(3, 1fr); }
  .branch-btn b { max-width: 110px; }
}
@media (max-width: 1100px) {
  .hero-grid, .dash-grid, .rx-grid, .profile-grid, .split, .tpl-grid, .settings-grid, .ws-grid { grid-template-columns: minmax(0, 1fr); }
  .rx-grid > div, .tpl-grid > div { position: static !important; }
  .ws-side, .vnav { position: static; }
  .cols-3, .cols-4 { grid-template-columns: repeat(2, 1fr); }
  .stats, .stats.three, .stats.five { grid-template-columns: repeat(2, 1fr); }
  .branch-btn > span:not(.bi) { display: none; }
  .search { display: none; }
  .patient-summary { grid-template-columns: minmax(0, 1fr); }
  .foot-status { display: none; }
}
/* Off-canvas navigation: the rail's hover flyouts don't work on touch and its height clips long menus. */
@media (max-width: 991px) {
  .sidebar, body.sidebar-open .sidebar {
    width: min(280px, 86vw); transform: translateX(-100%); visibility: hidden;
    transition: transform .25s ease, visibility 0s linear .25s; z-index: 80;
  }
  body.nav-open .sidebar { transform: none; visibility: visible; transition: transform .25s ease; box-shadow: 0 0 40px rgba(15, 23, 42, .35); }
  .sidebar-toggle { display: none; }
  .main, body.sidebar-open .main { margin-left: 0; }
  .app-footer, body.sidebar-open .app-footer { left: 0; }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 79; background: rgba(15, 23, 42, .45);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .topbar .menu-btn { display: grid; flex-shrink: 0; margin-left: -8px; }
  .topbar { gap: 10px; }
}
@media (max-width: 760px) {
  .content { padding: 16px; }
  .topbar { padding: 0 12px; gap: 4px; }
  .topbar .crumbs { display: none; }
  .topbar .page-title { font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .m-title { display: block; }
  .topbar .spacer { min-width: 4px; }
  .topbar > .dropdown { position: static; }
  .topbar .dropdown-menu {
    position: fixed; top: calc(var(--topbar-h) + 6px); left: 10px; right: 10px;
    width: auto !important; min-width: 0; max-height: calc(100vh - var(--topbar-h) - 24px); overflow-y: auto;
  }
  .theme-grid { grid-template-columns: repeat(3, 1fr); }
  .new-btn { width: 38px; padding: 0; justify-content: center; }
  .new-btn .btn-text, .branch-btn > svg, .user-chip > svg { display: none; }
  .branch-btn { padding: 0 6px; }
  .user-chip { padding-left: 2px; }
  .app-footer { padding: 0 16px; }
  .foot-links a:not(:last-child), .foot-left > .foot-sep, .foot-left > span:last-child { display: none; }
  .lang, .user-chip .meta { display: none; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { display: none; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .stats, .stats.three, .stats.five, .cols-2, .cols-3, .cols-4, .kv-grid, .kv-grid.three, .kv-grid.four { grid-template-columns: minmax(0, 1fr); }
  .mini-vitals, .pay-modes { grid-template-columns: repeat(2, 1fr); }
  .ws-grid > .ws-right { grid-template-columns: minmax(0, 1fr); }
  .choice-grid { grid-template-columns: minmax(0, 1fr); }
  .hero .clock { display: none; }
  .card-head { flex-wrap: wrap; row-gap: 10px; }
  .card-head > .row, .card-head > .toolbar { flex-wrap: wrap; }
  .tabs, .steps, .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar, .steps::-webkit-scrollbar, .segmented::-webkit-scrollbar { display: none; }
  .tabs button, .segmented button, .steps > * { white-space: nowrap; flex-shrink: 0; }
  .tabs button.active::after { bottom: 0; }
  .content .input-icon, .content .input[style*="width"] { max-width: 100%; }
}
@media (max-width: 400px) {
  .topbar .help-btn { display: none; }
}
