/* ==========================================================================
   GoDigital Hup — application styles
   Layered on Bootstrap 5. --brand is injected per white-label tenant.
   ========================================================================== */

:root {
    --brand: #0d6efd;
    --sidebar-w: 248px;
    --nav-h: 58px;
    --surface: #f5f7fb;
    --border: #e4e8f0;
    --ink: #1c2434;
    --ink-muted: #6b7488;

    /* --- Sidebar ---------------------------------------------------------
       Deliberately fixed rather than derived from --brand. A white-label tenant
       picks --brand for buttons and highlights, where it sits on white; reusing
       it as a large dark background would make a light brand colour unreadable
       and a bright one exhausting to look at all day. The tenant's colour still
       drives the active item, which is where it reads as identity. */
    --sidebar-bg: #131b26;
    --sidebar-ink: #c6cedb;
    /* Lightened until it clears WCAG AA (4.5:1) against the panel. The obvious
       muted grey measured 4.27:1 — close enough to look fine and fail anyone
       reading it on a laptop in daylight. */
    --sidebar-ink-dim: #8391a5;
    --sidebar-hover: rgba(255, 255, 255, .07);
    --sidebar-divider: rgba(255, 255, 255, .07);
}

body {
    background: var(--surface);
    color: var(--ink);
    font-size: .925rem;
}

/* --- Brand helpers ------------------------------------------------------ */
/*
 * Driven through Bootstrap's own --bs-btn-* variables rather than by setting
 * background/colour directly.
 *
 * The direct version had a bug worth remembering. It styled `.btn-brand` and
 * `.btn-brand:hover`, but the hover rule only set `filter` and `color` — it
 * never re-declared a background. Bootstrap's `.btn:hover` DOES:
 *
 *     .btn:hover { background-color: var(--bs-btn-hover-bg); ... }
 *
 * and on a `.btn` with no Bootstrap variant class that variable is
 * `transparent`. Both selectors have the same specificity (0,2,0), so the one
 * declaring the property won: on hover the fill disappeared and `color:#fff`
 * left white text on a white card. The button became invisible exactly when
 * the pointer was on it.
 *
 * Setting the variables fixes hover, active, focus and disabled at once, and
 * cannot drift out of step with Bootstrap's internals again.
 *
 * Every state stays var(--brand): the brand colour is injected per white-label
 * tenant, so a hard-coded darker shade would be wrong for every tenant but one.
 * The darkening is done with a filter, which works against any hue.
 */
.btn-brand {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);

    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);

    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--brand);
    --bs-btn-active-border-color: var(--brand);

    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
}
.btn-brand:hover,
.btn-brand:focus-visible,
.btn-brand:active {
    filter: brightness(.92);
}
/* Bootstrap already dims a disabled button with opacity; darkening it too
   reads as "pressed" on a control that cannot be pressed. */
.btn-brand:disabled,
.btn-brand.disabled {
    filter: none;
}
.text-brand { color: var(--brand) !important; }

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 30px; height: 30px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    font-size: .95rem;
}
.brand-mark-lg {
    width: 52px; height: 52px;
    font-size: 1.6rem;
    background: var(--brand);
}

/* --- Top bar ------------------------------------------------------------ */
.app-navbar {
    height: var(--nav-h);
    background: var(--brand);
    color: #fff;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .12);
}
.app-navbar .navbar-brand,
.app-navbar .navbar-brand:hover { color: #fff; }

.wallet-chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    background: rgba(255, 255, 255, .17);
    color: #fff;
    padding: .32rem .7rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: .875rem;
    white-space: nowrap;
}

.avatar {
    display: inline-grid;
    place-items: center;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .22);
    font-size: .75rem;
    font-weight: 700;
}

/* --- Shell -------------------------------------------------------------- */
.app-shell { display: flex; min-height: calc(100vh - var(--nav-h)); }

