/*
 * Console theme — the shell (sidebar, top bar) plus a restyle of the Bootstrap
 * components every console page already uses. Pages keep their Bootstrap
 * markup; this file only changes how it looks.
 *
 * Palette: deep engine-navy chrome, cool grey paper, one catalog-blue for
 * actions, and signal amber reserved for "you are here" (active nav, focus).
 */

:root {
    --cx-ink: #1a2633;
    --cx-ink-soft: #52606d;
    --cx-ink-faint: #8794a1;
    --cx-paper: #eef1f4;
    --cx-surface: #ffffff;
    --cx-surface-sunk: #f6f8fa;
    --cx-line: #dce2e8;
    --cx-line-strong: #c5ced7;

    --cx-chrome: #0d2236;
    --cx-chrome-raised: #15304a;
    --cx-chrome-text: #b7c4d1;
    --cx-chrome-muted: #6f859a;

    --cx-blue: #2459c7;
    --cx-blue-dark: #1b469f;
    --cx-blue-tint: #e8effb;
    --cx-amber: #e8a317;

    --cx-radius-lg: 10px;
    --cx-radius: 6px;
    --cx-sidebar-width: 256px;

    --cx-font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --cx-font-display: "Archivo", "IBM Plex Sans", system-ui, sans-serif;
    --cx-font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

    /* Bootstrap 5.3 runtime variables */
    --bs-body-font-family: var(--cx-font-body);
    --bs-body-font-size: 0.9375rem;
    --bs-body-color: var(--cx-ink);
    /* Bootstrap paints inputs, dropdowns and modals with --bs-body-bg, so it
       stays white; the grey page colour is set on body itself. */
    --bs-body-bg: var(--cx-surface);
    --bs-emphasis-color: var(--cx-ink);
    --bs-secondary-color: var(--cx-ink-soft);
    --bs-font-monospace: var(--cx-font-mono);
    --bs-border-color: var(--cx-line);
    --bs-border-radius: var(--cx-radius);
    --bs-border-radius-sm: 4px;
    --bs-border-radius-lg: var(--cx-radius-lg);
    --bs-primary: var(--cx-blue);
    --bs-primary-rgb: 36, 89, 199;
    --bs-primary-text-emphasis: var(--cx-blue-dark);
    --bs-primary-bg-subtle: var(--cx-blue-tint);
    --bs-primary-border-subtle: #bccdf0;
    --bs-link-color: var(--cx-blue);
    --bs-link-color-rgb: 36, 89, 199;
    --bs-link-hover-color: var(--cx-blue-dark);
    --bs-link-hover-color-rgb: 27, 70, 159;
    --bs-focus-ring-color: rgba(232, 163, 23, .35);
}

body {
    background: var(--cx-paper);
    color: var(--cx-ink);
    font-feature-settings: "tnum" 1;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--cx-font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--cx-ink);
}

.h2, h2 { font-size: 1.6rem; }

code, kbd, pre, .font-monospace { font-family: var(--cx-font-mono); }
code { color: #9a3c0b; font-size: .85em; }

.text-muted { color: var(--cx-ink-soft) !important; }

/* ── Shell ─────────────────────────────────────────────────────────────── */

.cx-shell {
    display: flex;
    min-height: 100vh;
}

.cx-sidebar {
    position: sticky;
    top: 0;
    flex: 0 0 var(--cx-sidebar-width);
    width: var(--cx-sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--cx-chrome);
    color: var(--cx-chrome-text);
    z-index: 1040;
}

.cx-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1.15rem 1.25rem 1rem;
    color: #fff;
    text-decoration: none;
}

.cx-brand:hover { color: #fff; }

.cx-brand-mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--cx-amber);
    color: var(--cx-chrome);
    font-size: 1.05rem;
}

.cx-brand-name {
    font-family: var(--cx-font-display);
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.1;
}

.cx-brand-sub {
    display: block;
    font-family: var(--cx-font-body);
    font-weight: 400;
    font-size: .75rem;
    color: var(--cx-chrome-muted);
}

.cx-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: .25rem .75rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--cx-chrome-raised) transparent;
}

.cx-nav-group + .cx-nav-group { margin-top: 1.1rem; }

.cx-nav-heading {
    padding: 0 .65rem .35rem;
    font-size: .75rem;
    font-weight: 600;
    color: var(--cx-chrome-muted);
}

.cx-nav-divider {
    margin: 1.25rem .65rem .9rem;
    border-top: 1px solid var(--cx-chrome-raised);
}

