/*
 | Residieons 2.0 — design tokens
 |
 | Layered over Bootstrap 5.3 (vendored from Composer, no build step).
 | Bootstrap's own CSS variables are overridden here so its components pick
 | up our palette without recompiling Sass.
 |
 | Brand hue is a single token. To rebrand, change --rd-brand-* only.
 */

:root {
    color-scheme: light;

    /*
     | THE THEME TOKENS come first, printed by the layout from
     | config/appearance.php (App\Appearance\Appearance::css): --rd-primary,
     | --rd-primary-light, --rd-primary-ink, --rd-bg, --rd-surface,
     | --rd-surface-alt, --rd-border, --rd-border-strong, --rd-text-primary,
     | --rd-text-secondary, --rd-text-meta, --rd-danger, --rd-success,
     | --rd-warning, --rd-active-nav-bg, --rd-hero-bg, --rd-heading-font …
     | DESIGN-SPEC.md §3 is the reference for every one of them.
     |
     | Everything below is an ALIAS onto those tokens. Twenty module
     | stylesheets were written against the v1 names (--rd-brand-*, --rd-n-*,
     | the four-part semantic tones), so remapping them moves every screen onto
     | the chosen theme at once. New work uses the theme names directly.
     |
     | The rule the aliases keep: brand FILLS map to primary / primaryMid /
     | primaryLight; anything used as TEXT maps to an *Ink tone.
     */

    /* Brand scale → the palette's primary family. */
    --rd-brand-50:  var(--rd-primary-light);
    --rd-brand-100: var(--rd-primary-light);
    --rd-brand-200: var(--rd-primary-mid);
    --rd-brand-300: var(--rd-primary-mid);
    --rd-brand-400: var(--rd-primary);
    --rd-brand-500: var(--rd-primary);
    --rd-brand-600: var(--rd-primary-ink);
    --rd-brand-700: var(--rd-primary-ink);
    --rd-brand-800: var(--rd-hover-color);
    --rd-brand-900: var(--rd-text-primary);

    /* Neutral scale → surfaces, borders and the three text tones. */
    --rd-n-0:   var(--rd-surface);
    --rd-n-25:  var(--rd-surface-alt);
    --rd-n-50:  var(--rd-bg);
    --rd-n-100: var(--rd-border);
    --rd-n-200: var(--rd-border);
    --rd-n-300: var(--rd-border-strong);
    --rd-n-400: var(--rd-track-empty);
    --rd-n-500: var(--rd-text-meta);
    --rd-n-600: var(--rd-text-meta);
    --rd-n-700: var(--rd-text-secondary);
    --rd-n-800: var(--rd-text-secondary);
    --rd-n-900: var(--rd-text-primary);
    --rd-n-950: var(--rd-text-primary);

    /* v1's navy names. */
    --rd-canvas: var(--rd-bg);
    --rd-canvas-deep: var(--rd-surface-alt);
    --rd-navy: var(--rd-primary-ink);
    --rd-navy-hover: var(--rd-hover-color);
    --rd-navy-deep: var(--rd-text-primary);
    --rd-navy-tint: var(--rd-primary-light);
    --rd-navy-border: var(--rd-primary-mid);
    --rd-navy-soft: var(--rd-primary-light);
    --rd-navy-mid: var(--rd-primary-mid);

    /* Semantic tones — background, border, text, dot. Light ground + ink text. */
    --rd-ok-bg: var(--rd-success-light);   --rd-ok-bd: var(--rd-accent-mid);      --rd-ok-fg: var(--rd-success-ink);   --rd-ok-dot: var(--rd-accent);
    --rd-info-bg: var(--rd-primary-light); --rd-info-bd: var(--rd-primary-mid);   --rd-info-fg: var(--rd-primary-ink); --rd-info-dot: var(--rd-primary);
    --rd-warn-bg: var(--rd-warning-light); --rd-warn-bd: var(--rd-border-strong); --rd-warn-fg: var(--rd-warning);     --rd-warn-dot: var(--rd-secondary);
    --rd-bad-bg: var(--rd-danger-bg);      --rd-bad-bd: var(--rd-danger-border);  --rd-bad-fg: var(--rd-danger);       --rd-bad-dot: var(--rd-danger);
    --rd-plain-bg: var(--rd-surface-alt);  --rd-plain-bd: var(--rd-border-strong); --rd-plain-fg: var(--rd-text-secondary); --rd-plain-dot: var(--rd-text-meta);

    /* Inset panels and tinted columns. */
    --rd-amber-inset: var(--rd-warning-light);
    --rd-red-inset: var(--rd-danger-light);
    --rd-amber-icon: var(--rd-secondary-light);
    --rd-tint-col: var(--rd-surface-alt);
    --rd-tint-col-alt: var(--rd-surface-alt);
    --rd-tint-col-edge: var(--rd-border);

    /* --rd-success / --rd-warning / --rd-danger are theme tokens already
       (ink-strength, safe as text). Info has no token of its own. */
    --rd-info: var(--rd-primary-ink);

    /* Text aliases. */
    --rd-hairline:  var(--rd-border);
    --rd-text:      var(--rd-text-primary);
    --rd-text-2:    var(--rd-text-secondary);
    --rd-text-3:    var(--rd-text-secondary);
    --rd-text-muted:var(--rd-text-meta);
    --rd-text-faint:var(--rd-track-empty);

    /* Radii — the v2 ladder (DESIGN-SPEC §5). */
    --rd-radius-pill: 999px;
    --rd-radius-card: 16px;   /* cards, panels, stat cards */
    --rd-radius-inset: 14px;
    --rd-radius-block: 12px;
    --rd-radius-auth: 10px;
    --rd-radius-control: 10px; /* inputs, buttons, icon buttons */
    --rd-radius-tile: 9px;
    --rd-radius-toolbar: 8px;

    --rd-shadow-card: 0 1px 2px rgba(31,27,22,.04);
    --rd-shadow-sticky: 0 -1px 3px rgba(31,27,22,.05);
    --rd-shadow-doc: 0 2px 8px rgba(31,27,22,.06);
    --rd-shadow-selected: 0 12px 22px -12px var(--rd-active-nav-shadow);
    --rd-shadow-toast: 0 10px 28px rgba(31,27,22,.28);
    --rd-shadow-phone: 0 18px 44px rgba(31,27,22,.22);
    --rd-shadow-lift: 0 14px 30px -18px rgba(31,27,22,.35);
    --rd-focus-ring: 0 0 0 3px var(--rd-primary-light);

    /* v1 nav names, used by bulk bars, steps and avatars. */
    --rd-nav-hover: var(--rd-hover-bg);
    --rd-nav-active-bg: var(--rd-primary-light);
    --rd-nav-active-text: var(--rd-primary-ink);

    /* Shell sizes (DESIGN-SPEC §4.1); the rail width is per theme, below. */
    --rd-header-h: 66px;
    --rd-nav-w: 84px;
    --rd-rail-w: 238px;

    /* Bootstrap overrides */
    --bs-primary: var(--rd-primary-ink);
    --bs-body-bg: var(--rd-bg);
    --bs-body-color: var(--rd-text-secondary);
    --bs-heading-color: var(--rd-text-primary);
    --bs-border-color: var(--rd-border);
    --bs-border-radius: var(--rd-radius-control);
    --bs-body-font-family: var(--rd-body-font);
    --bs-font-monospace: var(--rd-mono-font);
    --bs-body-font-size: 0.84375rem;  /* 13.5px — the v2 body size */
    --bs-link-color: var(--rd-primary-ink);
    --bs-link-hover-color: var(--rd-hover-color);
    --bs-secondary-color: var(--rd-text-meta);
    --bs-secondary-bg: var(--rd-surface-alt);
    --bs-tertiary-color: var(--rd-text-meta);
    --bs-tertiary-bg: var(--rd-surface-alt);
    --bs-emphasis-color: var(--rd-text-primary);
}

