/* Poppins is self-hosted (SIL Open Font License, see assets/fonts/poppins/OFL.txt). */
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/poppins/Poppins-Regular.ttf') format('truetype'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/poppins/Poppins-Medium.ttf') format('truetype'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/poppins/Poppins-SemiBold.ttf') format('truetype'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/poppins/Poppins-Bold.ttf') format('truetype'); }

/* ==========================================================================
   App shell & components — layered on top of PurpleAdmin (Bootstrap 5).
   Brand colours come from white-label settings via --brand-1 / --brand-2.
   ========================================================================== */

:root {
    --brand-1: #9a55ff;
    --brand-2: #da8cff;
    --brand-gradient: linear-gradient(to right, var(--brand-2), var(--brand-1));
    --brand-soft: color-mix(in srgb, var(--brand-1) 10%, transparent);
    --brand-soft-2: color-mix(in srgb, var(--brand-1) 18%, transparent);

    --app-bg: #f2edf3;
    --surface: #ffffff;
    --surface-2: #f8f7fb;
    --border: #ebe9f1;
    --text: #343a40;
    --text-muted: #6c7383;
    --text-faint: #9aa0ac;
    --shadow-sm: 0 1px 2px rgba(25, 15, 45, .04), 0 1px 6px rgba(25, 15, 45, .04);
    --shadow: 0 2px 4px rgba(25, 15, 45, .04), 0 8px 24px rgba(25, 15, 45, .06);

    --sidebar-w: 264px;
    --sidebar-w-collapsed: 76px;
    --topbar-h: 64px;
    --radius: 12px;
    --radius-sm: 8px;

    --bs-body-font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --bs-primary: var(--brand-1);
}

[data-theme="dark"] {
    --app-bg: #14121b;
    --surface: #1d1a27;
    --surface-2: #252131;
    --border: #2f2a3d;
    --text: #e6e3ee;
    --text-muted: #a7a2b6;
    --text-faint: #7a7590;
    --brand-soft: color-mix(in srgb, var(--brand-1) 18%, transparent);
    --brand-soft-2: color-mix(in srgb, var(--brand-1) 28%, transparent);
    --shadow-sm: none;
    --shadow: 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
}

html, body { height: 100%; }