.cx-nav-role {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: 0 .65rem .6rem;
    font-family: var(--cx-font-display);
    font-weight: 600;
    font-size: .85rem;
    color: #fff;
}

.cx-nav-role i { color: var(--cx-amber); }

.cx-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cx-nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .45rem .65rem;
    border-radius: var(--cx-radius);
    color: var(--cx-chrome-text);
    font-size: .875rem;
    text-decoration: none;
    transition: background-color .12s ease, color .12s ease;
}

.cx-nav-link i {
    width: 1.1rem;
    font-size: 1rem;
    text-align: center;
    color: var(--cx-chrome-muted);
    transition: color .12s ease;
}

.cx-nav-link:hover {
    background: var(--cx-chrome-raised);
    color: #fff;
}

.cx-nav-link:hover i { color: var(--cx-chrome-text); }

/* The indicator lamp: the only place amber appears in the navigation. */
.cx-nav-link.active {
    background: var(--cx-chrome-raised);
    color: #fff;
    font-weight: 500;
}

.cx-nav-link.active::before {
    content: "";
    position: absolute;
    left: -.75rem;
    top: .4rem;
    bottom: .4rem;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--cx-amber);
}

.cx-nav-link.active i { color: var(--cx-amber); }

.cx-nav-link:focus-visible {
    outline: 2px solid var(--cx-amber);
    outline-offset: 1px;
}

.cx-nav-count {
    margin-left: auto;
    min-width: 1.4rem;
    padding: .1rem .45rem;
    border-radius: 999px;
    background: var(--cx-blue);
    color: #fff;
    font-size: .72rem;
    font-weight: 600;
    text-align: center;
}

.cx-nav-count.is-alert { background: #d63b3b; }

.cx-user {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .9rem 1rem;
    border-top: 1px solid var(--cx-chrome-raised);
}

.cx-user-avatar {
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--cx-chrome-raised);
    color: #fff;
    font-family: var(--cx-font-display);
    font-weight: 600;
    text-transform: uppercase;
}

.cx-user-email {
    min-width: 0;
    flex: 1 1 auto;
    font-size: .8rem;
    color: #fff;
}

.cx-user-email small {
    display: block;
    color: var(--cx-chrome-muted);
    font-size: .72rem;
}

.cx-user-email span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cx-icon-btn {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: var(--cx-radius);
    background: transparent;
    color: var(--cx-chrome-text);
    text-decoration: none;
}

.cx-icon-btn:hover { background: var(--cx-chrome-raised); color: #fff; }
.cx-icon-btn:focus-visible { outline: 2px solid var(--cx-amber); }

.cx-signin { margin: 1rem; }

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

.cx-topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 1030;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
    background: var(--cx-chrome);
    color: #fff;
}

.cx-topbar .cx-brand { padding: 0; }

.cx-content {
    width: 100%;
    padding: 1.75rem 2.25rem 3rem;
}

.cx-flashes .alert { margin-bottom: .75rem; }

.cx-backdrop { display: none; }

@media (max-width: 767.98px) {
    .cx-topbar { display: flex; }

    .cx-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 0 0 40px rgba(0, 0, 0, .3);
    }

    .cx-shell.is-open .cx-sidebar { transform: none; }

    .cx-shell.is-open .cx-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1035;
        background: rgba(13, 34, 54, .45);
    }

    .cx-content { padding: 1.25rem 1rem 2.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .cx-sidebar, .cx-nav-link, .cx-nav-link i { transition: none; }
}

/* ── Bootstrap components ──────────────────────────────────────────────── */

.card {
    --bs-card-border-color: var(--cx-line);
    --bs-card-border-radius: var(--cx-radius-lg);
    --bs-card-inner-border-radius: calc(var(--cx-radius-lg) - 1px);
    --bs-card-cap-bg: var(--cx-surface);
    --bs-card-bg: var(--cx-surface);
    border: 1px solid var(--cx-line);
    box-shadow: none;
}

/* Pages ask for shadows; the theme draws edges instead. */
.card.shadow, .card.shadow-sm, .card.shadow-lg { box-shadow: none !important; }

.card-header {
    padding: .8rem 1.1rem;
    border-bottom: 1px solid var(--cx-line);
    font-weight: 600;
}

.card-footer {
    background: var(--cx-surface-sunk);
    border-top: 1px solid var(--cx-line);
}

a > .card { transition: border-color .12s ease; }
a:hover > .card { border-color: var(--cx-blue); }