/* Rail width per theme — DESIGN-SPEC §4.1. */
[data-theme="aurora"] { --rd-nav-w: 244px; }
[data-theme="mint"]   { --rd-nav-w: 232px; }

/* Headings in the theme's heading face; numbers always in Plex Mono. */
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-family: var(--rd-heading-font); color: var(--rd-text-primary); }

/* ---- Base ---- */

body {
    background: var(--rd-bg);
    color: var(--rd-text);
}

/* Every number in the product aligns. Currency columns depend on this. */
.rd-num,
td.rd-num,
.table td.rd-num,
input[type="number"] {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* Keyboard focus must always be visible — telecallers work keyboard-first. */
:focus-visible {
    outline: 2px solid var(--rd-brand-600);
    outline-offset: 2px;
}

/* ---- Density ---- */

[data-density="compact"] .table > :not(caption) > * > * {
    padding-top: .3rem;
    padding-bottom: .3rem;
}

[data-density="comfortable"] .table > :not(caption) > * > * {
    padding-top: .65rem;
    padding-bottom: .65rem;
}

/* ---- Status chips ----
   Never colour alone: every chip carries its label as text. */

.rd-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 500;
    border: 1px solid transparent;
    white-space: nowrap;
}

.rd-chip::before {
    content: "";
    width: .4rem;
    height: .4rem;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.rd-chip-success { color: var(--rd-success); border-color: currentColor; }
.rd-chip-warning { color: var(--rd-warning); border-color: currentColor; }
.rd-chip-danger  { color: var(--rd-danger);  border-color: currentColor; }
.rd-chip-info    { color: var(--rd-info);    border-color: currentColor; }
.rd-chip-muted   { color: var(--rd-text-muted); border-color: var(--rd-border); }

/* ---- Shell ---- */

/*
 | The v2 shell (DESIGN-SPEC §4.1): a 66px light header across the full
 | width, the nav rail beneath it on the left, the page beside it.
 |
 | The window still scrolls (the header and rail are sticky) rather than
 | <main> being the scroll container: pagination jumps, sticky footers and
 | wire:navigate's scroll restore all depend on window scrolling. It draws the
 | same frame the design fixes at 100vh.
 */

.rd-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--rd-bg); }

