/*
 * Spectlance theme. Mobile-first: base rules are for phones, wider screens are added with min-width queries.
 * Colours come only from the --sl-* tokens below, so branding can later override them in one place.
 * Bootstrap 5.3 variables (--bs-*) are mapped onto the same tokens, so Bootstrap components match.
 *
 * Breakpoints (Bootstrap): sm 576px, md 768px, lg 992px, xl 1200px.
 */

/* ---------- Tokens ---------- */
:root,
[data-bs-theme="light"] {
  --sl-primary: #2f8cf4;
  --sl-primary-strong: #1f6fd1;
  --sl-primary-soft: #e8f2fe;
  --sl-gradient: linear-gradient(90deg, #79c2ff 0%, #3a92f5 100%);
  --sl-gradient-hover: linear-gradient(90deg, #62b5fb 0%, #2a80e6 100%);
  --sl-accent-shape: linear-gradient(100deg, #8cc9ff 0%, #3c8ff0 100%);

  --sl-bg: #f1f4f9;
  --sl-surface: #ffffff;
  --sl-surface-2: #f7f9fc;
  --sl-border: #e3e8ef;
  --sl-text: #111827;
  --sl-text-muted: #6b7280;
  --sl-sidebar-bg: #ffffff;
  --sl-sidebar-text: #374151;
  --sl-sidebar-active-bg: var(--sl-primary-soft);
  --sl-sidebar-active-text: var(--sl-primary-strong);

  --sl-radius-sm: 10px;
  --sl-radius: 14px;
  --sl-radius-lg: 24px;
  --sl-shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --sl-shadow: 0 8px 24px rgba(16, 24, 40, .08);
  --sl-shadow-lg: 0 24px 60px rgba(16, 24, 40, .14);
  --sl-focus: 0 0 0 .22rem rgba(47, 140, 244, .28);

  --sl-sidebar-width: 264px;
  --sl-topbar-height: 64px;
  --sl-touch: 44px;

  --bs-primary: var(--sl-primary);
  --bs-primary-rgb: 47, 140, 244;
  /* Tabs and links are always blue: */
  --sl-tab: #1f6fd1;
  --sl-tab-line: #2f8cf4;
  --sl-tab-soft: #e8f2fe;
  /* Links are always blue: the brand colour from Settings › General never changes them. */
  --sl-link: #1f6fd1;
  --sl-link-hover: #2f8cf4;
  --bs-link-color: var(--sl-link);
  --bs-link-color-rgb: 31, 111, 209;
  --bs-link-hover-color: var(--sl-link-hover);
  --bs-link-hover-color-rgb: 47, 140, 244;
  --bs-body-bg: var(--sl-bg);
  --bs-body-color: var(--sl-text);
  --bs-border-color: var(--sl-border);
  --bs-secondary-color: var(--sl-text-muted);
  --bs-border-radius: var(--sl-radius-sm);
  --bs-font-sans-serif: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

[data-bs-theme="dark"] {
  --sl-primary: #5aa7ff;
  --sl-primary-strong: #8cc2ff;
  --sl-primary-soft: rgba(90, 167, 255, .14);
  --sl-gradient: linear-gradient(90deg, #4a9ef8 0%, #2a73d6 100%);
  --sl-gradient-hover: linear-gradient(90deg, #5aa9fb 0%, #3381e6 100%);
  --sl-accent-shape: linear-gradient(100deg, #1e4f8f 0%, #2a73d6 100%);

  --sl-bg: #0d1320;
  --sl-surface: #151d2c;
  --sl-surface-2: #1b2536;
  --sl-border: #263248;
  --sl-text: #e7ecf3;
  --sl-text-muted: #9aa6b8;
  --sl-sidebar-bg: #121a28;
  --sl-sidebar-text: #c9d2df;
  --sl-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  --sl-shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);

  --bs-primary-rgb: 90, 167, 255;
  --bs-body-bg: var(--sl-bg);
  --bs-body-color: var(--sl-text);
  --bs-border-color: var(--sl-border);
  --bs-secondary-color: var(--sl-text-muted);
  --sl-link: #8cc2ff;
  --sl-tab: #8cc2ff;
  --sl-tab-line: #5aa7ff;
  --sl-tab-soft: rgba(90, 167, 255, .14);
  --sl-link-hover: #5aa7ff;
  --bs-link-color-rgb: 140, 194, 255;
  --bs-link-hover-color-rgb: 90, 167, 255;
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--sl-bg);
  color: var(--sl-text);
  font-family: var(--bs-font-sans-serif);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
:focus-visible { outline: none; box-shadow: var(--sl-focus); border-radius: 6px; }
.sl-icon { flex-shrink: 0; vertical-align: -0.2em; }
.text-muted, .form-text { color: var(--sl-text-muted) !important; }

.btn { min-height: var(--sl-touch); border-radius: var(--sl-radius-sm); font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; }
.btn-sm { min-height: 36px; }
.btn-primary { --bs-btn-bg: var(--sl-primary); --bs-btn-border-color: var(--sl-primary); --bs-btn-hover-bg: var(--sl-primary-strong); --bs-btn-hover-border-color: var(--sl-primary-strong); --bs-btn-active-bg: var(--sl-primary-strong); }
.btn-gradient { color: #fff; background: var(--sl-gradient); border: 0; box-shadow: 0 8px 18px rgba(47, 140, 244, .28); }
.btn-gradient:hover, .btn-gradient:focus-visible { color: #fff; background: var(--sl-gradient-hover); }
.btn-gradient:disabled { opacity: .7; }

.form-control, .form-select { min-height: var(--sl-touch); border-radius: var(--sl-radius-sm); border-color: var(--sl-border); background-color: var(--sl-surface); }
.form-control:focus, .form-select:focus { border-color: var(--sl-primary); box-shadow: var(--sl-focus); }
.form-check-input { width: 1.15em; height: 1.15em; }
.form-check-input:checked { background-color: var(--sl-primary); border-color: var(--sl-primary); }

/* Cards and boxes (content-box is what generated CRUD pages use) */
.card, .content-box {
  background: var(--sl-surface);
  border: 1px solid var(--sl-border);
  border-radius: var(--sl-radius);
  box-shadow: var(--sl-shadow-sm);
}
.content-box { padding: 1rem; }
.content-box h3, .content-box .page-title { font-size: 1.25rem; font-weight: 600; }
/* Fields laid out in a grid row: the row's gap does the spacing, not each field's bottom margin */
.content-box .row.g-3 > [class*="col"] > .mb-3 { margin-bottom: 0 !important; }
@media (min-width: 768px) { .content-box { padding: 1.5rem; } }

/* Tables: never widen the page; scroll inside their own box */
.grid-view, .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--sl-text-muted); font-weight: 600; white-space: nowrap; border-bottom-width: 1px; }
.table > :not(caption) > * > * { padding: .75rem .75rem; border-color: var(--sl-border); }
.pagination { flex-wrap: wrap; gap: .25rem; }

.alert { border-radius: var(--sl-radius-sm); border: 0; }
.breadcrumb { font-size: .85rem; margin-bottom: .5rem; --bs-breadcrumb-divider-color: var(--sl-text-muted); }
.breadcrumb a { text-decoration: none; }

/* ---------- App shell (signed-in) ---------- */
.sl-shell { min-height: 100vh; }

.sl-sidebar {
  --bs-offcanvas-width: var(--sl-sidebar-width);
  background: var(--sl-sidebar-bg);
  border-right: 1px solid var(--sl-border);
}
.sl-sidebar .offcanvas-header { height: var(--sl-topbar-height); border-bottom: 1px solid var(--sl-border); }
.sl-brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; color: var(--sl-text); text-decoration: none; letter-spacing: -.01em; }
.sl-brand:hover { color: var(--sl-text); }
.sl-brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--sl-gradient); color: #fff; display: inline-grid; place-items: center; box-shadow: 0 6px 14px rgba(47, 140, 244, .3); }

.sl-nav { list-style: none; margin: 0; padding: .75rem; display: flex; flex-direction: column; gap: 2px; }
.sl-nav-section { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--sl-text-muted); padding: 1rem .75rem .35rem; }
.sl-nav-link {
  display: flex; align-items: center; gap: .75rem; min-height: var(--sl-touch);
  padding: .5rem .75rem; border-radius: var(--sl-radius-sm);
  color: var(--sl-sidebar-text); text-decoration: none; font-weight: 500;
}
.sl-nav-link:hover { background: var(--sl-surface-2); color: var(--sl-text); }
.sl-nav-link.active { background: var(--sl-sidebar-active-bg); color: var(--sl-sidebar-active-text); }

.sl-main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.sl-role-badge { flex: none; padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; letter-spacing: .02em; white-space: nowrap; background: var(--sl-primary-soft); color: var(--sl-primary-strong); border: 1px solid var(--sl-border); }
.sl-topbar {
  position: sticky; top: 0; z-index: 1020;
  height: var(--sl-topbar-height);
  display: flex; align-items: center; gap: .5rem;
  padding: 0 1rem;
  background: color-mix(in srgb, var(--sl-surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--sl-border);
}
.sl-topsearch { display: none; align-items: center; position: relative; margin: 0 .25rem; }
.sl-topsearch .sl-icon { position: absolute; left: .7rem; color: var(--sl-text-muted); pointer-events: none; }
.sl-topsearch input { padding-left: 2.2rem; width: 13rem; border-radius: 999px; background: var(--sl-surface-2); }
@media (min-width: 768px) { .sl-topsearch { display: flex; } }
@media (min-width: 1200px) { .sl-topsearch input { width: 18rem; } }
.sl-icon-btn {
  width: var(--sl-touch); height: var(--sl-touch); min-height: var(--sl-touch);
  border-radius: 12px; border: 0; background: transparent; color: var(--sl-text);
  display: inline-grid; place-items: center; padding: 0;
}
.sl-icon-btn:hover { background: var(--sl-surface-2); }
.sl-bell-menu { width: 22rem; max-height: 80vh; overflow-y: auto; max-width: calc(100vw - 1.5rem); }
.sl-bell-head { display: flex; justify-content: space-between; align-items: center; padding: .7rem 1rem; border-bottom: 1px solid var(--sl-border); }
.sl-bell-item { display: flex; align-items: flex-start; gap: .7rem; padding: .7rem 1rem; border-bottom: 1px solid var(--sl-border); font-size: .88rem; line-height: 1.35; }
.sl-bell-item.is-unread .sl-bell-title { font-weight: 700; }
.sl-bell-dot { flex: none; width: .55rem; height: .55rem; border-radius: 50%; margin-top: .4rem; }
.sl-bell-text { display: flex; flex-direction: column; min-width: 0; }
.sl-bell-title { overflow-wrap: anywhere; }
.sl-bell-body { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sl-bell-body { font-size: .8rem; color: var(--sl-text-muted); }
.sl-bell-empty { padding: 1.2rem 1rem; text-align: center; color: var(--sl-text-muted); }
.sl-bell-foot { display: block; position: sticky; bottom: 0; background: var(--sl-surface); text-align: center; padding: .65rem 1rem; font-weight: 600; text-decoration: none; }
.sl-bell-foot:hover { background: var(--sl-surface-2); }
.sl-bell { position: relative; color: var(--sl-text); text-decoration: none; }
.sl-bell-count { position: absolute; top: 3px; right: 1px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #dc2626; color: #fff; font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center; border: 2px solid var(--sl-surface); box-sizing: content-box; }
.sl-acct { --sl-acct-c: #16a34a; display: inline-flex; align-items: center; gap: .6rem; padding: .2rem .8rem .2rem .3rem; border-radius: 14px; background: var(--sl-surface-2); border: 1px solid var(--sl-border); color: var(--sl-text); text-decoration: none; white-space: nowrap; line-height: 1.15; max-width: 15rem; }
.sl-acct:hover { border-color: var(--sl-acct-c); color: var(--sl-text); box-shadow: var(--sl-shadow); }
.sl-acct-icon { position: relative; width: 34px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center; background: color-mix(in srgb, var(--sl-acct-c) 16%, var(--sl-surface)); color: var(--sl-acct-c); flex: none; }
.sl-acct-icon::after { content: ""; position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--sl-acct-c); border: 2px solid var(--sl-surface); }
.sl-acct-text { display: flex; flex-direction: column; min-width: 0; }
.sl-acct-caption { font-size: .66rem; letter-spacing: .06em; text-transform: uppercase; color: var(--sl-text-muted); overflow: hidden; text-overflow: ellipsis; }
.sl-acct-main { font-weight: 700; font-size: .92rem; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.sl-acct-action { font-size: .75rem; font-weight: 600; color: var(--sl-acct-c); padding-left: .55rem; border-left: 1px solid var(--sl-border); }
.sl-acct-low { --sl-acct-c: #d97706; }
.sl-acct-empty, .sl-acct-hold { --sl-acct-c: #dc2626; }
.sl-acct-low .sl-acct-caption, .sl-acct-empty .sl-acct-caption, .sl-acct-hold .sl-acct-caption { color: var(--sl-acct-c); }
@media (max-width: 575.98px) { .sl-acct { padding-right: .4rem; gap: .4rem; } .sl-acct-caption { display: none; } .sl-acct-main { font-size: .8rem; } .sl-acct-icon { width: 30px; height: 30px; } }
.sl-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--sl-primary-soft); color: var(--sl-primary-strong); display: inline-grid; place-items: center; font-weight: 600; font-size: .85rem; }
.sl-user-btn { display: inline-flex; align-items: center; gap: .5rem; background: transparent; border: 0; color: var(--sl-text); min-height: var(--sl-touch); padding: 0 .25rem; border-radius: 12px; }
.sl-user-btn:hover { background: var(--sl-surface-2); }
.dropdown-menu { border-radius: var(--sl-radius-sm); border-color: var(--sl-border); box-shadow: var(--sl-shadow); padding: .4rem; }
.dropdown-item { border-radius: 8px; min-height: 40px; display: flex; align-items: center; gap: .6rem; }

.sl-content { padding: 1rem; flex: 1; }
.sl-footer { padding: 1rem; font-size: .8rem; color: var(--sl-text-muted); }
.sl-version { font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (min-width: 768px) {
  .sl-content { padding: 1.5rem; }
  .sl-topbar { padding: 0 1.5rem; }
  .sl-footer { padding: 1rem 1.5rem; }
}

/* From 992px the sidebar is fixed beside the content; below that it is an off-canvas drawer (Bootstrap offcanvas-lg). */
@media (min-width: 992px) {
  .sl-shell { display: flex; }
  .sl-sidebar.offcanvas-lg {
    position: sticky; top: 0; height: 100vh; width: var(--sl-sidebar-width); flex-shrink: 0;
    display: flex; flex-direction: column; overflow-y: auto;
  }
  /* Bootstrap's offcanvas-lg hides the header and clears the background from 992px; keep both for the fixed sidebar */
  .sl-sidebar.offcanvas-lg { background-color: var(--sl-sidebar-bg) !important; }
  .sl-sidebar.offcanvas-lg .offcanvas-header { display: flex; align-items: center; padding: 0 1rem; flex-shrink: 0; }
  .sl-sidebar .offcanvas-body { display: block; padding: 0; }
  .sl-main { flex: 1; }
  .sl-content { padding: 2rem; }
}

/* ---------- Public pages (signed-out, non-login) ---------- */
.sl-public-nav { background: var(--sl-surface); border-bottom: 1px solid var(--sl-border); }
.sl-public-nav .navbar { min-height: var(--sl-topbar-height); }

/* ---------- Auth pages (login, sign-up, reset): full-page split ---------- */
/* Phones and tablets: the form fills the screen. Desktop (992px+): art panel on the left at full height,
   form on the right. Nothing floats on a card, so the whole window is used. */
.sl-auth { min-height: 100vh; min-height: 100dvh; background: var(--sl-surface); }
.sl-auth-split { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1fr; }

.sl-auth-art { display: none; }

.sl-auth-panel { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; padding: 1.25rem; }
.sl-auth-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: var(--sl-touch); font-size: .92rem; color: var(--sl-text-muted); }
.sl-auth-top .sl-auth-top-link { margin-left: auto; text-align: right; }
.sl-auth-top a { font-weight: 600; text-decoration: none; }
.sl-auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2.5rem 0 2rem; }
.sl-auth-form-inner { width: 100%; max-width: 400px; }

.sl-auth h1 { font-size: 1.65rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: .35rem; }
.sl-auth-lead { color: var(--sl-text-muted); margin-bottom: 1.75rem; }

/* Email / Mobile number switch */
.sl-segment { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--sl-border); }
.sl-segment button {
  background: none; border: 0; min-height: var(--sl-touch);
  font-weight: 500; color: var(--sl-text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
}
.sl-segment button[aria-selected="true"] { color: var(--sl-text); border-bottom-color: var(--sl-text); }

/* Input with a leading icon and optional trailing button */
.sl-input { position: relative; }
.sl-input > .sl-icon { position: absolute; left: .95rem; top: 50%; transform: translateY(-50%); color: var(--sl-text-muted); pointer-events: none; }
.sl-input .form-control { padding-left: 2.85rem; min-height: 50px; background: var(--sl-surface); }
.sl-input .sl-input-action { position: absolute; right: .25rem; top: 50%; transform: translateY(-50%); }
.sl-input.has-action .form-control { padding-right: 3.25rem; }
.sl-input .form-control.is-invalid { background-image: none; }
.sl-auth .invalid-feedback { display: block; }

.sl-auth-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin: .25rem 0 1.25rem; font-size: .9rem; }
.sl-auth-row a { text-decoration: none; font-weight: 500; }
.sl-auth .btn-gradient { width: 100%; min-height: 52px; font-size: 1rem; }
.sl-auth-alt { text-align: center; margin-top: 1.5rem; font-size: .92rem; color: var(--sl-text-muted); }
.sl-auth-alt a { font-weight: 600; text-decoration: none; }
.sl-auth-legal { text-align: center; font-size: .78rem; color: var(--sl-text-muted); margin: 0; }
.sl-auth-legal a { color: inherit; }

@media (min-width: 576px) {
  .sl-auth-panel { padding: 1.5rem 2.5rem; }
}

@media (min-width: 992px) {
  .sl-auth-split { grid-template-columns: 46% 1fr; }
  .sl-auth-art {
    display: flex; flex-direction: column; justify-content: space-between;
    position: sticky; top: 0; height: 100vh; height: 100dvh;
    padding: 2rem 2.5rem 2.25rem;
    background: #cfe4fb url("../img/login-art.svg") center / cover no-repeat;
  }
  .sl-auth-art .sl-brand { color: #0f2a4d; }
  .sl-auth-top .sl-auth-mobile-brand { visibility: hidden; }
  .sl-auth-panel { padding: 2rem 3rem; }
}

@media (min-width: 1400px) {
  .sl-auth-split { grid-template-columns: 50% 1fr; }
}

/* Glass caption with rotating messages */
.sl-glass {
  align-self: center; width: min(520px, 100%);
  padding: 1.5rem 1.75rem 1rem;
  text-align: center; color: #fff;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 18px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 10px 30px rgba(15, 42, 77, .25);
}
.sl-slides { position: relative; min-height: 3.2rem; }
.sl-slide { position: absolute; inset: 0; opacity: 0; transition: opacity .5s ease; font-size: 1.15rem; line-height: 1.5; text-shadow: 0 1px 8px rgba(15, 42, 77, .35); }
.sl-slide.is-active { opacity: 1; position: relative; }
.sl-dots { display: flex; justify-content: center; gap: .15rem; margin-top: .6rem; }
.sl-dots button { width: 24px; height: 24px; border: 0; background: none; padding: 0; display: grid; place-items: center; }
.sl-dots button::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .7); transition: all .2s; }
.sl-dots button[aria-current="true"]::before { width: 10px; height: 10px; background: transparent; border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, .35); }

/* Error page */
.sl-error { max-width: 560px; margin: 4rem auto; text-align: center; }
.sl-error-code { font-size: 4.5rem; font-weight: 800; line-height: 1; background: var(--sl-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }

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

/* ---------- Two-step sign-in ---------- */
.sl-code-input { letter-spacing: .35em; font-variant-numeric: tabular-nums; }
.sl-steps { padding-left: 1.25rem; margin-bottom: 1.25rem; }
.sl-steps li { margin-bottom: .9rem; }
.sl-qr { display: block; width: fit-content; padding: 10px; background: #fff; border: 1px solid var(--sl-border); border-radius: var(--sl-radius-sm); line-height: 0; }
.sl-qr svg { width: 180px; height: 180px; }
.sl-secret { font-size: .95rem; letter-spacing: .08em; color: var(--sl-text); background: var(--sl-surface-2); padding: .5rem .75rem; border-radius: 8px; word-break: break-all; }

/* ---------- Users and roles ---------- */
.min-w-0 { min-width: 0; }
.sl-details dt { font-weight: 500; color: var(--sl-text-muted); }
.sl-details dd { margin-bottom: .6rem; overflow-wrap: anywhere; }
@media (min-width: 576px) { .sl-details dt, .sl-details dd { margin-bottom: .75rem; } }
.sl-role-list { display: grid; gap: .6rem; }
@media (min-width: 768px) { .sl-role-list { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); } }
.sl-role-option { display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem; border: 1px solid var(--sl-border); border-radius: var(--sl-radius-sm); cursor: pointer; background: var(--sl-surface); transition: border-color .15s, background-color .15s; }
.sl-role-option:hover { border-color: var(--sl-primary); }
.sl-role-option:has(input:checked) { border-color: var(--sl-primary); background: var(--sl-primary-soft); }
.sl-role-option .form-check-input { margin-top: .2rem; flex-shrink: 0; }
.sl-permission-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.sl-permission-list code { display: inline-block; font-size: .78rem; color: var(--sl-text); background: var(--sl-surface-2); border: 1px solid var(--sl-border); padding: .15rem .45rem; border-radius: 6px; }

/* ---------- Clients ---------- */
.sl-action > summary { list-style: none; }
.sl-action > summary::-webkit-details-marker { display: none; }
.sl-action[open] > summary { display: none; }
.sl-user-list > li { padding: .75rem 0; border-bottom: 1px solid var(--sl-border); }
.sl-user-list > li:first-child { padding-top: 0; }
.sl-user-list > li:last-child { border-bottom: 0; padding-bottom: 0; }
.sl-history > li { padding: .6rem 0 .6rem .9rem; border-left: 2px solid var(--sl-border); }
.sl-history > li + li { margin-top: .1rem; }

/* ---------- Dashboard ---------- */
.sl-stat { display: flex; flex-direction: column; gap: .2rem; }
.sl-stat-label { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--sl-text-muted); }
.sl-stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sl-stat-value-sm { font-size: 1.35rem; }
.sl-stat-note { font-size: .8rem; color: var(--sl-text-muted); }
.sl-stat-soon .sl-stat-value { color: var(--sl-text-muted); }
@media (min-width: 768px) { .sl-stat-value { font-size: 2rem; } .sl-stat-value-sm { font-size: 1.5rem; } }
.sl-placeholder-chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; margin-top: 1.25rem; padding-top: .5rem; border-bottom: 1px solid var(--sl-border); }
.sl-placeholder-chart span { flex: 1; border-radius: 6px 6px 0 0; background: var(--sl-primary-soft); }
.sl-checklist > li { display: flex; gap: .65rem; align-items: flex-start; padding: .45rem 0; }
.sl-check { flex-shrink: 0; width: 18px; height: 18px; margin-top: .15rem; border-radius: 50%; border: 2px solid var(--sl-border); }
.sl-checklist > li.is-done { color: var(--sl-text-muted); text-decoration: line-through; }
.sl-checklist > li.is-done .sl-check { border-color: var(--sl-primary); background: var(--sl-primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12 4 4 8-8'/%3E%3C/svg%3E") center / 12px no-repeat; }

/* ---------- Client page ---------- */
.sl-client-avatar { flex-shrink: 0; width: 52px; height: 52px; border-radius: var(--sl-radius-sm); display: grid; place-items: center; font-size: 1.4rem; font-weight: 700; color: #fff; background: var(--sl-gradient); box-shadow: var(--sl-shadow-sm); }
/* Tabs scroll sideways on small screens; the page never does. */
.sl-tabs { position: relative; border-bottom: 1px solid var(--sl-border); overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.sl-tabs::-webkit-scrollbar { display: none; }
.sl-tabs .nav { gap: .25rem; }
.sl-tabs .nav-link { white-space: nowrap; color: var(--sl-text-muted); padding: .7rem .8rem; display: flex; align-items: center; gap: .4rem; font-weight: 500; }
.sl-tabs .nav-link:hover { color: var(--sl-text); }
.sl-tabs .nav-link.active { color: var(--sl-tab); border-bottom-color: var(--sl-tab-line); }
.sl-tab-count { font-size: .72rem; font-weight: 600; line-height: 1; padding: .2rem .45rem; border-radius: 999px; background: var(--sl-surface-2); border: 1px solid var(--sl-border); color: var(--sl-text-muted); }
.sl-tabs .nav-link.active .sl-tab-count { background: var(--sl-tab-soft); border-color: transparent; color: var(--sl-tab); }
.sl-empty { text-align: center; padding: 2.5rem 1rem; }
.sl-empty-icon { width: 56px; height: 56px; margin: 0 auto .75rem; border-radius: 50%; display: grid; place-items: center; color: var(--sl-primary); background: var(--sl-primary-soft); }
.sl-note { white-space: normal; }

/* ---------- Signed in as a client user ---------- */
.sl-impersonation { position: sticky; top: 0; z-index: 1030; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; padding: .6rem 1rem; color: #fff; background: #b45309; }
.sl-impersonation.is-view { background: #1d4ed8; }
.sl-impersonation-text { display: flex; flex-direction: column; min-width: 0; font-size: .9rem; line-height: 1.3; }
.sl-impersonation-text span { opacity: .9; font-size: .82rem; }
@media (min-width: 768px) { .sl-impersonation { padding: .6rem 1.5rem; } .sl-impersonation-text { flex-direction: row; gap: .75rem; align-items: baseline; } }

/* ---------- Branding ---------- */
.sl-brand-stacked { flex-direction: column; align-items: flex-start; gap: .15rem; }
.sl-brand-name { font-size: .8rem; font-weight: 600; line-height: 1.1; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-brand-logo { display: block; max-height: 40px; max-width: 200px; width: auto; height: auto; object-fit: contain; }
.sl-logo-preview { display: grid; place-items: center; min-height: 96px; padding: 1rem; border: 1px dashed var(--sl-border); border-radius: var(--sl-radius-sm); background: var(--sl-surface-2); }
.sl-logo-preview img { max-height: 80px; max-width: 100%; object-fit: contain; }

/* ---------- Sidebar groups (main menu + sub-menus) ---------- */
.sl-nav-toggle { width: 100%; border: 0; background: none; text-align: left; font: inherit; font-weight: 500; cursor: pointer; }
.sl-nav-toggle > span { flex: 1; }
.sl-nav-chevron { flex-shrink: 0; color: var(--sl-text-muted); transition: transform .2s ease; }
.sl-nav-toggle:not(.collapsed) .sl-nav-chevron { transform: rotate(180deg); }
.sl-nav-group.has-active > .sl-nav-toggle { color: var(--sl-sidebar-active-text); }
.sl-nav-group.has-active > .sl-nav-toggle .sl-icon:first-child { color: var(--sl-primary); }
.sl-nav-toggle:focus-visible { outline: 0; box-shadow: var(--sl-focus); }
.sl-nav-sub { list-style: none; margin: 2px 0 4px 1.55rem; padding: 0 0 0 .75rem; border-left: 1px solid var(--sl-border); display: flex; flex-direction: column; gap: 2px; }
.sl-nav-sub.collapsing { display: flex; }
.sl-nav-sublink { min-height: 40px; padding: .4rem .75rem; font-size: .93rem; }

/* ---------- Audit log ---------- */
.sl-audit > li { border-bottom: 1px solid var(--sl-border); }
.sl-audit > li:last-child { border-bottom: 0; }
.sl-audit summary { list-style: none; display: flex; gap: .9rem; align-items: flex-start; padding: .75rem .25rem; cursor: pointer; }
.sl-audit summary::-webkit-details-marker { display: none; }
.sl-audit summary:hover { background: var(--sl-surface-2); }
.sl-audit-when { flex-shrink: 0; width: 8.5rem; font-size: .82rem; color: var(--sl-text-muted); font-variant-numeric: tabular-nums; padding-top: .1rem; }
.sl-audit-what { min-width: 0; flex: 1; }
.sl-audit-what > .fw-semibold + span { margin-left: .35rem; }
.sl-audit-body { padding: 0 .25rem .9rem 9.4rem; }
@media (max-width: 575.98px) {
  .sl-audit summary { flex-direction: column; gap: .15rem; }
  .sl-audit-when { width: auto; }
  .sl-audit-body { padding-left: .25rem; }
}
.sl-audit .table > :not(caption) > * > * { padding: .35rem .5rem; font-size: .85rem; }

/* Sign-up trap field: invisible to people and screen readers, filled by naive bots. */
.sl-trap { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Legal pages ---------- */
.sl-legal-body { line-height: 1.65; overflow-wrap: anywhere; }
.sl-legal-body h1, .sl-legal-body h2, .sl-legal-body h3 { margin-top: 1.5rem; margin-bottom: .6rem; font-weight: 700; }
.sl-legal-body h2 { font-size: 1.15rem; }
.sl-legal-body h3 { font-size: 1rem; }
.sl-legal-body blockquote { padding: .75rem 1rem; margin: 0 0 1rem; border-left: 3px solid var(--sl-primary); background: var(--sl-surface-2); border-radius: 0 8px 8px 0; }
.sl-legal-body table { width: 100%; margin-bottom: 1rem; border-collapse: collapse; }
.sl-legal-body th, .sl-legal-body td { border: 1px solid var(--sl-border); padding: .4rem .6rem; }
.sl-legal-scroll { max-height: 45vh; overflow-y: auto; padding: 1rem; border: 1px solid var(--sl-border); border-radius: var(--sl-radius-sm); background: var(--sl-surface-2); font-size: .92rem; }
.sl-legal-preview { padding: 1rem 1.25rem; border: 1px dashed var(--sl-border); border-radius: var(--sl-radius-sm); }
.sl-footer a, .sl-auth-legal a { color: inherit; }

/* ---------- Templates ---------- */
.sl-email-preview { width: 100%; height: 460px; border: 1px solid var(--sl-border); border-radius: var(--sl-radius-sm); background: #f1f4f9; }
.sl-sms-bubble { max-width: 320px; padding: .75rem 1rem; border-radius: 18px 18px 18px 4px; background: var(--sl-surface-2); border: 1px solid var(--sl-border); font-size: .95rem; overflow-wrap: anywhere; }
/* Rich text editor (Quill) in the theme's look */
.sl-editor { min-height: 260px; font-size: .95rem; }
.ql-toolbar.ql-snow { border-color: var(--sl-border); border-radius: var(--sl-radius-sm) var(--sl-radius-sm) 0 0; background: var(--sl-surface-2); }
.ql-container.ql-snow { border-color: var(--sl-border); border-radius: 0 0 var(--sl-radius-sm) var(--sl-radius-sm); font-family: inherit; font-size: .95rem; background: var(--sl-surface); }
.ql-editor { min-height: 240px; line-height: 1.6; }
.ql-snow .ql-tooltip { z-index: 5; }
[data-bs-theme="dark"] .ql-snow .ql-stroke { stroke: var(--sl-text); }
[data-bs-theme="dark"] .ql-snow .ql-fill { fill: var(--sl-text); }
[data-bs-theme="dark"] .ql-snow .ql-picker { color: var(--sl-text); }
.ql-editor p, .ql-editor ol, .ql-editor ul, .ql-editor blockquote { margin-bottom: .9rem; }
.ql-editor h2, .ql-editor h3 { margin: 1rem 0 .5rem; }

/* ---------- Chips (removable values) ---------- */
.sl-chip { display: inline-flex; align-items: center; gap: .25rem; padding: .15rem .25rem .15rem .6rem; border: 1px solid var(--sl-border); border-radius: 999px; background: var(--sl-surface-2); font-size: .85rem; }
.sl-chip-x { border: 0; background: none; color: var(--sl-text-muted); width: 22px; height: 22px; border-radius: 50%; line-height: 1; }
.sl-chip-x:hover { background: var(--sl-border); color: var(--sl-text); }

/* Live dashboard */
.sl-live-dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: #16a34a; box-shadow: 0 0 0 0 rgba(22, 163, 74, .5); animation: sl-pulse 2s infinite; vertical-align: middle; }
.sl-live-dot.is-off { background: #94a3b8; animation: none; box-shadow: none; }
@keyframes sl-pulse { 0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .45); } 70% { box-shadow: 0 0 0 .5rem rgba(22, 163, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); } }
@media (prefers-reduced-motion: reduce) { .sl-live-dot { animation: none; } }
.sl-chart-tip { position: absolute; z-index: 5; background: var(--sl-surface); color: var(--sl-text); border: 1px solid var(--sl-border); border-radius: .5rem; box-shadow: var(--sl-shadow); padding: .35rem .6rem; font-size: .78rem; pointer-events: none; white-space: nowrap; }
.sl-chart-tip i { display: inline-block; width: .6rem; height: .6rem; border-radius: 2px; margin-right: .35rem; }
.sl-chart-legend { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .78rem; color: var(--sl-text-muted); margin-top: .35rem; }
.sl-chart-legend b { display: inline-block; width: .65rem; height: .65rem; border-radius: 2px; margin-right: .35rem; }

/* ---- Campaign side panel (admin › client › Campaigns) */
#campaign-panel .offcanvas-header { background: var(--sl-gradient); color: #fff; border: 0; }
#campaign-panel .offcanvas-header .btn-close { filter: invert(1) grayscale(1) brightness(2); opacity: .9; }
#campaign-panel .offcanvas-body { padding: 0; background: var(--sl-surface-2); }
.sl-cp { --cp-a: #94a3b8; --cp-b: #64748b; }
.sl-cp-blue { --cp-a: #79c2ff; --cp-b: #2f8cf4; }
.sl-cp-green { --cp-a: #5eead4; --cp-b: #16a34a; }
.sl-cp-amber { --cp-a: #fcd34d; --cp-b: #f59e0b; }
.sl-cp-red { --cp-a: #fda4af; --cp-b: #e11d48; }
.sl-cp-hero { padding: 1.25rem 1.25rem 1.1rem; background: linear-gradient(135deg, var(--cp-a), var(--cp-b)); color: #fff; position: relative; overflow: hidden; }
.sl-cp-hero::after { content: ""; position: absolute; right: -2.5rem; top: -2.5rem; width: 9rem; height: 9rem; border-radius: 50%; background: rgba(255, 255, 255, .16); }
.sl-cp-hero > * { position: relative; z-index: 1; }
.sl-cp-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .7rem; border-radius: 999px; background: rgba(255, 255, 255, .22); font-size: .8rem; font-weight: 600; backdrop-filter: blur(2px); }
.sl-cp-pill::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: #fff; box-shadow: 0 0 0 .2rem rgba(255, 255, 255, .3); }
.sl-cp-chip { display: inline-block; padding: .15rem .6rem; border-radius: 999px; background: rgba(255, 255, 255, .16); font-size: .78rem; }
.sl-cp-sec { padding: 1rem 1.25rem 0; }
.sl-cp-sec h3 { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--sl-text-muted); margin: 0 0 .6rem; display: flex; align-items: center; gap: .5rem; }
.sl-cp-sec h3::after { content: ""; flex: 1; height: 1px; background: var(--sl-border); }
.sl-cp-bubble { position: relative; padding: .9rem 1rem; border-radius: 4px 18px 18px 18px; background: var(--sl-surface); border: 1px solid var(--sl-border); border-left: 4px solid var(--cp-b); box-shadow: var(--sl-shadow-sm); white-space: pre-wrap; word-break: break-word; }
.sl-cp-meta { font-size: .75rem; color: var(--sl-text-muted); margin-top: .35rem; }
.sl-cp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.sl-cp-tile { background: var(--sl-surface); border: 1px solid var(--sl-border); border-radius: var(--sl-radius-sm); padding: .6rem .75rem; min-width: 0; }
.sl-cp-tile.wide { grid-column: 1 / -1; }
.sl-cp-tile .k { font-size: .72rem; color: var(--sl-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.sl-cp-tile .v { font-weight: 600; overflow-wrap: anywhere; }
.sl-cp-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.sl-cp-stat { border-radius: var(--sl-radius); padding: .75rem .9rem; color: #fff; box-shadow: var(--sl-shadow-sm); }
.sl-cp-stat .n { font-size: 1.6rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.sl-cp-stat .l { font-size: .75rem; opacity: .92; letter-spacing: .03em; }
.sl-cp-s-blue { background: linear-gradient(135deg, #79c2ff, #2f8cf4); }
.sl-cp-s-violet { background: linear-gradient(135deg, #c4b5fd, #7c3aed); }
.sl-cp-s-green { background: linear-gradient(135deg, #5eead4, #16a34a); }
.sl-cp-s-amber { background: linear-gradient(135deg, #fcd34d, #f59e0b); }
.sl-cp-s-red { background: linear-gradient(135deg, #fda4af, #e11d48); }
.sl-cp-bar { display: flex; height: .7rem; border-radius: 999px; overflow: hidden; background: var(--sl-border); margin: .75rem 0 .3rem; }
.sl-cp-bar span { display: block; height: 100%; }
.sl-cp-legend { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .75rem; color: var(--sl-text-muted); }
.sl-cp-legend i { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .3rem; }
.sl-cp-runs { list-style: none; margin: 0; padding: 0 0 0 .9rem; border-left: 2px solid var(--sl-border); }
.sl-cp-runs li { position: relative; padding: 0 0 .75rem .9rem; font-size: .85rem; }
.sl-cp-runs li::before { content: ""; position: absolute; left: -1.38rem; top: .3rem; width: .7rem; height: .7rem; border-radius: 50%; background: var(--cp-b); border: 2px solid var(--sl-surface-2); }
.sl-cp-end { height: 1.25rem; }

/* Tab-style navigation stays blue whatever the brand colour is. */
.nav-pills { --bs-nav-pills-link-active-bg: var(--sl-tab-line); --bs-nav-pills-link-active-color: #fff; }
.nav-tabs { --bs-nav-link-color: var(--sl-tab); --bs-nav-link-hover-color: var(--sl-link-hover); }

/* ---- Drag-and-drop file area (theme.js, data-sl-drop): the real file input sits invisibly over it */
.sl-drop { position: relative; flex: 1 1 auto; min-width: 0; border: 2px dashed var(--sl-border); border-radius: var(--sl-radius); background: var(--sl-surface-2); padding: 1.1rem 1rem; text-align: center; transition: border-color .15s, background-color .15s, box-shadow .15s; }
.sl-drop:hover { border-color: var(--sl-primary); }
.sl-drop:focus-within { border-color: var(--sl-primary); box-shadow: var(--sl-focus); }
.sl-drop.is-over { border-color: var(--sl-primary); background: var(--sl-primary-soft); }
.sl-drop.has-file { border-style: solid; border-color: var(--sl-primary); background: var(--sl-primary-soft); }
.sl-drop .sl-drop-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; padding: 0; margin: 0; }
.sl-drop-body { pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.sl-drop-icon { color: var(--sl-primary); }
.sl-drop-text { font-weight: 600; overflow-wrap: anywhere; }
.sl-drop-hint, .sl-drop-file { font-size: .8rem; color: var(--sl-text-muted); }
.sl-drop-error { color: var(--bs-danger, #dc3545); font-size: .85rem; margin-top: .35rem; }
.sl-drop-error:empty { display: none; }