.app-sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    border-right: 0;
    color: var(--sidebar-ink);

    /* !important is load-bearing here, not laziness.
       The panel carries Bootstrap's `.offcanvas-lg`, and above the lg
       breakpoint Bootstrap declares:
           .offcanvas-lg { background-color: transparent !important }
       to undo the offcanvas styling it applies on smaller screens. No amount of
       selector specificity beats an !important, so the only way to keep a
       background on desktop is to match it. Without this the panel is
       transparent from 992px up and the page surface shows through — which
       looks like "the colour did not apply". */
    background-color: var(--sidebar-bg) !important;

    /* The sidebar is the scroll container at EVERY breakpoint, not only on
       desktop. In offcanvas mode it is a fixed-height panel, and without this
       a menu taller than the screen simply could not be scrolled on a phone.
       It also gives the scroll-position restore one consistent element to
       address, rather than a different one per breakpoint. */
    overflow-y: auto;

    /* Reaching the end of the menu must not start scrolling the page behind
       it — that is how a tap-scroll on mobile ends up moving the wrong thing. */
    overscroll-behavior: contain;

    /* Position restoring must be instant. A smooth scroll here would animate
       the sidebar from the top down to the saved position on every page load,
       which is the visible jump this is meant to remove. */
    scroll-behavior: auto;
}

@media (min-width: 992px) {
    .app-sidebar {
        position: sticky;
        top: var(--nav-h);
        height: calc(100vh - var(--nav-h));
    }
}

.sidebar-nav { padding: .6rem .55rem 2rem; }

.sidebar-group {
    padding: 1.05rem .75rem .35rem;
    font-size: .66rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--sidebar-ink-dim);
}
/* No heading above the first group — it would sit tight under the navbar. */
.sidebar-group:first-child { padding-top: .35rem; }

/* --- Menu search --------------------------------------------------------- */
.sidebar-search {
    position: relative;
    padding: .7rem .8rem .2rem;
}
.sidebar-search i {
    position: absolute;
    left: 1.45rem;
    top: 50%;
    transform: translateY(-30%);
    font-size: .85rem;
    color: var(--sidebar-ink-dim);
    pointer-events: none;
}
.sidebar-search input {
    padding-left: 2rem;
    background: rgba(255, 255, 255, .06);
    border-color: rgba(255, 255, 255, .12);
    color: #fff;
}
.sidebar-search input::placeholder { color: var(--sidebar-ink-dim); }
.sidebar-search input:focus {
    background: rgba(255, 255, 255, .1);
    border-color: rgba(255, 255, 255, .28);
    color: #fff;
    box-shadow: none;
}
/* The browser's own clear affordance is dark-on-dark and invisible here. */
.sidebar-search input::-webkit-search-cancel-button { filter: invert(1); opacity: .5; }

.sidebar-empty {
    padding: 1rem .9rem;
    margin: 0;
    font-size: .85rem;
    color: var(--sidebar-ink-dim);
}

/* --- Two-level menu ------------------------------------------------------ */
.sidebar-toggle {
    width: 100%;
    border: 0;
    background: none;
    text-align: left;
    font-family: inherit;
}
.sidebar-caret {
    margin-left: auto;
    font-size: .75rem !important;
    width: auto !important;
    flex: 0 0 auto !important;
    transition: transform .16s ease;
}
.sidebar-toggle.collapsed .sidebar-caret { transform: rotate(-90deg); }

/* --- Logout ---------------------------------------------------------------
   The last entry is a BUTTON in a form, because /logout is POST-only — a GET
   link there would answer 405. The browser-button resets that .sidebar-toggle
   carries are repeated here rather than shared, because this button is not a
   toggle and must not inherit the caret rules that come with that class. */
