:root {
    --sidebar-width: 268px;
    --brand-navy: #082b58;
    --brand-blue: #0b75db;
    --brand-cyan: #10c9e8;
    --brand-sky: #eaf7ff;
    --brand-ink: #14304b;
    --brand-muted: #708399;
    --brand-line: #dfeaf4;
    --app-bg: #f4f9fd;
    --card-bg: rgba(255, 255, 255, .96);
    --card-shadow: 0 14px 34px rgba(8, 43, 88, .08);
    --card-shadow-hover: 0 18px 40px rgba(8, 43, 88, .13);
    --radius-xl: 1.35rem;
    --radius-lg: 1rem;
    --radius-md: .8rem;
}

html { scroll-behavior: smooth; }

body {
    background:
        radial-gradient(circle at 92% 2%, rgba(16, 201, 232, .09), transparent 23rem),
        radial-gradient(circle at 4% 100%, rgba(11, 117, 219, .08), transparent 24rem),
        var(--app-bg);
    color: var(--brand-ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    background-image:
        linear-gradient(120deg, transparent 0 18%, rgba(11,117,219,.025) 18.1% 18.4%, transparent 18.5% 100%),
        linear-gradient(300deg, transparent 0 86%, rgba(16,201,232,.03) 86.1% 86.5%, transparent 86.6% 100%);
}

a { color: var(--brand-blue); }
a:hover { color: #075cae; }

.text-secondary { color: var(--brand-muted) !important; }
.money { white-space: nowrap; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* Layout */
.app-sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1030;
    overflow-y: auto;
    padding-bottom: 6rem !important;
    background:
        radial-gradient(circle at 18% 0, rgba(16,201,232,.18), transparent 18rem),
        linear-gradient(180deg, #082f62 0%, #06305a 48%, #052544 100%);
    border-right: 1px solid rgba(255,255,255,.08);
    box-shadow: 20px 0 50px rgba(8,43,88,.09);
}

.app-sidebar::after {
    content: "";
    position: absolute;
    inset: auto -10rem -10rem auto;
    width: 20rem;
    height: 20rem;
    border: 1px solid rgba(16,201,232,.12);
    border-radius: 50%;
    pointer-events: none;
}

.app-sidebar .brand {
    color: #fff;
    font-weight: 800;
    letter-spacing: -.02em;
    text-decoration: none;
}

.brand-mark {
    width: 46px;
    height: 46px;
    object-fit: contain;
    filter: drop-shadow(0 8px 18px rgba(0, 204, 238, .18));
    flex: 0 0 auto;
}

.brand-title { font-size: 1rem; line-height: 1.1; }
.brand-subtitle { color: rgba(226, 244, 255, .7); font-size: .73rem; font-weight: 500; }

.app-sidebar .nav { position: relative; z-index: 1; }
.app-sidebar .nav-link {
    color: rgba(225, 239, 250, .73);
    border-radius: .9rem;
    padding: .72rem .82rem;
    margin: .08rem 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .15rem;
    transition: background .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.app-sidebar .nav-link i { width: 1.35rem; font-size: 1.06rem; color: #83dff1; }
.app-sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
    transform: translateX(2px);
}
.app-sidebar .nav-link.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(11,117,219,.88), rgba(16,201,232,.32));
    box-shadow: 0 10px 22px rgba(0, 72, 142, .25), inset 0 0 0 1px rgba(255,255,255,.08);
}
.app-sidebar .nav-link.active i { color: #fff; }
.app-sidebar hr { border-color: rgba(255,255,255,.13) !important; opacity: 1 !important; }

.app-main {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-width: 0;
    min-height: 100vh;
}

.topbar {
    min-height: 72px;
    position: sticky;
    top: 0;
    z-index: 1020;
    background: rgba(255,255,255,.86);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(198, 218, 233, .7);
    box-shadow: 0 4px 18px rgba(8,43,88,.035);
}

.topbar .btn-light,
.topbar .dropdown-toggle {
    background: #fff;
    border: 1px solid var(--brand-line);
    color: var(--brand-ink);
    border-radius: .8rem;
    box-shadow: 0 5px 14px rgba(8,43,88,.05);
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: .55rem;
    min-width: 0;
}
.mobile-brand img { width: 30px; height: 30px; object-fit: contain; }
.mobile-brand span { font-weight: 800; color: var(--brand-navy); white-space: nowrap; }

.content-wrap {
    width: 100%;
    max-width: 1560px;
    min-width: 0;
    padding: 1.6rem clamp(1rem, 2.3vw, 2.25rem) 2.4rem;
    margin: 0 auto;
}

.legal-footer {
    clear: both;
    width: 100%;
    margin-top: 2rem;
    border-top: 1px solid rgba(205, 224, 238, .72);
}

.legal-footer a {
    display: inline-block;
    margin-block: .25rem;
}

/* Typography + headings */
h1, h2, h3, h4, h5, h6 { color: var(--brand-ink); letter-spacing: -.025em; }
h1, h2, h3 { font-weight: 800; }
h2 { font-size: clamp(1.55rem, 2.1vw, 2rem); }

.content-wrap > .d-flex.flex-wrap.justify-content-between.align-items-center.gap-2.mb-4 {
    position: relative;
    padding: .35rem 0 .35rem .9rem;
}
.content-wrap > .d-flex.flex-wrap.justify-content-between.align-items-center.gap-2.mb-4::before {
    content: "";
    position: absolute;
    inset: .4rem auto .4rem 0;
    width: 4px;
    border-radius: 99px;
    background: linear-gradient(180deg, var(--brand-cyan), var(--brand-blue));
}

/* Cards */
.card {
    border: 1px solid rgba(205, 224, 238, .82);
    border-radius: var(--radius-xl);
    background: var(--card-bg);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}
.card-header,
.card-footer {
    border-color: rgba(213, 228, 240, .84) !important;
    background: rgba(255,255,255,.88) !important;
}
.card-header { font-weight: 700; }
.metric-card {
    position: relative;
    border: 0;
    min-height: 128px;
    transition: transform .2s ease, box-shadow .2s ease;
    isolation: isolate;
}
.metric-card::after {
    content: "";
    position: absolute;
    inset: auto -2.3rem -2.8rem auto;
    width: 7rem;
    height: 7rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(16,201,232,.12), transparent 68%);
    z-index: -1;
}
.metric-card:hover { transform: translateY(-2px); box-shadow: var(--card-shadow-hover); }
.metric-card .card-body { padding: 1.25rem; }
.metric-icon {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    border-radius: 1rem;
    font-size: 1.25rem;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}
.metric-card .fs-4 { font-size: clamp(1.32rem, 2.1vw, 1.7rem) !important; color: var(--brand-ink); }

/* Buttons */
.btn {
    border-radius: .8rem;
    font-weight: 700;
    transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease, border-color .16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
    border-color: transparent;
    background: linear-gradient(135deg, #0876de, #08b9df);
    box-shadow: 0 9px 20px rgba(11,117,219,.19);
}
.btn-primary:hover,
.btn-primary:focus { border-color: transparent; background: linear-gradient(135deg, #0668c7, #08a8cb); }
.btn-outline-primary { color: #0871d1; border-color: #8ac8ef; background: rgba(255,255,255,.72); }
.btn-outline-primary:hover { color: #fff; border-color: #0876de; background: #0876de; }
.btn-outline-secondary { color: #5d7186; border-color: #c7d6e3; background: rgba(255,255,255,.78); }
.btn-success { box-shadow: 0 8px 18px rgba(25,135,84,.13); }
.btn-danger { box-shadow: 0 8px 18px rgba(220,53,69,.12); }
.btn-sm { border-radius: .65rem; }

/* Forms */
.form-label { font-size: .86rem; font-weight: 700; color: #435d74; margin-bottom: .42rem; }
.form-control,
.form-select {
    min-height: 44px;
    border: 1px solid #cfe0ec;
    border-radius: .82rem;
    background-color: rgba(255,255,255,.95);
    color: var(--brand-ink);
    box-shadow: inset 0 1px 2px rgba(8,43,88,.015);
}
.form-control:focus,
.form-select:focus {
    border-color: #51bce6;
    box-shadow: 0 0 0 .22rem rgba(16, 201, 232, .12);
}
.form-control::placeholder { color: #9aabbb; }
.form-check-input:checked { background-color: var(--brand-blue); border-color: var(--brand-blue); }

/* Alerts */
.alert { border-radius: 1rem; border-width: 1px; box-shadow: 0 7px 20px rgba(8,43,88,.035); }
.alert-light { background: rgba(255,255,255,.86); border-color: #d9e7f1 !important; }

/* Tables */
.table-responsive { border-radius: inherit; }
.table { color: var(--brand-ink); --bs-table-bg: transparent; }
.table > :not(caption) > * > * { padding: .9rem .85rem; border-color: #e8f0f6; vertical-align: middle; }
.table thead th {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .055em;
    color: #7890a6;
    font-weight: 800;
    background: #f7fbfe;
    border-bottom-color: #dce9f2;
}
.table tbody tr { transition: background-color .14s ease; }
.table tbody tr:hover { background: rgba(234,247,255,.58); }
.table a.fw-semibold { color: #086ac7; }

.badge {
    border-radius: 999px;
    padding: .46em .7em;
    letter-spacing: .01em;
}
.badge-status,
.badge.text-bg-secondary { background: #e7f3fb !important; color: #255f8d !important; }
.badge.text-bg-primary { background: #dceeff !important; color: #075da9 !important; }
.badge.text-bg-success { background: #dcf5e7 !important; color: #157347 !important; }
.badge.text-bg-warning { background: #fff2cb !important; color: #7d5b00 !important; }
.badge.text-bg-danger { background: #fde4e7 !important; color: #a52c3a !important; }

/* Lists and dropdowns */
.list-group-item { border-color: #edf2f6; background: transparent; }
.list-group-item-action:hover { background: #f3faff; }
.dropdown-menu {
    border: 1px solid #dbe8f1;
    border-radius: 1rem;
    padding: .5rem;
    box-shadow: 0 18px 45px rgba(8,43,88,.14);
}
.dropdown-item { border-radius: .65rem; padding: .62rem .7rem; }
.dropdown-item:hover { background: #eef8ff; color: #075fae; }

/* Dashboard */
.dashboard-chart-card .card-body { padding: 1.2rem 1.2rem 1rem; }
.chart-shell { position: relative; min-height: 320px; height: 320px; }
.dashboard-upcoming .list-group-item { padding: 1rem 1.15rem; }
.dashboard-upcoming strong { color: var(--brand-ink); }

/* Guest / auth */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
    background:
        radial-gradient(circle at 12% 12%, rgba(16,201,232,.22), transparent 20rem),
        radial-gradient(circle at 88% 88%, rgba(11,117,219,.18), transparent 24rem),
        linear-gradient(135deg, #effaff, #f7fbff 42%, #e9f5ff);
}
.auth-card { width: 100%; max-width: 470px; border: 1px solid rgba(184,215,237,.75); }
.auth-logo-wrap {
    width: 68px;
    height: 68px;
    margin-inline: auto;
    display: grid;
    place-items: center;
    border-radius: 1.15rem;
    background: linear-gradient(145deg, #eefbff, #fff);
    box-shadow: 0 12px 24px rgba(8,43,88,.1), inset 0 0 0 1px rgba(130,198,237,.45);
}
.auth-logo-wrap img { width: 48px; height: 48px; object-fit: contain; }

/* Plan cards */
.navbar { backdrop-filter: blur(12px); }
section.py-5 .card { transition: transform .2s ease, box-shadow .2s ease; }
section.py-5 .card:hover { transform: translateY(-3px); box-shadow: var(--card-shadow-hover); }

/* WhatsApp */
.support-whatsapp {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1080;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .8rem 1rem;
    border-radius: 999px;
    background: #25D366;
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    box-shadow: 0 10px 26px rgba(24, 145, 80, .24);
    transition: .2s ease;
}
.support-whatsapp:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 12px 30px rgba(24,145,80,.3); }
.support-whatsapp i { font-size: 1.3rem; }

.sidebar-backdrop { display: none; }

@media (min-width: 992px) {
    body.authenticated .support-whatsapp {
        left: 18px;
        right: auto;
        bottom: 18px;
        width: calc(var(--sidebar-width) - 36px);
        box-shadow: 0 8px 22px rgba(0,0,0,.2);
    }
}

@media (max-width: 1199.98px) {
    :root { --sidebar-width: 250px; }
    .content-wrap { padding-inline: 1.25rem; }
}

@media (max-width: 991.98px) {
    .app-sidebar {
        width: min(82vw, 310px);
        transform: translateX(-104%);
        transition: transform .22s ease;
        box-shadow: 24px 0 55px rgba(3, 30, 56, .25);
    }
    .app-sidebar.show { transform: translateX(0); }
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1025;
        background: rgba(5, 31, 56, .34);
        backdrop-filter: blur(1.5px);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity .2s ease, visibility .2s ease;
    }
    .sidebar-backdrop.show { opacity: 1; visibility: visible; pointer-events: auto; }
    body.sidebar-open { overflow: hidden; }
    .app-main { margin-left: 0; width: 100%; }
    .content-wrap { padding: 1rem 1rem 6.25rem; }
    .topbar { min-height: 66px; }
    .chart-shell { min-height: 290px; height: 290px; }
}

/* On small screens data grids become real stacked cards: no horizontal dragging. */
@media (max-width: 767.98px) {
    .table-responsive {
        overflow-x: visible !important;
        overflow-y: visible !important;
        border-radius: 0;
        background: transparent;
    }

    .responsive-data-table {
        display: block;
        width: 100%;
        margin: 0;
        border: 0;
        background: transparent;
    }
    .responsive-data-table thead { display: none; }
    .responsive-data-table tbody {
        display: grid;
        width: 100%;
        gap: .8rem;
        padding: .8rem;
    }
    .responsive-data-table tbody tr {
        display: block;
        width: 100%;
        padding: .28rem .95rem;
        border: 1px solid #dce9f2;
        border-radius: 1rem;
        background: #fff;
        box-shadow: 0 8px 22px rgba(8,43,88,.055);
    }
    .responsive-data-table tbody tr:hover { background: #fff; }
    .responsive-data-table tbody td {
        display: grid;
        grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
        align-items: start;
        gap: .75rem;
        width: 100%;
        padding: .68rem 0;
        border: 0;
        border-bottom: 1px dashed #e4edf4;
        text-align: right !important;
        overflow-wrap: anywhere;
    }
    .responsive-data-table tbody td:last-child { border-bottom: 0; }
    .responsive-data-table tbody td::before {
        content: attr(data-label);
        color: #7890a6;
        font-size: .72rem;
        line-height: 1.35;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: .045em;
        text-align: left;
        padding-top: .14rem;
    }
    .responsive-data-table tbody td > * { min-width: 0; }
    .responsive-data-table tbody td .btn { margin-block: .1rem; }
    .responsive-data-table tbody td[data-label="Ações"],
    .responsive-data-table tbody td[data-label="Acoes"] {
        align-items: center;
    }
    .mobile-card-actions {
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: .45rem;
        flex-wrap: wrap;
    }
    .mobile-card-actions > a,
    .mobile-card-actions > button,
    .mobile-card-actions > form {
        flex: 0 0 auto;
        margin: 0 !important;
    }
    .mobile-card-actions > form {
        display: inline-flex !important;
        align-items: center;
    }
    .mobile-card-actions .btn {
        width: auto !important;
        min-width: 2.35rem;
        margin: 0 !important;
    }
    .responsive-data-table tbody td[data-empty="true"] {
        display: block;
        padding: 1.2rem .4rem;
        border: 0;
        text-align: center !important;
        color: var(--brand-muted);
    }
    .responsive-data-table tbody td[data-empty="true"]::before { display: none; }
    .responsive-data-table tbody tr.table-empty-row { padding: 0; }

    .card > .table-responsive + .card-footer,
    .card > .card-footer { border-radius: 0 0 var(--radius-xl) var(--radius-xl); }

    .content-wrap > .d-flex.flex-wrap.justify-content-between.align-items-center.gap-2.mb-4 {
        align-items: stretch !important;
    }
    .content-wrap > .d-flex.flex-wrap.justify-content-between.align-items-center.gap-2.mb-4 > .btn,
    .content-wrap > .d-flex.flex-wrap.justify-content-between.align-items-center.gap-2.mb-4 > .d-flex {
        width: 100%;
    }
    .content-wrap > .d-flex.flex-wrap.justify-content-between.align-items-center.gap-2.mb-4 > .d-flex .btn { flex: 1 1 0; }

    .card .card-body form .d-flex.gap-2 { flex-wrap: wrap; }
    .card .card-body form .d-flex.gap-2 .btn { flex: 1 1 auto; }
    .chart-shell { height: 270px; min-height: 270px; }
}

@media (max-width: 575.98px) {
    .content-wrap { padding-inline: .75rem; }
    .card { border-radius: 1rem; }
    .metric-card .card-body { padding: 1rem; }
    .metric-icon { width: 46px; height: 46px; }
    .topbar { padding-inline: .75rem !important; }
    .topbar .dropdown-toggle { max-width: 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mobile-brand span { display: none; }
    .support-whatsapp { right: 16px; bottom: 16px; width: 52px; height: 52px; padding: 0; }
    .support-whatsapp span { display: none; }
    .support-whatsapp i { font-size: 1.45rem; }
    body.guest { padding-bottom: 5.25rem; }
    .responsive-data-table tbody { padding: .7rem; }
    .responsive-data-table tbody td { grid-template-columns: 88px minmax(0, 1fr); }
}

@media print {
    .app-sidebar, .topbar, .no-print, .support-whatsapp { display: none !important; }
    .app-main { margin: 0; width: 100%; }
    body { background: white; }
    body::before { display: none; }
    .content-wrap { max-width: none; padding: 0; }
    .card { box-shadow: none; border-color: #ddd; }
    .table-responsive { overflow: visible !important; }
    .responsive-data-table { display: table; }
    .responsive-data-table thead { display: table-header-group; }
    .responsive-data-table tbody { display: table-row-group; padding: 0; }
    .responsive-data-table tbody tr { display: table-row; box-shadow: none; border: 0; padding: 0; }
    .responsive-data-table tbody td { display: table-cell; text-align: inherit !important; border-bottom: 1px solid #ddd; padding: .5rem; }
    .responsive-data-table tbody td::before { display: none; }
}

.min-w-0 { min-width: 0 !important; }
@media (max-width: 767.98px) {
    .responsive-data-table .input-group { flex-wrap: wrap; gap: .35rem; }
    .responsive-data-table .input-group > .form-control,
    .responsive-data-table .input-group > .form-select,
    .responsive-data-table .input-group > .btn { border-radius: .65rem !important; flex: 1 1 100%; width: 100%; }
}

.legal-copy h4 { margin-top: 1.75rem; margin-bottom: .65rem; }
.legal-copy h4:first-child { margin-top: 0; }
.legal-copy p, .legal-copy li { line-height: 1.72; }


/* Theme switcher */
.theme-toggle {
    border: 0;
    background: transparent;
    cursor: pointer;
}
.app-sidebar .theme-toggle {
    color: rgba(225, 239, 250, .78);
}
.app-sidebar .theme-toggle:hover,
.app-sidebar .theme-toggle:focus-visible {
    color: #fff;
    background: rgba(255,255,255,.08);
}
.theme-footer-toggle { font-weight: 600; }

html[data-theme="dark"] {
    color-scheme: dark;
    --brand-navy: #dcecff;
    --brand-blue: #55aefb;
    --brand-cyan: #39d4ed;
    --brand-sky: #0b2135;
    --brand-ink: #e6f0f8;
    --brand-muted: #9fb1c3;
    --brand-line: #294357;
    --app-bg: #07131f;
    --card-bg: rgba(13, 29, 43, .96);
    --card-shadow: 0 14px 34px rgba(0, 0, 0, .24);
    --card-shadow-hover: 0 18px 42px rgba(0, 0, 0, .34);
}

html[data-theme="dark"] body {
    background:
        radial-gradient(circle at 92% 2%, rgba(16, 201, 232, .08), transparent 23rem),
        radial-gradient(circle at 4% 100%, rgba(11, 117, 219, .10), transparent 24rem),
        var(--app-bg);
}
html[data-theme="dark"] body::before {
    background-image:
        linear-gradient(120deg, transparent 0 18%, rgba(85,174,251,.025) 18.1% 18.4%, transparent 18.5% 100%),
        linear-gradient(300deg, transparent 0 86%, rgba(57,212,237,.025) 86.1% 86.5%, transparent 86.6% 100%);
}
html[data-theme="dark"] a { color: #65b7ff; }
html[data-theme="dark"] a:hover { color: #8bc9ff; }
html[data-theme="dark"] .support-whatsapp {
    background: #1fa855;
    color: #fff;
    border: 1px solid rgba(255,255,255,.18);
    box-shadow: 0 10px 28px rgba(0, 0, 0, .34), 0 0 0 1px rgba(37, 211, 102, .10);
}
html[data-theme="dark"] .support-whatsapp:hover,
html[data-theme="dark"] .support-whatsapp:focus-visible {
    background: #25D366;
    color: #fff;
    box-shadow: 0 13px 32px rgba(0, 0, 0, .42), 0 0 0 3px rgba(37, 211, 102, .13);
}
html[data-theme="dark"] .app-sidebar {
    background:
        radial-gradient(circle at 18% 0, rgba(16,201,232,.12), transparent 18rem),
        linear-gradient(180deg, #071d34 0%, #071a2d 48%, #051522 100%);
    border-right-color: rgba(112, 177, 220, .13);
    box-shadow: 20px 0 50px rgba(0,0,0,.16);
}
html[data-theme="dark"] .topbar {
    background: rgba(9, 23, 36, .88);
    border-bottom-color: rgba(63, 91, 114, .72);
    box-shadow: 0 4px 18px rgba(0,0,0,.15);
}
html[data-theme="dark"] .topbar .btn-light,
html[data-theme="dark"] .topbar .dropdown-toggle,
html[data-theme="dark"] .btn-light {
    background: #122638;
    border-color: #2a465c;
    color: #e7f2fb;
}
html[data-theme="dark"] .btn-light:hover,
html[data-theme="dark"] .btn-light:focus { background: #183249; color: #fff; }
html[data-theme="dark"] .card { border-color: rgba(52, 82, 105, .92); }
html[data-theme="dark"] .card-header,
html[data-theme="dark"] .card-footer,
html[data-theme="dark"] .bg-white {
    background: rgba(13, 29, 43, .96) !important;
    border-color: rgba(52, 82, 105, .86) !important;
}
html[data-theme="dark"] .bg-light { background: #102536 !important; }
html[data-theme="dark"] .border { border-color: #304a5f !important; }
html[data-theme="dark"] .btn-outline-primary {
    color: #70bcff;
    border-color: #356f9f;
    background: rgba(14, 34, 50, .8);
}
html[data-theme="dark"] .btn-outline-primary:hover { color: #061522; background: #70bcff; border-color: #70bcff; }
html[data-theme="dark"] .btn-outline-secondary {
    color: #b1c3d2;
    border-color: #486075;
    background: rgba(14, 34, 50, .76);
}
html[data-theme="dark"] .form-label { color: #b8c9d7; }
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
    background-color: #0d2233;
    border-color: #355169;
    color: #edf6fd;
    box-shadow: inset 0 1px 2px rgba(0,0,0,.13);
}
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus {
    border-color: #47bce6;
    box-shadow: 0 0 0 .22rem rgba(16, 201, 232, .14);
}
html[data-theme="dark"] .form-control::placeholder { color: #71889a; }
html[data-theme="dark"] .alert-light {
    background: rgba(15, 35, 51, .92);
    border-color: #355169 !important;
    color: #dce8f2;
}
html[data-theme="dark"] .table { --bs-table-color: var(--brand-ink); --bs-table-bg: transparent; }
html[data-theme="dark"] .table > :not(caption) > * > * { border-color: #233c50; }
html[data-theme="dark"] .table thead th {
    color: #9fb3c4;
    background: #0c2030;
    border-bottom-color: #304b61;
}
html[data-theme="dark"] .table tbody tr:hover { background: rgba(37, 77, 104, .25); }
html[data-theme="dark"] .table a.fw-semibold { color: #6bbcff; }
html[data-theme="dark"] .table-light { --bs-table-bg: #102536; --bs-table-color: #dbe8f2; }
html[data-theme="dark"] .badge-status,
html[data-theme="dark"] .badge.text-bg-secondary { background: #17344a !important; color: #9fd4ff !important; }
html[data-theme="dark"] .badge.text-bg-primary { background: #103e62 !important; color: #a9d9ff !important; }
html[data-theme="dark"] .badge.text-bg-success { background: #123c2d !important; color: #8be0b5 !important; }
html[data-theme="dark"] .badge.text-bg-warning { background: #493b16 !important; color: #f7d77a !important; }
html[data-theme="dark"] .badge.text-bg-danger { background: #4a2028 !important; color: #ffabb5 !important; }
html[data-theme="dark"] .badge.text-bg-light { background: #173044 !important; color: #d7e6f2 !important; }
html[data-theme="dark"] .list-group-item { border-color: #223b4f; color: var(--brand-ink); }
html[data-theme="dark"] .list-group-item-action:hover { background: #102a3d; }
html[data-theme="dark"] .dropdown-menu {
    background: #0e2233;
    border-color: #304b61;
    box-shadow: 0 18px 45px rgba(0,0,0,.34);
}
html[data-theme="dark"] .dropdown-item { color: #dbe8f2; }
html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus { background: #17364d; color: #8dccff; }
html[data-theme="dark"] .dropdown-divider { border-color: #30495d; }
html[data-theme="dark"] .auth-shell {
    background:
        radial-gradient(circle at 12% 12%, rgba(16,201,232,.11), transparent 20rem),
        radial-gradient(circle at 88% 88%, rgba(11,117,219,.12), transparent 24rem),
        linear-gradient(135deg, #07131f, #0a1a29 42%, #081726);
}
html[data-theme="dark"] .auth-card { border-color: rgba(55, 92, 119, .82); }
html[data-theme="dark"] .auth-logo-wrap {
    background: linear-gradient(145deg, #102a3d, #0c1e2d);
    box-shadow: 0 12px 24px rgba(0,0,0,.24), inset 0 0 0 1px rgba(73,139,178,.35);
}
html[data-theme="dark"] .navbar { background-color: rgba(9, 23, 36, .94) !important; }
html[data-theme="dark"] .navbar-brand { color: #e5f1fa; }

@media (max-width: 767.98px) {
    html[data-theme="dark"] .responsive-data-table tbody tr {
        border-color: #2c465b;
        background: #0d1f2f;
        box-shadow: 0 8px 22px rgba(0,0,0,.18);
    }
    html[data-theme="dark"] .responsive-data-table tbody tr:hover { background: #0d1f2f; }
    html[data-theme="dark"] .responsive-data-table tbody td { border-bottom-color: #284054; }
    html[data-theme="dark"] .responsive-data-table tbody td::before { color: #91a9bc; }
}

@media print {
    html[data-theme="dark"] body { background: #fff !important; color: #000 !important; }
    html[data-theme="dark"] body::before { display: none !important; }
    html[data-theme="dark"] .card,
    html[data-theme="dark"] .card-header,
    html[data-theme="dark"] .card-footer,
    html[data-theme="dark"] .bg-white,
    html[data-theme="dark"] .table thead th,
    html[data-theme="dark"] .responsive-data-table tbody tr {
        background: #fff !important;
        color: #000 !important;
        border-color: #ddd !important;
    }
    html[data-theme="dark"] h1,
    html[data-theme="dark"] h2,
    html[data-theme="dark"] h3,
    html[data-theme="dark"] h4,
    html[data-theme="dark"] h5,
    html[data-theme="dark"] h6,
    html[data-theme="dark"] .table { color: #000 !important; }
}

/* PWA install floating card */
.pwa-install-card {
    position: fixed;
    right: 22px;
    bottom: 96px;
    z-index: 1075;
    width: min(380px, calc(100vw - 32px));
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: .85rem;
    padding: 1rem 2.5rem 1rem 1rem;
    border: 1px solid rgba(129, 178, 214, .42);
    border-radius: 1.15rem;
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 18px 48px rgba(20, 61, 92, .18), 0 2px 8px rgba(20, 61, 92, .08);
    backdrop-filter: blur(14px);
    animation: pwa-install-card-in .22s ease-out;
}

.pwa-install-card-icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: .9rem;
    background: linear-gradient(145deg, #e8f6ff, #f7fcff);
    color: #0b75db;
    box-shadow: inset 0 0 0 1px rgba(11, 117, 219, .10);
    font-size: 1.35rem;
}

.pwa-install-card-title {
    padding-right: .25rem;
    color: #0b2f4f;
    font-weight: 800;
    line-height: 1.25;
}

.pwa-install-card-text {
    margin-top: .25rem;
    color: #5a7184;
    font-size: .88rem;
    line-height: 1.4;
}

.pwa-install-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    margin-top: .75rem;
}

.pwa-install-dismiss {
    position: absolute;
    top: .65rem;
    right: .65rem;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #718596;
    font-size: .82rem;
}

.pwa-install-dismiss:hover,
.pwa-install-dismiss:focus-visible {
    background: #edf5fb;
    color: #173b59;
}

.pwa-ios-instructions {
    margin-top: .8rem;
    padding-top: .7rem;
    border-top: 1px solid #dce9f2;
}

.pwa-ios-step {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: start;
    gap: .45rem;
    margin-top: .45rem;
    color: #4e6679;
    font-size: .82rem;
    line-height: 1.35;
}

.pwa-ios-step > span {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #e9f5ff;
    color: #0b75db;
    font-size: .72rem;
    font-weight: 800;
}

@keyframes pwa-install-card-in {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (min-width: 992px) {
    body.authenticated .pwa-install-card { bottom: 22px; }
}

@media (max-width: 575.98px) {
    .pwa-install-card {
        right: 12px;
        bottom: 80px;
        width: calc(100vw - 24px);
        grid-template-columns: 40px minmax(0, 1fr);
        gap: .7rem;
        padding: .85rem 2.25rem .85rem .85rem;
        border-radius: 1rem;
    }

    .pwa-install-card-icon { width: 40px; height: 40px; border-radius: .8rem; }
    .pwa-install-actions .btn-primary { flex: 1 1 auto; }
}

html[data-theme="dark"] .pwa-install-card {
    border-color: rgba(78, 119, 149, .78);
    background: rgba(10, 29, 44, .97);
    box-shadow: 0 18px 50px rgba(0, 0, 0, .42), 0 0 0 1px rgba(96, 169, 220, .06);
}

html[data-theme="dark"] .pwa-install-card-icon {
    background: linear-gradient(145deg, #102f46, #0b2538);
    color: #70bcff;
    box-shadow: inset 0 0 0 1px rgba(112, 188, 255, .14);
}

html[data-theme="dark"] .pwa-install-card-title { color: #e7f3fb; }
html[data-theme="dark"] .pwa-install-card-text,
html[data-theme="dark"] .pwa-ios-step { color: #a9bdcc; }
html[data-theme="dark"] .pwa-install-dismiss { color: #91a9bb; }
html[data-theme="dark"] .pwa-install-dismiss:hover,
html[data-theme="dark"] .pwa-install-dismiss:focus-visible { background: #17364d; color: #dcedf8; }
html[data-theme="dark"] .pwa-ios-instructions { border-top-color: #29465b; }
html[data-theme="dark"] .pwa-ios-step > span { background: #123c5b; color: #8dccff; }

@media print {
    .pwa-install-card { display: none !important; }
}


/* Searchable client combobox */
[data-client-options] {
    background: #fff !important;
    border: 1px solid rgba(0, 0, 0, .125);
    border-radius: .5rem;
    overflow: hidden auto;
}
[data-client-option] {
    background: #fff !important;
    color: #212529 !important;
}
[data-client-option]:hover,
[data-client-option]:focus,
[data-client-option].active {
    background: #f8f9fa !important;
    color: #212529 !important;
}
[data-client-option] + [data-client-option] {
    border-top-color: rgba(0, 0, 0, .075);
}

/* Password fields */
.password-input-shell {
    position: relative;
    width: 100%;
}
.password-input-shell > .form-control {
    padding-right: 3rem;
}
.password-toggle-button {
    position: absolute;
    top: 50%;
    right: .35rem;
    transform: translateY(-50%);
    width: 2.35rem;
    height: 2.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: .5rem;
    background: transparent;
    color: var(--bs-secondary-color);
    z-index: 3;
}
.password-toggle-button:hover,
.password-toggle-button:focus-visible {
    background: rgba(13, 110, 253, .1);
    color: var(--bs-primary);
    outline: 0;
}
.password-requirements {
    display: grid;
    gap: .22rem;
}
.password-requirements li {
    transition: color .15s ease;
}
.password-requirements li.is-valid { color: var(--bs-success-text-emphasis); }
.password-requirements li.is-pending { color: var(--bs-secondary-color); }

/* Beauty branding and white-label overrides */
body {
    background:
        radial-gradient(circle at 92% 2%, color-mix(in srgb, var(--brand-accent) 24%, transparent), transparent 23rem),
        radial-gradient(circle at 4% 100%, color-mix(in srgb, var(--brand-primary) 16%, transparent), transparent 24rem),
        var(--app-bg);
}

.app-sidebar {
    background:
        radial-gradient(circle at 18% 0, color-mix(in srgb, var(--brand-sidebar-glow) 30%, transparent), transparent 18rem),
        linear-gradient(180deg, var(--brand-sidebar-start) 0%, color-mix(in srgb, var(--brand-sidebar-start) 70%, var(--brand-sidebar-end) 30%) 48%, var(--brand-sidebar-end) 100%);
}

.app-sidebar::after {
    border-color: color-mix(in srgb, var(--brand-accent) 24%, transparent);
}

.topbar {
    background: color-mix(in srgb, var(--brand-topbar) 86%, rgba(255,255,255,.65));
    border-bottom: 1px solid color-mix(in srgb, var(--brand-line) 80%, #ffffff);
}

.topbar-tagline {
    color: var(--brand-muted);
}

.brand-mark {
    width: 46px;
    height: 46px;
    object-fit: contain;
    flex: 0 0 auto;
}

.brand-mark-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    color: #ffffff;
    font-weight: 800;
    letter-spacing: .04em;
    box-shadow: 0 12px 24px color-mix(in srgb, var(--brand-primary) 30%, transparent);
}

.brand-subtitle {
    color: color-mix(in srgb, var(--brand-accent) 50%, #ffffff);
}

.btn-primary {
    color: var(--brand-button-text);
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    box-shadow: 0 9px 20px color-mix(in srgb, var(--brand-primary) 22%, transparent);
}

.btn-primary:hover,
.btn-primary:focus {
    color: var(--brand-button-text);
    background: linear-gradient(135deg, color-mix(in srgb, var(--brand-primary) 88%, #000000), color-mix(in srgb, var(--brand-secondary) 88%, #000000));
}

.btn-outline-primary {
    color: var(--brand-primary);
    border-color: color-mix(in srgb, var(--brand-primary) 38%, #ffffff);
}

.btn-outline-primary:hover {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
}

.content-wrap > .d-flex.flex-wrap.justify-content-between.align-items-center.gap-2.mb-4::before {
    background: linear-gradient(180deg, var(--brand-accent), var(--brand-primary));
}

.brand-preview-card {
    overflow: hidden;
}

.brand-preview-shell {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem;
    border-radius: 1.15rem;
    background:
        radial-gradient(circle at top right, color-mix(in srgb, var(--brand-accent) 45%, transparent), transparent 7rem),
        linear-gradient(135deg, color-mix(in srgb, var(--brand-primary) 12%, #ffffff), color-mix(in srgb, var(--brand-secondary) 10%, #ffffff));
    border: 1px solid color-mix(in srgb, var(--brand-line) 72%, #ffffff);
}

.brand-preview-mark {
    width: 68px;
    height: 68px;
    border-radius: 22px;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    display: grid;
    place-items: center;
    color: #ffffff;
    box-shadow: 0 18px 32px color-mix(in srgb, var(--brand-primary) 20%, transparent);
    overflow: hidden;
}

.brand-preview-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #ffffff;
}

.brand-preview-mark span {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: .04em;
}

.brand-preview-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--brand-ink);
}

.brand-preview-tagline {
    margin-top: .25rem;
    color: var(--brand-muted);
    font-size: .92rem;
    line-height: 1.4;
}

.brand-preview-panels {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
}

.preview-chip {
    padding: .7rem .95rem;
    border-radius: .95rem;
    font-weight: 700;
    font-size: .9rem;
}

.preview-chip-primary {
    background: color-mix(in srgb, var(--brand-primary) 12%, #ffffff);
    color: var(--brand-primary);
}

.preview-chip-secondary {
    background: color-mix(in srgb, var(--brand-secondary) 10%, #ffffff);
    color: var(--brand-secondary);
}

.preview-chip-accent {
    background: color-mix(in srgb, var(--brand-accent) 55%, #ffffff);
    color: var(--brand-ink);
}

.brand-settings-fields.is-disabled {
    opacity: .6;
}

.brand-preset-grid {
    display: grid;
    gap: .75rem;
}

.brand-preset-card {
    border: 1px solid color-mix(in srgb, var(--brand-line) 80%, #ffffff);
    border-radius: 1rem;
    padding: .85rem .9rem;
    background: rgba(255,255,255,.75);
}

.brand-preset-card.active {
    border-color: color-mix(in srgb, var(--brand-primary) 45%, #ffffff);
    box-shadow: 0 10px 24px color-mix(in srgb, var(--brand-primary) 10%, transparent);
}

.brand-preset-swatches {
    display: flex;
    gap: .4rem;
    margin-bottom: .55rem;
}

.brand-preset-swatches span {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(255,255,255,.75);
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.current-brand-logo {
    width: 100%;
    max-width: 180px;
    padding: .75rem;
    border-radius: 1rem;
    border: 1px solid color-mix(in srgb, var(--brand-line) 76%, #ffffff);
    background: rgba(255,255,255,.8);
}

.current-brand-logo img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.color-field-stack {
    display: grid;
    gap: .9rem;
}

.color-input-wrap {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: .65rem;
    align-items: center;
}

.color-input-wrap .form-control-color {
    width: 52px;
    min-width: 52px;
    height: 44px;
    padding: .3rem;
    border-radius: .8rem;
}

html[data-theme="dark"] body {
    background:
        radial-gradient(circle at 92% 2%, color-mix(in srgb, var(--brand-accent) 15%, transparent), transparent 23rem),
        radial-gradient(circle at 4% 100%, color-mix(in srgb, var(--brand-primary) 14%, transparent), transparent 24rem),
        #18121a;
}

html[data-theme="dark"] .topbar,
html[data-theme="dark"] .card,
html[data-theme="dark"] .card-header,
html[data-theme="dark"] .card-footer {
    border-color: rgba(111, 92, 110, .55) !important;
}

html[data-theme="dark"] .brand-preview-shell,
html[data-theme="dark"] .current-brand-logo,
html[data-theme="dark"] .brand-preset-card {
    background: rgba(34, 24, 34, .72);
}

/* White-label logo cropper */
.brand-logo-selection-preview,
.current-brand-logo {
    max-width: 220px;
}

.brand-logo-selection-preview img,
.current-brand-logo img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    border-radius: 1rem;
    background: #ffffff;
    border: 1px solid color-mix(in srgb, var(--brand-line) 78%, #ffffff);
    box-shadow: 0 12px 28px color-mix(in srgb, var(--brand-primary) 10%, transparent);
}

.brand-logo-crop-modal .modal-content {
    overflow: hidden;
}

.brand-logo-crop-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 1.25rem;
    align-items: start;
}

.brand-logo-crop-stage {
    position: relative;
    width: min(100%, 560px);
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 1.25rem;
    background:
        linear-gradient(45deg, #f1f1f1 25%, transparent 25%),
        linear-gradient(-45deg, #f1f1f1 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f1f1f1 75%),
        linear-gradient(-45deg, transparent 75%, #f1f1f1 75%),
        #ffffff;
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
    border: 1px solid color-mix(in srgb, var(--brand-line) 85%, #ffffff);
}

.brand-logo-crop-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.brand-logo-crop-stage canvas.is-dragging {
    cursor: grabbing;
}

.brand-logo-crop-frame {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: 1.25rem;
    box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--brand-primary) 65%, #ffffff);
}

.brand-logo-crop-frame::after {
    content: "";
    position: absolute;
    inset: 9%;
    border-radius: 18%;
    border: 1px dashed rgba(255, 255, 255, .9);
    box-shadow: 0 0 0 999px rgba(0, 0, 0, .08);
}

.brand-logo-crop-controls {
    padding: 1rem;
    border-radius: 1rem;
    background: color-mix(in srgb, var(--brand-background) 74%, #ffffff);
    border: 1px solid color-mix(in srgb, var(--brand-line) 80%, #ffffff);
}

html[data-theme="dark"] .brand-logo-selection-preview img,
html[data-theme="dark"] .current-brand-logo img,
html[data-theme="dark"] .brand-logo-crop-stage {
    background-color: #ffffff;
}

html[data-theme="dark"] .brand-logo-crop-controls {
    background: rgba(40, 29, 40, .78);
}

@media (max-width: 767.98px) {
    .brand-logo-crop-workspace {
        grid-template-columns: 1fr;
    }

    .brand-logo-crop-controls {
        width: 100%;
    }
}
