/* ============================================================================
 * Royals666 Admin — Single Design System
 * ----------------------------------------------------------------------------
 * Replaces admin-scraped-polish.css. One file, no arms race.
 * Themes via Bootstrap 5's --bs-* CSS variables so framework internals stay
 * consistent; supplements with scoped rules under `main` for the admin shell.
 *
 * Design tokens are defined once at :root. Components use the tokens.
 * Specificity is held by `main .foo` not ``.
 * ============================================================================ */

/* 2026-05-19 cleanup pass:
 *  - Removed dead light-theme aside.ap-sidebar rule at former line 1339
 *    (superseded by dark variant with).
 *  - Collapsed 5 duplicate selector blocks (main .card/.tb-card,
 *    .nav-tabs, .nav-link, .nav-link.active) — single source per selector.
 *  - All edits are byte-removal of provably-dead rules. No visual change.
 */

:root {
    /* ── Palette ───────────────────────────────────────────────────────── */
    --r-bg:           #fafaf9;   /* page background */
    --r-surface:      #ffffff;   /* cards / panels */
    --r-surface-2:    #f5f5f4;   /* subtle hover / striped */
    --r-surface-3:    #fafaf9;   /* table header row */
    --r-line:         #e7e5e4;   /* default border */
    --r-line-2:       #f5f5f4;   /* lighter divider */

    --r-text:         #1c1917;   /* primary text */
    --r-text-2:       #525252;   /* secondary text */
    --r-muted:        #737373;   /* muted captions */
    --r-faint:        #a8a29e;   /* placeholders */

    --r-brand:        #2563eb;   /* primary action */
    --r-brand-2:      #1d4ed8;   /* primary hover */
    --r-brand-soft:   rgba(37, 99, 235, 0.10);

    --r-success:      #047857;
    --r-success-soft: #ecfdf5;
    --r-warn:         #b45309;
    --r-warn-soft:    #fffbeb;
    --r-danger:       #b91c1c;
    --r-danger-soft:  #fef2f2;
    --r-info:         #1d4ed8;
    --r-info-soft:    #eff6ff;

    /* ── Spacing / Radius / Shadow ─────────────────────────────────────── */
    --r-radius-sm:    8px;
    --r-radius-md:    10px;
    --r-radius-lg:    12px;
    --r-radius-pill:  9999px;

    --r-shadow-1:     0 1px 2px rgba(0, 0, 0, 0.04);
    --r-shadow-2:     0 4px 12px rgba(0, 0, 0, 0.06);

    --r-focus-ring:   0 0 0 3px rgba(51, 154, 240, 0.15);

    /* ── Type ──────────────────────────────────────────────────────────── */
    --r-font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --r-font-mono:    ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ============================================================================
 * Bootstrap CSS-variable theming.
 * Setting these here makes Bootstrap components honor the design system
 * natively, without any per-component override.
 * ============================================================================ */
:root {
    /* Bootstrap brand */
    --bs-primary:        var(--r-brand);
    --bs-primary-rgb:    37, 99, 235;
    --bs-success:        var(--r-success);
    --bs-warning:        var(--r-warn);
    --bs-danger:         var(--r-danger);
    --bs-info:           var(--r-info);

    /* Bootstrap body */
    --bs-body-bg:        var(--r-bg);
    --bs-body-color:     var(--r-text);
    --bs-body-font-family: var(--r-font);
    --bs-body-font-size: 14px;
    --bs-border-color:   var(--r-line);
    --bs-border-radius:  var(--r-radius-md);
    --bs-border-radius-sm: var(--r-radius-sm);
    --bs-border-radius-lg: var(--r-radius-lg);

    /* Bootstrap table */
    --bs-table-bg:       var(--r-surface);
    --bs-table-color:    var(--r-text);
    --bs-table-border-color: var(--r-line-2);
    --bs-table-hover-bg: var(--r-surface-2);
    --bs-table-hover-color: var(--r-text);

    /* Bootstrap form */
    --bs-form-control-bg: var(--r-surface);
    --bs-form-control-color: var(--r-text);
    --bs-form-select-bg: var(--r-surface);
}

/* ============================================================================
 * Body / typography baseline (admin shell only — doesn't leak to turbo theme)
 * ============================================================================ */
body.bg-stone-100 { background: var(--r-bg); color: var(--r-text); font-family: var(--r-font); }

main { color: var(--r-text); }
/* H1 sized to reference (28-30px, 700 weight, black, no underline / no border).
 * Page-head pattern is: <h1> immediately followed by .ap-breadcrumb. */
main h1 { font-size: 1.75rem;  line-height: 2.125rem; font-weight: 700; letter-spacing: -0.015em; color: #0c0a09; margin: 0 0 0.375rem; text-decoration: none; border: 0; }
main h2 { font-size: 1.125rem; line-height: 1.75rem;  font-weight: 700; color: var(--r-text); margin: 0 0 0.5rem; }
main h3 { font-size: 1rem;     line-height: 1.5rem;   font-weight: 700; color: var(--r-text); margin: 0 0 0.5rem; }
main p  { color: var(--r-text-2); }
main a  { color: var(--r-brand); text-decoration: none; }
main a:hover { color: var(--r-brand-2); }
main small, main .small { color: var(--r-muted); }

/* ============================================================================
 * Forms — inputs, selects, textareas, labels.
 * Targets both bare elements and Bootstrap .form-control / .form-select.
 * ============================================================================ */
main input[type="text"],
main input[type="email"],
main input[type="number"],
main input[type="password"],
main input[type="search"],
main input[type="date"],
main input[type="datetime-local"],
main input[type="tel"],
main input[type="url"],
main select,
main textarea,
main .form-control,
main .form-select {
    background: var(--r-surface);
    border: 1px solid var(--r-line);
    border-radius: var(--r-radius-md);
    padding: 8px 12px;
    font: inherit;
    font-size: 13px;
    color: var(--r-text);
    outline: none;
    box-shadow: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
    min-height: 38px;
}
main input::placeholder,
main textarea::placeholder { color: var(--r-faint); }
main input:focus,
main select:focus,
main textarea:focus,
main .form-control:focus,
main .form-select:focus {
    border-color: #339af0;
    box-shadow: var(--r-focus-ring);
}
main label,
main .form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #404040;
    margin-bottom: 6px;
}
main .form-text { font-size: 12px; color: var(--r-muted); margin-top: 4px; }
main .input-group .form-control,
main .input-group .form-select { border-radius: var(--r-radius-md); }

/* ============================================================================
 * Buttons — single set of variants, scraped palette.
 * ============================================================================ */
main .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--r-radius-md);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.2;
    border: 1px solid transparent;
    transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
main .btn:focus-visible { box-shadow: var(--r-focus-ring); }
main .btn:disabled, main .btn.disabled { opacity: 0.55; cursor: not-allowed; }