.rd-appbar {
    height: var(--rd-header-h);
    flex: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 18px;
    background: var(--rd-header-bg);
    border-bottom: 1px solid var(--rd-header-border);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    color: var(--rd-text-primary);
}

/* Every fixed item keeps its size; only the centre group gives way. */
.rd-appbar > * { flex: none; }

.rd-appbar-brand { display: flex; align-items: center; gap: 10px; color: var(--rd-text-primary); text-decoration: none; }
.rd-appbar-brand:hover { color: var(--rd-text-primary); text-decoration: none; }

/* actionBg (activeNavBg), not primary: the tone built to carry a white letter. */
.rd-appbar-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--rd-action-bg);
    color: #fff;
    font-family: var(--rd-heading-font);
    font-size: 16px;
    font-weight: 800;
}

.rd-appbar-name { font-family: var(--rd-heading-font); font-size: 16px; font-weight: 700; letter-spacing: -.02em; }
.rd-appbar-divider { width: 1px; height: 24px; background: var(--rd-border); }
.rd-appbar-section { font-size: 12.5px; font-weight: 700; color: var(--rd-text-meta); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Centre section tabs — only where the page provides them. */
.rd-appbar-tabs { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 3px; overflow: hidden; }

.rd-appbar-tab {
    padding: 7px 12px;
    border-radius: 10px;
    color: var(--rd-text-meta);
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.rd-appbar-tab:hover { background: var(--rd-surface-alt); color: var(--rd-text-primary); text-decoration: none; }
.rd-appbar-tab.is-active { background: var(--rd-primary-light); color: var(--rd-primary-ink); font-weight: 800; }

/* 36px icon buttons: WhatsApp and anything a module adds to the bar. */
.rd-appbar-icon {
    position: relative;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--rd-border);
    border-radius: 10px;
    background: var(--rd-surface);
    color: var(--rd-text-meta);
    font-size: 15px;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.rd-appbar-icon:hover { background: var(--rd-surface-alt); color: var(--rd-primary-ink); }

/* The person: 34px initials tile, name over role, and a menu with Sign out. */
.rd-appbar-person {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 6px 3px 3px;
    border: 0;
    border-radius: 12px;
    background: none;
    color: var(--rd-text-primary);
    text-align: left;
    cursor: pointer;
}

.rd-appbar-person:hover { background: var(--rd-surface-alt); }

.rd-appbar-avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 10px;
    background: var(--rd-primary-light);
    color: var(--rd-primary-ink);
    font-size: 12.5px;
    font-weight: 800;
}

.rd-appbar-who { line-height: 1.2; }
.rd-appbar-who b { display: block; font-size: 12.5px; font-weight: 800; color: var(--rd-text-primary); white-space: nowrap; }
.rd-appbar-who small { display: block; font-size: 11px; color: var(--rd-text-meta); white-space: nowrap; }

.rd-appbar-menu { min-width: 220px; padding: 6px; border: 1px solid var(--rd-border); border-radius: 14px; box-shadow: var(--rd-shadow-lift); }
.rd-appbar-menu .dropdown-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--rd-text-secondary); }
.rd-appbar-menu .dropdown-item:hover, .rd-appbar-menu .dropdown-item:focus { background: var(--rd-hover-bg); color: var(--rd-hover-color); }
.rd-appbar-menu .dropdown-item i { color: var(--rd-text-meta); }
.rd-appbar-menu-head { padding: 6px 10px 8px; border-bottom: 1px solid var(--rd-border); margin-bottom: 4px; font-size: 11.5px; color: var(--rd-text-meta); }
.rd-appbar-menu-head b { display: block; font-size: 13px; color: var(--rd-text-primary); }