.btn {
    --bs-btn-font-weight: 500;
    --bs-btn-border-radius: var(--cx-radius);
    --bs-btn-focus-box-shadow: 0 0 0 .2rem rgba(232, 163, 23, .4);
    font-size: .875rem;
}

.btn-sm { font-size: .8rem; }

.btn-primary {
    --bs-btn-bg: var(--cx-blue);
    --bs-btn-border-color: var(--cx-blue);
    --bs-btn-hover-bg: var(--cx-blue-dark);
    --bs-btn-hover-border-color: var(--cx-blue-dark);
    --bs-btn-active-bg: var(--cx-blue-dark);
    --bs-btn-active-border-color: var(--cx-blue-dark);
    --bs-btn-disabled-bg: var(--cx-blue);
    --bs-btn-disabled-border-color: var(--cx-blue);
}

.btn-outline-primary {
    --bs-btn-color: var(--cx-blue);
    --bs-btn-border-color: var(--cx-blue);
    --bs-btn-hover-bg: var(--cx-blue);
    --bs-btn-hover-border-color: var(--cx-blue);
    --bs-btn-active-bg: var(--cx-blue-dark);
    --bs-btn-active-border-color: var(--cx-blue-dark);
}

.btn-outline-secondary {
    --bs-btn-color: var(--cx-ink);
    --bs-btn-bg: var(--cx-surface);
    --bs-btn-border-color: var(--cx-line-strong);
    --bs-btn-hover-color: var(--cx-ink);
    --bs-btn-hover-bg: var(--cx-surface-sunk);
    --bs-btn-hover-border-color: var(--cx-ink-faint);
    --bs-btn-active-color: var(--cx-ink);
    --bs-btn-active-bg: var(--cx-paper);
    --bs-btn-active-border-color: var(--cx-ink-faint);
}

.btn-secondary {
    --bs-btn-bg: #52606d;
    --bs-btn-border-color: #52606d;
    --bs-btn-hover-bg: #3e4a56;
    --bs-btn-hover-border-color: #3e4a56;
}

.btn-light {
    --bs-btn-bg: var(--cx-surface-sunk);
    --bs-btn-border-color: var(--cx-line);
    --bs-btn-hover-bg: var(--cx-paper);
    --bs-btn-hover-border-color: var(--cx-line-strong);
}

.form-control, .form-select {
    border-color: var(--cx-line-strong);
    border-radius: var(--cx-radius);
    font-size: .9rem;
}

.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--cx-amber);
    box-shadow: 0 0 0 .2rem rgba(232, 163, 23, .25);
}

.form-check-input { border-color: var(--cx-ink-faint); }

.form-check-input:checked {
    background-color: var(--cx-blue);
    border-color: var(--cx-blue);
}

.form-label, .col-form-label {
    font-size: .85rem;
    font-weight: 500;
    color: var(--cx-ink);
}

.form-text { color: var(--cx-ink-faint); font-size: .8rem; }

.input-group-text {
    background: var(--cx-surface-sunk);
    border-color: var(--cx-line-strong);
    color: var(--cx-ink-soft);
}

.table {
    --bs-table-bg: var(--cx-surface);
    --bs-table-color: var(--cx-ink);
    --bs-table-border-color: var(--cx-line);
    --bs-table-striped-bg: var(--cx-surface-sunk);
    --bs-table-hover-bg: #f1f5fb;
    font-size: .875rem;
}

.table > :not(caption) > * > * { padding: .65rem .8rem; }
.table-sm > :not(caption) > * > * { padding: .35rem .6rem; }

.table > thead > tr > th,
.table thead.table-light > tr > th,
.table thead.table-dark > tr > th {
    --bs-table-bg: var(--cx-surface-sunk);
    --bs-table-color: var(--cx-ink-soft);
    background: var(--cx-surface-sunk);
    color: var(--cx-ink-soft);
    font-size: .78rem;
    font-weight: 600;
    border-bottom: 1px solid var(--cx-line-strong);
    white-space: nowrap;
}

.table-responsive {
    border: 1px solid var(--cx-line);
    border-radius: var(--cx-radius-lg);
    background: var(--cx-surface);
}

.table-responsive > .table { margin-bottom: 0; }
.table-responsive > .table > :last-child > tr:last-child > * { border-bottom: 0; }
.card .table-responsive { border: 0; border-radius: 0; }

.badge {
    --bs-badge-font-weight: 600;
    --bs-badge-border-radius: 4px;
    letter-spacing: .01em;
}

.badge.rounded-pill { --bs-badge-border-radius: 999px; }

.bg-primary { background-color: var(--cx-blue) !important; }
.text-primary { color: var(--cx-blue) !important; }