main .btn-primary   { background: var(--r-brand);   border-color: var(--r-brand);   color: #ffffff; }
main .btn-primary:hover { background: var(--r-brand-2); border-color: var(--r-brand-2); }
main .btn-success   { background: #10b981; border-color: #10b981; color: #ffffff; }
main .btn-success:hover { background: #059669; border-color: #059669; }
main .btn-danger    { background: #dc2626; border-color: #dc2626; color: #ffffff; }
main .btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
main .btn-warning   { background: #f59e0b; border-color: #f59e0b; color: #ffffff; }
main .btn-warning:hover { background: #d97706; border-color: #d97706; }
main .btn-info      { background: #0ea5e9; border-color: #0ea5e9; color: #ffffff; }
main .btn-secondary { background: var(--r-surface); border-color: var(--r-line); color: var(--r-text); }
main .btn-secondary:hover { background: var(--r-surface-2); border-color: #d6d3d1; }

main .btn-outline-primary,
main .btn-outline-secondary,
main .btn-outline-warning,
main .btn-outline-danger,
main .btn-outline-info,
main .btn-outline-success {
    background: transparent;
    color: var(--r-text);
}
main .btn-outline-primary { border-color: var(--r-brand);  color: var(--r-brand);  }
main .btn-outline-primary:hover { background: var(--r-brand-soft); }
main .btn-outline-warning { border-color: #fde68a; color: var(--r-warn); }
main .btn-outline-warning:hover { background: var(--r-warn-soft); }
main .btn-outline-danger  { border-color: #fecaca; color: var(--r-danger); }
main .btn-outline-danger:hover  { background: var(--r-danger-soft); }
main .btn-outline-info    { border-color: #bfdbfe; color: var(--r-info); }
main .btn-outline-info:hover    { background: var(--r-info-soft); }
main .btn-outline-success { border-color: #a7f3d0; color: var(--r-success); }
main .btn-outline-success:hover { background: var(--r-success-soft); }
main .btn-outline-secondary { border-color: var(--r-line); color: var(--r-text-2); }
main .btn-outline-secondary:hover { background: var(--r-surface-2); }

main .btn-sm { padding: 6px 12px; font-size: 12px; }
main .btn-lg { padding: 10px 22px; font-size: 14px; }

/* ============================================================================
 * Cards — Bootstrap .card and tb-card both adopt the same look.
 * ============================================================================ */
main .card,
main .tb-card {
    background: var(--r-surface);
    border: 1px solid var(--r-line);
    border-color: var(--r-hairline-2); /* merged from former Elite Refinement Layer */
    border-radius: var(--r-radius-lg);
    box-shadow: none;                  /* merged from former Elite Refinement Layer */
    color: var(--r-text);
}
main .card-header {
    background: var(--r-surface-3);
    color: var(--r-text);
    border-bottom: 1px solid var(--r-line);
    padding: 12px 18px;
    font-weight: 700;
    font-size: 13px;
}
main .card-body  { padding: 18px; }
main .card-footer {
    background: var(--r-surface-3);
    border-top: 1px solid var(--r-line);
    padding: 12px 18px;
}

main .tb-card-label { color: var(--r-muted); font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 6px; }
main .tb-card-value { color: #0c0a09;        font-size: 34px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
/* Refined KPI tile — white surface, 16px padding, 8px radius, subtle 1px border,
 * no shadow. Top-right overflow dots; big number; two-stat footer row. */
main .tb-card-stat  {
    padding: 16px;
    min-height: 132px;
    display: flex;
    flex-direction: column;
    background: var(--r-surface);
    border: 1px solid #e7e7e7;
    border-color: var(--r-hairline-2); /* merged from former Elite Refinement Layer */
    border-radius: var(--r-radius-sm);
    box-shadow: none;
}
main .tb-card-value svg { width: 28px; height: 28px; flex-shrink: 0; }
/* 3-dot overflow in the top-right of a KPI card. */
main .tb-card-stat .tb-card-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 10px;
}
main .tb-card-stat .tb-card-dots {
    background: transparent; border: 0; cursor: pointer;
    color: var(--r-faint); padding: 0 2px;
    font-size: 14px; line-height: 1;
}
main .tb-card-stat .tb-card-dots:hover { color: var(--r-text-2); }
/* Footer mini-stats row at the bottom of a KPI tile (label + value, one line). */
main .tb-card-stat .tb-card-footer {
    display: flex; gap: 18px; margin-top: auto; padding-top: 10px;
    border-top: 1px solid var(--r-line-2);
    font-size: 11px; color: var(--r-muted);
}
main .tb-card-stat .tb-card-footer .tb-card-foot {
    display: inline-flex; gap: 4px; align-items: baseline;
}
main .tb-card-stat .tb-card-footer .tb-card-foot-label { color: var(--r-muted); }
main .tb-card-stat .tb-card-footer .tb-card-foot-value { color: var(--r-text); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ============================================================================
 * Tables — Bootstrap .table + bare <table> + .tb-table-wrap.
 * Single look: white surface, gray uppercase header, soft hover.
 * ============================================================================ */
main .tb-table-wrap,
main .table-responsive {
    background: var(--r-surface);
    border: 1px solid var(--r-line);
    border-radius: var(--r-radius-lg);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--r-shadow-1);
}
main table,
main .table {
    width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    color: var(--r-text);
    --bs-table-color: var(--r-text);
}
main table thead th,
main .table thead th,
main .table-dark thead th {
    background: var(--r-surface-3);
    color: var(--r-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 11px 16px;
    text-align: left;
    border-bottom: 1px solid var(--r-line);
    white-space: nowrap;
    --bs-table-bg: var(--r-surface-3);
}
main table tbody td,
main .table tbody td,
main .table-dark tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--r-line-2);
    color: var(--r-text);
    vertical-align: middle;
    background: var(--r-surface);
    --bs-table-bg: var(--r-surface);
}
main table tbody tr:last-child td,
main .table tbody tr:last-child td { border-bottom: 0; }
main .table-hover tbody tr:hover td,
main table tbody tr:hover td        { background: var(--r-surface-2); }
main .table-dark   tbody tr:hover td { background: var(--r-surface-2); }

/* ============================================================================
 * Badges / pills — pill-shaped, semantic palette.
 * ============================================================================ */
main .badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 12px;
    min-height: 22px;
    font-size: 11px;
    font-weight: 700;
    border-radius: var(--r-radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
    white-space: nowrap;
    vertical-align: middle;
    color: #ffffff;
}
main .badge.bg-primary,   main .badge-primary   { background-color: #2563eb; color: #ffffff; border: 0; }
main .badge.bg-success,   main .badge-success   { background-color: #047857; color: #ffffff; border: 0; }
main .badge.bg-danger,    main .badge-danger    { background-color: #b91c1c; color: #ffffff; border: 0; }
main .badge.bg-info,      main .badge-info      { background-color: #1d4ed8; color: #ffffff; border: 0; }
main .badge.bg-warning,   main .badge-warning   { background-color: #d97706; color: #ffffff; border: 0; }
main .badge.bg-secondary, main .badge-secondary { background-color: #6b7280; color: #ffffff; border: 0; }
main .badge.bg-dark,      main .badge-dark      { background-color: #1f2937; color: #ffffff; border: 0; }

/* ============================================================================
 * Tabs — Bootstrap .nav-tabs → underline style; .tb-tabs → pill style.
 * ============================================================================ */
/* Flat underline-on-white tabs — matches every reference image (Transactions,
 * Casino, Sports, Bonus, Wallet, My Profile, Settings, Referrals).
 * White surface, no container card, hairline divider beneath the row,
 * active tab gets a brand-blue underline FLUSH with the strip's bottom border.
 * The -1px negative margin on .nav-item pulls the link's border-bottom directly
 * onto the strip's hairline so the active underline overlays rather than stacks. */
main .nav-tabs {
    display: flex;
    margin-bottom: 18px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--r-hairline-2); /* merged: was #e7e7e7 */
    padding: 0;
    gap: var(--r-space-2);                        /* merged: was 4px */
    --bs-nav-tabs-link-active-bg: transparent;
    --bs-nav-tabs-border-color: transparent;
}
main .nav-tabs .nav-item { margin: 0 0 -1px; display: flex; }
main .nav-tabs .nav-link {
    padding: var(--r-space-3) var(--r-space-4); /* merged: was 10px 16px 11px */
    margin-bottom: -1px;                        /* merged from former Elite Refinement Layer */
    font-size: 14px;
    font-weight: 500;
    color: var(--r-muted);
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    transition: color 150ms, border-color 150ms;
}
main .nav-tabs .nav-link:hover { color: var(--r-text); }
main .nav-tabs .nav-link.active {
    color: var(--r-text);
    background: transparent;
    border-bottom-color: var(--r-brand);
    font-weight: 600;
}

main .tb-tabs {
    display: inline-flex;
    background: transparent;
    padding: 4px;
    gap: 4px;
    margin-bottom: 18px;
}
main .tb-tabs a {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--r-muted);
    background: transparent;
    border-radius: var(--r-radius-sm);
    text-decoration: none;
}
main .tb-tabs a.active { background: #1c1917; color: #ffffff; }
main .tb-tabs a:not(.active):hover { background: var(--r-surface-2); color: var(--r-text); }

/* ============================================================================
 * Alerts — soft pastels using Bootstrap CSS vars.
 * ============================================================================ */
main .alert {
    border-radius: var(--r-radius-md);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 14px;
    --bs-alert-padding-x: 14px;
    --bs-alert-padding-y: 10px;
    --bs-alert-border-radius: var(--r-radius-md);
}
main .alert-success { --bs-alert-bg: var(--r-success-soft); --bs-alert-color: var(--r-success); --bs-alert-border-color: #a7f3d0; }
main .alert-warning { --bs-alert-bg: var(--r-warn-soft);    --bs-alert-color: var(--r-warn);    --bs-alert-border-color: #fde68a; }
main .alert-danger  { --bs-alert-bg: var(--r-danger-soft);  --bs-alert-color: var(--r-danger);  --bs-alert-border-color: #fecaca; }
main .alert-info    { --bs-alert-bg: var(--r-info-soft);    --bs-alert-color: var(--r-info);    --bs-alert-border-color: #bfdbfe; }

/* ============================================================================
 * Pagination — scraped active pill style.
 * ============================================================================ */
main .pagination {
    --bs-pagination-border-radius: var(--r-radius-sm);
    --bs-pagination-color:         var(--r-text-2);
    --bs-pagination-bg:            var(--r-surface);
    --bs-pagination-border-color:  var(--r-line);
    --bs-pagination-hover-bg:      var(--r-surface-2);
    --bs-pagination-active-bg:     #1c1917;
    --bs-pagination-active-border-color: #1c1917;
    --bs-pagination-active-color:  #ffffff;
    --bs-pagination-disabled-color: var(--r-faint);
    --bs-pagination-disabled-bg:   var(--r-surface-3);
    gap: 4px;
}

/* ============================================================================
 * Dropdown menus.
 * ============================================================================ */
main .dropdown-menu {
    --bs-dropdown-border-color: var(--r-line);
    --bs-dropdown-border-radius: var(--r-radius-md);
    --bs-dropdown-link-hover-bg: var(--r-surface-2);
    --bs-dropdown-link-hover-color: var(--r-text);
    --bs-dropdown-link-color: var(--r-text);
    --bs-dropdown-link-active-bg: var(--r-brand-soft);
    --bs-dropdown-link-active-color: var(--r-brand);
    box-shadow: var(--r-shadow-2);
    padding: 4px;
}
main .dropdown-item { border-radius: var(--r-radius-sm); padding: 6px 12px; font-size: 13px; }

/* ============================================================================
 * Bootstrap legacy text/bg color classes — neutralize to design system.
 * Many admin views still ship with the old dark-theme markup (.bg-dark,
 * .text-light, .border-secondary, .table-dark). These rules force them to
 * render as the scraped white-card look using so per-page inline
 * styles can't override them. The is scoped narrowly to legacy
 * dark-theme class names — every other rule in this file stays clean.
 * ============================================================================ */
main .text-warning { color: var(--r-warn); }
main .text-info    { color: var(--r-info); }
main .text-success { color: var(--r-success); }
main .text-danger  { color: var(--r-danger); }
main .text-primary { color: var(--r-brand); }
main .text-muted,
main .text-secondary { color: var(--r-muted); }

/* Dark-theme killers — wins over inline style + Bootstrap defaults. */
main .text-light,
main .text-white { color: var(--r-text); }
main .bg-dark,
main .bg-black,
main .bg-secondary,
main .card.bg-dark,
main .modal-content.bg-dark {
    background: var(--r-surface);
    background-color: var(--r-surface);
    color: var(--r-text);
    border-color: var(--r-line);
}
main .border-secondary,
main .border-dark { border-color: var(--r-line); }
main .bg-dark .text-light,
main .bg-secondary .text-light,
main .card.bg-dark .text-light,
main .card.bg-dark .text-muted,
main .card.bg-dark .text-secondary { color: var(--r-text); }
main .card.bg-dark .card-header,
main .card.bg-dark .card-footer { background: var(--r-surface-3); color: var(--r-text); border-color: var(--r-line); }

/* Bootstrap text-bg-* compound utilities — same treatment. */
main .text-bg-dark, main .text-bg-secondary, main .text-bg-black {
    background-color: var(--r-surface);
    color: var(--r-text);
}

/* Force-light table when .table-dark is applied (even inline style on rows). */
main table.table-dark,
main .table-dark > :not(caption) > * > * {
    background-color: var(--r-surface);
    color: var(--r-text);
    border-color: var(--r-line-2);
    --bs-table-bg: var(--r-surface);
    --bs-table-color: var(--r-text);
    --bs-table-border-color: var(--r-line-2);
}
main table.table-dark thead th { background-color: var(--r-surface-3); color: var(--r-muted); }
main table.table-dark tbody tr:hover td { background-color: var(--r-surface-2); }

/* Force-light navbar/list-group when dark variants applied. */
main .navbar-dark, main .list-group-item.bg-dark {
    background-color: var(--r-surface);
    color: var(--r-text);
}

/* Any element that has inline style="background: #000..." or "#1a1a1a..." style.
 * These attribute selectors only match exact-character patterns common in legacy
 * dark-theme inline styles. Cheap to evaluate, surgical in scope. */
main .card[style*="background:#1"], main .card[style*="background-color:#1"],
main .card[style*="background:#0"], main .card[style*="background-color:#0"],
main .card[style*="background: #1"], main .card[style*="background: #0"] {
    background: var(--r-surface);
    color: var(--r-text);
}

/* Bootstrap utility .container-fluid inside main — drop default 12px padding
 * since the layout wrapper already provides the page padding. */
main .container-fluid { padding-left: 0; padding-right: 0; }

/* ============================================================================
 * Active filter chip used by operator/* views.
 * ============================================================================ */
main .ap-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--r-radius-pill);
    background: var(--r-brand-soft);
    color: var(--r-brand);
    font-size: 12px;
    font-weight: 600;
}
main .ap-chip .ap-chip-close {
    background: transparent;
    border: 0;
    color: var(--r-brand);
    cursor: pointer;
    padding: 0 0 0 4px;
    font-size: 14px;
    line-height: 1;
}

/* ============================================================================
 * SHELL — premium header + main content area.
 * Eliminates the gap-below-header by tightening main's top padding and removing
 * the redundant <hr> separator that used to live in the layout. Hairline border
 * is now a single 1px bottom rule on the header.
 * ============================================================================ */
.ap-header {
    position: sticky; top: 0; z-index: 99;
    width: 100%; height: 56px;
    display: flex; align-items: center; gap: 16px;
    padding: 0 20px;
    background: #ffffff;
    border-bottom: 1px solid var(--r-line);
}
.ap-header-menu {
    background: transparent; border: 0; cursor: pointer; padding: 6px 8px;
    color: var(--r-text); font-size: 18px; border-radius: var(--r-radius-sm);
}
.ap-header-menu:hover { background: var(--r-surface-2); }
.ap-header-search {
    display: inline-flex; align-items: center; gap: 10px;
    background: #f3f4f6;
    border: 0; padding: 8px 12px; border-radius: var(--r-radius-md);
    color: #525252; font-size: 13px; cursor: pointer;
    min-width: 220px;
    transition: background 150ms;
}
.ap-header-search:hover { background: #e7e5e4; }
.ap-header-search i { font-size: 12px; color: #737373; }
.ap-header-search-label { flex: 1; text-align: left; }
.ap-header-search-kbd {
    display: inline-flex; align-items: center; gap: 4px;
    color: #737373; font-size: 11px;
}
.ap-header-search-kbd kbd {
    background: #ffffff; border: 1px solid var(--r-line);
    padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 600;
    font-family: var(--r-font); color: #525252;
}
.ap-header-right {
    margin-left: auto;
    display: flex; align-items: center; gap: 14px;
}
.ap-balance {
    display: inline-flex; align-items: center;
    background: #f3f4f6;
    border-radius: var(--r-radius-md);
    padding: 6px 4px;
}
.ap-balance-item {
    display: inline-flex; align-items: center; gap: 6px; padding: 0 12px;
}
.ap-balance-label { font-size: 10px; text-transform: uppercase; color: #737373; font-weight: 600; letter-spacing: 0.05em; }
.ap-balance-value { font-size: 13px; font-weight: 700; color: var(--r-text); font-variant-numeric: tabular-nums; }
.ap-balance-sep { width: 1px; height: 16px; background: #d4d4d8; }
.ap-balance { text-decoration: none; cursor: pointer; transition: background .12s ease; }
.ap-balance-icon { display: none; }
.ap-balance:hover { background: #e5e7eb; }
.ap-profile-wrap { position: relative; }
.ap-profile-btn { background: transparent; border: 0; cursor: pointer; padding: 0; }
.ap-profile-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: #1c1917; color: #ffffff;
    font-size: 13px; font-weight: 700;
    transition: transform .12s ease;
}
.ap-profile-btn:hover .ap-profile-avatar { transform: scale(1.05); }
.ap-profile-btn:focus-visible .ap-profile-avatar { outline: 2px solid #2563eb; outline-offset: 2px; }

/* Profile dropdown menu — clicked from the S avatar */
.ap-profile-menu {
    position: absolute; top: calc(100% + 8px); right: 0;
    min-width: 240px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .12);
    padding: 6px;
    z-index: 300;
    animation: ap-profile-menu-in .14s ease;
}
@keyframes ap-profile-menu-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ap-profile-menu-head {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px 12px;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 4px;
}
.ap-profile-avatar-lg { width: 40px; height: 40px; font-size: 15px; }
.ap-profile-menu-meta { display: flex; flex-direction: column; min-width: 0; }
.ap-profile-menu-name { font-size: 13px; font-weight: 700; color: #1c1917; }
.ap-profile-menu-handle { font-size: 11px; color: #737373; font-family: ui-monospace, Menlo, monospace; }
.ap-profile-menu-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 9px 12px;
    font-size: 13px; font-weight: 500;
    color: #1c1917; text-decoration: none;
    background: transparent; border: 0; border-radius: 8px;
    cursor: pointer; text-align: left;
}
.ap-profile-menu-item i { width: 16px; color: #737373; }
.ap-profile-menu-item:hover { background: #f5f5f4; }
.ap-profile-menu-item-danger { color: #dc2626; }
.ap-profile-menu-item-danger:hover { background: #fef2f2; }
.ap-profile-menu-item-danger i { color: #dc2626; }
.ap-profile-menu-sep { height: 1px; background: #f3f4f6; margin: 4px 0; }
.ap-profile-menu-logout { margin: 0; padding: 0; }

/* Command palette — opens via Ctrl+K or clicking the header search */
.ap-search-overlay {
    position: fixed; inset: 0;
    z-index: 400;
}
.ap-search-overlay[hidden] {
    display: none !important;
}
.ap-search-overlay:not([hidden]) {
    display: flex; align-items: flex-start; justify-content: center;
    background: rgba(15, 23, 42, .45);
    padding-top: 12vh;
    animation: ap-search-overlay-in .12s ease;
}
@keyframes ap-search-overlay-in { from { opacity: 0; } to { opacity: 1; } }
.ap-search-panel {
    width: min(640px, 92vw);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
    overflow: hidden;
    animation: ap-search-panel-in .16s cubic-bezier(.2,.8,.2,1);
}
@keyframes ap-search-panel-in {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ap-search-input-wrap {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid #f3f4f6;
}
.ap-search-input-wrap > i { color: #737373; }
.ap-search-input {
    flex: 1;
    background: transparent; border: 0; outline: none;
    font-size: 15px; color: #1c1917;
}
.ap-search-close {
    background: #f3f4f6; border: 0; padding: 4px 10px;
    border-radius: 6px; cursor: pointer;
    font-size: 11px; color: #737373;
}
.ap-search-close kbd { font-family: inherit; font-size: inherit; }
.ap-search-list {
    list-style: none; margin: 0; padding: 6px;
    max-height: 50vh; overflow-y: auto;
}
.ap-search-row a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 8px;
    font-size: 13px; font-weight: 500;
    color: #1c1917; text-decoration: none;
}
.ap-search-row a i { color: #d4d4d8; font-size: 11px; }
.ap-search-row.is-active a,
.ap-search-row a:hover { background: #f5f5f4; }
.ap-search-empty { padding: 24px; text-align: center; color: #737373; font-size: 13px; }

/* Hamburger sidebar collapse state — main shell takes full width.
 * Transitions live on the base elements so both directions (open AND close) animate;
 * the body class then drives the transform/padding change that the transition rides. */
.ap-sidebar { transition: transform .35s ease; }
.ap-shell   { transition: margin-left .35s ease, max-width .35s ease; }
@media (min-width: 992px) {
    body:not(.ap-sidebar-collapsed) [data-ap-shell].ap-shell {
        margin-left: 250px;
        max-width: calc(100% - 250px);
    }
}
@media (min-width: 992px) {
    body.ap-sidebar-collapsed .ap-sidebar { transform: translateX(-100%); }
    body.ap-sidebar-collapsed .ap-main    { padding-left: 24px; }
}

/* Brief highlight when AP.balance.set() rewrites a Cash/Coins value so the user
 * sees the number actually changed (deposit landed, settlement applied, etc). */
@keyframes ap-balance-flash {
    0%   { background: rgba(34, 197, 94, 0.25); }
    100% { background: transparent; }
}
.ap-balance-flash {
    animation: ap-balance-flash .9s ease-out;
    border-radius: 4px;
}

/* Main content area — tight padding, no awkward gap. */
.ap-main {
    background: var(--r-bg);
    min-height: calc(100vh - 56px);
    padding: 20px 24px 32px;
}
@media (max-width: 768px) {
    .ap-header {
        padding: 0 12px;
        gap: 8px;
        min-width: 0;
        overflow: hidden;
    }
    /* Icon-only search — 140px min-width pushed header past ~375px viewport. */
    .ap-header-search {
        min-width: 0;
        width: 36px;
        height: 36px;
        padding: 0;
        justify-content: center;
        flex: 0 0 auto;
    }
    .ap-header-search-label, .ap-header-search-kbd { display: none; }
    .ap-header-right {
        gap: 6px;
        flex: 1 1 auto;
        min-width: 0;
        justify-content: flex-end;
    }
    .ap-balance {
        min-width: 0;
        max-width: min(120px, 34vw);
        padding: 4px 8px;
        gap: 4px;
    }
    .ap-balance-icon {
        display: inline-flex;
        flex: 0 0 auto;
        font-size: 11px;
        color: #737373;
    }
    .ap-balance-label { display: none; }
    .ap-balance-item {
        padding: 0;
        min-width: 0;
        gap: 0;
    }
    .ap-balance-value {
        font-size: 12px;
        font-weight: 700;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .ap-theme-toggle { flex: 0 0 auto; }
    .ap-profile-wrap { flex: 0 0 auto; }
    .ap-main { padding: 16px 16px 24px; }
}

/* ============================================================================
 * BREADCRUMBS — sits directly beneath the <h1> in every page-head.
 * Muted-gray text with slash separators. The current (last) segment is in the
 * SAME gray as the other crumbs — NOT bolder, NOT darker — per the reference.
 * ============================================================================ */
main .ap-breadcrumb {
    font-size: 14px;
    color: var(--r-muted);
    margin-bottom: 18px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    font-weight: 400;
}
main .ap-breadcrumb a { color: var(--r-muted); text-decoration: none; }
main .ap-breadcrumb a:hover { color: var(--r-text); }
main .ap-breadcrumb .sep { color: var(--r-faint); }
/* Last segment intentionally not emphasised — matches the reference exactly. */
main .ap-breadcrumb .current { color: var(--r-muted); font-weight: 400; }

/* ============================================================================
 * TOGGLE SWITCH — used for KYC Verified, Betlock On, Banking enable, etc.
 * <label class="ap-switch"><input type="checkbox"><span></span></label>
 * ============================================================================ */
main .ap-switch {
    position: relative; display: inline-block;
    width: 36px; height: 20px;
    vertical-align: middle;
}
main .ap-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
main .ap-switch span {
    position: absolute; inset: 0; cursor: pointer;
    background: #d4d4d8; border-radius: 9999px;
    transition: background 180ms;
}
main .ap-switch span::before {
    content: ''; position: absolute;
    top: 2px; left: 2px; width: 16px; height: 16px;
    background: #ffffff; border-radius: 50%;
    transition: transform 180ms;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
main .ap-switch input:checked + span { background: #10b981; }
main .ap-switch input:checked + span::before { transform: translateX(16px); }
main .ap-switch input:disabled + span { opacity: 0.5; cursor: not-allowed; }

/* ============================================================================
 * INLINE EDIT — pencil icon next to a value triggers an inline editor.
 * <span class="ap-inline-value">John <button class="ap-inline-edit"><i class="fa-solid fa-pencil"></i></button></span>
 * ============================================================================ */
main .ap-inline-value {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--r-text); font-size: 13px;
}
main .ap-inline-edit {
    background: transparent; border: 0; cursor: pointer;
    color: var(--r-brand); padding: 2px 4px; border-radius: 4px;
    font-size: 11px;
    transition: background 150ms;
}
main .ap-inline-edit:hover { background: var(--r-brand-soft); }

/* ============================================================================
 * KPI CARD — premium dashboard tile with optional 3-dot action menu.
 * <div class="ap-kpi"><div class="ap-kpi-head"><span class="ap-kpi-label">Current Cashable Balance</span><button class="ap-kpi-dots"><i class="fa-solid fa-ellipsis"></i></button></div><div class="ap-kpi-value">₹1,234.00</div><div class="ap-kpi-subs">...</div></div>
 * ============================================================================ */
main .ap-kpi {
    background: var(--r-surface);
    border: 1px solid var(--r-line);
    border-radius: var(--r-radius-lg);
    padding: 18px;
    display: flex; flex-direction: column;
    transition: border-color 150ms;
}
main .ap-kpi:hover { border-color: #d6d3d1; }
main .ap-kpi-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 8px;
}
main .ap-kpi-label {
    font-size: 12px; color: var(--r-muted); font-weight: 500;
    line-height: 1.3;
}
main .ap-kpi-dots {
    background: transparent; border: 0; cursor: pointer;
    color: var(--r-faint); padding: 2px 4px;
    border-radius: 4px; font-size: 12px;
}
main .ap-kpi-dots:hover { background: var(--r-surface-2); color: var(--r-text-2); }
main .ap-kpi-value {
    font-size: 22px; font-weight: 700; color: var(--r-text);
    line-height: 1.2; font-variant-numeric: tabular-nums;
    margin-bottom: auto;
}
main .ap-kpi-subs {
    display: flex; gap: 14px; padding-top: 12px; margin-top: 12px;
    border-top: 1px solid var(--r-line-2);
}
main .ap-kpi-sub { display: flex; flex-direction: column; gap: 2px; }
main .ap-kpi-sub-label { font-size: 10px; color: var(--r-faint); text-transform: uppercase; letter-spacing: 0.05em; }
main .ap-kpi-sub-value { font-size: 12px; font-weight: 700; color: var(--r-text); font-variant-numeric: tabular-nums; }

/* ============================================================================
 * BALANCE CARDS — 4-tile wallet row (Bonus / Deposit-Withdraw / Losing Comm / Main).
 * ============================================================================ */
main .ap-wallet-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
    margin-bottom: 20px;
}
@media (max-width: 900px) { main .ap-wallet-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { main .ap-wallet-grid { grid-template-columns: 1fr; } }
main .ap-wallet-card {
    background: var(--r-surface);
    border: 1px solid var(--r-line); border-radius: var(--r-radius-lg);
    padding: 16px 18px;
    display: flex; flex-direction: column; gap: 6px;
    position: relative; overflow: hidden;
}
main .ap-wallet-card::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0;
    width: 3px; background: var(--r-brand);
}
main .ap-wallet-card.is-bonus::before    { background: #f59e0b; }
main .ap-wallet-card.is-dw::before       { background: #10b981; }
main .ap-wallet-card.is-comm::before     { background: #8b5cf6; }
main .ap-wallet-card.is-main::before     { background: var(--r-brand); }
main .ap-wallet-label { font-size: 11px; color: var(--r-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
main .ap-wallet-value { font-size: 22px; font-weight: 700; color: var(--r-text); font-variant-numeric: tabular-nums; line-height: 1.2; }

/* ============================================================================
 * BANKING toggle row used in player profile + gateways.
 * <div class="ap-banking-row"><span>Withdraw</span><label class="ap-switch">...</label></div>
 * ============================================================================ */
main .ap-banking-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    border: 1px solid var(--r-line); border-radius: var(--r-radius-md);
    background: var(--r-surface);
    margin-bottom: 8px;
}

/* ============================================================================
 * PAYMENT GATEWAY indicator badges (Deposit green / Withdraw red).
 * ============================================================================ */
main .ap-gateway-flag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; font-size: 10px; font-weight: 700; border-radius: 4px;
    text-transform: uppercase; letter-spacing: 0.04em;
}
main .ap-gateway-flag.is-in  { background: var(--r-success-soft); color: var(--r-success); }
main .ap-gateway-flag.is-out { background: var(--r-danger-soft);  color: var(--r-danger); }

/* ============================================================================
 * INLINE FORM ERROR — used in funds-transfer modal and elsewhere.
 * Replaces bulky alert boxes with a single red line beneath the input.
 * ============================================================================ */
main .ap-field-error {
    display: block; color: var(--r-danger);
    font-size: 12px; margin-top: 4px;
    font-weight: 500;
}

/* ============================================================================
 * MODAL OVERLAY — Funds Transfer + confirm dialogs.
 * Builds on admin-panel.css's ap-modal but tightens spacing.
 * ============================================================================ */
main .ap-modal-form .form-control,
main .ap-modal-form .form-select { margin-bottom: 10px; }

/* ============================================================================
 * STATUS BADGES — explicit per-status semantic mapping.
 * <span class="badge badge-approved">APPROVED</span>
 * ============================================================================ */
main .badge.badge-approved,  main .badge.is-approved  { background: var(--r-success-soft); color: var(--r-success); }
main .badge.badge-pending,   main .badge.is-pending   { background: var(--r-warn-soft);    color: var(--r-warn); }
main .badge.badge-rejected,  main .badge.is-rejected,
main .badge.badge-failed,    main .badge.is-failed    { background: var(--r-danger-soft);  color: var(--r-danger); }
main .badge.badge-processing, main .badge.is-processing { background: var(--r-info-soft); color: var(--r-info); }
main .badge.badge-win  { background: var(--r-success-soft); color: var(--r-success); }
main .badge.badge-lose, main .badge.badge-loss { background: var(--r-danger-soft); color: var(--r-danger); }

/* ============================================================================
 * DEBIT / CREDIT helpers for account statement.
 * ============================================================================ */
main .debit, main .ap-debit  { color: var(--r-danger);  font-weight: 600; font-variant-numeric: tabular-nums; }
main .credit, main .ap-credit { color: var(--r-success); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ============================================================================
 * Reduce default Bootstrap card-header heavy emphasis.
 * ============================================================================ */
main .card-header {
    background: transparent;
    border-bottom: 1px solid var(--r-line);
    font-weight: 700;
    color: var(--r-text);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.04em;
}

/* ============================================================================
 * REFERENCE-IMAGE PATTERNS — three idioms from the design specs:
 *   1. Soft-blue feature-availability banner.
 *   2. Inline permission-denial text (no alert box).
 *   3. Dark-pill primary CTA button.
 * ============================================================================ */

/* Soft-blue announcement banner used at the top of wallet/coming-soon pages. */
main .ap-banner-info {
    background: #dbeafe;
    color: #1e40af;
    border-radius: var(--r-radius-md);
    padding: 12px 18px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 18px;
}

/* Inline permission-denial text (no alert box). */
main .ap-perm-denied {
    text-align: center;
    padding: 14px 18px;
    font-size: 13px;
    color: var(--r-text-2);
    background: var(--r-surface);
    border: 1px solid var(--r-line);
    border-radius: var(--r-radius-md);
}
main .ap-perm-denied a,
main .ap-perm-denied .ap-perm-link {
    color: var(--r-danger);
    font-weight: 700;
    text-decoration: none;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 12px;
}
main .ap-perm-denied a:hover { text-decoration: underline; }

/* Dark-pill primary CTA — used by "Transactions BreakDown" + Details tab. */
main .btn-dark-pill,
main .tb-btn-primary {
    display: inline-flex; align-items: center; gap: 8px;
    background: #1c1917;
    color: #ffffff;
    border: 0;
    border-radius: 9999px;
    padding: 10px 24px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 150ms ease;
}
main .btn-dark-pill:hover,
main .tb-btn-primary:hover { background: #0a0a0a; }

/* Centered button row (for Transactions BreakDown). */
main .tb-cta-row {
    display: flex; justify-content: center;
    margin: 24px 0;
}

/* "Today" / date selector pill used in dashboard top-right.
 * Reference: light-gray pill, 6px radius, holds a <select> and a small
 * calendar icon on the right. The icon sits AFTER the select. */
main .ap-date-pill {
    display: inline-flex; align-items: center; gap: 8px;
    background: #f3f4f6;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--r-text);
    min-height: 36px;
}
main .ap-date-pill select {
    background: transparent;
    border: 0;
    color: var(--r-text);
    font-size: 13px;
    font-weight: 500;
    padding: 0 4px 0 0;
    min-height: 0;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}
main .ap-date-pill select:focus { box-shadow: none; outline: none; }
main .ap-date-pill i,
main .ap-date-pill .fa-calendar,
main .ap-date-pill .ap-date-pill-icon {
    color: var(--r-muted); font-size: 13px; margin-left: 2px;
}

/* Filter button row — flat light-gray container holding inputs + right-side
 * controls. Reference: 12px padding, 8px radius, inputs are white with a 1px
 * gray border, 6px radius, ~40px tall. The right side often holds the date
 * pill + a solid blue Search/Filters button (spacer pushes them right). */
main .ap-filter-row {
    display: flex; align-items: center;
    gap: var(--r-space-3);                          /* merged: was 10px */
    background: #f8f8f7;                            /* merged: was #f3f4f6 */
    border: 1px solid var(--r-hairline);            /* merged from former Elite Refinement Layer */
    border-radius: 10px;                            /* merged: was var(--r-radius-sm) */
    padding: var(--r-space-3) var(--r-space-4);     /* merged: was 12px */
    margin-bottom: 14px;
    flex-wrap: wrap;
}
main .ap-filter-row > input,
main .ap-filter-row > select,
main .ap-filter-row .form-control,
main .ap-filter-row .form-select {
    background: #ffffff;
    border: 1px solid var(--r-line);
    border-radius: 6px;
    min-height: 40px;
    padding: 8px 12px;
    font-size: 13px;
}
main .ap-filter-row .ap-filter-spacer { flex: 1 1 auto; min-width: 1px; }
main .ap-filter-row .btn-primary,
main .ap-filter-row .ap-filter-btn {
    background: var(--r-brand);
    border-color: var(--r-brand);
    color: #ffffff;
    min-height: 40px;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
}
main .ap-filter-row .btn-primary:hover,
main .ap-filter-row .ap-filter-btn:hover {
    background: var(--r-brand-2);
    border-color: var(--r-brand-2);
}

/* Pagination bar at the bottom of tables. Reference:
 *  - LEFT: a <select> "15 items" size selector.
 *  - RIGHT: chevron-left + page number + chevron-right.
 *    Active page is a solid blue square. Disabled chevrons rendered in light
 *    gray. The three buttons share the same square footprint. */
main .ap-pager {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    gap: 12px;
}
main .ap-pager .ap-pager-size {
    display: inline-flex; align-items: center; gap: 8px;
    color: var(--r-text-2); font-size: 13px;
}
main .ap-pager .ap-pager-size select {
    width: auto;
    min-width: 88px;
    min-height: 36px;
    border: 1px solid var(--r-line);
    border-radius: 6px;
    background: var(--r-surface);
    padding: 6px 10px;
    font-size: 13px;
}
main .ap-pager .ap-pager-nav {
    display: inline-flex; align-items: center; gap: 6px;
}
main .ap-pager .ap-pager-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 10px;
    background: var(--r-surface);
    border: 1px solid var(--r-line);
    border-radius: 6px;
    color: var(--r-text-2);
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    transition: background 150ms, color 150ms, border-color 150ms;
}
main .ap-pager .ap-pager-btn:hover:not(:disabled):not(.is-active) {
    background: var(--r-surface-2);
    color: var(--r-text);
}
main .ap-pager .ap-pager-btn.is-active,
main .ap-pager .ap-pager-btn.active {
    background: var(--r-brand);
    border-color: var(--r-brand);
    color: #ffffff;
}
main .ap-pager .ap-pager-btn:disabled,
main .ap-pager .ap-pager-btn.is-disabled {
    color: var(--r-faint);
    background: var(--r-surface);
    cursor: not-allowed;
}

/* ============================================================================
 * EMPTY STATE — "No Data Yet!" + centered spinner (seen on Wallet, Sports,
 * Bonus statement, Casino betlist, almost every empty table in the reference).
 * ============================================================================ */
main .ap-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 48px 24px;
    background: var(--r-surface);
    color: var(--r-muted);
    font-size: 13px; font-weight: 500;
    gap: 12px;
}
main .ap-empty-spinner {
    width: 28px; height: 28px;
    border: 3px solid #dbeafe;
    border-top-color: var(--r-brand);
    border-radius: 50%;
    animation: ap-spin 800ms linear infinite;
}
@keyframes ap-spin { to { transform: rotate(360deg); } }
main .ap-empty-text { color: var(--r-muted); font-weight: 500; }

/* ============================================================================
 * KPI PERCENTAGE DELTA — small inline ↑0% / ↓5% indicators on stat cards
 * (Web Analytics row: Unique Visitors, Bounce Rate, etc.)
 * ============================================================================ */
main .ap-delta {
    display: inline-flex; align-items: center; gap: 2px;
    font-size: 11px; font-weight: 600;
    padding: 2px 6px; border-radius: 6px;
}
main .ap-delta.is-up   { background: var(--r-success-soft); color: var(--r-success); }
main .ap-delta.is-down { background: var(--r-danger-soft);  color: var(--r-danger); }
main .ap-delta.is-flat { background: var(--r-surface-2);    color: var(--r-muted); }

/* ============================================================================
 * DRAG-DROP UPLOAD ZONE — banner-create page pattern (dashed border, icon,
 * "Drag image here or click to select file" + file-size hint).
 * ============================================================================ */
main .ap-dropzone {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 36px 24px;
    background: var(--r-surface);
    border: 2px dashed var(--r-line);
    border-radius: var(--r-radius-md);
    color: var(--r-muted);
    text-align: center;
    cursor: pointer;
    transition: border-color 150ms ease, background 150ms ease;
}
main .ap-dropzone:hover { border-color: var(--r-brand); background: #fafaf9; }
main .ap-dropzone .ap-dropzone-icon { font-size: 28px; color: var(--r-faint); margin-bottom: 12px; }
main .ap-dropzone .ap-dropzone-hint { font-size: 11px; color: var(--r-faint); margin-top: 4px; }

/* ============================================================================
 * COLOR-PICKER SWATCH with pencil edit (Flag-create pattern).
 * ============================================================================ */
main .ap-color-row {
    display: flex; align-items: center; gap: 8px;
}
main .ap-color-swatch {
    width: 100%; height: 36px;
    border-radius: var(--r-radius-sm);
    border: 1px solid var(--r-line);
    flex: 1;
}

/* ============================================================================
 * INFO LINE banner (smaller variant of .ap-banner-info — single soft-blue
 * line above a section, used by Sports Betlist linking SPM Sports / Betfair).
 * ============================================================================ */
main .ap-info-line {
    background: var(--r-info-soft);
    color: var(--r-info);
    border-radius: var(--r-radius-sm);
    padding: 8px 12px;
    font-size: 12px;
    margin-bottom: 12px;
    display: flex; align-items: center; gap: 6px;
}
main .ap-info-line a { color: var(--r-info); text-decoration: underline; font-weight: 600; }

/* ============================================================================
 * REFINED TABLE PATTERN (.tb-table) — matches the reference exactly.
 *  - Column headers: UPPERCASE, 12px, gray, 500 weight, letter-spacing 0.04em.
 *  - Row height ~52px, soft 1px bottom border on each row.
 *  - Status/amount chips: small pill, red-soft / green-soft semantic palette.
 *  - "View"-style link columns rendered as brand-blue underlined text.
 * Selector scope is intentionally narrow (main .tb-table) so we don't
 * override the broader main .table rules earlier in this file. The .tb-table
 * primitive comes from operator-tb.css — these rules refine it.
 * ============================================================================ */
main .tb-table thead th {
    font-size: 12px;
    font-weight: 500;
    color: var(--r-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 12px 16px;
    height: 44px;
    background: var(--r-surface);
    border-bottom: 1px solid #e7e7e7;
}
main .tb-table tbody td {
    height: 52px;
    padding: 14px 16px;
    border-bottom: 1px solid #f0eeec;
    color: var(--r-text);
    font-size: 13px;
}
main .tb-table tbody tr:last-child td { border-bottom: 0; }

/* Inline "View" / row-action link inside a table cell. */
main .tb-table .tb-link-view,
main .tb-table a.tb-view {
    color: var(--r-brand);
    text-decoration: underline;
    font-weight: 500;
}
main .tb-table .tb-link-view:hover,
main .tb-table a.tb-view:hover { color: var(--r-brand-2); }

/* Status/amount chips embedded in tables. Small pill, 24-28px tall. */
main .tb-chip,
main .tb-table .tb-chip {
    display: inline-flex; align-items: center; justify-content: center;
    height: 26px; padding: 0 10px;
    border-radius: 9999px;
    font-size: 12px; font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}
main .tb-chip.tb-chip-credit,
main .tb-chip.is-credit,
main .tb-chip.is-active,
main .tb-chip.is-approved   { background: #dcfce7; color: #15803d; }
main .tb-chip.tb-chip-debit,
main .tb-chip.is-debit,
main .tb-chip.is-inactive,
main .tb-chip.is-rejected,
main .tb-chip.is-failed     { background: #fee2e2; color: #b91c1c; }
main .tb-chip.is-pending    { background: #fef3c7; color: #b45309; }
main .tb-chip.is-info       { background: var(--r-info-soft); color: var(--r-info); }
main .tb-chip.is-neutral    { background: var(--r-surface-2); color: var(--r-text-2); }

/* ============================================================================
 * "BETA" pill — small orange chip used next to the "Wallets" sidebar item
 * and inline next to feature-preview labels.
 * ============================================================================ */
.ap-beta-pill,
main .ap-beta-pill {
    display: inline-flex; align-items: center;
    height: 16px;
    padding: 0 6px;
    margin-left: 6px;
    background: #f59e0b;
    color: #ffffff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-radius: 4px;
    line-height: 1;
}

/* ============================================================================
 * SIDEBAR REFINEMENTS — single-column dark pattern.
 *  - Brand wordmark white sans-serif, centered.
 *  - Pinned footer: Log Out + tiny "SPM PORTAL" caption.
 *  - Active item: light pill (#fafaf9) with dark text (#0E0E10),
 *    row-width minus 8px horizontal margin, 6-8px rounded corners.
 *  - Hover state: subtle white overlay 0.05.
 *  - Parent rows have a chevron that rotates 90° when expanded; children are
 *    indented and slightly smaller (~40px tall).
 * Specificity is held by `aside.ap-sidebar` — no needed.
 * ============================================================================ */
/* 2026-05-19 cleanup: light `background` + `border-right` removed — both are
 * superseded by the dark variant (background by line ~1872 ``,
 * border-right by the grouped selector at line ~1706). Only `width: 250px`
 * remains alive (no later override). */
aside.ap-sidebar { width: 250px; }
aside.ap-sidebar .ap-sidebar-brand {
    color: #1c1917;
    font-family: var(--r-font);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0;
    text-transform: none;
    padding: 20px 16px;
    text-align: center;
}
aside.ap-sidebar .ap-sidebar-footer-label {
    text-align: center;
    margin-top: 8px;
    font-size: 10px;
    color: rgba(28,25,23,0.50);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ============================================================================
 * ELITE REFINEMENT LAYER
 * ----------------------------------------------------------------------------
 * Pixel-grade refinements applied as the LAST layer of the cascade so they
 * win against earlier definitions without an arms race.
 *
 * Doctrine:
 *  - Strict 4pt/8pt spatial grid expressed as --r-space-* tokens.
 *  - Hairline borders (rgba ~0.06-0.08 opacity equivalent on a light theme).
 *  - Buttons gain :active press feedback + brand-tinted focus ring.
 *  - Inputs/selects normalised to 40px (h-10) so every form row aligns.
 *  - Cards lose their default soft shadow in favour of a single hairline
 *    border — premium-corporate look, not Material-bouncy.
 * ============================================================================ */

:root {
    /* 4pt / 8pt spatial grid */
    --r-space-1: 4px;
    --r-space-2: 8px;
    --r-space-3: 12px;
    --r-space-4: 16px;
    --r-space-5: 20px;
    --r-space-6: 24px;
    --r-space-7: 32px;
    --r-space-8: 40px;
    --r-space-9: 48px;

    /* Hairlines (light-theme equivalent of rgba(255,255,255,0.08)) */
    --r-hairline:   rgba(28, 25, 23, 0.06);
    --r-hairline-2: rgba(28, 25, 23, 0.10);

    /* Focus ring re-tied to brand (was an arbitrary #339af0) */
    --r-focus-ring: 0 0 0 3px var(--r-brand-soft);

    /* Tactile press shadow for primary actions */
    --r-press-shadow: inset 0 1px 0 rgba(0,0,0,0.10);

    /* Standard control height (h-10 on the 4pt grid) */
    --r-control-h: 40px;
    --r-control-h-sm: 32px;
    --r-control-h-lg: 44px;
}

/* ── Buttons: 4pt-grid heights + tactile :active + brand focus ──────────── */
main .btn {
    height: var(--r-control-h);
    padding: 0 var(--r-space-4);
    line-height: 1;
    border-radius: 8px;
    transition: background 120ms ease, border-color 120ms ease,
                color 120ms ease, transform 80ms ease, box-shadow 120ms ease;
}
main .btn-sm { height: var(--r-control-h-sm); padding: 0 var(--r-space-3); font-size: 12px; }
main .btn-lg { height: var(--r-control-h-lg); padding: 0 var(--r-space-5); font-size: 14px; }
main .btn:active:not(:disabled):not(.disabled) {
    transform: translateY(1px);
    box-shadow: var(--r-press-shadow);
}
main .btn-primary:active:not(:disabled):not(.disabled) {
    background: #1e40af;
    border-color: #1e40af;
}
main .btn:focus-visible {
    outline: 0;
    box-shadow: var(--r-focus-ring);
}

/* ── Inputs / selects: standard 40px height, hairline border ────────────── */
main input[type="text"],
main input[type="email"],
main input[type="number"],
main input[type="password"],
main input[type="search"],
main input[type="date"],
main input[type="datetime-local"],
main input[type="tel"],
main input[type="url"],
main .form-control,
main .form-select,
main .tb-input,
main .tb-select {
    height: var(--r-control-h);
    padding: 0 var(--r-space-3);
    border-color: var(--r-hairline-2);
    border-radius: 8px;
    font-size: 13px;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
main textarea.form-control { height: auto; padding: var(--r-space-3); }
main input:focus,
main .form-control:focus,
main .form-select:focus,
main .tb-input:focus,
main .tb-select:focus {
    border-color: var(--r-brand);
    box-shadow: var(--r-focus-ring);
    outline: 0;
}

/* 2026-05-19 cleanup: the four card/filter/tab-strip duplicate selectors
 * from the former "Elite Refinement Layer" have been merged into their
 * earlier definitions (main .card/.tb-card line ~221, main .tb-card-stat
 * line ~248, main .nav-tabs/.nav-link/.nav-link.active lines ~371-396,
 * main .ap-filter-row line ~1071). Each selector now appears exactly once. */

/* ── Tables: row hairline matches card hairline ─────────────────────────── */
main .tb-table tbody tr td,
main .tb-table thead tr th {
    border-bottom-color: var(--r-hairline);
}

/* ── Page-head: tight 24px margin below breadcrumb (no awkward gap) ─────── */
main .tb-page-head { margin-bottom: var(--r-space-6); }
main .tb-page-head .ap-breadcrumb { margin-bottom: 0; }

/* ── Header: hairline-not-line + tighter avatar gap ─────────────────────── */
.ap-header {
    border-bottom-color: var(--r-hairline-2);
    gap: var(--r-space-4);
}
.ap-balance-sep { background: var(--r-hairline-2); }

/* ── KPI pill chips inside tables (debit red / credit green): 4pt grid ──── */
main .tb-table .tb-pill {
    height: 24px;
    padding: 0 var(--r-space-3);
    font-size: 12px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

/* ── Pager: solid blue active, hairline button border ───────────────────── */
main .ap-pager-btn {
    height: 36px;
    min-width: 36px;
    border-color: var(--r-hairline-2);
    border-radius: 8px;
}
main .ap-pager-btn.active,
main .ap-pager-btn.is-active {
    background: var(--r-brand);
    border-color: var(--r-brand);
    color: #ffffff;
}

/* 2026-05-19 cleanup: two light-sidebar rules removed here —
 *   `body aside.ap-sidebar { background:#fff; border-right:... }`
 *   `body aside.ap-sidebar .ap-sidebar-brand-row { background:#fff; border-bottom:... }`
 * Both fully superseded by the dark variant grouped selector at line ~1703-1710
 * (same specificity, later in source) and the rule at line ~1872. */

/* ── Sidebar section labels (Overview / Operations / Products / ...) ───── */
aside.ap-sidebar .ap-section-label {
    padding: 16px 16px 6px;
    margin: 4px 8px 0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(28,25,23,0.50);
    user-select: none;
    list-style: none;
}
aside.ap-sidebar .ap-section-label:first-child { padding-top: 8px; }

/* ── Kill ALL loading/buffering spinners across the admin panel ─────────
 * The user explicitly does NOT want any buffering icon shown when opening
 * elements. Empty states still render their text (e.g. "No Data Yet!"),
 * but the spinning ring is suppressed everywhere. */
body main .ap-empty-spinner,
body main .ap-empty-spinner::before,
body main .ap-empty-spinner::after { display: none; }

/* ── Grid helpers (4pt grid, design-system gap) ─────────────────────────
 * These replace Bootstrap row/col-md-* in new admin views. Defining them
 * here means views never fall back to Bootstrap's 12-col grid (which has
 * different gutters and breaks our tight spacing). */
main .tb-grid-2,
main .tb-grid-3,
main .tb-grid-4,
main .tb-grid-5,
main .tb-grid-6 {
    display: grid;
    gap: var(--r-space-4);
}
main .tb-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
main .tb-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
main .tb-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
main .tb-grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
main .tb-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1199px) {
    main .tb-grid-5,
    main .tb-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    main .tb-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
    main .tb-grid-2,
    main .tb-grid-3,
    main .tb-grid-4,
    main .tb-grid-5,
    main .tb-grid-6 { grid-template-columns: 1fr; }
}

/* ── Override-killers for the new pages
 * Bootstrap row/col-md-* defaults have different gutters than our 4pt grid.
 * When a new admin view falls back to Bootstrap grid (because we hadn't yet
 * defined .tb-grid-N), the resulting spacing looks inconsistent with the
 * rest of the panel. These rules normalize Bootstrap grid utilities used
 * INSIDE admin views so they don't look out of place. */
main .row > [class*="col-"] { padding-left: 8px; padding-right: 8px; }
main .row { margin-left: -8px; margin-right: -8px; row-gap: var(--r-space-4); }

/* ── Defensive: inline-style cards inside admin panels should not have
 * radius-9999 or shadows; tighten them in case a view sneaks them in. */
main .card[style],
main .tb-card[style] {
    box-shadow: none;
}
/* ============================================================================
 * 12. LEGACY OVERRIDES (FORCE LIGHT THEME EVERYWHERE)
 * ============================================================================ */
.main-wrapper.Dashboard-bg,
.main-wrapper.admin-bg,
.Dashboard-bg,
.admin-bg,
body {
    background: #f8fafc;
    background-color: #f8fafc;
}

/* Force top header to be white if legacy classes try to make it dark */
.top-header-section .navbar,
.top-header-section .header-bg,
.navbar {
    background: #ffffff;
    background-color: #ffffff;
}

.top-bg {
    background: #ffffff;
}

/* Force text in header to be dark */
.top-header-section .navbar a,
.top-header-section .navbar span,
.top-header-section .navbar p {
    color: #1c1917;
}

.page-wrapper.bg-none {
    background: transparent;
}

/* ============================================================
 * 2026-05-18 rev4 — HERO-CARD LOGO FILLS THE HEADER (edge-to-edge)
 * Logo height matches typical header content height so the mark's top and
 * bottom touch the header's top/bottom edges. To allow that, we ALSO zero the
 * vertical padding on the logo's parent container (`.logo`, `.logo > a`, and
 * the admin avatar wrapper) — otherwise the parent padding pushes the logo
 * inward. Header outer height stays whatever the rest of the layout sets;
 * only the empty whitespace around the logo is removed.
 * ============================================================ */
.brand-logo-img {
    /* 2026-05-18 rev7 — REVERT all visual filters (no hue-rotate, no saturate,
       no contrast, no drop-shadow). Logo renders in its original PNG colors.
       Desktop size bumped from 96px → 120px for a more prominent header logo.
       Tablet + mobile sizes (defined in the @media blocks below) are unchanged. */
    height: 120px;
    width: auto;
    display: block;
    object-fit: contain;
    transition: transform .18s ease;
}
.brand-logo-img:hover {
    transform: translateY(-1px) scale(1.02);
}
/* Collapse parent padding/line-height so the logo can reach the header edges.
   Only targets containers known to hold the brand-logo-img to avoid side-effects. */
.logo,
.logo > a,
.spade-header-custom .flex-shrink-0 {
    padding-top: 0;
    padding-bottom: 0;
    line-height: 0;
}
/* Admin sidebar (vertical surface, not a horizontal header) — keep separate scale. */
.ap-sidebar-brand .brand-logo-img,
aside.ap-sidebar .brand-logo-img { height: 72px; }

/* Tablet */
@media (max-width: 991.98px) {
    .brand-logo-img { height: 80px; }
    .ap-sidebar-brand .brand-logo-img,
    aside.ap-sidebar .brand-logo-img { height: 64px; }
}
/* Mobile (≤575px) */
@media (max-width: 575.98px) {
    .brand-logo-img { height: 72px; }
    .ap-sidebar-brand .brand-logo-img,
    aside.ap-sidebar .brand-logo-img { height: 56px; }
}

/* ============================================================================
 * 2026-05-18: DARK SIDEBAR — match the user-supplied reference screenshot.
 *
 * Background: zinc-900 (#18181B). Wordmark white bold. Section labels muted
 * gray uppercase. Nav rows light-gray text with line-gray icons. Hover is a
 * subtle white overlay; active row keeps the existing light-pill pattern but
 * inverts to dark text on the pill, which still reads well on the dark rail.
 *
 * Placed at the END of the cascade so it wins against all prior light-theme
 * rules without an arms race. Specificity = `body aside.ap-sidebar`.
 * Brand logo image is hidden — the reference shows the wordmark only.
 * ============================================================================ */
body aside.ap-sidebar,
body aside.ap-sidebar .ap-sidebar-brand-row {
    background: #18181B;
    border-right: 1px solid rgba(255,255,255,0.06);
}
body aside.ap-sidebar .ap-sidebar-brand-row {
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
/* Wordmark — pure white, larger, no all-caps. */
body aside.ap-sidebar .ap-sidebar-brand,
body aside.ap-sidebar .ap-sidebar-brand > span {
    color: #ffffff;
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 0;
    text-transform: none;
    padding: 20px 16px 18px;
    text-align: center;
}
/* Logo image: visible on every surface. Earlier revision hid it via
 * display:none to mimic a text-only reference screenshot; user reverted that
 * call — restore the image so the brand mark shows above the wordmark. */
body aside.ap-sidebar .ap-sidebar-brand .brand-logo-img {
    display: block;
    margin: 0 auto 8px;
    max-width: 80%;
}
/* Section labels — muted gray. */
body aside.ap-sidebar .ap-section-label {
    color: rgba(255,255,255,0.42);
    padding: 18px 18px 8px;
    margin: 4px 0 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.10em;
}
/* Default nav row colors — light gray with line-gray icons. */
body aside.ap-sidebar nav ul li > a,
body aside.ap-sidebar nav ul li > button {
    color: rgba(255,255,255,0.78);
}
body aside.ap-sidebar .ap-row,
body aside.ap-sidebar .ap-subrow {
    color: rgba(255,255,255,0.78);
}
body aside.ap-sidebar .ap-row-icon i,
body aside.ap-sidebar .ap-subrow i,
body aside.ap-sidebar nav i.fa-solid,
body aside.ap-sidebar nav i.bi {
    color: rgba(255,255,255,0.55);
}
body aside.ap-sidebar .ap-row-label,
body aside.ap-sidebar .ap-subrow-label {
    color: rgba(255,255,255,0.88);
}
/* Hover — subtle white overlay (matches macOS-dark sidebar pattern). */
body aside.ap-sidebar .ap-row:hover,
body aside.ap-sidebar .ap-subrow:hover {
    background: rgba(255,255,255,0.06);
    color: #ffffff;
}
body aside.ap-sidebar .ap-row:hover .ap-row-icon i,
body aside.ap-sidebar .ap-subrow:hover i {
    color: rgba(255,255,255,0.88);
}
/* Active pill — light cream pill with near-black text on the dark rail. */
body aside.ap-sidebar .ap-row.is-active,
body aside.ap-sidebar .ap-subrow.is-active {
    background: #FAFAF9;
    color: #0E0E10;
}
body aside.ap-sidebar .ap-row.is-active .ap-row-icon i,
body aside.ap-sidebar .ap-row.is-active .ap-row-label,
body aside.ap-sidebar .ap-subrow.is-active i,
body aside.ap-sidebar .ap-subrow.is-active .ap-subrow-label,
/* 2026-05-20 fix: subrow label markup uses .ap-row-label class (NOT .ap-subrow-label),
 * so the original active-text rule above never matched it. Without this addition the
 * .ap-row-label rule at line ~1743 (color:rgba(255,255,255,0.88)) wins and the active
 * subrow renders as near-white text on the near-white active pill — invisible. */
body aside.ap-sidebar .ap-subrow.is-active .ap-row-label,
body aside.ap-sidebar .ap-subrow.is-active .ap-row-icon i,
body aside.ap-sidebar .ap-row.is-active .ap-subrow-label {
    color: #0E0E10;
}
/* Chevron + sub-row indents — gray. */
body aside.ap-sidebar .ap-row .link-arrow,
body aside.ap-sidebar .ap-row .sb-chevron,
body aside.ap-sidebar .ap-row svg {
    color: rgba(255,255,255,0.42);
}
/* Footer (Log Out + portal tag). */
body .ap-sidebar-footer,
body aside.ap-sidebar + .ap-sidebar-footer {
    background: #0F0F11;
    border-top: 1px solid rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.78);
}
body aside.ap-sidebar .ap-sidebar-logout,
body .ap-sidebar-footer a { color: rgba(255,255,255,0.88); }
body aside.ap-sidebar .ap-sidebar-logout:hover,
body .ap-sidebar-footer a:hover { background: rgba(255,255,255,0.06); color: #ffffff; }
body aside.ap-sidebar .ap-sidebar-footer-label,
body .ap-sidebar-footer .ap-sidebar-footer-label,
body .ap-sidebar-footer .op-sidebar-footer-mark { color: rgba(255,255,255,0.42); }
/* Sidebar search input (if used). */
body aside.ap-sidebar input[type="text"],
body aside.ap-sidebar input[type="search"],
body aside.ap-sidebar .sidebar-search-box input {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.10);
    color: rgba(255,255,255,0.88);
}
body aside.ap-sidebar input::placeholder { color: rgba(255,255,255,0.42); }

/* Keyboard focus ring for sidebar links + group toggles.
 * Without this, tab-navigation across the dark sidebar has no visible cue
 * (text-decoration:none on the <a>, default browser outline barely shows
 * against #18181B). Brand-gold ring at 2px keeps it consistent with the
 * existing focus pattern in the rest of the admin design system. */
body aside.ap-sidebar a:focus-visible,
body aside.ap-sidebar button:focus-visible {
    outline: 2px solid #fbbf24;
    outline-offset: -2px;
    border-radius: 8px;
}

/* ============================================================================
 * 2026-05-19 (v2): Sidebar full-height fix. The aside is already
 * `position: fixed; h-[100svh]` (Tailwind) so it IS viewport-tall — but the
 * MENU CONTENT inside is shorter than the aside, and because aside has
 * `overflow-auto`, the BG of the aside element shows through correctly...
 * except the OUTER `<div class="flex bg-stone-100">` that wraps body's
 * content is painting LIGHT bg below the aside's bottom edge (visible when
 * page is scrolled or aside doesn't reach absolute viewport top).
 *
 * Bulletproof fix: a viewport-pinned `body::before` pseudo-element that
 * paints the left 250 px column dark, BEHIND everything else. Independent
 * of any flex/Tailwind interactions.
 * ============================================================================ */
body aside.ap-sidebar {
    min-height: 100vh;
    min-height: 100svh;
    align-self: stretch;
}
/* Desktop: paint the left 250 px gutter dark as a viewport-pinned
 * background. Works regardless of what's between body and aside in the
 * DOM tree. z-index: 0 keeps it behind the aside (which has z-[200])
 * and behind the main content (which has its own bg paint). */
@media (min-width: 992px) {
    body::before {
        content: "";
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 250px;
        background: #18181B;
        z-index: 0;
        pointer-events: none;
    }
    /* Also paint the inner flex wrapper's left 250 px so even if ::before
     * is overridden by something, the immediate parent of aside still
     * shows dark. linear-gradient lets the right side stay bg-stone-100. */
    body > #__next > div.flex,
    body > div.flex {
        background:
            linear-gradient(to right, #18181B 0, #18181B 250px, #f5f5f4 250px, #f5f5f4 100%);
        background-attachment: fixed;
    }
}

/* 2026-05-19 (v3): Force aside bg dark with to defeat any inline
 * <style> in partials that accidentally sets background:#fff on a sidebar
 * child. is used surgically here because the inline rules in
 * admin-sidebar.blade.php have (0,2,2) specificity which would otherwise win. */
body aside.ap-sidebar {
    background-color: #18181B;
}
body aside.ap-sidebar .ap-sidebar-footer {
    background: #0F0F11;
}
/* Active pill stays cream — explicitly allowed in the allowlist. */
body aside.ap-sidebar .ap-row.is-active,
body aside.ap-sidebar .ap-subrow.is-active {
    background-color: #FAFAF9;
}

/* ============================================================================
 * 2026-05-18: MOBILE RESPONSIVE — admin shell at <768px viewport.
 *
 * Without this block the sidebar (fixed 250px) consumed 2/3 of a 375px iPhone
 * viewport and the main content overflowed horizontally past 585px. Fix:
 *  - Sidebar slides off-canvas by default; hamburger reveals it as an overlay.
 *  - When open, a translucent backdrop (.ap-sidebar-backdrop) catches clicks
 *    to close. JS adds/removes the backdrop element.
 *  - Main shell collapses to full width (no 250px left gutter).
 *  - Header right-side balance pills shrink to icons only on very narrow
 *    viewports so the hamburger + brand + balance fit a single row.
 * ============================================================================ */
@media (max-width: 991.98px) {
    /* Sidebar is fixed-overlay, slides in from the left. */
    body aside.ap-sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        z-index: 1070; width: min(280px, 86vw);
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 0 0 24px rgba(0,0,0,0.45);
    }
    body:not(.ap-sidebar-collapsed) aside.ap-sidebar {
        transform: translateX(0);
    }
    /* Keep hamburger reachable while the drawer is open. */
    .ap-header {
        z-index: 1080;
    }
    /* Lock page scroll while the off-canvas drawer is open. */
    body:not(.ap-sidebar-collapsed) {
        overflow: hidden;
        touch-action: none;
    }
    /* When sidebar is collapsed, main shell takes the full viewport width. */
    body [data-ap-shell],
    body .ap-main-shell,
    body main.ap-main,
    body .ap-main {
        margin-left: 0;
        max-width: 100%;
        width: 100%;
    }
    body.ap-sidebar-collapsed .ap-main,
    body:not(.ap-sidebar-collapsed) .ap-main {
        padding-left: 16px;
        padding-right: 16px;
    }
    /* Let dashboard content grow past one screen; fixed 100svh trapped scroll. */
    body [data-ap-shell].ap-shell {
        height: auto;
        min-height: 100svh;
    }
    /* Suppress horizontal overflow at the document root. */
    html, body { overflow-x: hidden; max-width: 100%; }
    /* Backdrop overlay (JS injects this element when sidebar opens). */
    .ap-sidebar-backdrop {
        position: fixed; inset: 0; z-index: 1060;
        background: rgba(0,0,0,0.5);
        opacity: 0; pointer-events: none;
        transition: opacity .25s ease;
    }
    body:not(.ap-sidebar-collapsed) .ap-sidebar-backdrop {
        opacity: 1; pointer-events: auto;
    }
}
@media (max-width: 575.98px) {
    /* Tighten header pills below the iPhone-SE viewport. */
    .ap-header { padding-left: 8px; padding-right: 8px; gap: 6px; }
    .ap-header-search-label,
    .ap-header-search-kbd { display: none; }
    .ap-balance {
        max-width: min(96px, 30vw);
        padding: 4px 6px;
    }
    .ap-balance-value { font-size: 11px; }
    .ap-theme-toggle { display: none; }
    main .tb-page-head { flex-direction: column; align-items: stretch; }
    main .tb-page-head .ap-date-filter-container { width: 100%; }
}

/* =====================================================================
   Phase 2A — Dark theme overrides
   ---------------------------------------------------------------------
   Activated by <html data-theme="dark">. Light theme remains the default
   and is unaffected (these rules only match when the attribute is set).
   The layout's inline boot script sets the attribute BEFORE paint to
   avoid a light flash on dark-mode users.
   ===================================================================== */
[data-theme="dark"] {
    --r-bg:        #0E0E10;
    --r-surface:   #1c1917;
    --r-surface-2: #292524;
    --r-surface-3: #1c1917;
    --r-text:      #fafaf9;
    --r-text-2:    rgba(250,250,249,0.78);
    --r-faint:     rgba(250,250,249,0.6);
    --r-line:      rgba(250,250,249,0.12);
    --r-line-2:    rgba(250,250,249,0.08);
}
[data-theme="dark"] body { background: var(--r-bg); color: var(--r-text); }

/* Shell surfaces */
[data-theme="dark"] .ap-header { background: var(--r-surface); border-bottom-color: var(--r-line); }
[data-theme="dark"] .ap-header-menu { color: var(--r-text); }
[data-theme="dark"] .ap-header-menu:hover { background: rgba(250,250,249,0.06); }
[data-theme="dark"] .ap-header-search { background: rgba(250,250,249,0.06); color: var(--r-text-2); }
[data-theme="dark"] .ap-header-search:hover { background: rgba(250,250,249,0.10); }
[data-theme="dark"] .ap-header-search i { color: var(--r-faint); }
[data-theme="dark"] .ap-header-search-kbd { color: var(--r-faint); }
[data-theme="dark"] .ap-header-search-kbd kbd { background: var(--r-surface-2); border-color: var(--r-line); color: var(--r-text-2); }
[data-theme="dark"] .ap-balance { background: rgba(250,250,249,0.06); color: var(--r-text); }
[data-theme="dark"] .ap-balance-label { color: var(--r-faint); }
[data-theme="dark"] .ap-balance-sep { background: var(--r-line); }
[data-theme="dark"] .tb-card,
[data-theme="dark"] aside.ap-sidebar { background: var(--r-surface); border-color: var(--r-line); color: var(--r-text); }

/* Sidebar rows (overrides the partial's inline <style> — same specificity,
   later in source order wins on ties because admin-design-system.css is
   loaded in <head> BEFORE the body partial; therefore we need at least
   the same specificity AND the `data-theme="dark"` selector to ensure
   override semantics. The attribute selector is matched first, so combined
   `[data-theme="dark"] aside.ap-sidebar ...` (2 classes + 1 attr = 0,3,0)
   beats `aside.ap-sidebar ...` (1 class + tag = 0,1,1). Cascade works. */
[data-theme="dark"] aside.ap-sidebar nav ul li > a,
[data-theme="dark"] aside.ap-sidebar nav ul li > button { color: rgba(250,250,249,0.75); }
[data-theme="dark"] aside.ap-sidebar .ap-row { color: rgba(250,250,249,0.75); }
[data-theme="dark"] aside.ap-sidebar .ap-row:hover { background: rgba(250,250,249,0.06); color: rgba(250,250,249,0.95); }
[data-theme="dark"] body aside.ap-sidebar .ap-row.is-active { background: rgba(250,250,249,0.10); color: #fafaf9; }
[data-theme="dark"] aside.ap-sidebar .ap-subrow { color: rgba(250,250,249,0.65); }
[data-theme="dark"] aside.ap-sidebar .ap-subrow:hover { background: rgba(250,250,249,0.06); color: rgba(250,250,249,0.92); }
[data-theme="dark"] body aside.ap-sidebar .ap-subrow.is-active { background: rgba(250,204,21,0.18); color: #fafaf9; }
/* 2026-05-20 — the light-mode rule at line ~1771 forces .ap-row-label /
   .ap-row-icon i to color:#0E0E10 (near-black) inside .is-active because
   the active pill is cream in light mode. In dark mode the active pill
   is a gold tint on a dark rail, so near-black text on it is unreadable
   (the bug from the user's "Requests" screenshot). Restore white text on
   the dark active pill. */
[data-theme="dark"] aside.ap-sidebar .ap-row.is-active .ap-row-label,
[data-theme="dark"] aside.ap-sidebar .ap-row.is-active .ap-row-icon i,
[data-theme="dark"] aside.ap-sidebar .ap-subrow.is-active .ap-row-label,
[data-theme="dark"] aside.ap-sidebar .ap-subrow.is-active .ap-row-icon i {
    color: #fafaf9 !important;
}

/* Tables */
[data-theme="dark"] .tb-table { background: var(--r-surface); color: var(--r-text); }
[data-theme="dark"] .tb-table th { background: rgba(250,250,249,0.04); color: var(--r-text); border-color: var(--r-line); }
[data-theme="dark"] .tb-table td { border-color: var(--r-line); }
[data-theme="dark"] .tb-table tbody tr:hover { background: rgba(250,250,249,0.04); }

/* Form inputs */
[data-theme="dark"] .tb-input,
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] select,
[data-theme="dark"] textarea { background: var(--r-surface); color: var(--r-text); border-color: var(--r-line); }
[data-theme="dark"] .tb-input:focus,
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus { background: var(--r-surface); color: var(--r-text); }
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: var(--r-faint); }

/* Modals + dropdowns + breadcrumbs */
[data-theme="dark"] .modal-content { background: var(--r-surface); color: var(--r-text); border-color: var(--r-line); }
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer { border-color: var(--r-line); }
[data-theme="dark"] .dropdown-menu { background: var(--r-surface); border-color: var(--r-line); }
[data-theme="dark"] .dropdown-item { color: var(--r-text); }
[data-theme="dark"] .dropdown-item:hover { background: rgba(250,250,249,0.06); color: var(--r-text); }
[data-theme="dark"] .breadcrumb a { color: rgba(250,250,249,0.65); }
[data-theme="dark"] .ap-breadcrumb,
[data-theme="dark"] .ap-breadcrumb a { color: rgba(250,250,249,0.65); }

/* Profile menu popover */
[data-theme="dark"] .ap-profile-menu { background: var(--r-surface); border-color: var(--r-line); color: var(--r-text); }
[data-theme="dark"] .ap-profile-menu-item { color: var(--r-text); }
[data-theme="dark"] .ap-profile-menu-item:hover { background: rgba(250,250,249,0.06); }
[data-theme="dark"] .ap-profile-menu-sep { background: var(--r-line); }
[data-theme="dark"] .ap-profile-menu-handle { color: var(--r-faint); }

/* Tailwind utility helpers used in the shell */
[data-theme="dark"] .bg-stone-100 { background-color: var(--r-bg); }