.rd-body { flex: 1; min-height: 0; display: flex; }

/* ---- The nav rail: one list, three looks (DESIGN-SPEC §4.1) ---- */

.rd-sidebar {
    width: var(--rd-nav-w);
    flex: none;
    background: var(--rd-sidebar-bg);
    border-right: 1px solid var(--rd-sidebar-border);
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    overflow-y: auto;
    scrollbar-width: thin;
}

[data-theme="sunrise"] .rd-sidebar { padding: 16px 0; }

.rd-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
[data-theme="sunrise"] .rd-nav { gap: 6px; align-items: center; }

.rd-nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    flex: none;
    padding: 9px 12px;
    border-radius: 9px;
    color: var(--rd-text-meta);
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.rd-nav-link i { font-size: 15px; width: 18px; text-align: center; flex: none; }
.rd-nav-link .rd-nav-short { display: none; }

.rd-nav-link:hover { background: var(--rd-hover-bg); color: var(--rd-hover-color); text-decoration: none; }

.rd-nav-link.is-active {
    background: var(--rd-active-nav-bg);
    color: var(--rd-active-nav-color);
    box-shadow: 0 12px 22px -12px var(--rd-active-nav-shadow);
}

/* Sunrise: an 84px icon rail — 66px items, icon over an 11px short label. */
[data-theme="sunrise"] .rd-nav-link {
    flex-direction: column;
    gap: 5px;
    width: 66px;
    padding: 10px 0;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

[data-theme="sunrise"] .rd-nav-link i { font-size: 17px; width: auto; }
[data-theme="sunrise"] .rd-nav-link .rd-nav-full { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[data-theme="sunrise"] .rd-nav-link .rd-nav-short { display: block; line-height: 1.1; }
[data-theme="sunrise"] .rd-nav-link.is-active { font-weight: 800; }

/* Aurora: a 244px sidebar of pills on a gradient. */
[data-theme="aurora"] .rd-nav-link { padding: 11px 13px; border-radius: 13px; font-weight: 600; }

/* Mint: a 232px flat sidebar; the active item is a white card. */
[data-theme="mint"] .rd-nav-link { font-weight: 500; }
[data-theme="mint"] .rd-nav-link.is-active { font-weight: 600; }

.rd-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

:root { --rd-stick: 0px; }

@media (min-width: 768px) {
    :root { --rd-stick: var(--rd-header-h); }

    .rd-appbar { position: sticky; top: 0; z-index: 40; }

    .rd-sidebar {
        position: sticky;
        top: var(--rd-header-h);
        height: calc(100vh - var(--rd-header-h));
        align-self: flex-start;
    }
}

.rd-pagehead {
    flex: none;
    padding: 22px 26px 0;
}

/* Page padding — the design's main: 24px 26px 28px. */
.rd-content { flex: 1; padding: 22px 26px 36px; }
.rd-pagehead + .rd-content { padding-top: 16px; }

.rd-card {
    background: var(--rd-surface);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius-card);
    box-shadow: var(--rd-shadow-card);
}

[data-theme="aurora"] .rd-card { box-shadow: 0 10px 30px -22px rgba(49,46,129,.35); }

/* Narrow laptops: the wide sidebars fall back to the icon rail's width. */
@media (min-width: 768px) and (max-width: 1100px) {
    [data-theme="aurora"], [data-theme="mint"] { --rd-nav-w: 200px; }
    .rd-appbar-tabs { display: none; }
}

/* Phones: the rail becomes a bottom tab bar of five, the fifth being More. */
@media (max-width: 767.98px) {
    .rd-appbar { padding: 0 12px; gap: 8px; }
    .rd-appbar-section, .rd-appbar-divider, .rd-appbar-tabs, .rd-appbar-who, .rd-appbar-name { display: none; }
    .rd-appbar-spacer { flex: 1; }

    .rd-body { flex-direction: column; }

    .rd-sidebar,
    [data-theme="sunrise"] .rd-sidebar {
        width: 100%;
        order: 2;
        flex-direction: row;
        border-right: 0;
        border-top: 1px solid var(--rd-sidebar-border);
        position: sticky;
        bottom: 0;
        padding: 4px;
        z-index: 20;
        overflow: visible;
    }

    .rd-nav, [data-theme="sunrise"] .rd-nav { flex-direction: row; width: 100%; gap: 2px; align-items: stretch; }

    .rd-nav-link,
    [data-theme] .rd-nav-link {
        flex: 1;
        flex-direction: column;
        justify-content: center;
        gap: 3px;
        width: auto;
        min-height: 48px;
        padding: 6px 2px;
        border-radius: 12px;
        font-size: 11px;
        text-align: center;
    }

    .rd-nav-link .rd-nav-full, [data-theme] .rd-nav-link .rd-nav-full { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .rd-nav-link .rd-nav-short, [data-theme] .rd-nav-link .rd-nav-short { display: block; }
    .rd-nav-link i { font-size: 17px; width: auto; }

    .rd-pagehead { padding: 16px 16px 0; }
    .rd-content { padding: 14px 16px 32px; }
}

/* The platform console's sign-out, and any plain text button in the bar. */
.rd-appbar-signout { font-size: 12.5px; font-weight: 700; color: var(--rd-text-secondary); background: var(--rd-surface); border: 1px solid var(--rd-border); border-radius: 10px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.rd-appbar-signout:hover { border-color: var(--rd-primary); color: var(--rd-hover-color); }
.rd-appbar-spacer { flex: 1 1 auto; }

/* Guest pages — sign in, sign up, provisioning — have no workspace to navigate. */
.rd-guest { min-height: 100vh; display: flex; flex-direction: column; }
.rd-guest-brand { padding: 1rem 1.25rem; font-weight: 600; }
.rd-guest .rd-content { padding-top: 2rem; }

/* Dashboard tiles */
.rd-stat-value { font-size: 1.5rem; font-weight: 600; line-height: 1.1; }
.rd-stat-label { color: var(--rd-text-muted); font-size: .8rem; }

/* ---- Brand colour on Bootstrap components ----
   Overriding --bs-primary is not enough: Bootstrap 5.3 compiles each
   component's colours into its own variables from Sass, so buttons, focus
   rings and checkboxes stayed default blue while links took the brand. */

.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--rd-primary-ink);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--rd-primary-ink);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-focus-shadow-rgb: 120, 60, 40;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--rd-primary-ink);
    --bs-btn-active-border-color: transparent;
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--rd-primary-ink);
    --bs-btn-disabled-border-color: transparent;
    /* actionBg: activeNavBg, the tone built to carry white (a gradient in Aurora). */
    background: var(--rd-action-bg);
    font-weight: 800;
    white-space: nowrap;
}

