/**
 * Modern Theme Layer
 * AutoCarWash POS System
 *
 * Loaded last on every page (after page-level <style> blocks) so the whole
 * system shares one clean, modern look. Only visual properties (colour,
 * radius, shadow, typography) are touched — page layouts stay intact.
 * No expensive global transitions: only interactive elements animate,
 * and only the properties that change.
 */

:root {
    /* Brand palette */
    --brand-50:  #eef2ff;
    --brand-100: #e0e7ff;
    --brand-500: #6366f1;
    --brand-600: #4f46e5;
    --brand-700: #4338ca;

    --ink:       #0f172a;
    --ink-2:     #334155;
    --muted:     #64748b;
    --line:      #e6e9f0;
    --surface:   #ffffff;
    --canvas:    #f5f7fb;

    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 16px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 8px 24px -6px rgba(15, 23, 42, .12);
    --ease:      cubic-bezier(.2, .8, .2, 1);

    --brand-gradient: linear-gradient(125deg, #1e1b4b 0%, #4338ca 48%, #6366f1 100%);

    /* App shell */
    --sidebar-w: 260px;
    --sidebar-w-collapsed: 76px;
    --topbar-h: 64px;
    --sidebar-bg: #0f172a;

    /* Legacy variables used by page-level styles — remapped to the new palette */
    --primary-color:   var(--brand-600);
    --secondary-color: var(--brand-500);
    --success-color:   #10b981;
    --danger-color:    #ef4444;
    --warning-color:   #f59e0b;
    --info-color:      #0ea5e9;
    --dark-color:      var(--ink);
    --light-color:     var(--canvas);

    /* Bootstrap 5.3 tokens */
    --bs-primary: var(--brand-600);
    --bs-primary-rgb: 79, 70, 229;
    --bs-link-color: var(--brand-600);
    --bs-link-color-rgb: 79, 70, 229;
    --bs-link-hover-color: var(--brand-700);
    --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--canvas);
    --bs-border-color: var(--line);
    --bs-border-radius: var(--radius-sm);
    --bs-border-radius-lg: var(--radius);
    --bs-secondary-color: var(--muted);
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }

body {
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--bs-body-font-family);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 { color: var(--ink); font-weight: 700; letter-spacing: -.01em; }
.text-muted { color: var(--muted) !important; }
a { text-decoration-thickness: 1px; text-underline-offset: 2px; }

::selection { background: var(--brand-100); color: var(--brand-700); }

/* ---------- Navbar ---------- */
.navbar.navbar-dark,
.navbar[class*="gradient"] {
    background: linear-gradient(120deg, #1e1b4b 0%, var(--brand-700) 55%, var(--brand-500) 100%) !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .06), var(--shadow-sm);
}
.navbar.navbar-light,
.navbar.bg-light,
.navbar.bg-white {
    background: rgba(255, 255, 255, .85) !important;
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line) !important;
}
.navbar-brand { font-weight: 800; letter-spacing: -.02em; }

/* ---------- Sidebar ---------- */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--line);
    box-shadow: none;
}
.sidebar .nav-link {
    color: var(--ink-2);
    font-weight: 500;
    font-size: .925rem;
    padding: 10px 16px;
    margin: 2px 12px;
    border-radius: 10px;
    transition: background-color .15s var(--ease), color .15s var(--ease);
}
.sidebar .nav-link i { color: var(--muted); transition: color .15s var(--ease); }
.sidebar .nav-link:hover {
    background: var(--canvas);
    color: var(--ink);
}
.sidebar .nav-link.active {
    background: var(--brand-50);
    color: var(--brand-700);
    font-weight: 600;
}
.sidebar .nav-link:hover i,
.sidebar .nav-link.active i { color: var(--brand-600); }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.card:hover { transform: none; }
/* No background here: some pages use coloured/gradient headers with white text */
.card-header,
.card-footer { border-color: var(--line); }
.card-header { font-weight: 600; }
.card-header:first-child { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }

