/* ============================================================================
   crm-modern.css  —  Gurita CRM design + dark/light/auto theme layer
   Loaded after adminlte.min.css so these rules win cascade ties.

   Design language: a working tool, dense and quiet. One accent (the
   Primary Color, deep reef teal by default), cool slate neutrals, flat
   bordered surfaces, Instrument Sans for the interface with Fraunces only
   for page titles, muted semantic colors. Shadows mark things that float
   (menus, dialogs); cards are separated by borders, and nothing lifts on
   hover. All values flow from the --crm-* tokens below;
   [data-bs-theme="dark"] overrides them so every component adapts.

   The accent is brand-driven: admin/index.php emits --crm-brand and
   --crm-brand-rgb from Site Settings → Primary Color. Everything here
   derives from those two values via color-mix(), so changing the brand
   color in Site Settings rethemes the whole CRM.
   ============================================================================ */

/* ══════════════════════════════════════════════════════════════════════════════
   1. DESIGN TOKENS — light mode (defaults)
   ══════════════════════════════════════════════════════════════════════════════ */
:root {
  /* Brand accent — --crm-brand(-rgb) are injected by admin/index.php from
     Site Settings; the fallbacks keep standalone pages (login) on-palette. */
  --crm-primary:      var(--crm-brand, #0e6f7c);
  --crm-primary-rgb:  var(--crm-brand-rgb, 14, 111, 124);
  --crm-primary-dark: color-mix(in srgb, var(--crm-primary) 82%, #000);
  --crm-primary-soft: color-mix(in srgb, var(--crm-primary) 10%, transparent);
  --crm-primary-glow: color-mix(in srgb, var(--crm-primary) 22%, transparent);
  /* Accent for TEXT/icons — lightened in dark mode for legibility while
     buttons/badges keep the solid accent. */
  --crm-accent-ink:   var(--crm-primary);
  /* Legacy alias (referenced by inline styles in admin/index.php) */
  --gurita-primary:   var(--crm-primary);

  /* Semantic — muted, not neon */
  --crm-success: #059669;
  --crm-warning: #d97706;
  --crm-danger:  #dc2626;
  --crm-info:    #0284c7;

  /* Surfaces — cool slate neutrals */
  --crm-bg:        #f4f6f9;
  --crm-surface:   #ffffff;
  --crm-surface-2: #f8fafc;
  --crm-border:    #e5e9f0;
  --crm-row-line:  color-mix(in srgb, var(--crm-border) 65%, transparent);

  /* Text */
  --crm-ink:   #101828;
  --crm-muted: #64748b;
  --crm-faint: #94a3b8;

  /* Typography */
  --crm-font: 'Instrument Sans', -apple-system, BlinkMacSystemFont,
              'Segoe UI', system-ui, sans-serif;
  --crm-font-display: 'Fraunces', Georgia, 'Times New Roman', serif;

  /* Radii */
  --crm-r:    12px;
  --crm-r-sm: 8px;
  --crm-r-lg: 16px;

  /* Elevations — soft and small; depth comes from borders, not blur */
  --crm-s1: 0 1px 2px rgba(16,24,40,.05);
  --crm-s2: 0 2px 8px rgba(16,24,40,.07), 0 1px 2px rgba(16,24,40,.04);
  --crm-s3: 0 8px 24px rgba(16,24,40,.10);
  --crm-s4: 0 20px 48px rgba(16,24,40,.16);

  /* Speed */
  --crm-t: .18s cubic-bezier(.4,0,.2,1);

  /* ── Bootstrap variable remap ──────────────────────────────────────────
     Rethemes every var-driven utility (.text-primary, .bg-*-subtle,
     .text-bg-*, .badge, .progress-bar, links) without touching markup. */
  --bs-primary:               var(--crm-primary);
  --bs-primary-rgb:           var(--crm-primary-rgb);
  --bs-primary-bg-subtle:     color-mix(in srgb, var(--crm-primary) 9%, #fff);
  --bs-primary-border-subtle: color-mix(in srgb, var(--crm-primary) 25%, #fff);
  --bs-primary-text-emphasis: color-mix(in srgb, var(--crm-primary) 80%, #000);

  --bs-success: var(--crm-success);  --bs-success-rgb: 5, 150, 105;
  --bs-success-bg-subtle:     color-mix(in srgb, var(--crm-success) 9%, #fff);
  --bs-success-border-subtle: color-mix(in srgb, var(--crm-success) 25%, #fff);
  --bs-success-text-emphasis: color-mix(in srgb, var(--crm-success) 80%, #000);

  --bs-warning: var(--crm-warning);  --bs-warning-rgb: 217, 119, 6;
  --bs-warning-bg-subtle:     color-mix(in srgb, var(--crm-warning) 10%, #fff);
  --bs-warning-border-subtle: color-mix(in srgb, var(--crm-warning) 28%, #fff);
  --bs-warning-text-emphasis: color-mix(in srgb, var(--crm-warning) 80%, #000);

  --bs-danger: var(--crm-danger);    --bs-danger-rgb: 220, 38, 38;
  --bs-danger-bg-subtle:      color-mix(in srgb, var(--crm-danger) 8%, #fff);
  --bs-danger-border-subtle:  color-mix(in srgb, var(--crm-danger) 25%, #fff);
  --bs-danger-text-emphasis:  color-mix(in srgb, var(--crm-danger) 80%, #000);

  --bs-info: var(--crm-info);        --bs-info-rgb: 2, 132, 199;
  --bs-info-bg-subtle:        color-mix(in srgb, var(--crm-info) 9%, #fff);
  --bs-info-border-subtle:    color-mix(in srgb, var(--crm-info) 25%, #fff);
  --bs-info-text-emphasis:    color-mix(in srgb, var(--crm-info) 80%, #000);

  --bs-link-color:       var(--crm-accent-ink);
  --bs-link-color-rgb:   var(--crm-primary-rgb);
  --bs-link-hover-color: var(--crm-primary-dark);

  /* Generic .border / .border-end / .border-bottom utilities. Left alone they
     use AdminLTE's own greys (#dee2e6 light, #495057 dark) rather than the CRM
     hairline, which in dark theme read as a warm grey line against the cool
     chrome. --bs-border-color-translucent is deliberately not remapped: several
     components rely on it actually being translucent. */
  --bs-border-color:     var(--crm-border);
}

/* ── Dark-mode token overrides ───────────────────────────────────────────── */
[data-bs-theme="dark"] {
  --crm-bg:        #0b1120;
  --crm-surface:   #111a2e;
  --crm-surface-2: #172136;
  --crm-border:    #1f2d45;
  --crm-ink:       #e2e8f0;
  --crm-muted:     #94a3b8;
  --crm-faint:     #64748b;

  --crm-accent-ink: color-mix(in srgb, var(--crm-primary) 55%, #fff);

  --crm-s1: 0 1px 2px rgba(0,0,0,.40);
  --crm-s2: 0 2px 8px rgba(0,0,0,.42), 0 1px 2px rgba(0,0,0,.30);
  --crm-s3: 0 8px 24px rgba(0,0,0,.48);
  --crm-s4: 0 20px 48px rgba(0,0,0,.60);

  --bs-primary-bg-subtle:     color-mix(in srgb, var(--crm-primary) 18%, #0b1120);
  --bs-primary-border-subtle: color-mix(in srgb, var(--crm-primary) 32%, #0b1120);
  --bs-primary-text-emphasis: color-mix(in srgb, var(--crm-primary) 50%, #fff);

  --bs-success-bg-subtle:     color-mix(in srgb, var(--crm-success) 16%, #0b1120);
  --bs-success-border-subtle: color-mix(in srgb, var(--crm-success) 30%, #0b1120);
  --bs-success-text-emphasis: color-mix(in srgb, var(--crm-success) 55%, #fff);

  --bs-warning-bg-subtle:     color-mix(in srgb, var(--crm-warning) 16%, #0b1120);
  --bs-warning-border-subtle: color-mix(in srgb, var(--crm-warning) 30%, #0b1120);
  --bs-warning-text-emphasis: color-mix(in srgb, var(--crm-warning) 60%, #fff);

  --bs-danger-bg-subtle:      color-mix(in srgb, var(--crm-danger) 16%, #0b1120);
  --bs-danger-border-subtle:  color-mix(in srgb, var(--crm-danger) 30%, #0b1120);
  --bs-danger-text-emphasis:  color-mix(in srgb, var(--crm-danger) 55%, #fff);

  --bs-info-bg-subtle:        color-mix(in srgb, var(--crm-info) 16%, #0b1120);
  --bs-info-border-subtle:    color-mix(in srgb, var(--crm-info) 30%, #0b1120);
  --bs-info-text-emphasis:    color-mix(in srgb, var(--crm-info) 55%, #fff);

  --bs-link-color:       var(--crm-accent-ink);
  --bs-link-hover-color: color-mix(in srgb, var(--crm-primary) 40%, #fff);

  --bs-border-color:     var(--crm-border);
}

/* Accent text stays readable on dark surfaces (solid accent is too dark) */
[data-bs-theme="dark"] .text-primary { color: var(--crm-accent-ink) !important; }

/* ══════════════════════════════════════════════════════════════════════════════
   2. BASE
   ══════════════════════════════════════════════════════════════════════════════ */
body {
  font-family: var(--crm-font);
  background: var(--crm-bg) !important;
  color: var(--crm-ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.bg-body-tertiary { background: var(--crm-bg) !important; }

/* Bootstrap's .bg-light is a hardcoded #f8f9fa in BOTH themes — --bs-light-rgb
   is declared once on :root and never re-declared for dark. Anywhere it is used
   as a panel surface it therefore stayed white in dark mode while the text
   inside it was themed light: the settings column and toolbar of the email
   template editor, the integrations icon tiles, the fixed rows in User Roles.
   --crm-bg keeps the light-mode relationship intact — a recessed panel with the
   raised .form-control surface sitting on top of it — because in light theme
   --crm-bg (#f4f6f9) is already what .bg-light was.

   Remapping --bs-light-rgb itself would be tidier but is wrong: it also drives
   .text-light (a colour) and .text-bg-light, which pins #000 text on top of it,
   so every light badge in the CRM would turn into black-on-dark. */
[data-bs-theme="dark"] .app-main .bg-light,
[data-bs-theme="dark"] .modal .bg-light {
  background-color: var(--crm-bg) !important;
}
/* The same trap one level up: .text-bg-light is a neutral chip in light theme
   ("Guest-provided", booking states in Reports) and a glaring white one in
   dark, with .text-dark/.text-muted inside pinned for the white. .alert-light
   is the matching notice panel (Edit Guest's read-only explanations). */
[data-bs-theme="dark"] :is(.app-main, .modal) .text-bg-light {
  background-color: var(--crm-surface-2) !important;
  color: var(--crm-muted) !important;
}
[data-bs-theme="dark"] :is(.app-main, .modal) .text-bg-light.text-dark { color: var(--crm-ink) !important; }
[data-bs-theme="dark"] :is(.app-main, .modal) .alert-light {
  background: var(--crm-surface-2);
  color: var(--crm-ink);
  border-color: var(--crm-border);
}

/* Visible keyboard focus everywhere — never removed, only styled */
:focus-visible {
  outline: 2px solid var(--crm-primary);
  outline-offset: 2px;
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Custom scrollbar */
::-webkit-scrollbar          { width: 6px; height: 6px; }
::-webkit-scrollbar-track    { background: transparent; }
::-webkit-scrollbar-thumb    { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb       { background: #1f2d45; }
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #334155; }

/* ══════════════════════════════════════════════════════════════════════════════
   3. APP HEADER (top navbar)
   ══════════════════════════════════════════════════════════════════════════════ */
.app-header.navbar {
  border-bottom: 1px solid var(--crm-border);
  box-shadow: none;
  background: var(--crm-surface) !important;
  transition: background var(--crm-t), border-color var(--crm-t);
  z-index: 1040;
  min-height: 52px;
}
[data-bs-theme="dark"] .app-header.navbar {
  background: var(--crm-surface) !important;
}

.app-header .nav-link {
  color: var(--crm-muted);
  border-radius: var(--crm-r-sm);
  padding: 6px 10px;
  transition: color var(--crm-t), background var(--crm-t);
}
.app-header .nav-link:hover { color: var(--crm-ink); background: var(--crm-surface-2); }

/* Date badge — quiet chip instead of a solid grey pill */
.app-header .badge.bg-secondary {
  background: var(--crm-surface-2) !important;
  color: var(--crm-muted);
  border: 1px solid var(--crm-border);
  font-weight: 500;
}

/* Theme toggle button */
#btnThemeToggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border-radius: var(--crm-r-sm);
  border: 1px solid var(--crm-border);
  background: transparent;
  color: var(--crm-muted);
  cursor: pointer;
  transition: all var(--crm-t);
  vertical-align: middle;
}
#btnThemeToggle:hover {
  color: var(--crm-accent-ink);
  border-color: color-mix(in srgb, var(--crm-primary) 30%, transparent);
  background: var(--crm-primary-soft);
}
#btnThemeToggle i { font-size: 14px; pointer-events: none; }

/* Notifications badge */
.navbar-badge { font-size: 9px; padding: 2px 5px; }

/* Notification dropdown rows: icon | message | timestamp, all on one baseline.
   The timestamp used to be a .float-end span, which dropped to its own line. */
.crm-notif-item {
  display: flex; align-items: center; gap: .5rem;
  white-space: normal;
}
.crm-notif-icon { flex: 0 0 auto; font-size: 14px; line-height: 1; }
.crm-notif-text { flex: 1 1 auto; min-width: 0; }
.crm-notif-time {
  flex: 0 0 auto; margin-left: auto;
  font-size: 11px; color: var(--crm-faint); white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════════════════
   4. SIDEBAR
   ══════════════════════════════════════════════════════════════════════════════ */
.app-sidebar {
  background: #0d1424 !important;
  border-right: 1px solid rgba(255,255,255,.05);
  box-shadow: none;
}

/* Brand — left-aligned, in line with the nav items below it. AdminLTE
   centres .sidebar-brand; the logo and name start at the same edge as the
   menu icons instead. */
.app-sidebar .sidebar-brand { justify-content: flex-start; }
.sidebar-brand .brand-link {
  display: flex; align-items: center; width: 100%;
  padding: 15px 24px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  text-decoration: none;
}
.sidebar-brand .brand-text {
  color: #fff; font-weight: 600; font-size: 14.5px; letter-spacing: -.01em;
}

/* Nav items — slim, flat, accent-tinted active state */
.sidebar-wrapper .sidebar-menu > .nav-item > .nav-link {
  margin: 1px 12px;
  border-radius: var(--crm-r-sm);
  color: rgba(255,255,255,.58);
  font-size: 13px;
  font-weight: 500;
  transition: color var(--crm-t), background var(--crm-t);
  padding: 8px 12px;
}
.sidebar-wrapper .sidebar-menu > .nav-item > .nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,.06);
}
.sidebar-wrapper .sidebar-menu > .nav-item > .nav-link.active,
.sidebar-wrapper .sidebar-menu > .nav-item.menu-open > .nav-link.active {
  color: #fff !important;
  background: color-mix(in srgb, var(--crm-primary) 24%, transparent) !important;
  box-shadow: none;
}
.sidebar-wrapper .sidebar-menu > .nav-item > .nav-link .nav-icon {
  color: rgba(255,255,255,.35);
  width: 20px; text-align: center;
  font-size: 15px;
  transition: color var(--crm-t);
}
.sidebar-wrapper .sidebar-menu > .nav-item > .nav-link:hover .nav-icon { color: rgba(255,255,255,.75); }
.sidebar-wrapper .sidebar-menu > .nav-item > .nav-link.active .nav-icon,
.sidebar-wrapper .sidebar-menu > .nav-item.menu-open > .nav-link.active .nav-icon {
  color: color-mix(in srgb, var(--crm-primary) 45%, #fff) !important;
}
/* Section headings (Guests, Marketing, …) — see crm_nav_groups(). */
.sidebar-wrapper .sidebar-menu > .nav-header {
  padding: 16px 24px 6px;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255,255,255,.5);
  background: none;
}

/* Sidebar as a flex column, so the user card can sit at the foot.
   AdminLTE gives .sidebar-wrapper a fixed calc(100vh - brand) height under
   layout-fixed (and on mobile), which would push anything placed after it
   off-screen. Letting it flex instead makes the menu take the remaining
   space and scroll inside it, with the card pinned below. */
.app-sidebar {
  display: flex;
  flex-direction: column;
}
.app-sidebar .sidebar-brand { flex-shrink: 0; }
.app-sidebar .sidebar-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  height: auto !important;
  overflow-x: hidden;
  overflow-y: auto;
}
/* Desktop: the sticky sidebar is a grid item capped at 100vh; pin it to
   exactly that so the card reaches the bottom even on short pages. Mobile
   is already full height (position:fixed; top:0; bottom:0). */
@media (min-width: 992px) {
  .layout-fixed .app-sidebar { height: 100vh; }
}

/* User card — avatar, name + role, sign-out icon */
.sidebar-user {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 12px;
  padding: 12px 0 14px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-user-link {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 8px;
  border-radius: var(--crm-r-sm);
  text-decoration: none;
  transition: background var(--crm-t);
}
.sidebar-user-link:hover,
.sidebar-user-link:focus-visible { background: rgba(255,255,255,.06); }
.sidebar-user-avatar {
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--crm-primary);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .02em;
}
/* The uploaded photo sits over the initials; it is only rendered when one
   exists, and crmAvatarToInitials() removes it if the file fails to load. */
.sidebar-user-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.sidebar-user-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.sidebar-user-name,
.sidebar-user-role {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-name { color: #fff; font-size: 13px; font-weight: 600; }
.sidebar-user-role { color: rgba(255,255,255,.5); font-size: 11.5px; }
.sidebar-user-logout {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--crm-r-sm);
  color: rgba(255,255,255,.55);
  font-size: 16px;
  text-decoration: none;
  transition: color var(--crm-t), background var(--crm-t);
}
.sidebar-user-logout:hover,
.sidebar-user-logout:focus-visible {
  color: #f87171;
  background: rgba(248,113,113,.12);
}

/* ══════════════════════════════════════════════════════════════════════════════
   5. CONTENT AREA
   ══════════════════════════════════════════════════════════════════════════════ */
.app-content-header {
  background: transparent;
  border-bottom: 0;
  padding: 1.1rem 0 .1rem;
}
.app-content-header h3 {
  font-family: var(--crm-font-display); font-optical-sizing: auto;
  font-size: 22px; font-weight: 600; color: var(--crm-ink); letter-spacing: -.015em;
}
.app-content { padding: 1.25rem 1.25rem 1.5rem; }

/* Footer */
.app-footer {
  border-top: 1px solid var(--crm-border);
  background: var(--crm-surface) !important;
  color: var(--crm-muted);
  font-size: 12.5px;
  padding: .8rem 1.25rem;
}
.app-footer a { color: var(--crm-muted); }
.app-footer a:hover { color: var(--crm-accent-ink); }

/* ══════════════════════════════════════════════════════════════════════════════
   6. CARDS — flat surfaces, hairline borders, no hover theatrics
   ══════════════════════════════════════════════════════════════════════════════ */
.app-main .card {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-r);
  box-shadow: var(--crm-s1);
  transition: border-color var(--crm-t);
  overflow: hidden;
}

.app-main .card > .card-header {
  background: transparent;
  border-bottom: 1px solid var(--crm-border);
  padding: .95rem 1.25rem .85rem;
}
.app-main .card > .card-header .card-title {
  font-size: 14px; font-weight: 600; color: var(--crm-ink);
  margin: 0; letter-spacing: -.01em;
}
.app-main .card > .card-body { padding: 1.25rem; }
.app-main .card > .card-body.p-0 { padding: 0 !important; }

.app-main .btn-tool { color: var(--crm-faint); border-radius: var(--crm-r-sm); transition: all var(--crm-t); }
.app-main .btn-tool:hover { color: var(--crm-ink); background: var(--crm-surface-2); }

/* ══════════════════════════════════════════════════════════════════════════════
   7. INFO-BOXES (stat widgets) — tinted icon chips instead of gradients
   ══════════════════════════════════════════════════════════════════════════════ */
.app-main .info-box {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-r);
  box-shadow: var(--crm-s1);
  padding: 16px 18px;
  min-height: auto;
  overflow: hidden;
}

.app-main .info-box .info-box-icon {
  width: 48px; height: 48px; border-radius: var(--crm-r-sm);
  font-size: 20px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: none;
}
.app-main .info-box .info-box-content { padding: 0 0 0 14px; display: flex; flex-direction: column; justify-content: center; }
.app-main .info-box .info-box-text   { font-size: 11px; color: var(--crm-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.app-main .info-box .info-box-number { font-size: 24px; font-weight: 700; color: var(--crm-ink); line-height: 1.15; letter-spacing: -.02em; }

/* Tinted icon chips (soft background + emphasized icon color) */
.app-main .info-box-icon.text-bg-primary   { background: var(--bs-primary-bg-subtle) !important;  color: var(--bs-primary-text-emphasis) !important; }
.app-main .info-box-icon.text-bg-success   { background: var(--bs-success-bg-subtle) !important;  color: var(--bs-success-text-emphasis) !important; }
.app-main .info-box-icon.text-bg-warning   { background: var(--bs-warning-bg-subtle) !important;  color: var(--bs-warning-text-emphasis) !important; }
.app-main .info-box-icon.text-bg-danger    { background: var(--bs-danger-bg-subtle) !important;   color: var(--bs-danger-text-emphasis) !important; }
.app-main .info-box-icon.text-bg-info      { background: var(--bs-info-bg-subtle) !important;     color: var(--bs-info-text-emphasis) !important; }
.app-main .info-box-icon.text-bg-secondary { background: var(--crm-surface-2) !important;         color: var(--crm-muted) !important; }

/* Clickable info-box: a stat card that doubles as a filter (Guests module).
   It is a real <button> for keyboard and screen-reader use, so drop the
   native button chrome and let the .info-box card styling above show. */
.app-main .info-box.info-box-link {
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.app-main .info-box.info-box-link:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   8. SMALL-BOX — flattened from solid gradients to tinted surfaces
   ══════════════════════════════════════════════════════════════════════════════ */
.app-main .small-box {
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-r);
  box-shadow: var(--crm-s1);
  overflow: hidden;
}
.app-main .small-box > .inner h3 { font-weight: 700; letter-spacing: -.02em; }

.app-main .small-box.text-bg-primary   { background: var(--bs-primary-bg-subtle) !important;  color: var(--bs-primary-text-emphasis) !important;  border-color: var(--bs-primary-border-subtle); }
.app-main .small-box.text-bg-success   { background: var(--bs-success-bg-subtle) !important;  color: var(--bs-success-text-emphasis) !important;  border-color: var(--bs-success-border-subtle); }
.app-main .small-box.text-bg-warning   { background: var(--bs-warning-bg-subtle) !important;  color: var(--bs-warning-text-emphasis) !important;  border-color: var(--bs-warning-border-subtle); }
.app-main .small-box.text-bg-danger    { background: var(--bs-danger-bg-subtle) !important;   color: var(--bs-danger-text-emphasis) !important;   border-color: var(--bs-danger-border-subtle); }
.app-main .small-box.text-bg-info      { background: var(--bs-info-bg-subtle) !important;     color: var(--bs-info-text-emphasis) !important;     border-color: var(--bs-info-border-subtle); }
.app-main .small-box.text-bg-secondary { background: var(--crm-surface-2) !important;         color: var(--crm-ink) !important; }

/* Inner text/icon/footer inherit the tinted emphasis color */
.app-main .small-box .small-box-icon { color: currentColor; opacity: .18; }
.app-main .small-box .small-box-footer,
.app-main .small-box .small-box-footer.text-light,
.app-main .small-box .text-light {
  color: inherit !important;
  opacity: .78;
  background: rgba(0,0,0,.04);
}
[data-bs-theme="dark"] .app-main .small-box .small-box-footer,
[data-bs-theme="dark"] .app-main .small-box .text-light { background: rgba(255,255,255,.04); }

/* ══════════════════════════════════════════════════════════════════════════════
   9. TABLES — light row separators, no grid, comfortable padding
   ══════════════════════════════════════════════════════════════════════════════ */
/* Bootstrap paints every cell with --bs-table-bg, which defaults to
   --bs-body-bg (#212529 in AdminLTE's dark theme) — a warm grey that sat as an
   opaque slab over the cool --crm-surface card behind it. Light theme hid the
   bug because there --bs-body-bg is #fff, the same as --crm-surface. Going
   transparent lets a table take whatever surface it is placed on, in both
   themes; the striped/hover states below are painted separately and unaffected. */
.app-main .table, .modal .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--crm-ink);
  color: var(--crm-ink);
  font-size: 13px;   /* every module used to set this per table, and the ones that forgot sat at 16px */
}
/* Nested detail tables (guest history, balance ledgers) run one step denser. */
.app-main .table.crm-table-dense, .modal .table.crm-table-dense { font-size: 12px; }
.app-main .table > thead.table-light th,
.app-main .table > thead th {
  background: transparent;
  color: var(--crm-muted);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--crm-border);
  padding: .6rem 1rem;
  white-space: nowrap;
}
.app-main .table > tbody td {
  vertical-align: middle;
  border-color: var(--crm-row-line);
  padding: .72rem 1rem;
  color: var(--crm-ink);
}
.app-main .table-hover > tbody > tr { transition: background var(--crm-t); }
.app-main .table-hover > tbody > tr:hover > * { background: var(--crm-surface-2); }

[data-bs-theme="dark"] .app-main .table > thead.table-light th,
[data-bs-theme="dark"] .app-main .table > thead th {
  background: transparent;
  border-bottom-color: var(--crm-border);
  color: var(--crm-muted);
}
[data-bs-theme="dark"] .app-main .table > tbody td { border-color: var(--crm-row-line); }
[data-bs-theme="dark"] .app-main .table-hover > tbody > tr:hover > * { background: var(--crm-surface-2); }

/* .table-light hardcodes #f8f9fa. The <thead class="table-light"> in .app-main
   is overridden above, but it is also used on modal theads (outside that scope)
   and on the day-separator <tr class="table-light"> rows in the bookings
   arrivals list, where it painted a white band across a dark table. Re-point the
   variant at the dark surface tokens rather than editing 23 call sites. The
   standalone print views are deliberately left out — they should stay light. */
[data-bs-theme="dark"] .app-main .table-light,
[data-bs-theme="dark"] .modal .table-light {
  --bs-table-color: var(--crm-ink);
  --bs-table-bg: var(--crm-surface-2);
  --bs-table-border-color: var(--crm-border);
  --bs-table-striped-color: var(--crm-ink);
  --bs-table-striped-bg: var(--crm-surface-2);
  --bs-table-active-color: var(--crm-ink);
  --bs-table-active-bg: var(--crm-surface-2);
  --bs-table-hover-color: var(--crm-ink);
  --bs-table-hover-bg: var(--crm-surface-2);
}

/* ══════════════════════════════════════════════════════════════════════════════
   10. BUTTONS — flat triad: solid primary / neutral secondary / ghost outline
   ══════════════════════════════════════════════════════════════════════════════ */
.app-main .btn, .modal .btn { border-radius: var(--crm-r-sm); font-weight: 600; font-size: 13px; transition: all var(--crm-t); }
.app-main .btn-sm, .modal .btn-sm { font-size: 12.5px; }

.app-main .btn-primary, .modal .btn-primary {
  --bs-btn-bg: var(--crm-primary);
  --bs-btn-border-color: var(--crm-primary);
  --bs-btn-hover-bg: var(--crm-primary-dark);
  --bs-btn-hover-border-color: var(--crm-primary-dark);
  --bs-btn-active-bg: var(--crm-primary-dark);
  --bs-btn-active-border-color: var(--crm-primary-dark);
  --bs-btn-disabled-bg: var(--crm-primary);
  --bs-btn-disabled-border-color: var(--crm-primary);
  --bs-btn-focus-shadow-rgb: var(--crm-primary-rgb);
  background-image: none;
  box-shadow: none;
}
.app-main .btn-primary:hover, .modal .btn-primary:hover { box-shadow: var(--crm-s2); }

/* Neutral secondary (modal Cancel etc.) */
.app-main .btn-secondary, .modal .btn-secondary {
  --bs-btn-bg: var(--crm-surface-2);
  --bs-btn-color: var(--crm-ink);
  --bs-btn-border-color: var(--crm-border);
  --bs-btn-hover-bg: color-mix(in srgb, var(--crm-ink) 7%, var(--crm-surface-2));
  --bs-btn-hover-color: var(--crm-ink);
  --bs-btn-hover-border-color: var(--crm-border);
  --bs-btn-active-bg: color-mix(in srgb, var(--crm-ink) 10%, var(--crm-surface-2));
  --bs-btn-active-color: var(--crm-ink);
  --bs-btn-active-border-color: var(--crm-border);
}

/* Ghost accent */
.app-main .btn-outline-primary, .modal .btn-outline-primary {
  --bs-btn-color: var(--crm-accent-ink);
  --bs-btn-border-color: color-mix(in srgb, var(--crm-primary) 35%, transparent);
  --bs-btn-hover-color: var(--crm-accent-ink);
  --bs-btn-hover-bg: var(--crm-primary-soft);
  --bs-btn-hover-border-color: color-mix(in srgb, var(--crm-primary) 45%, transparent);
  --bs-btn-active-color: var(--crm-accent-ink);
  --bs-btn-active-bg: var(--crm-primary-glow);
  --bs-btn-active-border-color: color-mix(in srgb, var(--crm-primary) 45%, transparent);
}

/* Ghost neutral */
.app-main .btn-outline-secondary, .modal .btn-outline-secondary {
  --bs-btn-color: var(--crm-muted);
  --bs-btn-border-color: var(--crm-border);
  --bs-btn-hover-color: var(--crm-ink);
  --bs-btn-hover-bg: var(--crm-surface-2);
  --bs-btn-hover-border-color: color-mix(in srgb, var(--crm-muted) 40%, var(--crm-border));
  --bs-btn-active-color: var(--crm-ink);
  --bs-btn-active-bg: var(--crm-surface-2);
  --bs-btn-active-border-color: var(--crm-border);
}

/* Semantic buttons — muted palette, flat */
.app-main .btn-success, .modal .btn-success {
  --bs-btn-bg: var(--crm-success); --bs-btn-border-color: var(--crm-success);
  --bs-btn-hover-bg: color-mix(in srgb, var(--crm-success) 85%, #000);
  --bs-btn-hover-border-color: color-mix(in srgb, var(--crm-success) 85%, #000);
  --bs-btn-active-bg: color-mix(in srgb, var(--crm-success) 80%, #000);
  --bs-btn-active-border-color: color-mix(in srgb, var(--crm-success) 80%, #000);
  --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff;
}
.app-main .btn-danger, .modal .btn-danger {
  --bs-btn-bg: var(--crm-danger); --bs-btn-border-color: var(--crm-danger);
  --bs-btn-hover-bg: color-mix(in srgb, var(--crm-danger) 85%, #000);
  --bs-btn-hover-border-color: color-mix(in srgb, var(--crm-danger) 85%, #000);
  --bs-btn-active-bg: color-mix(in srgb, var(--crm-danger) 80%, #000);
  --bs-btn-active-border-color: color-mix(in srgb, var(--crm-danger) 80%, #000);
  --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff;
}
.app-main .btn-warning, .modal .btn-warning {
  --bs-btn-bg: var(--crm-warning); --bs-btn-border-color: var(--crm-warning);
  --bs-btn-hover-bg: color-mix(in srgb, var(--crm-warning) 85%, #000);
  --bs-btn-hover-border-color: color-mix(in srgb, var(--crm-warning) 85%, #000);
  --bs-btn-active-bg: color-mix(in srgb, var(--crm-warning) 80%, #000);
  --bs-btn-active-border-color: color-mix(in srgb, var(--crm-warning) 80%, #000);
}
.app-main .btn-info, .modal .btn-info {
  --bs-btn-bg: var(--crm-info); --bs-btn-border-color: var(--crm-info);
  --bs-btn-hover-bg: color-mix(in srgb, var(--crm-info) 85%, #000);
  --bs-btn-hover-border-color: color-mix(in srgb, var(--crm-info) 85%, #000);
  --bs-btn-active-bg: color-mix(in srgb, var(--crm-info) 80%, #000);
  --bs-btn-active-border-color: color-mix(in srgb, var(--crm-info) 80%, #000);
  --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff;
}

.app-main .btn-group .btn { border-radius: var(--crm-r-sm); }

/* ══════════════════════════════════════════════════════════════════════════════
   11. BADGES
   ══════════════════════════════════════════════════════════════════════════════ */
.app-main .badge {
  font-weight: 600; letter-spacing: .01em;
  padding: .3em .6em; border-radius: 6px; font-size: 11.5px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   12. FORMS
   ══════════════════════════════════════════════════════════════════════════════ */
.app-main .form-control,
.app-main .form-select,
.app-main .input-group-text {
  border-radius: var(--crm-r-sm);
  border-color: var(--crm-border);
  background: var(--crm-surface);
  color: var(--crm-ink);
  font-size: 13.5px;
  transition: border-color var(--crm-t), box-shadow var(--crm-t), background var(--crm-t);
}
.app-main .input-group > .form-control,
.app-main .input-group > .form-select { border-radius: 0; }
.app-main .input-group > :first-child { border-top-left-radius: var(--crm-r-sm); border-bottom-left-radius: var(--crm-r-sm); }
.app-main .input-group > :last-child  { border-top-right-radius: var(--crm-r-sm); border-bottom-right-radius: var(--crm-r-sm); }
.app-main .form-control:hover:not(:focus),
.app-main .form-select:hover:not(:focus) { border-color: color-mix(in srgb, var(--crm-muted) 35%, var(--crm-border)); }
.app-main .form-control:focus,
.app-main .form-select:focus {
  border-color: var(--crm-primary);
  box-shadow: 0 0 0 3px var(--crm-primary-soft);
  background: var(--crm-surface);
  color: var(--crm-ink);
}
.app-main .form-label { color: var(--crm-ink); font-weight: 500; font-size: 13px; }
.app-main .form-text  { color: var(--crm-muted); font-size: 12px; }

.app-main .form-check-input:checked { background-color: var(--crm-primary); border-color: var(--crm-primary); }
.app-main .form-check-input:focus  { border-color: var(--crm-primary); box-shadow: 0 0 0 3px var(--crm-primary-soft); }

[data-bs-theme="dark"] .app-main .form-control,
[data-bs-theme="dark"] .app-main .form-select,
[data-bs-theme="dark"] .app-main .input-group-text {
  background: var(--crm-surface-2);
  border-color: var(--crm-border);
  color: var(--crm-ink);
}
[data-bs-theme="dark"] .app-main .form-control:focus,
[data-bs-theme="dark"] .app-main .form-select:focus {
  background: var(--crm-surface-2);
}
[data-bs-theme="dark"] .app-main .form-control::placeholder { color: var(--crm-faint); }

/* ══════════════════════════════════════════════════════════════════════════════
   13. TABS
   ══════════════════════════════════════════════════════════════════════════════ */
.app-main .nav-tabs { border-bottom: 1px solid var(--crm-border); gap: 2px; }
.app-main .nav-tabs .nav-link {
  border: 0; color: var(--crm-muted); font-weight: 500; font-size: 13.5px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  border-radius: 0; padding: .6rem 1rem;
  transition: color var(--crm-t), border-color var(--crm-t);
}
.app-main .nav-tabs .nav-link:hover { color: var(--crm-ink); }
.app-main .nav-tabs .nav-link.active {
  color: var(--crm-accent-ink); background: transparent; font-weight: 600;
  border-bottom-color: var(--crm-primary);
}

/* ══════════════════════════════════════════════════════════════════════════════
   14. MODALS
   ══════════════════════════════════════════════════════════════════════════════ */

.modal-content {
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-r-lg);
  overflow: hidden;
  box-shadow: var(--crm-s4);
  background: var(--crm-surface);
}

.modal-header {
  padding: 1.05rem 1.4rem;
  border-bottom: 1px solid var(--crm-border);
  background: var(--crm-surface);
  color: var(--crm-ink);
}
.modal-header .modal-title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }

/* One header style for every modal. Most module markup still carries
   .bg-primary/.bg-success/.bg-warning/.bg-danger + .text-white from before the
   flat design, and Integrations swaps success/danger from JS on its test
   result, so the variant is honoured here rather than stripped from the
   markup: the header stays on the surface like the confirm dialog, and the
   variant survives as a tinted title icon plus, for anything but primary, a
   3px accent along the top edge. The inset shadow draws inside the header, so
   the modal's rounded corners still clip it. */
.modal-header[class*="bg-"] {
  background: var(--crm-surface) !important;
  color: var(--crm-ink) !important;
  border-bottom: 1px solid var(--crm-border);
}
.modal-header.bg-primary .modal-title > .bi:first-child { color: var(--crm-accent-ink); }
.modal-header.bg-success { box-shadow: inset 0 3px 0 var(--crm-success); }
.modal-header.bg-success .modal-title > .bi:first-child { color: var(--crm-success); }
.modal-header.bg-warning { box-shadow: inset 0 3px 0 var(--crm-warning); }
.modal-header.bg-warning .modal-title > .bi:first-child { color: var(--crm-warning); }
.modal-header.bg-danger  { box-shadow: inset 0 3px 0 var(--crm-danger); }
.modal-header.bg-danger  .modal-title > .bi:first-child { color: var(--crm-danger); }
/* .btn-close-white was only there for the coloured band. */
.modal-header .btn-close-white { filter: none; }
[data-bs-theme="dark"] .modal-header .btn-close-white { filter: var(--bs-btn-close-white-filter); }

.modal-body {
  padding: 1.4rem;
  background: var(--crm-surface);
  color: var(--crm-ink);
}
.modal-footer {
  border-top: 1px solid var(--crm-border);
  padding: .9rem 1.4rem;
  background: var(--crm-surface-2);
}

[data-bs-theme="dark"] .modal-header { background: var(--crm-surface); }
[data-bs-theme="dark"] .modal-body   { background: var(--crm-surface); }
[data-bs-theme="dark"] .modal-footer { background: var(--crm-surface-2); }

/* ══════════════════════════════════════════════════════════════════════════════
   15. DROPDOWNS
   ══════════════════════════════════════════════════════════════════════════════ */
.dropdown-menu {
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-r);
  box-shadow: var(--crm-s3);
  padding: .35rem;
  background: var(--crm-surface);
  animation: dropIn .14s cubic-bezier(.4,0,.2,1);
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: none; }
}
.dropdown-item {
  border-radius: var(--crm-r-sm); font-size: 13.5px; color: var(--crm-ink);
  padding: .5rem .85rem;
  transition: background var(--crm-t);
}
.dropdown-item:hover, .dropdown-item:focus { background: var(--crm-surface-2); color: var(--crm-ink); }
.dropdown-divider { border-color: var(--crm-border); margin: .35rem 0; }
.dropdown-header {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--crm-faint); padding: .5rem .85rem;
}
/* Avatar-only account toggle: it is the whole click target now, so give it a
   visible hover/open state instead of the name that used to sit beside it. */
.crm-user-toggle { padding: .35rem .4rem; line-height: 0; }
.crm-nav-avatar {
  box-shadow: 0 0 0 2px transparent;
  transition: box-shadow var(--crm-t);
}
.crm-user-toggle:hover .crm-nav-avatar,
.crm-user-toggle:focus-visible .crm-nav-avatar,
.crm-user-toggle.show .crm-nav-avatar {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--crm-primary) 45%, transparent);
}

/* User menu. AdminLTE styles this header for a light background and never sets
   a text colour, so the name and role inherited the dark body ink and read
   almost black on the purple. Its 175px min-height also left a slab of empty
   purple under the role. These selectors match AdminLTE's own specificity so
   the overrides actually land. */
.navbar-nav > .user-menu > .dropdown-menu {
  overflow: hidden;                 /* clip the purple to the rounded corners */
  border-radius: var(--crm-r);
}
.navbar-nav > .user-menu > .dropdown-menu > li.user-header {
  min-height: 0;
  padding: 20px 16px 18px;
  text-align: center;
  background: var(--crm-primary) !important;
  color: #fff;
}
.crm-user-avatar { box-shadow: 0 0 0 3px rgba(255,255,255,.25); }
/* AdminLTE sizes this <p> at 17px from a 4-class selector, so match it. */
.navbar-nav > .user-menu > .dropdown-menu > li.user-header > p.crm-user-name {
  margin-top: 0;
  font-size: 15px; font-weight: 600; line-height: 1.3; color: #fff;
  word-break: break-word;
}
.crm-user-role {
  display: block; margin-top: 3px;
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: rgba(255,255,255,.78);
}
.navbar-nav > .user-menu > .dropdown-menu > .user-footer {
  display: flex; gap: .5rem;
  padding: 10px;
  background: var(--crm-surface-2);
  border-top: 1px solid var(--crm-border);
}
/* Bootstrap's own outline greys are dim on the dark surface, and the CRM
   .btn-outline-* overrides are scoped to .app-main/.modal, so style these here. */
.navbar-nav > .user-menu > .dropdown-menu > .user-footer .btn {
  flex: 1 1 0;
  font-size: 12.5px; font-weight: 600;
  border-radius: var(--crm-r-sm);
  border: 1px solid var(--crm-border);
  background: var(--crm-surface);
  color: var(--crm-ink);
  transition: background var(--crm-t), color var(--crm-t), border-color var(--crm-t);
}
.navbar-nav > .user-menu > .dropdown-menu > .user-footer .btn:hover {
  background: var(--crm-primary-soft);
  border-color: color-mix(in srgb, var(--crm-primary) 30%, transparent);
  color: var(--crm-accent-ink);
}
.navbar-nav > .user-menu > .dropdown-menu > .user-footer .btn-outline-danger { color: var(--crm-danger); }
.navbar-nav > .user-menu > .dropdown-menu > .user-footer .btn-outline-danger:hover {
  background: color-mix(in srgb, var(--crm-danger) 10%, var(--crm-surface));
  border-color: color-mix(in srgb, var(--crm-danger) 32%, transparent);
  color: var(--crm-danger);
}
[data-bs-theme="dark"] .dropdown-menu { background: var(--crm-surface); border-color: var(--crm-border); }

/* ══════════════════════════════════════════════════════════════════════════════
   16. ALERTS — derived from semantic tokens, adapts to both themes
   ══════════════════════════════════════════════════════════════════════════════ */
.app-main .alert { border-radius: var(--crm-r-sm); border: 1px solid; font-size: 13.5px; }
.app-main .alert-success {
  background: color-mix(in srgb, var(--crm-success) 8%, var(--crm-surface));
  color: color-mix(in srgb, var(--crm-success) 70%, var(--crm-ink));
  border-color: color-mix(in srgb, var(--crm-success) 25%, var(--crm-surface));
}
.app-main .alert-danger {
  background: color-mix(in srgb, var(--crm-danger) 7%, var(--crm-surface));
  color: color-mix(in srgb, var(--crm-danger) 70%, var(--crm-ink));
  border-color: color-mix(in srgb, var(--crm-danger) 25%, var(--crm-surface));
}
.app-main .alert-warning {
  background: color-mix(in srgb, var(--crm-warning) 8%, var(--crm-surface));
  color: color-mix(in srgb, var(--crm-warning) 65%, var(--crm-ink));
  border-color: color-mix(in srgb, var(--crm-warning) 28%, var(--crm-surface));
}
.app-main .alert-info {
  background: color-mix(in srgb, var(--crm-info) 8%, var(--crm-surface));
  color: color-mix(in srgb, var(--crm-info) 70%, var(--crm-ink));
  border-color: color-mix(in srgb, var(--crm-info) 25%, var(--crm-surface));
}

/* Callouts */
.app-main .callout {
  border: 1px solid var(--crm-border); border-left-width: 3px;
  border-radius: var(--crm-r-sm); background: var(--crm-surface); box-shadow: none;
}

/* ══════════════════════════════════════════════════════════════════════════════
   17. DATATABLES
   ══════════════════════════════════════════════════════════════════════════════ */
.app-main .dataTables_wrapper .dataTables_filter input {
  border-radius: var(--crm-r-sm); border: 1px solid var(--crm-border);
  background: var(--crm-surface); color: var(--crm-ink);
  padding: 4px 10px; font-size: 13px;
  transition: border-color var(--crm-t), box-shadow var(--crm-t);
}
.app-main .dataTables_wrapper .dataTables_filter input:focus {
  outline: none; border-color: var(--crm-primary); box-shadow: 0 0 0 3px var(--crm-primary-soft);
}

/* ── Layout: the table scrolls, the controls don't ──────────────────────────
   admin/index.php gives every DataTable the same `dom`:
     .crm-dt-top     search box (hidden when the table has searching off)
     .crm-dt-scroll  the <table>, and the only thing that pans sideways
     .crm-dt-footer  Show N · Showing X–Y of Z · pager — a copy of the
                     Audit Logs card-footer (logs/index.php)
   Previously info + pager sat inside the same .table-responsive as the
   table, so any overflow at all drew a scrollbar under the pager. */

/* Module markup wraps each table in .table-responsive. Once DataTables has
   taken it over, .crm-dt-scroll does the scrolling; left alone, the outer
   one would scroll the footer along with the table. */
.app-main .table-responsive:has(> .dataTables_wrapper) { overflow: visible; }
.app-main .dataTables_wrapper .crm-dt-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* autoWidth writes a measured pixel width onto the <table>, and it came out
   3px wider than its container — on its own enough to raise the scrollbar.
   width:100% is a floor for a table, not a cap, so one that really needs
   more room still grows and scrolls. The margin reset drops DataTables' 6px
   so the table meets the card header and footer like the logs table does. */
.app-main .dataTables_wrapper .crm-dt-scroll > table.dataTable {
  width: 100% !important;
  margin: 0 !important;
}

.app-main .dataTables_wrapper .crm-dt-top {
  display: flex; justify-content: flex-end;
  padding: .85rem 1rem .75rem;
}
.app-main .dataTables_wrapper .crm-dt-top:empty { display: none; }

/* Bootstrap's own .card-footer tokens, so the bar tracks the Audit Logs
   footer exactly in both themes. The "Show" select is left to the generic
   .form-select rules (DataTables gives it form-select-sm), which is what the
   logs page's own select uses. */
.app-main .dataTables_wrapper .crm-dt-footer {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  padding: var(--bs-card-cap-padding-y) var(--bs-card-cap-padding-x);
  background-color: var(--bs-card-cap-bg);
  border-top: var(--bs-card-border-width) solid var(--bs-card-border-color);
}
.app-main .dataTables_wrapper .crm-dt-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
}
.app-main .dataTables_wrapper .crm-dt-footer .dataTables_length label {
  display: flex; align-items: center; gap: .5rem; margin: 0;
  font-size: .875em; color: var(--bs-secondary-color);
}
.app-main .dataTables_wrapper .crm-dt-footer .dataTables_info {
  padding-top: 0;
  font-size: .875em; color: var(--bs-secondary-color);
}
.app-main .dataTables_wrapper .crm-dt-footer .dataTables_paginate { margin-left: auto; }
.app-main .dataTables_wrapper .crm-dt-footer .dataTables_paginate .pagination { margin: 0; }

/* Pagination — one uniform style for every table in the CRM.
   DataTables runs with the Bootstrap 5 integration (see admin/index.php),
   so its pager renders as ul.pagination > li.page-item > a.page-link —
   the same markup the logs module builds by hand (#logsPagination).
   Styling .pagination generically keeps them identical, and the explicit
   padding/font-size below also neutralizes size variants (.pagination-sm). */
.app-main .pagination { margin-bottom: 0; gap: 4px; }
.app-main .pagination .page-link {
  border-radius: var(--crm-r-sm) !important;
  border: 1px solid transparent;
  margin-left: 0;
  background: transparent;
  color: var(--crm-muted);
  font-size: 13px;
  line-height: 1.4;
  padding: 4px 10px;
  box-shadow: none !important;
  transition: all var(--crm-t);
}
.app-main .pagination .page-item:not(.active):not(.disabled) .page-link:hover {
  background: var(--crm-surface-2); border-color: var(--crm-border); color: var(--crm-ink);
}
.app-main .pagination .page-item.active .page-link {
  background: var(--crm-primary); border-color: var(--crm-primary); color: #fff;
}
.app-main .pagination .page-item.disabled .page-link,
.app-main .pagination .page-item.disabled .page-link:hover {
  background: transparent; border-color: transparent;
  color: var(--crm-faint); cursor: not-allowed;
}

[data-bs-theme="dark"] .app-main .dataTables_wrapper .dataTables_filter input {
  background: var(--crm-surface-2); border-color: var(--crm-border); color: var(--crm-ink);
}

/* ══════════════════════════════════════════════════════════════════════════════
   18. TOAST
   ══════════════════════════════════════════════════════════════════════════════ */
/* One fixed stack (admin/index.php appends it once), newest at the bottom,
   so several toasts at once no longer sit on top of each other. */
.crm-toast-stack {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  pointer-events: none;
}
.crm-toast {
  pointer-events: auto;
  min-width: 240px; max-width: 360px;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-r-sm);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 11px;
  box-shadow: var(--crm-s3);
  border-left: 3px solid;
  font-size: 13.5px; font-weight: 500;
  color: var(--crm-ink);
  animation: toastIn .2s cubic-bezier(.4,0,.2,1);
  transition: opacity var(--crm-t), transform var(--crm-t);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px) translateY(3px); }
  to   { opacity: 1; transform: none; }
}
.crm-toast-msg   { flex: 1; min-width: 0; }
.crm-toast-close { flex-shrink: 0; width: .6em; height: .6em; opacity: .5; }
.crm-toast-close:hover { opacity: .9; }

/* ══════════════════════════════════════════════════════════════════════════════
   19. EMPTY STATES
   ══════════════════════════════════════════════════════════════════════════════ */
.app-main .crm-empty,
.app-main .text-center.text-muted.py-4,
.app-main .text-center.text-muted.py-5 { color: var(--crm-faint) !important; }

/* ══════════════════════════════════════════════════════════════════════════════
   20. PROGRESS BARS
   ══════════════════════════════════════════════════════════════════════════════ */
.progress { border-radius: 99px; overflow: hidden; background: var(--crm-border); height: 6px; }
.progress-bar { transition: width .8s cubic-bezier(.4,0,.2,1) .1s; border-radius: 99px; }

/* ══════════════════════════════════════════════════════════════════════════════
   21. DASHBOARD — KPI CARDS (flat, tinted icon chips)
   ══════════════════════════════════════════════════════════════════════════════ */
/* .kpi-row is the same card outside the dashboard (Settings → Referral).
   :is() takes the specificity of its strongest argument, so these rules keep
   the #kpiRow weight they always had and nothing overriding them elsewhere
   starts losing. */
:is(#kpiRow, .kpi-row) .kpi-card {
  display: flex; align-items: center; gap: 15px;
  background: var(--crm-surface); border-radius: var(--crm-r); padding: 18px 20px;
  box-shadow: var(--crm-s1);
  border: 1px solid var(--crm-border);
  transition: border-color var(--crm-t);
  overflow: hidden;
}
#kpiRow a:hover .kpi-card,
.kpi-row button.kpi-card:hover,
.kpi-row button.kpi-card:focus-visible {
  border-color: color-mix(in srgb, var(--crm-primary) 30%, var(--crm-border));
}

/* A .kpi-row card is itself the <button>, not wrapped in a link. Undo the UA
   button styling so it renders exactly like the dashboard's cards. */
.kpi-row button.kpi-card {
  width: 100%; height: 100%; text-align: left;
  font: inherit; color: inherit; cursor: pointer;
}
.kpi-row button.kpi-card:focus-visible { outline: 2px solid var(--crm-primary); outline-offset: 2px; }
.kpi-row .kpi-body { min-width: 0; flex: 1 1 auto; }   /* a long "$100 + €50" wraps instead of stretching */

/* Chevron that says "this opens something". Faint until hover, so four of
   them do not shout, but always there so the cards never read as static. */
.kpi-row .kpi-go { color: var(--crm-muted); opacity: .4; transition: opacity var(--crm-t), transform var(--crm-t); }
.kpi-row button.kpi-card:hover .kpi-go,
.kpi-row button.kpi-card:focus-visible .kpi-go { opacity: 1; transform: translateX(2px); }

:is(#kpiRow, .kpi-row) .kpi-icon {
  width: 46px; height: 46px; border-radius: var(--crm-r-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}

:is(#kpiRow, .kpi-row) .kpi-primary .kpi-icon { background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); }
:is(#kpiRow, .kpi-row) .kpi-success .kpi-icon { background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
:is(#kpiRow, .kpi-row) .kpi-warning .kpi-icon { background: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); }
:is(#kpiRow, .kpi-row) .kpi-danger  .kpi-icon { background: var(--bs-danger-bg-subtle);  color: var(--bs-danger-text-emphasis); }
:is(#kpiRow, .kpi-row) .kpi-info    .kpi-icon { background: var(--bs-info-bg-subtle);    color: var(--bs-info-text-emphasis); }
/* Nothing to act on: a zero count, or a programme that is switched off. */
:is(#kpiRow, .kpi-row) .kpi-muted   .kpi-icon { background: var(--bs-secondary-bg-subtle); color: var(--bs-secondary-text-emphasis); }

:is(#kpiRow, .kpi-row) .kpi-value { font-size: 26px; font-weight: 700; line-height: 1.1; color: var(--crm-ink); letter-spacing: -.02em; }
:is(#kpiRow, .kpi-row) .kpi-label { font-size: 11.5px; font-weight: 600; color: var(--crm-muted); margin-top: 3px; text-transform: uppercase; letter-spacing: .05em; }
:is(#kpiRow, .kpi-row) .kpi-delta { font-size: 11.5px; font-weight: 500; margin-top: 5px; }

/* ══════════════════════════════════════════════════════════════════════════════
   22. DASHBOARD — MODULE TILES
   ══════════════════════════════════════════════════════════════════════════════ */
.module-tile {
  display: flex; align-items: center; gap: 13px; padding: 13px 15px;
  background: var(--crm-surface); border: 1px solid var(--crm-border); border-radius: var(--crm-r); height: 100%;
  transition: border-color var(--crm-t);
  text-decoration: none;
}
.module-tile:hover {
  border-color: color-mix(in srgb, var(--crm-primary) 35%, var(--crm-border));
}
.module-tile-icon {
  width: 40px; height: 40px; border-radius: var(--crm-r-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.module-tile-title { display: block; font-size: 13.5px; font-weight: 600; color: var(--crm-ink); }
.module-tile-meta  { display: block; font-size: 11px; color: var(--crm-faint); margin-top: 1px; }
.module-tile-chevron { color: var(--crm-faint); font-size: 13px; transition: transform var(--crm-t), color var(--crm-t); margin-left: auto; }
.module-tile:hover .module-tile-chevron { color: var(--crm-accent-ink); transform: translateX(3px); }

/* ══════════════════════════════════════════════════════════════════════════════
   23. DASHBOARD — HERO GREETING
   ══════════════════════════════════════════════════════════════════════════════ */
.dash-hero {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-r);
  padding: 22px 26px;
}
.dash-hero-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--crm-accent-ink); margin-bottom: 4px;
}
.dash-hero-title {
  font-family: var(--crm-font-display); font-size: 1.5rem; font-weight: 600; color: var(--crm-ink);
  margin: 0 0 4px; letter-spacing: -.02em;
}
.dash-hero-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--crm-surface); border: 1px solid var(--crm-border);
  border-radius: 999px; padding: 5px 14px;
  font-size: 12.5px; font-weight: 500; color: var(--crm-ink);
}
.dash-hero-pill-divider { color: var(--crm-faint); }

/* ══════════════════════════════════════════════════════════════════════════════
   24. GUEST AVATAR
   ══════════════════════════════════════════════════════════════════════════════ */
.guest-initial {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 12px; font-weight: 600; color: #fff; flex-shrink: 0;
  background: var(--crm-primary); overflow: hidden;
}
.guest-initial.inactive { background: var(--crm-faint); }

/* ══════════════════════════════════════════════════════════════════════════════
   25. MOBILE RESPONSIVENESS
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Reduce content padding on small screens ─────────────────────── */
@media (max-width: 767.98px) {
  .app-content { padding: 1rem .75rem; }
  .app-content-header h3 { font-size: 15px; }
}
@media (max-width: 575.98px) {
  .app-content { padding: .75rem .5rem; }
  .app-content-header { padding: .5rem 0; }
}

/* ── Horizontal scroll for dense card tables ─────────────────────── */
/* Targets .card-body.p-0 which is the pattern used for all data tables
   in this CRM (guests, users, roles, bookings). Allows horizontal panning
   on narrower screens before the Responsive extension hides columns. */
@media (max-width: 991.98px) {
  .app-main .card-body.p-0 {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── DataTables: controls layout on mobile ───────────────────────── */
@media (max-width: 575.98px) {
  .app-main .dataTables_wrapper .dataTables_filter {
    flex: 1 1 auto;   /* fill .crm-dt-top so the full-width input below has room */
    text-align: left;
  }
  .app-main .dataTables_wrapper .dataTables_filter label {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .app-main .dataTables_wrapper .dataTables_filter input {
    width: 100%;
    margin-left: 0 !important;
  }
  .app-main .pagination .page-link {
    padding: 3px 7px;
    font-size: 11.5px;
  }
}

/* ── DataTables Responsive child rows ───────────────────────────── */
/* Style the collapsed-column child rows that the Responsive extension
   inserts when columns are hidden at small breakpoints. */
.dtr-details { width: 100%; }
.dtr-details td { padding: .3rem 0; font-size: 12.5px; }
.dtr-title { color: var(--crm-muted); font-weight: 600; text-transform: uppercase;
             font-size: 10.5px; letter-spacing: .04em; width: 35%; }
.dtr-data  { color: var(--crm-ink); }
td.child   { background: var(--crm-surface-2) !important;
             border-bottom: 1px solid var(--crm-border) !important; }
[data-bs-theme="dark"] td.child { background: var(--crm-surface-2) !important; }

/* ── Action bar: filters stack under buttons on xs ───────────────── */
@media (max-width: 575.98px) {
  .d-flex.flex-wrap.gap-2.align-items-center.mb-3 > .ms-auto {
    width: 100%;
    margin-left: 0 !important;
  }
  .d-flex.flex-wrap.gap-2.align-items-center.mb-3 > .ms-auto > .form-select {
    width: 100% !important;
    margin-bottom: .25rem;
  }
  .d-flex.flex-wrap.gap-2.align-items-center.mb-3 > .ms-auto > .d-flex {
    width: 100%;
    flex-wrap: wrap;
  }
  .d-flex.flex-wrap.gap-2.align-items-center.mb-3 > .ms-auto > .d-flex > .form-select {
    flex: 1 1 0;
    min-width: 0;
  }
}

/* ── Bookings filter bar: date pickers on mobile ─────────────────── */
@media (max-width: 767.98px) {
  /* Let the flex-grow inputs wrap when there isn't enough room */
  .card-body .d-flex.flex-wrap.gap-3.align-items-end > div { flex-shrink: 1; }
}
@media (max-width: 575.98px) {
  .card-body .d-flex.flex-wrap.gap-3.align-items-end > div { width: 100%; }
  .card-body .d-flex.flex-wrap.gap-3.align-items-end .d-flex.gap-2 {
    flex-wrap: wrap;
  }
}

/* ── Modals: near-full-width with small margin on phones ─────────── */
@media (max-width: 575.98px) {
  .modal-dialog,
  .modal-dialog.modal-lg,
  .modal-dialog.modal-xl {
    margin: .5rem auto;
    max-width: calc(100vw - 1rem);
  }
  .modal-content {
    border-radius: var(--crm-r-sm);
  }
  .modal-header { padding: .9rem 1rem; }
  .modal-body   { padding: 1rem; }
  .modal-footer { padding: .75rem 1rem; }
  .modal-body .row.g-3 > [class*="col-md"] { width: 100%; }
}

/* ── Toast: stretch to near-full-width on mobile ─────────────────── */
@media (max-width: 575.98px) {
  .crm-toast-stack {
    left: 12px;
    right: 12px;
    bottom: 16px;
    align-items: stretch;
  }
  .crm-toast {
    max-width: none;
    min-width: 0;
  }
}

/* ── KPI / info-box widgets: compact on mobile ───────────────────── */
@media (max-width: 575.98px) {
  :is(#kpiRow, .kpi-row) .kpi-card  { padding: 14px 16px; gap: 12px; }
  :is(#kpiRow, .kpi-row) .kpi-icon  { width: 40px; height: 40px; font-size: 17px; }
  :is(#kpiRow, .kpi-row) .kpi-value { font-size: 22px; }
  /* Dashboard only: its deltas are trend garnish. On .kpi-row the detail line
     is the substance ("$300 owed to members"), so it stays. */
  #kpiRow .kpi-delta   { display: none; }
  .kpi-row .kpi-go     { display: none; }   /* two cards to a row — no room */

  /* Stat rows run two to a row on phones (col-6), so the card gives the
     label room to wrap under a smaller icon instead of clipping it. */
  .app-main .info-box  { padding: 12px; height: 100%; }
  .app-main .info-box .info-box-icon   { width: 36px; height: 36px; font-size: 15px; }
  .app-main .info-box .info-box-content { padding-left: 10px; min-width: 0; }
  .app-main .info-box .info-box-text   { white-space: normal; font-size: 10.5px; line-height: 1.3; }
  .app-main .info-box .info-box-number { font-size: 19px; }
  :is(#kpiRow, .kpi-row) .kpi-card { height: 100%; }
  #kpiRow > [class*="col"] > a { display: block; height: 100%; }   /* dashboard cards sit inside a link */
}

/* ── Dashboard hero: compact on mobile ──────────────────────────── */
@media (max-width: 575.98px) {
  .dash-hero       { padding: 16px; }
  .dash-hero-title { font-size: 1.2rem; }
  .dash-hero-pill  { font-size: 11.5px; padding: 4px 10px; }
}

/* ── Module tiles: denser on mobile ─────────────────────────────── */
@media (max-width: 575.98px) {
  .module-tile { padding: 12px 14px; gap: 10px; }
  .module-tile-icon { width: 36px; height: 36px; font-size: 16px; }
}

/* ── Required form fields: consistent red asterisk marker ───────── */
.required-mark {
  color: var(--crm-danger);
  font-weight: 700;
  margin-left: 2px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   26. MODULE CONVENTIONS — shared pieces modules used to restyle inline
   ══════════════════════════════════════════════════════════════════════════════ */
/* Compact label above a filter or advanced-search field. */
.app-main .form-label.form-label-sm,
.modal .form-label.form-label-sm { font-size: 12px; margin-bottom: .25rem; }

/* Small caps heading over a group of fields or a detail section. */
.crm-eyebrow {
  font-size: 11px; font-weight: 600; color: var(--crm-muted);
  text-transform: uppercase; letter-spacing: .05em;
}

/* Secondary line under a control or inside a card footer. */
.crm-note { font-size: 12px; color: var(--crm-muted); }

/* Recessed panel inside a card or modal: bulk-action bar, merge candidates. */
.crm-panel {
  background: var(--crm-surface-2);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-r-sm);
}

/* Large faint icon at the top of an empty or not-yet-loaded panel. */
.crm-empty-icon { display: block; font-size: 2.5rem; line-height: 1; opacity: .4; margin-bottom: .5rem; }

/* A card header with its own controls (Arrivals, Cruise Manifest): on a
   phone the title takes its own line and the controls share the next. */
@media (max-width: 575.98px) {
  .app-main .card-header.d-flex.flex-wrap > .card-title { width: 100%; }
  .app-main .card-header.d-flex.flex-wrap > .form-select { flex: 1 1 8rem; width: auto !important; min-width: 0; }
}

/* A filter button group too long for a phone (Data Erasures) pans sideways
   inside its own strip rather than pushing the card wider than the screen. */
@media (max-width: 767.98px) {
  .app-main .crm-scroll-group {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    margin-left: 0 !important;
    order: 3;
    flex: 1 1 100%;
  }
  .app-main .crm-scroll-group::-webkit-scrollbar { display: none; }
  .app-main .crm-scroll-group > .btn { white-space: nowrap; flex: 0 0 auto; }
}

/* Integrations: a connection row keeps its actions to the right on desktop;
   on a phone they drop under the details and run left to right, so the
   name and URL keep the full width. */
@media (max-width: 575.98px) {
  .crm-conn-row { flex-wrap: wrap; }
  .crm-conn-row > .crm-conn-actions {
    flex: 1 1 100%;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between;
  }
}

/* Reports draws its bar and donut charts as inline SVG. SVG presentation
   attributes cannot take var(), so the colours live here as classes. */
.rpt-svg-grid     { stroke: var(--crm-border); }
.rpt-svg-axis     { fill: var(--crm-faint); }
.rpt-svg-value    { fill: var(--crm-muted); }
.rpt-svg-total    { fill: var(--crm-ink); }
.rpt-svg-bar      { fill: color-mix(in srgb, var(--crm-primary) 35%, var(--crm-surface)); }
.rpt-svg-bar-now  { fill: var(--crm-primary); }
.rpt-swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  vertical-align: -1px; margin-right: 2px;
}
.rpt-swatch.rpt-svg-bar     { background: color-mix(in srgb, var(--crm-primary) 35%, var(--crm-surface)); }
.rpt-swatch.rpt-svg-bar-now { background: var(--crm-primary); }


/* Touch targets: icon-only table actions sit at 24px on desktop, too small
   to hit reliably with a thumb. Coarse pointers get 36px. */
@media (pointer: coarse) {
  .app-main .table .btn-sm,
  .app-main .btn-group-sm > .btn,
  .app-main .btn-tool { min-width: 36px; min-height: 36px; }
}

/* ── Print (Reports → Print, and Ctrl+P anywhere) ─────────────────
   The page, not the chrome around it. A .crm-print-all tab set prints
   every tab, since a report printed from one tab should not silently
   leave out the other three. */
@media print {
  .app-sidebar, .app-header, .app-footer, .crm-toast-stack,
  .app-main .card-tools, .app-main .btn-tool { display: none !important; }
  .app-wrapper { display: block !important; }
  .app-main { margin: 0 !important; }
  .app-content { padding: 0 !important; }
  .app-main .card, .app-main .info-box { box-shadow: none !important; break-inside: avoid; }
  .crm-print-all > .tab-pane { display: block !important; opacity: 1 !important; margin-bottom: 1rem; }
}

/* ── Sidebar: modules the current role can't access are shown
   locked/greyed instead of being silently omitted, so staff know
   the feature exists rather than assuming it's missing. ─────────── */
.sidebar-menu .nav-link.disabled {
  opacity: .45;
  pointer-events: none;
  user-select: none;
}

/* ══════════════════════════════════════════════════════════════════════════════
   27. SEP 2026 REDESIGN — Guest Profiles, Booking History, Dashboard
       (Natalie's mockups, 25 Sep 2026). Shared by all three, so a stat card
       or a filter chip looks the same wherever it appears.
   ══════════════════════════════════════════════════════════════════════════════ */

/* 3SIXTY tier colours, the ones Gurita uses (Nomad → Xclusive, light to dark).
   Fixed rather than derived from the Primary Color: they identify a tier, and
   the reservation team reads them across both systems. White text on each. */
:root {
  --crm-tier-nomad:    #6a9fc4;
  --crm-tier-member:   #3b76a3;
  --crm-tier-world:    #43509c;
  --crm-tier-xclusive: #26356a;
}
.crm-tier {
  display: inline-block; padding: 3px 9px; border-radius: 6px; color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap; line-height: 1.3;
}
.crm-tier-nomad    { background: var(--crm-tier-nomad); }
.crm-tier-member   { background: var(--crm-tier-member); }
.crm-tier-world    { background: var(--crm-tier-world); }
.crm-tier-xclusive { background: var(--crm-tier-xclusive); }
.crm-tier-text-nomad    { color: var(--crm-tier-nomad); }
.crm-tier-text-member   { color: var(--crm-tier-member); }
.crm-tier-text-world    { color: var(--crm-tier-world); }
.crm-tier-text-xclusive { color: var(--crm-tier-xclusive); }
[data-bs-theme="dark"] .crm-tier-text-member   { color: color-mix(in srgb, var(--crm-tier-member) 55%, #fff); }
[data-bs-theme="dark"] .crm-tier-text-world    { color: color-mix(in srgb, var(--crm-tier-world) 50%, #fff); }
[data-bs-theme="dark"] .crm-tier-text-xclusive { color: color-mix(in srgb, var(--crm-tier-xclusive) 40%, #fff); }
.crm-tier-until { display: block; font-size: 11px; color: var(--crm-muted); margin-top: 3px; white-space: nowrap; }

/* Stat card: label, big number, one line of context. A <button> when it
   doubles as a filter; .is-active marks the filter currently applied. */
.crm-stat {
  display: block; width: 100%; height: 100%; text-align: left;
  background: var(--crm-surface); border: 1px solid var(--crm-border);
  border-radius: var(--crm-r); padding: 16px 18px; box-shadow: var(--crm-s1);
  color: var(--crm-ink); font: inherit; transition: border-color var(--crm-t), box-shadow var(--crm-t);
}
button.crm-stat { cursor: pointer; }
button.crm-stat:hover { border-color: color-mix(in srgb, var(--crm-primary) 40%, var(--crm-border)); box-shadow: var(--crm-s2); }
button.crm-stat:focus-visible { outline: 2px solid var(--crm-primary); outline-offset: 2px; }
.crm-stat.is-active { border-color: var(--crm-primary); box-shadow: 0 0 0 3px var(--crm-primary-glow); }
.crm-stat-label { display: block; font-size: 11px; font-weight: 700; color: var(--crm-muted); text-transform: uppercase; letter-spacing: .06em; }
.crm-stat-value { display: block; font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; letter-spacing: -.02em; margin-top: 6px; }
.crm-stat-meta  { display: block; font-size: 12px; color: var(--crm-muted); margin-top: 4px; }
.crm-stat-meta.is-up { color: var(--crm-success); }
.crm-stat-meta.is-down { color: var(--crm-danger); }

/* Search bar with an Advanced search toggle that shows how many filters are on. */
.crm-adv-toggle { background: var(--crm-ink); color: var(--crm-surface); border: 0; font-weight: 600; white-space: nowrap; }
.crm-adv-toggle:hover, .crm-adv-toggle:focus-visible, .crm-adv-toggle.active { background: var(--crm-ink); color: var(--crm-surface); opacity: .9; }
.crm-adv-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 999px; background: var(--crm-surface); color: var(--crm-ink);
  font-size: 11px; font-weight: 800; margin-left: 6px;
}
.crm-adv-count:empty { display: none; }
.crm-adv-group + .crm-adv-group { margin-top: 14px; }
.crm-quick-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.crm-quick-chips .btn { border-radius: 999px; font-size: 12px; font-weight: 600; }

/* "Filtered by" strip: one removable chip per active filter. */
.crm-filter-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; }
.crm-filter-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px;
  border-radius: 999px; background: var(--crm-surface-2); border: 1px solid var(--crm-border);
  font-weight: 600; color: var(--crm-ink);
}
.crm-filter-chip button {
  border: 0; background: transparent; color: var(--crm-muted); padding: 0 4px; line-height: 1; font-size: 14px;
}
.crm-filter-chip button:hover { color: var(--crm-danger); }

/* Bulk selection bar inside the table card. */
.crm-bulk-bar {
  background: var(--crm-ink); color: var(--crm-surface); border-radius: var(--crm-r-sm);
  padding: 8px 12px; gap: 10px; align-items: center; flex-wrap: wrap;
}
.crm-bulk-bar .btn-outline-light { --bs-btn-color: var(--crm-surface); --bs-btn-border-color: color-mix(in srgb, var(--crm-surface) 40%, transparent); }
.crm-bulk-bar .btn-link { color: var(--crm-surface); text-decoration: none; font-weight: 600; }

/* A table row that opens a record: the whole row is the target. Buttons,
   links and checkboxes inside keep their own behaviour. */
.app-main table.crm-row-link tbody tr[data-open] { cursor: pointer; }
.app-main table.crm-row-link tbody tr[data-open]:hover > * { background: color-mix(in srgb, var(--crm-primary) 4%, var(--crm-surface)); }
.app-main .crm-group-row > td {
  background: var(--crm-surface-2) !important; font-size: 11px; font-weight: 700; color: var(--crm-muted);
  text-transform: uppercase; letter-spacing: .06em; padding-top: 8px !important; padding-bottom: 8px !important;
}

/* Initials avatar for a guest without a photo. */
.crm-initials {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: inline-flex;
  align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  background: var(--crm-surface-2); color: var(--crm-muted); border: 1px solid var(--crm-border); overflow: hidden;
}
.crm-initials { position: relative; }
.crm-initials img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.crm-status-dot { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.crm-status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--crm-faint); }
.crm-status-dot.is-on::before { background: var(--crm-success); }
.crm-guest-link { color: var(--crm-ink); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.crm-guest-link:hover { color: var(--crm-accent-ink); }

/* Guest Profile modal: section chips and summary tiles. */
.crm-jump-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.crm-jump-chips a {
  padding: 4px 12px; border-radius: 999px; border: 1px solid var(--crm-border);
  font-size: 12px; font-weight: 600; color: var(--crm-ink); text-decoration: none; background: var(--crm-surface);
}
.crm-jump-chips a:hover { border-color: var(--crm-primary); color: var(--crm-accent-ink); }
.crm-tile { background: var(--crm-primary-soft); border-radius: var(--crm-r-sm); padding: 12px 14px; height: 100%; }
.crm-tile-value { font-size: 20px; font-weight: 800; line-height: 1.2; margin-top: 2px; }
.crm-comment {
  border: 1px solid var(--crm-border); background: var(--crm-surface-2); border-radius: var(--crm-r-sm);
  padding: 8px 10px; font-size: 13px; margin-top: 6px;
}
.crm-comment-guest { background: color-mix(in srgb, var(--crm-info) 6%, var(--crm-surface)); border-color: color-mix(in srgb, var(--crm-info) 20%, var(--crm-border)); }
.crm-comment-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 11px; color: var(--crm-muted); margin-bottom: 3px; }
.crm-comment-text { white-space: pre-wrap; }
.crm-doc-link {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--crm-border);
  border-radius: var(--crm-r-sm); font-size: 13px; color: var(--crm-ink); text-decoration: none;
}
.crm-doc-link:hover { border-color: var(--crm-primary); }
.crm-doc-link .ms-auto { color: var(--crm-accent-ink); font-weight: 600; }

/* Dashboard: new guests per month. Plain HTML bars rather than a chart
   library: twelve values, one series (two with "vs last year"), labelled on
   the bar, with a table view below. The current month is striped because
   it is not over yet. */
.dash-bars { display: flex; align-items: stretch; gap: 6px; height: 240px; padding-top: 18px; }
.dash-bar-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.dash-bar-plot {
  flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px;
  border-bottom: 1px solid var(--crm-border);
}
.dash-bar {
  position: relative; flex: 1 1 0; max-width: 34px; min-height: 2px;
  background: var(--crm-primary); border-radius: 4px 4px 0 0;
}
.dash-bar.is-partial {
  background: repeating-linear-gradient(135deg, var(--crm-primary) 0 4px,
              color-mix(in srgb, var(--crm-primary) 35%, var(--crm-surface)) 4px 8px);
}
.dash-bar-prev { display: none; background: color-mix(in srgb, var(--crm-muted) 45%, var(--crm-surface)); }
.dash-bars.show-prev .dash-bar-prev { display: block; }
.dash-bar-value {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  font-size: 11px; font-weight: 600; color: var(--crm-muted); padding-bottom: 2px; white-space: nowrap;
}
.dash-bars.show-prev .dash-bar-value { font-size: 10px; }
.dash-bar-label { text-align: center; font-size: 11px; color: var(--crm-muted); margin-top: 4px; line-height: 1.2; }
.dash-bar-label span { display: block; font-size: 10px; color: var(--crm-faint); }
.dash-legend { display: inline-flex; gap: 12px; }
.dash-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.dash-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--crm-primary); }
.dash-swatch-prev { background: color-mix(in srgb, var(--crm-muted) 45%, var(--crm-surface)); }
@media (max-width: 575.98px) {
  .dash-bars { gap: 2px; height: 200px; }
  .dash-bar-value { font-size: 9px; }
}

/* Dashboard: label · bar · figure rows (sources, tags, nationalities). */
.dash-meter { display: grid; grid-template-columns: minmax(0, 7.5rem) 1fr auto; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 8px; }
.dash-meter-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-meter-track { height: 8px; border-radius: 4px; background: var(--crm-surface-2); border: 1px solid var(--crm-border); overflow: hidden; }
.dash-meter-track > span { display: block; height: 100%; background: var(--crm-primary); border-radius: 4px; }
.dash-meter-value { font-weight: 600; color: var(--crm-muted); white-space: nowrap; font-size: 12px; }