.btn-primary:hover, .btn-primary:focus-visible { background: var(--rd-action-bg); filter: brightness(1.1); }
.btn-outline-primary {
    --bs-btn-color: var(--rd-primary-ink);
    --bs-btn-border-color: var(--rd-primary-mid);
    --bs-btn-hover-color: var(--rd-hover-color);
    --bs-btn-hover-bg: var(--rd-primary-light);
    --bs-btn-hover-border-color: var(--rd-primary);
    --bs-btn-focus-shadow-rgb: 120, 60, 40;
    --bs-btn-active-color: var(--rd-primary-ink);
    --bs-btn-active-bg: var(--rd-primary-light);
    --bs-btn-active-border-color: var(--rd-primary);
    font-weight: 700;
    white-space: nowrap;
}

/* Outline buttons (DESIGN-SPEC §5.3): surface fill, border, textSecondary. */
.btn-outline-secondary, .btn-light {
    --bs-btn-color: var(--rd-text-secondary);
    --bs-btn-bg: var(--rd-surface);
    --bs-btn-border-color: var(--rd-border);
    --bs-btn-hover-color: var(--rd-hover-color);
    --bs-btn-hover-bg: var(--rd-surface);
    --bs-btn-hover-border-color: var(--rd-primary);
    --bs-btn-active-color: var(--rd-hover-color);
    --bs-btn-active-bg: var(--rd-surface-alt);
    --bs-btn-active-border-color: var(--rd-primary);
    --bs-btn-disabled-color: var(--rd-text-meta);
    --bs-btn-disabled-bg: var(--rd-surface);
    --bs-btn-disabled-border-color: var(--rd-border);
    font-weight: 700;
    white-space: nowrap;
}