.alert {
    --bs-alert-border-radius: var(--cx-radius);
    border-width: 1px 1px 1px 4px;
    font-size: .9rem;
}

.alert-success { --bs-alert-border-color: #8fd1a8; border-left-color: #1f8a4c; }
.alert-danger, .alert-error { --bs-alert-border-color: #f0b4b4; border-left-color: #c23030; }
.alert-warning { --bs-alert-border-color: #f2d48a; border-left-color: var(--cx-amber); }
.alert-info { --bs-alert-border-color: #b3cdf2; border-left-color: var(--cx-blue); }

/* Flash label "error" is not a Bootstrap variant; give it the danger look. */
.alert-error {
    --bs-alert-color: #842029;
    --bs-alert-bg: #f8d7da;
}

.nav-tabs {
    --bs-nav-tabs-border-color: var(--cx-line);
    --bs-nav-tabs-link-active-color: var(--cx-ink);
    --bs-nav-tabs-link-active-bg: var(--cx-surface);
    --bs-nav-tabs-link-active-border-color: var(--cx-line) var(--cx-line) var(--cx-surface);
    --bs-nav-link-color: var(--cx-ink-soft);
    --bs-nav-link-hover-color: var(--cx-ink);
    --bs-nav-link-font-weight: 500;
    font-size: .875rem;
}

.nav-pills {
    --bs-nav-pills-link-active-bg: var(--cx-blue);
    --bs-nav-link-color: var(--cx-ink-soft);
    --bs-nav-link-hover-color: var(--cx-ink);
}

.pagination {
    --bs-pagination-color: var(--cx-ink);
    --bs-pagination-border-color: var(--cx-line);
    --bs-pagination-hover-bg: var(--cx-surface-sunk);
    --bs-pagination-active-bg: var(--cx-blue);
    --bs-pagination-active-border-color: var(--cx-blue);
    --bs-pagination-font-size: .85rem;
}

.list-group {
    --bs-list-group-border-color: var(--cx-line);
    --bs-list-group-action-hover-bg: var(--cx-surface-sunk);
    --bs-list-group-active-bg: var(--cx-blue);
    --bs-list-group-active-border-color: var(--cx-blue);
}

.progress {
    --bs-progress-bg: var(--cx-paper);
    --bs-progress-bar-bg: var(--cx-blue);
    --bs-progress-border-radius: 999px;
}

.dropdown-menu {
    --bs-dropdown-border-color: var(--cx-line);
    --bs-dropdown-link-active-bg: var(--cx-blue);
    --bs-dropdown-font-size: .875rem;
    box-shadow: 0 8px 24px rgba(13, 34, 54, .12);
}

.modal-content {
    border: 1px solid var(--cx-line);
    border-radius: var(--cx-radius-lg);
}

.border-bottom { border-bottom-color: var(--cx-line) !important; }

/* ── Small helpers formerly inlined in the base template ───────────────── */

.form-card { max-width: 720px; }
.paypal-frame { width: 100%; height: 550px; border: none; overflow: hidden; }
.hash-value { word-break: break-all; line-height: 1.4; font-family: var(--cx-font-mono); }

/* ── Sign-in, registration and password-reset pages ────────────────────── */

.cx-auth {
    min-height: 100vh;
    background:
        linear-gradient(var(--cx-chrome), var(--cx-chrome)) top / 100% 38vh no-repeat,
        var(--cx-paper);
}

.cx-auth-brand {
    justify-content: center;
    padding: 3rem 1rem 0;
}

/* ── Stat strip: one card split into labelled figures ──────────────────── */

.cx-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.cx-stat {
    padding: 0.9rem 1.2rem;
    border-right: 1px solid var(--cx-line);
}

.cx-stat:last-child { border-right: 0; }

.cx-stat > span {
    display: block;
    font-size: 0.78rem;
    color: var(--cx-ink-soft);
}

.cx-stat > strong {
    font-family: var(--cx-font-display);
    font-size: 1.3rem;
    font-weight: 600;
}

.cx-stat small {
    margin-left: 0.25rem;
    font-family: var(--cx-font-body);
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--cx-ink-soft);
}

/* A compact from–to pair of number inputs in a filter bar. */
.cx-range { flex-wrap: nowrap; }
.cx-range .form-control { width: 5rem; }

/* User form: per-user payment allowlist switches with their current effect. */
.user-pay-switches {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.75rem;
}

.user-pay-switch {
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--cx-line);
    border-radius: var(--cx-radius);
    background: var(--cx-surface-sunk);
}