.sidebar-logout {
    margin: .35rem 0 0;
    padding-top: .35rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-logout .sidebar-link {
    width: 100%;
    border: 0;
    background: none;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
}
/* Signing out is destructive enough to warn on hover, but not loud enough to
   sit in red all day next to the pages people actually want. */
.sidebar-logout .sidebar-link:hover,
.sidebar-logout .sidebar-link:focus-visible {
    background: rgba(220, 53, 69, .16);
    color: #ffb3ba;
}
.sidebar-logout .sidebar-link:hover i,
.sidebar-logout .sidebar-link:focus-visible i { color: #ff8f99; }

.sidebar-submenu {
    /* The rail lines the children up under their parent's icon, so the tree is
       readable without indenting so far that long labels wrap. */
    margin: 1px 0 .3rem 1.55rem;
    padding-left: .55rem;
    border-left: 1px solid rgba(255, 255, 255, .1);
}
.sidebar-link.sidebar-sub {
    padding: .45rem .6rem;
    font-size: .875rem;
    font-weight: 400;
    gap: 0;
}
.sidebar-link.sidebar-sub.active { font-weight: 500; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .62rem .75rem;
    margin-bottom: 1px;
    border-radius: 8px;
    color: var(--sidebar-ink);
    text-decoration: none;
    font-size: .935rem;
    font-weight: 500;
    line-height: 1.35;
    transition: background-color .12s ease, color .12s ease;
}
.sidebar-link i {
    font-size: 1.05rem;
    width: 1.35rem;
    flex: 0 0 1.35rem;
    text-align: center;
    color: var(--sidebar-ink-dim);
    transition: color .12s ease;
}
.sidebar-link span { min-width: 0; }

.sidebar-link:hover,
.sidebar-link:focus-visible {
    background: var(--sidebar-hover);
    color: #fff;
}
/* Icons keep their own colour on hover — brightened rather than washed to
   white, so the colour stays a reliable way to find an item by eye. */
.sidebar-link:hover i,
.sidebar-link:focus-visible i { filter: brightness(1.2); }

/* --- Icon colours -------------------------------------------------------
   Grouped by MEANING, not one hue per item. Fifty-nine unrelated colours
   would read as confetti; a handful of consistent families means the colour
   itself carries information — anything green moves money, anything amber is
   about people, anything rose wants attention.

   All are light and saturated enough to clear WCAG 1.4.11 (3:1 for non-text)
   against the panel. Verified, not eyeballed.
   ---------------------------------------------------------------------- */

/* Money: wallet, banking, pricing, anything with an amount attached. */
.sidebar-link .bi-bank,
.sidebar-link .bi-cash-stack,
.sidebar-link .bi-cash-coin,
.sidebar-link .bi-currency-rupee,
.sidebar-link .bi-credit-card,
.sidebar-link .bi-credit-card-2-front,
.sidebar-link .bi-list-columns,
.sidebar-link .bi-arrow-left-right,
.sidebar-link .bi-qr-code,
.sidebar-link .bi-receipt,
.sidebar-link .bi-percent,
.sidebar-link .bi-tags,
.sidebar-link .bi-safe,
.sidebar-link .bi-sliders,
.sidebar-link .bi-wallet2 { color: #34d399; }

/* People and hierarchy. */
.sidebar-link .bi-people,
.sidebar-link .bi-person-plus,
.sidebar-link .bi-person-badge,
.sidebar-link .bi-person-gear,
.sidebar-link .bi-person-check,
.sidebar-link .bi-diagram-3 { color: #fbbf24; }

/* Services the customer actually buys. */
.sidebar-link .bi-plus-square,
.sidebar-link .bi-card-text,
.sidebar-link .bi-card-checklist,
.sidebar-link .bi-grid-3x3-gap,
.sidebar-link .bi-card-heading { color: #a78bfa; }

/* Support and self-service. */
.sidebar-link .bi-life-preserver,
.sidebar-link .bi-headset,
.sidebar-link .bi-download,
.sidebar-link .bi-patch-check,
.sidebar-link .bi-chat-dots,
.sidebar-link .bi-inbox { color: #22d3ee; }

/* Overview, search and reporting. */
.sidebar-link .bi-speedometer2,
.sidebar-link .bi-graph-up,
.sidebar-link .bi-search,
.sidebar-link .bi-activity,
.sidebar-link .bi-journal-text,
.sidebar-link .bi-check2-square { color: #60a5fa; }

/* Things that want attention: alerts, faults, reversals. */
.sidebar-link .bi-bell,
.sidebar-link .bi-bug,
.sidebar-link .bi-shield-exclamation,
.sidebar-link .bi-megaphone,
.sidebar-link .bi-megaphone-fill,
.sidebar-link .bi-arrow-counterclockwise { color: #fb7185; }

/* Content, branding and company identity. */
.sidebar-link .bi-images,
.sidebar-link .bi-file-text,
.sidebar-link .bi-palette,
.sidebar-link .bi-building,
.sidebar-link .bi-journal-code,
.sidebar-link .bi-cloud-arrow-up { color: #f472b6; }

/* Infrastructure and configuration — deliberately the quietest family, so the
   operational plumbing does not compete with the day-to-day work above it. */
.sidebar-link .bi-gear,
.sidebar-link .bi-toggles,
.sidebar-link .bi-tools,
.sidebar-link .bi-hdd,
.sidebar-link .bi-hdd-stack,
.sidebar-link .bi-hdd-network,
.sidebar-link .bi-code-slash,
.sidebar-link .bi-archive,
.sidebar-link .bi-clock-history,
.sidebar-link .bi-envelope-gear,
.sidebar-link .bi-ui-checks-grid { color: #94a3b8; }

/* The active item is the one place the tenant's colour appears in the sidebar,
   which is enough to read as branding without colouring the whole panel. */
.sidebar-link.active {
    background: var(--brand);
    color: #fff;
    font-weight: 600;
}
.sidebar-link.active i { color: #fff; }
.sidebar-link.active:hover { background: var(--brand); filter: brightness(1.06); }

/* Keyboard focus must stay visible against the dark panel. */
.sidebar-link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .55);
    outline-offset: -2px;
}

/* A thin, dark scrollbar — the default light one is jarring on this panel. */
.app-sidebar { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.16) transparent; }
.app-sidebar::-webkit-scrollbar { width: 8px; }
.app-sidebar::-webkit-scrollbar-track { background: transparent; }
.app-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .14);
    border-radius: 8px;
}
.app-sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .24); }

/* Offcanvas header, on tablet and mobile. */
.app-sidebar .offcanvas-header {
    border-bottom: 1px solid var(--sidebar-divider);
    color: #fff;
}
.app-sidebar .offcanvas-title { color: #fff; font-size: 1rem; }

.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-main > .container-fluid { flex: 1 0 auto; }

.app-footer {
    border-top: 1px solid var(--border);
    background: #fff;
    padding: .85rem 0;
    color: var(--ink-muted);
}

/* --- Cards and tables --------------------------------------------------- */
.card {
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: .85rem 1.1rem;
    font-weight: 600;
}

.table { font-size: .875rem; }
.table > thead > tr > th {
    background: #fafbfd;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--ink-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table > tbody > tr > td { vertical-align: middle; }

.table-sticky { max-height: 70vh; overflow: auto; }
.table-sticky thead th { position: sticky; top: 0; z-index: 2; }

.mono {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: .8rem;
}

/* Amount columns: tabular figures so digits line up down the column. */
.amount {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
}
.amount-credit { color: #12805c; }
.amount-debit  { color: #b02a37; }

/* --- Stat tiles --------------------------------------------------------- */
.stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.1rem;
    height: 100%;
}
.stat-label {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin-bottom: .35rem;
}
.stat-value {
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stat-meta { font-size: .78rem; color: var(--ink-muted); margin-top: .3rem; }

.stat-icon {
    display: inline-grid;
    place-items: center;
    width: 38px; height: 38px;
    border-radius: 9px;
    font-size: 1.05rem;
}

/* --- Badges ------------------------------------------------------------- */
.badge {
    font-weight: 600;
    letter-spacing: .02em;
    padding: .34em .6em;
}

/* --- Auth --------------------------------------------------------------- */
.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(1000px 500px at 100% 0%, color-mix(in srgb, var(--brand) 14%, transparent), transparent),
        var(--surface);
    padding: 24px;
}
.auth-wrap { width: 100%; max-width: 420px; }
.auth-card {
    background: #fff;
    border-radius: 14px;
    padding: 2rem;
}
.auth-brand { text-align: center; margin-bottom: 1.5rem; }

/* --- Utilities ---------------------------------------------------------- */
.empty-state { padding: 3rem 1rem; text-align: center; color: var(--ink-muted); }
.empty-state i { font-size: 2.2rem; opacity: .45; display: block; margin-bottom: .6rem; }

.filter-bar {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .85rem 1rem;
    margin-bottom: 1rem;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1.15rem;
}
.page-header h1 { font-size: 1.3rem; font-weight: 700; margin: 0; }
.page-header .subtitle { font-size: .82rem; color: var(--ink-muted); margin-top: .15rem; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
    position: relative;
    padding: 0 0 1.1rem 1.5rem;
    border-left: 2px solid var(--border);
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
    content: '';
    position: absolute;
    left: -6px; top: 3px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--brand);
}

/* A visible reminder that this figure is authoritative money. */
.ledger-note {
    font-size: .78rem;
    color: var(--ink-muted);
    border-left: 3px solid var(--brand);
    padding-left: .7rem;
}

/* --- Breadcrumbs ---------------------------------------------------------
   Deliberately quiet: this is orientation, not navigation people hunt for. */
.app-breadcrumb { margin-bottom: .9rem; }
.app-breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .3rem .45rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: .8rem;
    color: var(--ink-muted);
}
.app-breadcrumb li { display: flex; align-items: center; gap: .45rem; }
.app-breadcrumb li + li::before {
    content: "\203A";
    color: var(--ink-muted);
    opacity: .7;
}
.app-breadcrumb a { color: var(--ink-muted); text-decoration: none; }
.app-breadcrumb a:hover { color: var(--brand); text-decoration: underline; }
.app-breadcrumb [aria-current="page"] span { color: var(--ink); font-weight: 500; }

/* ---------------------------------------------------------------------------
   Banner slider
   ---------------------------------------------------------------------------
   Every banner occupies the SAME fixed-height box whatever its own proportions,
   so the dashboard below it never moves as the slides change. `contain` rather
   than `cover` because these are artwork with text printed across them —
   cropping to fill the box would cut the message in half.

   The height is fluid between a floor and a ceiling: tall enough to read on a
   phone, never tall enough to push the wallet and stats below the fold, which
   is what a natural-height stack did.
--------------------------------------------------------------------------- */
.banner-slider { background: #0d1117; border-radius: .5rem; overflow: hidden; }

.banner-slider .banner-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    height: clamp(120px, 20vw, 260px);
}

.banner-slider .banner-slide img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* The default controls vanish against a light banner; a scrim keeps them
   visible on artwork of any colour. */
.banner-slider .carousel-control-prev,
.banner-slider .carousel-control-next { width: 8%; opacity: .65; }
.banner-slider .carousel-control-prev:hover,
.banner-slider .carousel-control-next:hover { opacity: 1; }
.banner-slider .carousel-control-prev-icon,
.banner-slider .carousel-control-next-icon {
    background-color: rgba(0, 0, 0, .45);
    border-radius: 50%;
    padding: .85rem;
    background-size: 45%;
}

.banner-slider .carousel-indicators { margin-bottom: .35rem; }
.banner-slider .carousel-indicators [data-bs-target] {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 0;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
}

@media print {
    .app-navbar, .app-sidebar, .app-footer, .filter-bar, .btn,
    .app-breadcrumb, .banner-slider { display: none !important; }
    .app-shell { display: block; }
    .card { border: none; box-shadow: none; }
}