.btn { --bs-btn-border-radius: var(--rd-radius-control); }
.btn-sm { --bs-btn-border-radius: 9px; }

.btn-link { --bs-btn-color: var(--rd-primary-ink); --bs-btn-hover-color: var(--rd-hover-color); }
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: var(--rd-primary);
    box-shadow: var(--rd-focus-ring);
}

.form-check-input:checked {
    background-color: var(--rd-brand-700);
    border-color: var(--rd-brand-700);
}

.pagination {
    --bs-pagination-color: var(--rd-brand-700);
    --bs-pagination-hover-color: var(--rd-brand-800);
    --bs-pagination-focus-color: var(--rd-brand-800);
    --bs-pagination-focus-box-shadow: var(--rd-focus-ring);
    --bs-pagination-active-bg: var(--rd-primary-ink);
    --bs-pagination-active-border-color: var(--rd-brand-700);
    /* Compact: a list's pager is a control, not a banner. At Bootstrap's
       default size "1 … 4802" took a third of the footer. */
    --bs-pagination-padding-x: .55rem;
    --bs-pagination-padding-y: .2rem;
    --bs-pagination-font-size: .8125rem;
    --bs-pagination-border-radius: 8px;
    margin: 0;
}

/* v2 pager: 32px squares with gaps, mono numbers, the current page filled. */
.pagination { gap: 6px; --bs-pagination-bg: var(--rd-surface); --bs-pagination-border-color: var(--rd-border); --bs-pagination-color: var(--rd-text-secondary); --bs-pagination-hover-bg: var(--rd-surface); --bs-pagination-hover-border-color: var(--rd-primary); --bs-pagination-disabled-bg: var(--rd-surface-alt); --bs-pagination-disabled-border-color: var(--rd-border); }
.pagination .page-link { min-width: 32px; height: 32px; display: grid; place-items: center; padding: 0 8px; border-radius: 8px !important; margin: 0 !important; text-align: center; font-family: var(--rd-mono-font); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pagination .page-item.active .page-link { font-weight: 600; color: #fff; }

/* Livewire's pager prints "Showing 1 to 25 of N results". Where a footer
   already states its own range and page size — the leads list, the call queue —
   that line is a second, differently worded copy squeezed into the same row. */
.lead-foot-pages nav p.small,
.tc-table-foot nav p.small,
.rd-own-count nav p.small { display: none; }

.lead-foot-pages nav > div,
.tc-table-foot nav > div { gap: 8px; }

/* ---- Shared module patterns ----
   Every module uses these rather than inventing its own, so four modules built
   in parallel still read as one product. Module-specific styles go in
   public/css/modules/<module>.css. */

/* Page header: title, subtitle and actions */
.rd-page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1rem;
}

.rd-page-title { font-size: 1.125rem; font-weight: 600; margin: 0; }
.rd-page-subtitle { color: var(--rd-text-muted); font-size: .8rem; margin: 0; }

/* Filter bar above a list */
.rd-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: flex-end;
}

/* Bulk action bar — shown only while rows are selected */
.rd-bulk-bar {
    position: sticky;
    top: var(--rd-stick);
    z-index: 5;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .5rem .75rem;
    margin-bottom: .75rem;
    background: var(--rd-nav-active-bg);
    color: var(--rd-nav-active-text);
    border-radius: var(--rd-radius-card);
}

.rd-table-select { width: 2.25rem; }

/* Kanban pipeline */
.rd-kanban {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    overflow-x: auto;
    padding-bottom: .5rem;
}

.rd-kanban-col {
    flex: 0 0 280px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 12rem);
    background: var(--rd-surface);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius-card);
}