.stat-card,
.stat-box,
.table-card,
.filter-card {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    transition: box-shadow .2s var(--ease), transform .2s var(--ease);
}
.stat-card:hover,
.stat-box:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card h3 { font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-card .icon { border-radius: 12px; }

.quick-action-card,
.quick-action-btn {
    border-radius: var(--radius);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-xs);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease);
}
.quick-action-card:hover,
.quick-action-btn:hover {
    border-color: var(--brand-500);
    box-shadow: 0 6px 18px -6px rgba(79, 70, 229, .35);
    transform: translateY(-2px);
}

/* ---------- Buttons ---------- */
.btn {
    --bs-btn-font-weight: 600;
    border-radius: 10px;
    letter-spacing: 0;
    box-shadow: none;
    transition: background-color .15s var(--ease), border-color .15s var(--ease),
                color .15s var(--ease), box-shadow .15s var(--ease), transform .08s var(--ease);
}
.btn:hover { transform: none; }
.btn:active { transform: scale(.98); }
.btn-sm, .btn-group-sm > .btn { border-radius: 8px; }
.btn-lg { border-radius: 12px; }

.btn-primary {
    --bs-btn-bg: var(--brand-600);
    --bs-btn-border-color: var(--brand-600);
    --bs-btn-hover-bg: var(--brand-700);
    --bs-btn-hover-border-color: var(--brand-700);
    --bs-btn-active-bg: var(--brand-700);
    --bs-btn-active-border-color: var(--brand-700);
    --bs-btn-disabled-bg: var(--brand-500);
    --bs-btn-disabled-border-color: var(--brand-500);
    --bs-btn-focus-shadow-rgb: 99, 102, 241;
    box-shadow: 0 1px 2px rgba(79, 70, 229, .25), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand-600);
    --bs-btn-border-color: var(--brand-100);
    --bs-btn-hover-bg: var(--brand-600);
    --bs-btn-hover-border-color: var(--brand-600);
    --bs-btn-active-bg: var(--brand-700);
    --bs-btn-active-border-color: var(--brand-700);
}
.btn-light {
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: var(--line);
    --bs-btn-hover-bg: var(--canvas);
    --bs-btn-hover-border-color: #d5dae4;
}
.btn-info { --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-bg: #0ea5e9; --bs-btn-border-color: #0ea5e9; --bs-btn-hover-bg: #0284c7; --bs-btn-hover-border-color: #0284c7; }

/* Quiet icon buttons used in table action groups */
.btn-icon {
    width: 32px; height: 32px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px;
}

/* Loading state (set by ui.js on submit) */
.btn.is-loading { pointer-events: none; opacity: .75; }
.btn.is-loading::after {
    content: ""; width: 1em; height: 1em; margin-left: .5em;
    display: inline-block; vertical-align: -.15em;
    border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
    animation: ui-spin .6s linear infinite;
}
@keyframes ui-spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.form-control,
.form-select {
    border-color: var(--line);
    border-radius: 10px;
    background-color: var(--surface);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.form-control:hover,
.form-select:hover { border-color: #cfd5e1; }
.form-control:focus,
.form-select:focus {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .15);
}
.form-control-sm, .form-select-sm { border-radius: 8px; }
.form-label { font-weight: 600; font-size: .875rem; color: var(--ink-2); }
.input-group-text { background: var(--canvas); border-color: var(--line); color: var(--muted); }
.input-group > :first-child:not(.dropdown-menu) { border-top-left-radius: 10px; border-bottom-left-radius: 10px; }
.input-group > :last-child:not(.dropdown-menu) { border-top-right-radius: 10px; border-bottom-right-radius: 10px; }
.form-check-input:checked { background-color: var(--brand-600); border-color: var(--brand-600); }
.form-check-input:focus { box-shadow: 0 0 0 4px rgba(99, 102, 241, .15); border-color: var(--brand-500); }

/* ---------- Tables ---------- */
.table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: #f8f9fc;
    --bs-table-striped-bg: #fafbfd;
    border-collapse: collapse;
    border-spacing: 0;
    color: var(--ink);
}
.table > :not(caption) > * > * { border-bottom-color: var(--line); }
.table thead th,
.table > thead > tr > th {
    background: #f8f9fc;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table-light { --bs-table-bg: #f8f9fc; --bs-table-color: var(--muted); }
.table tbody tr { box-shadow: none; transform: none; }
.table tbody tr:hover { transform: none; box-shadow: none; }
.table tbody tr td:first-child,
.table tbody tr td:last-child { border-radius: 0; }
.table td { font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge {
    font-weight: 600;
    border-radius: 999px;
    padding: .38em .75em;
    letter-spacing: .01em;
}
.badge.bg-success   { background-color: #dcfce7 !important; color: #166534 !important; }
.badge.bg-danger    { background-color: #fee2e2 !important; color: #991b1b !important; }
.badge.bg-warning   { background-color: #fef3c7 !important; color: #92400e !important; }
.badge.bg-info      { background-color: #e0f2fe !important; color: #075985 !important; }
.badge.bg-primary   { background-color: var(--brand-100) !important; color: var(--brand-700) !important; }
.badge.bg-secondary { background-color: #eef1f6 !important; color: #475569 !important; }
.badge.bg-dark      { background-color: #1e293b !important; color: #f8fafc !important; }

/* ---------- Alerts ---------- */
.alert {
    border: 1px solid transparent;
    border-left-width: 4px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
}
.alert-success { background: #f0fdf4; border-color: #bbf7d0; border-left-color: #16a34a; color: #14532d; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; border-left-color: #dc2626; color: #7f1d1d; }
.alert-warning { background: #fffbeb; border-color: #fde68a; border-left-color: #d97706; color: #78350f; }
.alert-info    { background: #f0f9ff; border-color: #bae6fd; border-left-color: #0284c7; color: #0c4a6e; }

/* ---------- Modals ---------- */
.modal-backdrop.show { opacity: .45; }
.modal-backdrop { background-color: #0f172a; }
.modal-content {
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 24px 48px -12px rgba(15, 23, 42, .25);
    overflow: hidden;
}
.modal-header { border-bottom: 1px solid var(--line); }
.modal-footer { border-top: 1px solid var(--line); background: #fbfcfe; }
.modal-title { font-weight: 700; }
.modal.fade .modal-dialog { transition: transform .2s var(--ease), opacity .2s var(--ease); transform: translateY(12px) scale(.98); }
.modal.show .modal-dialog { transform: none; }

/* ---------- Dropdowns, pagination, nav tabs ---------- */
.dropdown-menu {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 6px;
}
.dropdown-item { border-radius: 8px; padding: 8px 12px; }
.dropdown-item:active { background: var(--brand-600); }

.pagination { --bs-pagination-border-radius: 10px; gap: 4px; }
.page-link { border-radius: 10px !important; border-color: var(--line); color: var(--ink-2); min-width: 38px; text-align: center; }
.page-item.active .page-link { background: var(--brand-600); border-color: var(--brand-600); }

.nav-tabs { border-bottom-color: var(--line); }
.nav-tabs .nav-link { border: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.nav-tabs .nav-link.active { color: var(--brand-700); border-bottom-color: var(--brand-600); background: transparent; }
.nav-pills .nav-link.active { background: var(--brand-600); }

.progress { background: #eef1f6; border-radius: 999px; }
.progress-bar { background: linear-gradient(90deg, var(--brand-600), var(--brand-500)); }

/* ---------- Scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: #cbd2de transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd2de; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #a8b1c2; }

/* ---------- Accessibility & motion ---------- */
:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Page transition: fade in content fast, no layout shift ---------- */
@keyframes ui-fade-in { from { opacity: 0; } to { opacity: 1; } }
.main-content, body > .container, body > .container-fluid { animation: ui-fade-in .18s ease-out both; }

/* =====================================================================
   APP SHELL — shared sidebar + top bar (includes/app_shell.php)
   ===================================================================== */
body.has-shell {
    padding-left: var(--sidebar-w);
    padding-top: var(--topbar-h);
    min-height: 100vh;
}
body.has-shell.shell-collapsed { padding-left: var(--sidebar-w-collapsed); }

/* Hide each page's legacy navigation — the shell replaces it */
body.has-shell > nav.navbar,
body.has-shell .sidebar:not(.app-sidebar),
body.has-shell .mobile-shortcuts { display: none !important; }
body.has-shell .main-content { margin-left: 0 !important; max-width: none !important; }
body.has-shell .d-flex > .main-content { flex: 1; min-width: 0; }

/* Redundant "Dashboard" buttons inside page headers (sidebar covers it) */
body.has-shell :is(.branches-header, .customers-header, .customer-header, .expenses-header, .sales-header,
    .services-header, .settings-header, .users-header, .vehicles-header, .reports-header, .loyalty-header,
    .header-card, .pos-header) a[href$="dashboard.php"] { display: none !important; }

/* Full-height POS fits under the top bar */
@media (min-width: 992px) {
    body.has-shell .pos-container { height: calc(100vh - var(--topbar-h)); }
}

/* ---------- Sidebar ---------- */
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    background-image: radial-gradient(120% 60% at 0% 0%, rgba(99, 102, 241, .22) 0%, transparent 60%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: width .2s var(--ease), transform .25s var(--ease);
}

.app-brand { height: var(--topbar-h); display: flex; align-items: center; padding: 0 16px; flex-shrink: 0; }
.app-brand-link { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; min-width: 0; }
.app-brand-logo {
    width: 36px; height: 36px; border-radius: 10px; object-fit: cover; flex-shrink: 0;
    background: #fff; box-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 4px 12px rgba(0,0,0,.3);
}
.app-brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.app-brand-text strong { font-size: .95rem; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-brand-text small { color: #94a3b8; font-size: .72rem; }

.app-search-trigger {
    margin: 4px 14px 8px;
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, .18);
    background: rgba(255, 255, 255, .04);
    color: #94a3b8;
    font-size: .85rem;
    text-align: left;
    transition: background-color .15s var(--ease), border-color .15s var(--ease);
}
.app-search-trigger:hover { background: rgba(255, 255, 255, .08); border-color: rgba(148, 163, 184, .3); color: #e2e8f0; }
.app-search-trigger kbd {
    margin-left: auto; font-size: .68rem; padding: 2px 6px; border-radius: 6px;
    background: rgba(255,255,255,.08); color: #94a3b8; border: 1px solid rgba(255,255,255,.08);
}

.app-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 10px 16px; scrollbar-color: rgba(148,163,184,.25) transparent; }
.app-nav-section + .app-nav-section { margin-top: 14px; }
.app-nav-heading {
    font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
    color: #64748b; padding: 6px 12px; white-space: nowrap;
}
.app-nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; margin: 1px 0;
    border-radius: 10px;
    color: #cbd5e1; text-decoration: none;
    font-size: .9rem; font-weight: 500;
    white-space: nowrap;
    position: relative;
    transition: background-color .15s var(--ease), color .15s var(--ease);
}
.app-nav-link i { width: 20px; text-align: center; color: #94a3b8; font-size: .95rem; transition: color .15s var(--ease); }
.app-nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.app-nav-link:hover i { color: #c7d2fe; }
.app-nav-link.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, .32), rgba(99, 102, 241, .12));
    color: #fff; font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(129, 140, 248, .25);
}
.app-nav-link.active i { color: #a5b4fc; }
.app-nav-link.active::before {
    content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
    border-radius: 0 3px 3px 0; background: #818cf8;
}

.app-sidebar-footer { padding: 10px; border-top: 1px solid rgba(148, 163, 184, .12); flex-shrink: 0; }
.app-collapse-btn {
    width: 100%; display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; border: 0; border-radius: 10px;
    background: transparent; color: #94a3b8; font-size: .85rem;
}
.app-collapse-btn i { width: 20px; transition: transform .2s var(--ease); }
.app-collapse-btn:hover { background: rgba(255, 255, 255, .06); color: #fff; }

/* Collapsed (icon rail) */
.shell-collapsed .app-sidebar { width: var(--sidebar-w-collapsed); }
.shell-collapsed .app-sidebar .app-nav-label,
.shell-collapsed .app-sidebar .app-brand-text,
.shell-collapsed .app-sidebar .app-nav-heading { display: none; }
.shell-collapsed .app-sidebar .app-nav-section + .app-nav-section { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(148,163,184,.1); }
.shell-collapsed .app-sidebar .app-nav-link,
.shell-collapsed .app-sidebar .app-collapse-btn,
.shell-collapsed .app-sidebar .app-search-trigger { justify-content: center; padding-left: 0; padding-right: 0; }
.shell-collapsed .app-sidebar .app-search-trigger { margin: 4px 12px 8px; }
.shell-collapsed .app-sidebar .app-brand { justify-content: center; padding: 0; }
.shell-collapsed .app-sidebar .app-collapse-btn i { transform: rotate(180deg); }
.shell-collapsed .app-topbar { left: var(--sidebar-w-collapsed); }

/* ---------- Top bar ---------- */
.app-topbar {
    position: fixed;
    top: 0; right: 0; left: var(--sidebar-w);
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 12px;
    padding: 0 20px;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line);
    z-index: 1030;
    transition: left .2s var(--ease);
}
.app-crumbs { min-width: 0; flex: 1; }
.app-breadcrumb { display: flex; align-items: center; gap: 6px; font-size: .72rem; color: var(--muted); line-height: 1.2; white-space: nowrap; overflow: hidden; }
.app-breadcrumb i { font-size: .55rem; opacity: .6; }
.app-breadcrumb a { color: var(--muted); text-decoration: none; }
.app-breadcrumb a:hover { color: var(--brand-600); }
.app-page-title { font-weight: 700; font-size: 1.05rem; color: var(--ink); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-page-title i { color: var(--brand-600); margin-right: 6px; font-size: .95rem; }

.app-topbar-actions { display: flex; align-items: center; gap: 10px; }
.app-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 999px;
    background: var(--canvas); border: 1px solid var(--line);
    font-size: .8rem; font-weight: 500; color: var(--ink-2); white-space: nowrap;
}
.app-chip i { color: var(--muted); }
.app-newsale { border-radius: 999px !important; padding-left: 14px; padding-right: 14px; }

.app-icon-btn {
    width: 38px; height: 38px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.app-menu-btn { display: none; }

/* User menu (native <details>, no JS needed) */
.app-user { position: relative; }
.app-user > summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    padding: 4px 10px 4px 4px; border-radius: 999px;
    border: 1px solid transparent;
    transition: background-color .15s var(--ease), border-color .15s var(--ease);
}
.app-user > summary::-webkit-details-marker { display: none; }
.app-user > summary:hover, .app-user[open] > summary { background: var(--canvas); border-color: var(--line); }
.app-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand-gradient); color: #fff;
    font-size: .78rem; font-weight: 700; letter-spacing: .02em; flex-shrink: 0;
}
.app-avatar-lg { width: 42px; height: 42px; font-size: .9rem; }
.app-user-meta { flex-direction: column; line-height: 1.15; }
.app-user-meta strong { font-size: .85rem; color: var(--ink); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-user-meta small { font-size: .72rem; color: var(--muted); }
.app-user-caret { font-size: .65rem; color: var(--muted); }
.app-user-menu {
    position: absolute; right: 0; top: calc(100% + 8px);
    min-width: 240px; padding: 6px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 14px; box-shadow: var(--shadow-md);
    animation: ui-fade-in .12s ease-out;
}
.app-user-menu-head { display: flex; gap: 12px; align-items: center; padding: 10px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.app-user-menu a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 8px;
    color: var(--ink-2); text-decoration: none; font-size: .9rem;
}
.app-user-menu a:hover { background: var(--canvas); color: var(--ink); }
.app-user-menu a.text-danger:hover { background: #fef2f2; }

/* ---------- Quick jump palette ---------- */
.cmdk { position: fixed; inset: 0; z-index: 2000; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.cmdk[hidden] { display: none; }
.cmdk-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px); }
.cmdk-panel {
    position: relative; width: 100%; max-width: 560px;
    background: var(--surface); border-radius: 16px;
    box-shadow: 0 30px 60px -12px rgba(15, 23, 42, .45);
    overflow: hidden; animation: ui-fade-in .12s ease-out;
}
.cmdk-input-wrap { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.cmdk-input { flex: 1; border: 0; outline: 0; font-size: 1rem; background: transparent; color: var(--ink); }
.cmdk-list { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.cmdk-list li a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 10px;
    color: var(--ink-2); text-decoration: none;
}
.cmdk-list li a i { width: 20px; text-align: center; color: var(--muted); }
.cmdk-list li a small { margin-left: auto; color: var(--muted); font-size: .72rem; }
.cmdk-list li.selected a { background: var(--brand-50); color: var(--brand-700); }
.cmdk-list li.selected a i { color: var(--brand-600); }
.cmdk-empty { padding: 20px; text-align: center; color: var(--muted); }
.cmdk-foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: .72rem; color: var(--muted); background: #fbfcfe; }
.cmdk kbd {
    font-family: inherit; font-size: .7rem; padding: 2px 6px; margin-right: 3px;
    border-radius: 6px; background: var(--canvas); border: 1px solid var(--line); color: var(--muted);
}

/* ---------- Mobile: off-canvas sidebar ---------- */
.app-sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
    body.has-shell, body.has-shell.shell-collapsed { padding-left: 0; }
    .app-sidebar,
    .shell-collapsed .app-sidebar { width: 280px; transform: translateX(-100%); box-shadow: none; }
    .shell-collapsed .app-sidebar .app-nav-label,
    .shell-collapsed .app-sidebar .app-brand-text,
    .shell-collapsed .app-sidebar .app-nav-heading { display: revert; }
    .shell-collapsed .app-sidebar .app-nav-link,
    .shell-collapsed .app-sidebar .app-search-trigger { justify-content: flex-start; padding-left: 12px; padding-right: 12px; }
    .shell-collapsed .app-sidebar .app-brand { justify-content: flex-start; padding: 0 16px; }
    .app-sidebar-footer { display: none; }
    body.shell-open .app-sidebar { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .35); }
    body.shell-open .app-sidebar-backdrop {
        display: block; position: fixed; inset: 0; z-index: 1035;
        background: rgba(15, 23, 42, .5); animation: ui-fade-in .15s ease-out;
    }
    body.shell-open { overflow: hidden; }
    .app-topbar, .shell-collapsed .app-topbar { left: 0; padding: 0 12px; }
    .app-menu-btn { display: inline-flex; }
}
@media (max-width: 575.98px) {
    .app-breadcrumb { display: none; }
    .app-page-title { font-size: .98rem; }
}

/* =====================================================================
   UNIFIED PAGE HEADERS — every module's hero banner shares one style
   ===================================================================== */
:is(.branches-header, .customers-header, .customer-header, .expenses-header, .sales-header,
    .services-header, .settings-header, .users-header, .vehicles-header, .reports-header,
    .loyalty-header, .header-card, .dashboard-hero) {
    position: relative;
    overflow: hidden;
    background: var(--brand-gradient) !important;
    color: #fff !important;
    border-radius: 20px !important;
    padding: 26px 28px !important;
    margin-bottom: 24px !important;
    border: 0 !important;
    box-shadow: 0 18px 40px -18px rgba(67, 56, 202, .55) !important;
}
:is(.branches-header, .customers-header, .customer-header, .expenses-header, .sales-header,
    .services-header, .settings-header, .users-header, .vehicles-header, .reports-header,
    .loyalty-header, .header-card, .dashboard-hero)::after {
    content: "";
    position: absolute;
    right: -60px; top: -80px;
    width: 280px; height: 280px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, .16) 0%, rgba(255, 255, 255, 0) 70%);
    pointer-events: none;
}
:is(.branches-header, .customers-header, .customer-header, .expenses-header, .sales-header,
    .services-header, .settings-header, .users-header, .vehicles-header, .reports-header,
    .loyalty-header, .header-card, .dashboard-hero) :is(h1, h2, h3, h4) {
    color: #fff; font-weight: 800; letter-spacing: -.02em; font-size: clamp(1.3rem, 1.1rem + .8vw, 1.75rem);
}
:is(.branches-header, .customers-header, .customer-header, .expenses-header, .sales-header,
    .services-header, .settings-header, .users-header, .vehicles-header, .reports-header,
    .loyalty-header, .header-card, .dashboard-hero) :is(h1, h2, h3, h4) > i {
    width: 44px; height: 44px; margin-right: 12px;
    display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
    border-radius: 12px; background: rgba(255, 255, 255, .14); font-size: 1.1rem;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}
:is(.branches-header, .customers-header, .customer-header, .expenses-header, .sales-header,
    .services-header, .settings-header, .users-header, .vehicles-header, .reports-header,
    .loyalty-header, .header-card, .dashboard-hero) p { color: rgba(255, 255, 255, .78); }
:is(.branches-header, .customers-header, .customer-header, .expenses-header, .sales-header,
    .services-header, .settings-header, .users-header, .vehicles-header, .reports-header,
    .loyalty-header, .header-card, .dashboard-hero) .btn-light {
    --bs-btn-bg: rgba(255, 255, 255, .95);
    --bs-btn-border-color: transparent;
    --bs-btn-color: var(--brand-700);
    --bs-btn-hover-bg: #fff;
    --bs-btn-hover-color: var(--brand-700);
}
:is(.branches-header, .customers-header, .customer-header, .expenses-header, .sales-header,
    .services-header, .settings-header, .users-header, .vehicles-header, .reports-header,
    .loyalty-header, .header-card, .dashboard-hero) > * { position: relative; z-index: 1; }

/* Legacy header markup uses non-wrapping flex rows — let them wrap on small screens */
:is(.branches-header, .customers-header, .customer-header, .expenses-header, .sales-header,
    .services-header, .settings-header, .users-header, .vehicles-header, .reports-header,
    .loyalty-header, .header-card, .dashboard-hero) .d-flex { flex-wrap: wrap; gap: 12px; }
:is(.branches-header, .customers-header, .customer-header, .expenses-header, .sales-header,
    .services-header, .settings-header, .users-header, .vehicles-header, .reports-header,
    .loyalty-header, .header-card, .dashboard-hero) .d-flex > * { min-width: 0; }
body.has-shell { overflow-x: clip; }

/* Dashboard hero metrics */
.hero-metric {
    min-width: 120px;
    padding: 10px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .12);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
    backdrop-filter: blur(4px);
}
.hero-metric small { display: block; font-size: .72rem; color: rgba(255, 255, 255, .72); text-transform: uppercase; letter-spacing: .06em; }
.hero-metric strong { font-size: 1.15rem; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 575.98px) { .hero-metric { flex: 1 1 30%; min-width: 0; padding: 8px 10px; } .hero-metric strong { font-size: .95rem; } }

/* Stat cards everywhere: one calm style (thin border instead of thick coloured edge) */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line) !important;
}
.stat-card p { color: var(--muted); font-weight: 500; }

/* Page containers: consistent spacing under the top bar */
body.has-shell :is(.branches-container, .customers-container, .customer-container, .expenses-container,
    .sales-container, .services-container, .settings-container, .users-container, .vehicles-container,
    .reports-container, .loyalty-container, .page-wrap) {
    margin-top: 0 !important;
    padding: 24px !important;
}
@media (max-width: 575.98px) {
    body.has-shell :is(.branches-container, .customers-container, .customer-container, .expenses-container,
        .sales-container, .services-container, .settings-container, .users-container, .vehicles-container,
        .reports-container, .loyalty-container, .page-wrap) { padding: 14px !important; }
    :is(.branches-header, .customers-header, .customer-header, .expenses-header, .sales-header,
        .services-header, .settings-header, .users-header, .vehicles-header, .reports-header,
        .loyalty-header, .header-card, .dashboard-hero) { padding: 20px !important; border-radius: 16px !important; }
}

/* Secondary content pages (forms, details) get a centred readable width */
body.has-shell > .container.py-4,
body.has-shell > .container-fluid.py-3 { padding-top: 24px !important; }

@media print {
    body { background: #fff; }
    body.has-shell { padding: 0 !important; }
    .app-sidebar, .app-topbar, .app-sidebar-backdrop, .cmdk { display: none !important; }
    .card, .stat-card { box-shadow: none !important; }
    .main-content, body > .container, body > .container-fluid { animation: none; }
}