body {
    font-family: var(--bs-body-font-family);
    background: var(--app-bg);
    color: var(--text);
    font-size: .875rem;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6,
.card .card-title, .btn, .form-control, .form-select, .table, .dropdown-menu, .badge {
    font-family: var(--bs-body-font-family);
}

a { color: var(--brand-1); }
a:hover { color: color-mix(in srgb, var(--brand-1) 80%, #000); }

:focus-visible {
    outline: 2px solid var(--brand-1);
    outline-offset: 2px;
}

.skip-link {
    position: absolute; left: 8px; top: -60px; z-index: 2000;
    background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}
.skip-link:focus { top: 8px; }

/* -------------------------------------------------------------- PurpleAdmin shell integration
   Layout markup is PurpleAdmin's own (navbar / sidebar / main-panel / content-wrapper / footer).
   Only white-label colours and small additions are applied here. */
.bg-gradient-primary, .btn-gradient-primary, .badge-gradient-primary { background: linear-gradient(to right, var(--brand-2), var(--brand-1)) !important; }
.text-primary { color: var(--brand-1) !important; }
.sidebar .nav .nav-item.active > .nav-link .menu-title,
.sidebar .nav .nav-item.active > .nav-link i,
.sidebar .nav.sub-menu .nav-item .nav-link.active,
.sidebar .nav.sub-menu .nav-item .nav-link:hover { color: var(--brand-1); }
.sidebar .nav .nav-item .nav-link .menu-title { font-family: var(--bs-body-font-family); }
.sidebar .nav .nav-item.active > .nav-link .menu-title { font-weight: 500; }
.sidebar .nav.sub-menu .nav-item .nav-link.active { font-weight: 500; }
.sidebar .nav.sub-menu .nav-item .nav-link.active::before { background: var(--brand-1); }
.sidebar .nav .nav-item.sidebar-logout { border-top: 1px solid var(--border); margin-top: .5rem; }
.sidebar .nav .nav-item.sidebar-logout .nav-link { text-align: left; color: #3e4b5b; }
.sidebar .nav .nav-item.sidebar-logout .nav-link:hover { color: #d63f5c; }

.profile-initials { width: 44px; height: 44px; border-radius: 100%; display: inline-grid; place-items: center; background: linear-gradient(to right, var(--brand-2), var(--brand-1)); color: #fff; font-weight: 600; font-size: .85rem; }
.navbar .navbar-menu-wrapper .navbar-nav .nav-item.nav-profile .nav-link .nav-profile-img .profile-initials { width: 32px; height: 32px; font-size: .72rem; }
.navbar .navbar-brand-wrapper .brand-text-logo { font-weight: 700; font-size: 1.2rem; background: linear-gradient(to right, var(--brand-2), var(--brand-1)); -webkit-background-clip: text; background-clip: text; color: transparent; white-space: nowrap; display: inline-block; max-width: 210px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.navbar .navbar-brand-wrapper .navbar-brand img { max-height: 54px; max-width: 200px; width: auto; height: auto; object-fit: contain; }
.brand-mark-mini { width: 34px; height: 34px; border-radius: 9px; display: inline-grid; place-items: center; color: #fff; font-weight: 700; background: linear-gradient(to right, var(--brand-2), var(--brand-1)); }
.navbar .navbar-menu-wrapper .navbar-nav .nav-item.nav-logout .nav-link { font-size: 1.25rem; }

.page-header { gap: 12px; flex-wrap: wrap; }
.page-header .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page-header .page-sub { font-size: .84rem; }
.page-title { font-weight: 600; }

/* Gradient stat cards (PurpleAdmin "card-img-holder") */
.card-img-holder .card-body h2 { word-break: break-word; }
.stat-card .card-text { opacity: .9; }

/* Mobile off-canvas: PurpleAdmin slides from the right; keep it above content */
@media (max-width: 991.98px) {
    .sidebar-offcanvas { z-index: 1040; box-shadow: 0 0 24px rgba(0, 0, 0, .15); overflow-y: auto; }
    .content-wrapper { padding: 1.25rem 1rem; }
}

/* -------------------------------------------------------------- Cards & surfaces */
.card { background: var(--surface); color: var(--text); }
.card:not([class*="bg-gradient"]) { border: 0; }
.card .card-body { padding: 1.5rem; }
.card .card-title { color: var(--text); }
.card-header-app {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--border);
}
.card-header-app h2, .card-header-app h3 { font-size: 1rem; font-weight: 600; margin: 0; }

.kpi-card { position: relative; overflow: hidden; height: 100%; }
.kpi-card .kpi-icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: grid; place-items: center; font-size: 1.35rem;
    background: var(--brand-soft); color: var(--brand-1);
}
.kpi-card .kpi-label { color: var(--text-muted); font-size: .78rem; font-weight: 500; margin: 14px 0 4px; }
.kpi-card .kpi-value { font-size: 1.4rem; font-weight: 600; line-height: 1.25; word-break: break-word; }
.kpi-card .kpi-meta { font-size: .74rem; color: var(--text-faint); margin-top: 6px; }
.kpi-card.kpi-hero { background: var(--brand-gradient); color: #fff; border: 0; }
.kpi-card.kpi-hero .kpi-label, .kpi-card.kpi-hero .kpi-meta { color: rgba(255, 255, 255, .85); }
.kpi-card.kpi-hero .kpi-icon { background: rgba(255, 255, 255, .2); color: #fff; }

.tone-success { --tone: #1bcfb4; }
.tone-danger { --tone: #fe7c96; }
.tone-warning { --tone: #fed713; }
.tone-info { --tone: #198ae3; }
[class*="tone-"] .kpi-icon { background: color-mix(in srgb, var(--tone) 15%, transparent); color: color-mix(in srgb, var(--tone) 85%, #000); }

/* -------------------------------------------------------------- Buttons */
.btn { border-radius: var(--radius-sm); font-weight: 500; font-size: .845rem; padding: .6rem 1.1rem; line-height: 1.4; }
.btn-sm { padding: .35rem .75rem; font-size: .78rem; }
.btn .mdi { font-size: 1.05em; vertical-align: -1px; }
.btn-gradient-primary, .btn-brand {
    background: var(--brand-gradient); border: 0; color: #fff;
}
.btn-gradient-primary:hover, .btn-brand:hover { color: #fff; filter: brightness(.96); box-shadow: 0 4px 14px var(--brand-soft-2); }
.btn-gradient-primary:disabled, .btn-brand:disabled { opacity: .65; }
.btn-light-app { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn-light-app:hover { background: var(--border); color: var(--text); }
.btn-outline-brand { border: 1px solid var(--brand-1); color: var(--brand-1); background: transparent; }
.btn-outline-brand:hover { background: var(--brand-soft); color: var(--brand-1); }
.btn.is-loading { pointer-events: none; opacity: .8; }

/* -------------------------------------------------------------- Forms */
.form-label { font-weight: 500; font-size: .8rem; color: var(--text); margin-bottom: 6px; }
.form-label .req { color: #e14d6a; margin-left: 2px; }
.form-control, .form-select {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background-color: var(--surface); color: var(--text);
    font-size: .86rem; padding: .6rem .85rem; min-height: 42px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-1);
    box-shadow: 0 0 0 3px var(--brand-soft-2);
    background-color: var(--surface); color: var(--text);
}
.form-control::placeholder { color: var(--text-faint); }
.form-control.is-invalid, .form-select.is-invalid { border-color: #e14d6a; }
.invalid-feedback { font-size: .76rem; }
.form-text { color: var(--text-faint); font-size: .74rem; }
.input-group-text { background: var(--surface-2); border-color: var(--border); color: var(--text-muted); border-radius: var(--radius-sm); }
.form-check-input:checked { background-color: var(--brand-1); border-color: var(--brand-1); }
.form-check-input:focus { box-shadow: 0 0 0 3px var(--brand-soft-2); border-color: var(--brand-1); }
.form-section-title { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin: 8px 0 14px; }

.password-field { position: relative; }
.password-field .form-control { padding-right: 44px; }
.password-field .toggle-visibility {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 36px; height: 36px; border: 0; background: none; color: var(--text-faint); border-radius: 8px;
}

/* -------------------------------------------------------------- Tables */
.table { color: var(--text); --bs-table-bg: transparent; --bs-table-color: var(--text); margin-bottom: 0; }
.table > :not(caption) > * > * { border-bottom-color: var(--border); padding: .85rem 1rem; vertical-align: middle; }
.table thead th {
    font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-muted); background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table-hover > tbody > tr:hover > * { --bs-table-hover-bg: var(--surface-2); --bs-table-bg-state: var(--surface-2); color: var(--text); }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-responsive { border-radius: 0 0 var(--radius) var(--radius); }

/* Small screens: stacked rows for tables marked .table-stack */
@media (max-width: 767.98px) {
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { border-bottom: 1px solid var(--border); padding: 10px 0; }
    .table-stack > :not(caption) > * > * { border: 0; padding: 4px 16px; }
    .table-stack td[data-label] { display: flex; justify-content: space-between; gap: 12px; text-align: right; }
    .table-stack td[data-label]::before { content: attr(data-label); font-weight: 500; color: var(--text-muted); text-align: left; }
}

/* -------------------------------------------------------------- Badges / status */
.badge-status {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 20px;
    font-size: .7rem; font-weight: 600; letter-spacing: .02em; white-space: nowrap;
    background: var(--surface-2); color: var(--text-muted);
}
.badge-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-success { background: #e3f9f5; color: #0f9c87; }
.status-danger { background: #ffe9ee; color: #d63f5c; }
.status-warning { background: #fff6d6; color: #a07c00; }
.status-info { background: #e5f2fd; color: #1474c2; }
.status-brand { background: var(--brand-soft); color: var(--brand-1); }
.status-muted { background: var(--surface-2); color: var(--text-muted); }
[data-theme="dark"] .status-success { background: rgba(27, 207, 180, .15); color: #4fe0c8; }
[data-theme="dark"] .status-danger { background: rgba(254, 124, 150, .15); color: #ff95aa; }
[data-theme="dark"] .status-warning { background: rgba(254, 215, 19, .13); color: #f5d34a; }
[data-theme="dark"] .status-info { background: rgba(25, 138, 227, .15); color: #6db8f5; }

.currency-tag { display: inline-block; font-size: .66rem; font-weight: 600; padding: 2px 6px; border-radius: 5px; background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

/* -------------------------------------------------------------- Empty state & skeleton */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state .empty-icon {
    width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 20px;
    display: grid; place-items: center; font-size: 2rem;
    background: var(--brand-soft); color: var(--brand-1);
}
.empty-state h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 6px; }
.empty-state p { color: var(--text-muted); max-width: 420px; margin: 0 auto 18px; }

.skeleton {
    display: block; border-radius: 6px; min-height: 12px;
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
    background-size: 400% 100%;
    animation: skeleton 1.4s ease infinite;
}
@keyframes skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* -------------------------------------------------------------- Checklist */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist .tick { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-2); color: var(--text-faint); }
.checklist .done .tick { background: #e3f9f5; color: #0f9c87; }

/* -------------------------------------------------------------- Dropdowns, modals, toasts */
.dropdown-menu {
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    background: var(--surface); padding: 6px; font-size: .84rem;
}
.dropdown-item { border-radius: 8px; padding: 8px 12px; color: var(--text); display: flex; align-items: center; gap: 10px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-2); color: var(--text); }
.dropdown-item .mdi { font-size: 1.1rem; color: var(--text-muted); }
.dropdown-divider { border-color: var(--border); }
.dropdown-header { color: var(--text-faint); }

.modal-content { border: 0; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.modal-header, .modal-footer { border-color: var(--border); }
.modal-dialog { margin-left: auto; margin-right: auto; max-width: min(500px, calc(100vw - 24px)); }
.modal-lg { max-width: min(800px, calc(100vw - 24px)); }

.toast-stack { position: fixed; top: 76px; right: 20px; z-index: 1090; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast-app {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 14px 16px; border-radius: var(--radius);
    background: var(--surface); color: var(--text); box-shadow: var(--shadow);
    border: 1px solid var(--border); border-left: 4px solid var(--tone, var(--brand-1));
    animation: toast-in .25s ease;
}
.toast-app .mdi { font-size: 1.3rem; color: var(--tone, var(--brand-1)); line-height: 1.1; }
.toast-app .msg { flex: 1; font-size: .84rem; }
.toast-app .close { border: 0; background: none; color: var(--text-faint); font-size: 1.1rem; line-height: 1; padding: 0; }
.toast-app.toast-success { --tone: #1bcfb4; }
.toast-app.toast-error { --tone: #fe7c96; }
.toast-app.toast-warning { --tone: #f2b705; }
.toast-app.toast-info { --tone: #198ae3; }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* -------------------------------------------------------------- Auth pages */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }
.auth-aside {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 48px; color: #fff;
    background: var(--brand-gradient);
}
.auth-aside::after {
    content: ''; position: absolute; width: 520px; height: 520px; border-radius: 50%;
    right: -180px; bottom: -200px; background: rgba(255, 255, 255, .09);
}
.auth-aside::before {
    content: ''; position: absolute; width: 300px; height: 300px; border-radius: 50%;
    left: -90px; top: -110px; background: rgba(255, 255, 255, .07);
}
.auth-aside > * { position: relative; z-index: 1; }
.auth-aside .brand-mark { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: rgba(255, 255, 255, .2); font-weight: 600; font-size: 1.3rem; }
.auth-aside h2 { font-size: 2rem; font-weight: 600; line-height: 1.25; max-width: 440px; }
.auth-aside p { opacity: .9; max-width: 420px; }
.auth-aside .feature { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; opacity: .95; }
.auth-aside .logo-box { background: #fff; border-radius: 12px; padding: 10px 14px; display: inline-flex; }
.auth-aside .logo-box img { max-height: 40px; max-width: 200px; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 410px; }
.auth-card h1 { font-size: 1.5rem; font-weight: 600; margin-bottom: 6px; }
.auth-card .lead-sub { color: var(--text-muted); margin-bottom: 28px; }
.auth-mobile-brand { display: none; }
@media (max-width: 991.98px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .auth-mobile-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; font-weight: 600; }
}

/* -------------------------------------------------------------- Error pages */
.error-page { min-height: 60vh; display: grid; place-items: center; text-align: center; }
.error-page .code { font-size: 4.5rem; font-weight: 700; background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; }

/* -------------------------------------------------------------- Footer */
.app-footer { padding: 16px 28px; font-size: .76rem; color: var(--text-faint); border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }

/* -------------------------------------------------------------- Dark-mode patches for PurpleAdmin components */
[data-theme="dark"] .navbar .navbar-brand-wrapper, [data-theme="dark"] .navbar .navbar-menu-wrapper, [data-theme="dark"] .sidebar,
[data-theme="dark"] .sidebar .nav .nav-item.active, [data-theme="dark"] .footer, [data-theme="dark"] .sidebar .nav.sub-menu { background: var(--surface) !important; }
[data-theme="dark"] .content-wrapper { background: var(--app-bg); }
[data-theme="dark"] .sidebar .nav .nav-item .nav-link, [data-theme="dark"] .navbar .navbar-menu-wrapper .navbar-nav .nav-item .nav-link,
[data-theme="dark"] .page-header .page-title, [data-theme="dark"] .navbar .navbar-menu-wrapper .navbar-toggler { color: var(--text); }
[data-theme="dark"] .sidebar .nav .nav-item:hover { background: var(--surface-2); }
[data-theme="dark"] .navbar .navbar-menu-wrapper .search-field .input-group input { color: var(--text); }
[data-theme="dark"] .text-dark, [data-theme="dark"] .text-black { color: var(--text) !important; }
[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }
[data-theme="dark"] .bg-white, [data-theme="dark"] .bg-light { background-color: var(--surface) !important; }
[data-theme="dark"] .border, [data-theme="dark"] .border-bottom, [data-theme="dark"] .border-top { border-color: var(--border) !important; }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* Utilities */
.fw-600 { font-weight: 600 !important; }
.text-faint { color: var(--text-faint) !important; }
.text-brand { color: var(--brand-1) !important; }
.min-w-0 { min-width: 0; }
.gap-y-4 { row-gap: 1.5rem; }

/* -------------------------------------------------------------- Settings tabs */
.settings-tabs { gap: 4px; border-bottom: 1px solid var(--border); padding-bottom: 0; scrollbar-width: none; }
.settings-tabs .nav-link {
    border-radius: 0; background: none !important; color: var(--text-muted); font-weight: 500; font-size: .84rem;
    padding: 10px 14px 12px; border-bottom: 2px solid transparent; white-space: nowrap;
}
.settings-tabs .nav-link:hover { color: var(--text); }
.settings-tabs .nav-link.active { color: var(--brand-1); border-bottom-color: var(--brand-1); }
.settings-tabs .nav-link.has-error::after { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #e14d6a; margin-left: 6px; vertical-align: middle; }

/* -------------------------------------------------------------- Branding page */
.asset-slot { display: flex; gap: 14px; align-items: center; padding: 12px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface-2); }
.asset-slot.is-invalid { border-color: #e14d6a; }
.asset-thumb { width: 72px; height: 56px; flex-shrink: 0; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; color: var(--text-faint); font-size: 1.5rem; }
.asset-thumb.dark { background: #1d1a27; }
.asset-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.color-input .form-control-color { max-width: 52px; padding: 6px; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.brand-preview-sticky { position: sticky; top: calc(var(--topbar-h) + 20px); }
#brandPreview { --p1: #9a55ff; --p2: #da8cff; --acc: #9a55ff; }
.pv-sidebar { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface); }
.pv-brand { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.pv-brand img { max-height: 30px; max-width: 150px; }
.pv-brand small { display: block; font-size: .7rem; color: var(--text-faint); }
.pv-mark { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 600; background: linear-gradient(to right, var(--p2), var(--p1)); }
.pv-item { padding: 8px 10px; border-radius: 8px; color: var(--text-muted); font-size: .82rem; display: flex; gap: 8px; align-items: center; }
.pv-item.active { background: color-mix(in srgb, var(--p1) 12%, transparent); color: var(--p1); font-weight: 600; }
.pv-btn { margin-top: 10px; text-align: center; color: #fff; padding: 8px; border-radius: 8px; font-size: .8rem; font-weight: 500; background: linear-gradient(to right, var(--p2), var(--p1)); }
.pv-login { border-radius: var(--radius); padding: 18px; color: #fff; background: linear-gradient(to right, var(--p2), var(--p1)); display: flex; flex-direction: column; gap: 4px; }
.pv-login span { font-size: .8rem; opacity: .9; }
.pv-invoice { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: #fff; color: #343a40; }
.pv-inv-title { font-weight: 700; letter-spacing: .06em; color: var(--acc); font-size: .85rem; }
.pv-rule { height: 3px; background: var(--acc); border-radius: 2px; margin: 12px 0; }
.pv-acc { color: var(--acc); }
@media (max-width: 1199.98px) { .brand-preview-sticky { position: static; } }

/* -------------------------------------------------------------- Pagination, toolbars, detail lists */
.pagination-app { gap: 4px; flex-wrap: wrap; }
.pagination-app .page-link { border: 1px solid var(--border); border-radius: 8px !important; color: var(--text-muted); background: var(--surface); min-width: 36px; text-align: center; font-size: .82rem; padding: 6px 10px; }
.pagination-app .page-item.active .page-link { background: var(--brand-1); border-color: var(--brand-1); color: #fff; }
.pagination-app .page-link:hover { background: var(--surface-2); color: var(--text); }
.table-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.table-toolbar .search { position: relative; flex: 1 1 260px; max-width: 420px; }
.table-toolbar .search .mdi { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 1.1rem; }
.table-toolbar .search input { padding-left: 38px; }
.table-toolbar .form-select { width: auto; min-width: 130px; flex: 0 1 auto; }
.table-footer { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; padding: 14px 20px; border-top: 1px solid var(--border); font-size: .8rem; color: var(--text-muted); }
.cell-title { font-weight: 600; color: var(--text); text-decoration: none; }
.cell-title:hover { color: var(--brand-1); }
.cell-sub { font-size: .76rem; color: var(--text-faint); }
.dl-grid { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 10px 16px; margin: 0; font-size: .84rem; }
.dl-grid dt { color: var(--text-muted); font-weight: 500; }
.dl-grid dd { margin: 0; word-break: break-word; }
.nav-tabs-app { border-bottom: 1px solid var(--border); gap: 4px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.nav-tabs-app .nav-link { border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--text-muted); font-weight: 500; padding: 12px 14px; white-space: nowrap; background: none; }
.nav-tabs-app .nav-link.active { color: var(--brand-1); border-bottom-color: var(--brand-1); background: none; }
.nav-tabs-app .count { font-size: .68rem; background: var(--surface-2); border-radius: 10px; padding: 1px 7px; margin-left: 4px; color: var(--text-muted); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; font-size: .82rem; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-1); }
.timeline li::after { content: ''; position: absolute; left: 7.5px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.alert-app { border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); padding: 14px 16px; font-size: .84rem; }
.alert-app.warning { background: #fff8e1; border-color: #f5dc8a; color: #6d5400; }
[data-theme="dark"] .alert-app.warning { background: rgba(254, 215, 19, .08); border-color: rgba(254, 215, 19, .3); color: #f5d34a; }

/* Polish */
.app-content .form-select { color: var(--text); padding-right: 2.25rem; background-position: right .75rem center; }
.app-content .form-select:invalid, .app-content .form-select option[value=""] { color: var(--text-muted); }
.cell-sub { line-height: 1.5; margin-top: 2px; }
.table td { line-height: 1.45; }
.dl-grid dt, .dl-grid dd { padding: 0; margin-left: 0; }

/* -------------------------------------------------------------- Document editor (container-query responsive) */
.items-editor { container-type: inline-size; container-name: items; }
.items-head, .item-row {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) 74px 62px 70px 96px 116px 118px 104px 74px;
    gap: 6px; align-items: start; padding: 10px 14px;
}
.items-head { background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: .66rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.items-head .num { text-align: right; }
.item-row { border-bottom: 1px solid var(--border); }
.item-row:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.item-row.has-error { background: color-mix(in srgb, #fe7c96 7%, transparent); }
.item-row.has-error [data-taxnote] { color: #d63f5c !important; }
.item-row .form-control-sm, .item-row .form-select-sm { min-height: 34px; font-size: .8rem; padding: .3rem .45rem; }
.item-row .form-select-sm { padding-right: 1.4rem; background-position: right .35rem center; }
.item-row textarea { resize: vertical; min-height: 34px; }
.item-row .c-amt { padding-top: 7px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.item-row .c-amt small { font-weight: 400; font-size: .68rem; }
.item-row .c-act { display: flex; justify-content: flex-end; }
.item-row .c-act .icon-btn { width: 24px; height: 32px; font-size: .95rem; }
.item-row .m-label { display: none; }
@container items (max-width: 1040px) {
    .items-head { display: none; }
    .item-row { grid-template-columns: repeat(6, minmax(0, 1fr)); padding: 14px 16px; gap: 8px; }
    .item-row .m-label { display: block; font-size: .66rem; font-weight: 600; text-transform: uppercase; color: var(--text-faint); margin-bottom: 3px; }
    .item-row .c-item { grid-column: 1 / -1; }
    .item-row .c-hsn, .item-row .c-qty, .item-row .c-unit, .item-row .c-price, .item-row .c-disc, .item-row .c-tax { grid-column: span 2; }
    .item-row .c-amt { grid-column: span 4; text-align: left; padding-top: 0; }
    .item-row .c-act { grid-column: span 2; align-self: end; }
    .item-row .c-act .icon-btn { width: 34px; }
}
@container items (max-width: 520px) {
    .item-row .c-hsn, .item-row .c-qty, .item-row .c-unit, .item-row .c-price, .item-row .c-disc, .item-row .c-tax { grid-column: span 3; }
}
.totals-sticky { position: sticky; top: calc(var(--topbar-h) + 20px); }
.totals-list { margin: 0 0 12px; }
.totals-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: .84rem; }
.totals-list dt { font-weight: 400; color: var(--text-muted); }
.totals-list dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 500; text-align: right; }
.totals-list .grand { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 12px; }
.totals-list .grand dt { color: var(--text); font-weight: 600; }
.totals-list .grand dd { font-size: 1.2rem; font-weight: 700; color: var(--brand-1); }
@media (max-width: 1199.98px) { .totals-sticky { position: static; } }

/* select2 skin */
.select2-container { max-width: 100%; }
.app-content .select2-container .select2-selection--single,
.app-content .select2-container--default .select2-selection--single { height: 42px !important; min-height: 42px; border: 1px solid var(--border) !important; border-radius: var(--radius-sm) !important; background: var(--surface) !important; display: flex; align-items: center; padding: 0 !important; }
.app-content .select2-container .select2-selection--single .select2-selection__rendered { line-height: 1.3 !important; padding: 0 30px 0 12px !important; color: var(--text) !important; font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-content .select2-container .select2-selection--single .select2-selection__placeholder { color: var(--text-faint); }
.app-content .select2-container .select2-selection--single .select2-selection__arrow { height: 40px !important; top: 0 !important; right: 6px !important; }
.select2-container--default.select2-container--focus .select2-selection--single, .select2-container--open .select2-selection--single { border-color: var(--brand-1); box-shadow: 0 0 0 3px var(--brand-soft-2); }
.select2-dropdown { border-color: var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); box-shadow: var(--shadow); z-index: 1060; }
.select2-search--dropdown .select2-search__field { border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; background: var(--surface); color: var(--text); }
.select2-results__option { font-size: .84rem; padding: 8px 12px; }
.select2-container--default .select2-results__option--highlighted[aria-selected], .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable { background: var(--brand-1); }
.is-invalid + .select2 .select2-selection { border-color: #e14d6a; }

/* Template picker */
.template-card { display: block; cursor: pointer; padding: 14px; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: border-color .15s ease, box-shadow .15s ease; height: 100%; }
.btn-check:checked + .template-card { border-color: var(--brand-1); box-shadow: 0 0 0 4px var(--brand-soft); }
.btn-check:focus-visible + .template-card { outline: 2px solid var(--brand-1); outline-offset: 2px; }
.tpl-thumb { display: block; height: 110px; border-radius: 8px; background: #fff; border: 1px solid #e6e6ee; padding: 10px; position: relative; overflow: hidden; }
.tpl-thumb span { display: block; height: 8px; border-radius: 3px; background: #e9e9ef; margin-bottom: 8px; }
.tpl-thumb span:nth-child(1) { width: 40%; }
.tpl-thumb span:nth-child(3) { height: 26px; }
.tpl-thumb span:nth-child(4) { width: 45%; margin-left: 55%; }
.tpl-modern { border-top: 6px solid var(--brand-1); }
.tpl-modern span:nth-child(3) { background: var(--brand-soft-2); }
.tpl-modern span:nth-child(4) { background: var(--brand-1); }
.tpl-classic span:nth-child(3) { background: transparent; border: 1px solid #c9ccd6; }
.tpl-classic span:nth-child(1) { border-bottom: 3px double var(--brand-1); background: #ddd; }
.tpl-minimal span { height: 1px; background: #bbb; margin-bottom: 18px; }
.tpl-minimal span:nth-child(1) { height: 6px; background: #333; }
.notif-dot { position: absolute; top: 4px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: #e14d6a; color: #fff; font-size: .62rem; font-weight: 600; display: grid; place-items: center; line-height: 1; }

/* Support thread */
.support-thread { display: flex; flex-direction: column; gap: 12px; }
.support-thread .msg { max-width: 85%; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.support-thread .msg.mine { align-self: flex-end; background: var(--brand-soft); border-color: transparent; }
.support-thread .meta { font-size: .74rem; color: var(--text-muted); margin-bottom: 4px; }
.support-thread .body { font-size: .86rem; overflow-wrap: anywhere; }

/* Stand-alone pages (public document links) */
.app-content { padding: 28px 16px; max-width: 1200px; margin: 0 auto; width: 100%; }
.navbar .navbar-brand-wrapper .brand-text-logo { font-weight: 700; font-size: 1.45rem; letter-spacing: -.01em; }
@media (min-width: 992px) {
    .sidebar-icon-only .sidebar .nav .nav-item.sidebar-logout .nav-link { justify-content: center; padding-left: 0; padding-right: 0; }
    .sidebar-icon-only .sidebar .nav .nav-item.sidebar-logout .nav-link i.menu-icon { margin-left: 0; }
}

/* "Login as" banner — fixed above PurpleAdmin's fixed navbar */
.impersonation-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 1100; height: 44px; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 0 12px;
    background: linear-gradient(to right, var(--brand-2), var(--brand-1)); color: #fff; font-size: .84rem; }
.impersonation-bar .btn { padding: .25rem .7rem; }
.is-impersonating .navbar.fixed-top { top: 44px; }
.is-impersonating .page-body-wrapper { padding-top: 114px !important; }
@media (max-width: 991.98px) { .is-impersonating .sidebar-offcanvas { top: 114px; } }
@media (max-width: 575.98px) { .impersonation-bar span { font-size: .72rem; } .impersonation-bar { gap: 6px; } }