.rd-kanban-col-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--rd-border);
    font-weight: 600;
}

.rd-kanban-col-body {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    min-height: 3rem;
    padding: .5rem;
    overflow-y: auto;
}

.rd-kanban-card {
    padding: .5rem .6rem;
    background: var(--rd-bg);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius-control);
}

/* Stepper for multi-step flows such as imports */
.rd-stepper {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.rd-step { display: flex; align-items: center; gap: .4rem; color: var(--rd-text-muted); font-size: .8rem; }

.rd-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border: 1px solid var(--rd-border);
    border-radius: 50%;
    font-weight: 600;
}

.rd-step.is-current { color: var(--rd-text); font-weight: 600; }
.rd-step.is-current .rd-step-num { background: var(--rd-brand-700); border-color: var(--rd-brand-700); color: #fff; }
.rd-step.is-done .rd-step-num { background: var(--rd-nav-active-bg); color: var(--rd-nav-active-text); }

/* Upload drop zone */
.rd-dropzone {
    padding: 1.5rem;
    text-align: center;
    color: var(--rd-text-muted);
    background: var(--rd-surface);
    border: 2px dashed var(--rd-border);
    border-radius: var(--rd-radius-card);
}

.rd-dropzone:hover { border-color: var(--rd-brand-400); }

/* Activity timeline */
.rd-timeline { list-style: none; margin: 0; padding: 0; }
.rd-timeline-item { position: relative; padding: 0 0 .9rem 1.5rem; }

.rd-timeline-item::before {
    content: "";
    position: absolute;
    left: .35rem;
    top: .4rem;
    width: .5rem;
    height: .5rem;
    border-radius: 50%;
    background: var(--rd-brand-500);
}

.rd-timeline-item::after {
    content: "";
    position: absolute;
    left: .575rem;
    top: 1rem;
    bottom: 0;
    width: 1px;
    background: var(--rd-border);
}

.rd-timeline-item:last-child::after { display: none; }

/* Key–value details */
.rd-dl {
    display: grid;
    grid-template-columns: minmax(8rem, 35%) 1fr;
    gap: .35rem 1rem;
    margin: 0;
}

.rd-dl dt { color: var(--rd-text-muted); font-weight: 400; }
.rd-dl dd { margin: 0; }

/* Initials avatar */
.rd-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    font-size: .7rem;
    font-weight: 600;
    background: var(--rd-nav-active-bg);
    color: var(--rd-nav-active-text);
}

@media (max-width: 767.98px) {
    .rd-kanban-col { flex-basis: 85vw; }
    .rd-dl { grid-template-columns: 1fr; }
}

/* ---- Mobile navigation overflow: the More sheet ----
   Thirteen modules do not fit a phone's tab bar, and hiding the overflow put
   eight of them out of reach on a phone entirely. The bar now spends its fifth
   slot on More, which opens this sheet. Phone only — the desktop sidebar still
   lists every link and none of this applies to it.

   Rows are a list, not tab-bar tabs, so they do not reuse .rd-nav-link: the
   mobile rules above turn that class into a centred icon-over-label column. */

.rd-nav-sheet {
    height: auto;
    max-height: 78vh;
    background: var(--rd-surface);
    color: var(--rd-text);
    border-top: 1px solid var(--rd-border);
    border-top-left-radius: var(--rd-radius-card);
    border-top-right-radius: var(--rd-radius-card);
}

.rd-nav-sheet-group {
    padding: .75rem .25rem .25rem;
    color: var(--rd-text-muted);
    font-size: .625rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.rd-nav-sheet-link {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: .5rem .75rem;
    border-radius: var(--rd-radius-control);
    color: var(--rd-text);
    text-decoration: none;
    font-weight: 500;
}

.rd-nav-sheet-link:hover { background: var(--rd-nav-hover); color: var(--rd-text); }
.rd-nav-sheet-link.is-active { background: var(--rd-nav-active-bg); color: var(--rd-nav-active-text); }

.rd-nav-sheet-link .bi {
    font-size: 1rem;
    width: 1.25rem;
    margin-right: .6rem;
    text-align: center;
    flex: none;
}

/* "Working in" — the workspace-wide business/branch choice in the app bar.
   Amber when a focus is set, so nobody forgets they are looking at one part. */
.rd-focus {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 3px 4px 3px 10px;
    border: 1px solid var(--rd-border);
    border-radius: 10px;
    background: var(--rd-surface-alt);
    color: var(--rd-text-meta);
    font-size: 12px;
}

.rd-focus > .bi { font-size: 13px; color: var(--rd-primary-ink); }
.rd-focus-label { margin: 0; font-weight: 700; white-space: nowrap; }

.rd-focus select {
    max-width: 200px;
    height: 28px;
    padding: 0 26px 0 10px;
    border: 1px solid var(--rd-border);
    border-radius: 8px;
    background: var(--rd-surface) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%237a6a5c' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") no-repeat right 9px center / 10px 10px;
    color: var(--rd-text-primary);
    font-size: 12px;
    font-weight: 700;
    appearance: none;
    cursor: pointer;
    text-overflow: ellipsis;
}

/* A focus is set: warning tones, so nobody forgets they see one part. */
.rd-focus.is-on { border-color: var(--rd-secondary); background: var(--rd-warning-light); color: var(--rd-warning); }
.rd-focus.is-on > .bi { color: var(--rd-warning); }
.rd-focus.is-on select { color: var(--rd-warning); }

@media (max-width: 767.98px) {
    .rd-focus { margin-right: 8px; }
    .rd-focus-label, .rd-focus > .bi { display: none; }
    .rd-focus select { max-width: 130px; }
}

/* ---- Bootstrap tabs and pills on the v2 theme ----
   Every secondary page that uses .nav-tabs (a module's own section links) or
   .nav-pills gets the v2 underline tabs and chips, without per-page edits. */
.nav-tabs { gap: 2px; border-bottom: 1px solid var(--rd-border); flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; --bs-nav-tabs-border-width: 0; }
.nav-tabs .nav-link { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; margin-bottom: -1px; border: 0; border-bottom: 2.5px solid transparent; border-radius: 0; background: none; color: var(--rd-text-meta); font-size: 13px; font-weight: 700; white-space: nowrap; }
.nav-tabs .nav-link .bi { font-size: 12px; }
.nav-tabs .nav-link:hover { color: var(--rd-hover-color); border-bottom-color: transparent; }
.nav-tabs .nav-link.active, .nav-tabs .nav-item.show .nav-link { border-bottom-color: var(--rd-primary); color: var(--rd-primary-ink); font-weight: 800; background: none; }
.nav-pills { gap: 6px; flex-wrap: wrap; }
.nav-pills .nav-link { min-height: 34px; padding: 7px 13px; border-radius: 9px; border: 1px solid var(--rd-border); background: var(--rd-surface); color: var(--rd-text-meta); font-size: 12.5px; font-weight: 700; }
.nav-pills .nav-link:hover { border-color: var(--rd-primary); color: var(--rd-hover-color); }
.nav-pills .nav-link.active { background: var(--rd-text-primary); border-color: var(--rd-text-primary); color: #fff; font-weight: 800; }

/* v1 chips on the theme: light ground + ink text + dot. */
.rd-chip { padding: 3px 10px; border: 0; font-weight: 800; font-size: 11.5px; }
.rd-chip-success { background: var(--rd-success-light); color: var(--rd-success-ink); }
.rd-chip-warning { background: var(--rd-secondary-light); color: var(--rd-secondary-ink); }
.rd-chip-danger  { background: var(--rd-danger-bg); color: var(--rd-danger); }
.rd-chip-info    { background: var(--rd-primary-light); color: var(--rd-primary-ink); }
.rd-chip-muted   { background: var(--rd-surface-alt); color: var(--rd-text-secondary); }
.rd-chip-success::before { background: var(--rd-accent); }
.rd-chip-warning::before { background: var(--rd-secondary); }
.rd-chip-danger::before { background: var(--rd-danger); }
.rd-chip-info::before { background: var(--rd-primary); }
.rd-chip-muted::before { background: var(--rd-text-meta); }

/* Platform support session banner (G31) — always visible while support is inside. */
.rd-support-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; padding: 10px 14px; border-radius: 12px; background: var(--rd-secondary-light); border: 1px solid var(--rd-secondary); color: var(--rd-secondary-ink); font-size: 13px; }
.rd-support-bar .bi { font-size: 16px; }
.rd-support-bar.is-write { background: var(--rd-danger-light); border-color: var(--rd-danger); color: var(--rd-danger); }
