:root {
    --app-bg: #f5f2ec;
    --app-bg-2: #eef6f4;
    --app-surface: #ffffff;
    --app-surface-2: #fbfaf7;
    --app-border: #ded8cc;
    --app-border-strong: #c8bead;
    --app-text: #1d2329;
    --app-muted: #6f746f;
    --app-ink: #172026;
    --app-primary: #0c7476;
    --app-primary-dark: #07595b;
    --app-primary-soft: #e4f3f1;
    --app-accent: #c7802f;
    --app-accent-soft: #fff0dc;
    --app-success: #29785b;
    --app-warning: #a66713;
    --app-danger: #b33a2f;
    --app-shadow: 0 18px 45px rgba(33, 35, 32, 0.10);
    --app-shadow-soft: 0 10px 28px rgba(33, 35, 32, 0.07);
    --bs-primary: var(--app-primary);
    --bs-primary-rgb: 12, 116, 118;
}

* {
    letter-spacing: 0;
}

.app-body {
    min-height: 100vh;
    color: var(--app-text);
    background:
        radial-gradient(circle at 8% 0%, rgba(199, 128, 47, 0.13), transparent 30rem),
        radial-gradient(circle at 88% 6%, rgba(12, 116, 118, 0.12), transparent 26rem),
        linear-gradient(180deg, var(--app-bg-2) 0, var(--app-bg) 25rem, #f8f6f1 100%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(23, 32, 38, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(23, 32, 38, 0.03) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.72), transparent 34rem);
}

.app-main {
    max-width: 1500px;
}

.page-shell {
    max-width: 1160px;
}

.app-navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(23, 32, 38, 0.96);
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 12px 32px rgba(15, 20, 24, 0.18);
    backdrop-filter: blur(14px);
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.72rem;
    min-height: 42px;
    font-weight: 800;
}

.app-brand-mark {
    display: inline-grid;
    width: 38px;
    height: 38px;
    place-items: center;
    color: #fff8ed;
    background: linear-gradient(135deg, var(--app-accent), var(--app-primary));
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
    font-size: 0.82rem;
}

.app-brand-text {
    color: #fff;
}

.app-navbar .nav-link {
    color: rgba(255, 255, 255, 0.78);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.62rem 0.82rem;
    font-weight: 700;
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link:focus {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.08);
}

.app-navbar .nav-link.active {
    color: #fff;
    background: rgba(12, 116, 118, 0.42);
    border-color: rgba(147, 220, 213, 0.28);
}

.app-cash-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.45rem 0.8rem;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.92rem;
    text-decoration: none;
    white-space: nowrap;
    transition: filter 0.15s ease;
}

.app-cash-chip:hover {
    filter: brightness(1.08);
}

.app-cash-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: 0 0 auto;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.app-cash-chip.is-open {
    color: #e8fff6;
    background: rgba(41, 120, 91, 0.32);
    border-color: rgba(134, 220, 184, 0.25);
}

.app-cash-chip.is-open .app-cash-dot {
    background: #46d39a;
}

.app-cash-chip.is-closed {
    color: #ffe9df;
    background: rgba(179, 58, 47, 0.22);
    border-color: rgba(255, 172, 150, 0.25);
}

.app-cash-chip.is-closed .app-cash-dot {
    background: #ff7a63;
}

.app-cash-chip--compact {
    min-height: 38px;
    margin-left: auto;
    margin-right: 0.5rem;
    font-size: 0.85rem;
}

.app-icon-quick {
    padding-left: 0.6rem;
    padding-right: 0.6rem;
}

.app-user-toggle {
    gap: 0.55rem;
}

.app-user-toggle::after {
    margin-left: 0.1rem;
}

.app-user-avatar {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--app-accent), var(--app-primary));
    color: #fff;
    font-size: 0.78rem;
    font-weight: 800;
    flex: 0 0 auto;
}

.nav-ic {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.app-quicknav,
.app-nav-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.app-quick {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 48px;
    padding: 0.5rem 0.85rem;
    color: rgba(255, 255, 255, 0.82);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.app-quick:hover,
.app-quick:focus {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.08);
}

.app-quick.active {
    color: #fff;
    background: rgba(12, 116, 118, 0.42);
    border-color: rgba(147, 220, 213, 0.28);
}

.app-quick-primary,
.app-quick-primary.active {
    color: #fff;
    background: linear-gradient(135deg, var(--app-accent), var(--app-primary));
    border-color: rgba(255, 255, 255, 0.22);
}

.app-quick-primary:hover,
.app-quick-primary:focus {
    color: #fff;
    background: linear-gradient(135deg, var(--app-accent), var(--app-primary-dark));
    border-color: rgba(255, 255, 255, 0.30);
}

.app-quick .nav-ic {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
}

.app-navbar .app-user-name {
    cursor: default;
}

.app-menu-list {
    min-width: 264px;
    padding: 0.4rem;
}

.app-menu-list .dropdown-header {
    color: var(--app-muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.45rem 0.6rem 0.2rem;
}

.app-menu-list .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.62rem 0.6rem;
    border-radius: 8px;
    font-weight: 600;
}

.app-menu-list .dropdown-item .nav-ic {
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
    color: var(--app-primary);
}

.app-menu-list .dropdown-item:active,
.app-menu-list .dropdown-item:active .nav-ic {
    color: #fff;
}

/* Méga-menu « Plus » : colonnes thématiques (opérationnel uniquement). */
.app-megamenu {
    min-width: 0;
    /* max-content = les colonnes se posent côte à côte ; borné à l'écran. */
    width: max-content;
    max-width: min(560px, calc(100vw - 1rem));
    padding: 0.6rem;
}

/* Menu du compte (administration) : liste unique, bornée en hauteur. */
.app-account-menu {
    max-height: min(80vh, 560px);
    overflow-y: auto;
}

.app-megamenu-cols {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
}

.app-megamenu-col {
    flex: 1 1 210px;
    min-width: 200px;
}

.app-megamenu .dropdown-header {
    padding-top: 0.35rem;
}

@media (max-width: 1199.98px) {
    .app-megamenu {
        width: 100%;
        max-width: none;
    }

    .app-megamenu-col {
        flex-basis: 100%;
    }
}

@media (max-width: 1199.98px) {
    .app-quicknav,
    .app-nav-right {
        width: 100%;
        margin-top: 0.5rem;
    }

    .app-quicknav .app-quick,
    .app-nav-right .app-cash-chip,
    .app-nav-right .app-user-menu {
        flex: 1 1 auto;
        justify-content: center;
    }

    .app-user-menu .app-user-toggle {
        width: 100%;
        justify-content: center;
    }
}

/* Barre d'actions du bas : visible sur mobile et tablette (sous xl). */
.app-bottomnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1035;
    display: flex;
    justify-content: space-around;
    gap: 0.25rem;
    padding: 0.35rem 0.4rem;
    padding-bottom: calc(0.35rem + env(safe-area-inset-bottom, 0px));
    background: rgba(23, 32, 38, 0.98);
    border-top: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 -8px 24px rgba(15, 20, 24, 0.22);
    backdrop-filter: blur(14px);
}

.app-bottom-item {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 52px;
    padding: 0.3rem 0.2rem;
    color: rgba(255, 255, 255, 0.7);
    background: transparent;
    border: 0;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.app-bottom-item .nav-ic {
    width: 24px;
    height: 24px;
}

.app-bottom-item:hover,
.app-bottom-item:focus,
.app-bottom-item.active {
    color: #fff;
}

.app-bottom-item.active .nav-ic {
    color: #46c7c9;
}

.app-bottom-primary .nav-ic {
    color: #46c7c9;
}

/* Espace pour ne pas masquer le contenu derriere la barre du bas. */
@media (max-width: 1199.98px) {
    .app-body.is-authenticated {
        padding-bottom: 64px;
    }
}

@media (min-width: 1200px) {
    .app-bottomnav {
        display: none !important;
    }
}

.app-footer {
    color: var(--app-muted);
    font-size: 0.82rem;
    padding: 0 0 1.2rem;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--app-text);
    font-weight: 800;
}

.text-muted {
    color: var(--app-muted) !important;
}

.app-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.35rem;
    padding: 1.15rem 1.25rem;
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid rgba(222, 216, 204, 0.82);
    border-radius: 8px;
    box-shadow: var(--app-shadow-soft);
    backdrop-filter: blur(12px);
}

.app-page-title {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.app-page-icon {
    display: inline-grid;
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    place-items: center;
    color: var(--app-primary-dark);
    background: var(--app-primary-soft);
    border: 1px solid rgba(12, 116, 118, 0.15);
    border-radius: 8px;
    font-weight: 900;
}

.app-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.55rem;
}

.app-header-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.header-stat {
    padding-left: 0.85rem;
    border-left: 3px solid var(--app-primary);
}

.header-stat-label {
    color: var(--app-muted);
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
}

.header-stat-value {
    color: var(--app-ink);
    font-size: 1.35rem;
    font-weight: 900;
    line-height: 1.2;
}

.app-panel,
.bg-white.border,
.card,
.modal-content,
.dropdown-menu {
    background: var(--app-surface) !important;
    border-color: var(--app-border-strong) !important;
    box-shadow: var(--app-shadow);
}

.app-panel {
    border: 1px solid var(--app-border);
    border-radius: 8px;
}

.app-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--app-border);
}

.app-toolbar {
    padding: 0.9rem;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(33, 35, 32, 0.05);
}

.rounded,
.card,
.modal-content,
.dropdown-menu,
.alert,
.form-control,
.form-select,
.input-group-text,
.btn {
    border-radius: 8px !important;
}

.table-responsive {
    scrollbar-width: thin;
    scrollbar-color: var(--app-border-strong) transparent;
}

.table {
    --bs-table-color: var(--app-text);
    --bs-table-hover-bg: #f4f8f6;
    margin-bottom: 0;
    font-size: 0.93rem;
}

.table > :not(caption) > * > * {
    padding: 0.84rem 0.9rem;
    border-bottom-color: #ece5da;
}

.table-light {
    --bs-table-bg: #f5f0e7;
    --bs-table-color: #4d514d;
}

.table thead th {
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody tr:last-child > * {
    border-bottom-width: 0;
}

.table strong {
    font-weight: 800;
}

.form-label {
    color: #3b403c;
    font-size: 0.86rem;
    font-weight: 800;
}

.form-control,
.form-select {
    border-color: #d1c8ba;
    background-color: rgba(255, 255, 255, 0.92);
}

.form-control:hover,
.form-select:hover {
    border-color: var(--app-border-strong);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 0.22rem rgba(12, 116, 118, 0.16);
}

.input-group-lg > .form-control,
.input-group-lg > .btn {
    min-height: 3.15rem;
}

.btn {
    border-width: 1px;
    font-weight: 800;
    box-shadow: none !important;
}

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

.btn-outline-primary {
    --bs-btn-color: var(--app-primary-dark);
    --bs-btn-border-color: rgba(12, 116, 118, 0.46);
    --bs-btn-hover-bg: var(--app-primary);
    --bs-btn-hover-border-color: var(--app-primary);
}

.btn-outline-secondary {
    --bs-btn-color: #4d514d;
    --bs-btn-border-color: #c7bcad;
    --bs-btn-hover-bg: #f0e8dc;
    --bs-btn-hover-border-color: #b9ad9c;
    --bs-btn-hover-color: #252a27;
}

.btn-outline-danger {
    --bs-btn-color: var(--app-danger);
    --bs-btn-border-color: rgba(179, 58, 47, 0.42);
    --bs-btn-hover-bg: var(--app-danger);
    --bs-btn-hover-border-color: var(--app-danger);
}

.badge {
    border-radius: 6px;
    font-weight: 800;
    padding: 0.45em 0.62em;
}

.text-bg-success {
    color: #fff !important;
    background-color: var(--app-success) !important;
}

.text-bg-warning {
    color: #3f2c0a !important;
    background-color: #f1bf5a !important;
}

.text-bg-danger {
    color: #fff !important;
    background-color: var(--app-danger) !important;
}

.alert {
    border-color: transparent;
    box-shadow: 0 10px 24px rgba(33, 35, 32, 0.06);
}

.alert-info {
    color: #134d4e;
    background: var(--app-primary-soft);
}

.alert-warning {
    color: #5f3b08;
    background: var(--app-accent-soft);
}

.alert-danger {
    color: var(--app-danger);
    background: #fff0ed;
}

.alert-success {
    color: #16533d;
    background: #e8f5ef;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.dashboard-metric-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric-card {
    min-height: 128px;
    padding: 1.05rem;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--app-shadow-soft);
}

.metric-label {
    color: var(--app-muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
}

.metric-value {
    margin-top: 0.45rem;
    color: var(--app-ink);
    font-size: 2rem;
    font-weight: 900;
    line-height: 1;
}

.metric-note {
    margin-top: 0.72rem;
    color: var(--app-muted);
    font-size: 0.86rem;
}

.recouvrement-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 767.98px) {
    .recouvrement-metrics {
        grid-template-columns: 1fr;
    }
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
}

.dashboard-quick-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quick-action {
    display: block;
    min-height: 138px;
    padding: 1.05rem;
    color: var(--app-text);
    text-decoration: none;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(250, 247, 241, 0.95));
    box-shadow: var(--app-shadow-soft);
}

.quick-action:hover,
.quick-action:focus {
    color: var(--app-text);
    border-color: rgba(12, 116, 118, 0.34);
    transform: translateY(-1px);
}

.quick-action-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--app-primary-dark), var(--app-primary));
    border-color: rgba(12, 116, 118, 0.44);
}

.quick-action-primary:hover,
.quick-action-primary:focus {
    color: #fff;
}

.quick-action-primary span,
.quick-action-primary strong {
    color: #fff;
}

.quick-action strong {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 1.02rem;
}

.quick-action span {
    color: var(--app-muted);
    font-size: 0.9rem;
}

.metric-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.metric-icon,
.quick-action-icon {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    color: var(--app-primary-dark);
    background: var(--app-primary-soft);
    border-radius: 11px;
}

.metric-icon .nav-ic,
.quick-action-icon .nav-ic {
    width: 22px;
    height: 22px;
}

.metric-card .metric-value {
    margin-top: 0.7rem;
}

.metric-accent-green .metric-icon {
    color: #0f6e56;
    background: rgba(29, 158, 117, 0.14);
}

.metric-accent-red .metric-icon {
    color: #a32d2d;
    background: rgba(226, 75, 74, 0.13);
}

.metric-accent-amber .metric-icon {
    color: #854f0b;
    background: rgba(186, 117, 23, 0.16);
}

.quick-action-icon {
    margin-bottom: 0.7rem;
}

.quick-action-primary .quick-action-icon {
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
}

.dashboard-kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.metric-link {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.metric-link:hover,
.metric-link:focus {
    color: inherit;
    border-color: rgba(12, 116, 118, 0.34);
    transform: translateY(-1px);
}

.panel-icon {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    color: var(--app-primary-dark);
    background: var(--app-primary-soft);
    border-radius: 9px;
}

.panel-icon .nav-ic {
    width: 18px;
    height: 18px;
}

.panel-icon-warn {
    color: #854f0b;
    background: rgba(186, 117, 23, 0.16);
}

.panel-icon-accent {
    color: #0f6e56;
    background: rgba(29, 158, 117, 0.14);
}

/* Dashboard (accueil comptoir) — bandeau et cartes KPI dediees pour la presentation. */
.dashboard-hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--app-primary-dark) 0%, var(--app-primary) 70%, #0a8385 100%);
    border-color: transparent;
    box-shadow: 0 18px 40px rgba(7, 89, 91, 0.28);
}

.dashboard-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle at 92% -10%, rgba(255, 255, 255, 0.16), transparent 55%);
    pointer-events: none;
}

.dashboard-hero .app-page-icon {
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.24);
}

.dashboard-hero h1 {
    color: #fff;
}

.dashboard-hero-date {
    color: rgba(255, 255, 255, 0.82);
    font-weight: 600;
}

.btn-hero-primary {
    color: var(--app-primary-dark);
    font-weight: 800;
    background: #fff;
    border: 1px solid #fff;
}

.btn-hero-primary:hover,
.btn-hero-primary:focus {
    color: var(--app-primary-dark);
    background: rgba(255, 255, 255, 0.9);
}

.btn-hero-outline {
    color: #fff;
    font-weight: 800;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.55);
}

.btn-hero-outline:hover,
.btn-hero-outline:focus {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    border-color: #fff;
}

.dashboard-kpi-grid .metric-card {
    position: relative;
    overflow: hidden;
    animation: dashboard-card-in 0.45s ease both;
}

.dashboard-kpi-grid .metric-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--app-primary);
}

.dashboard-kpi-grid .metric-accent-green::before {
    background: #1d9e75;
}

.dashboard-kpi-grid .metric-accent-red::before {
    background: var(--app-danger);
}

.dashboard-kpi-grid .metric-accent-amber::before {
    background: var(--app-accent);
}

.dashboard-kpi-grid .metric-card:nth-child(1) { animation-delay: 0.02s; }
.dashboard-kpi-grid .metric-card:nth-child(2) { animation-delay: 0.08s; }
.dashboard-kpi-grid .metric-card:nth-child(3) { animation-delay: 0.14s; }
.dashboard-kpi-grid .metric-card:nth-child(4) { animation-delay: 0.2s; }
.dashboard-kpi-grid .metric-card:nth-child(5) { animation-delay: 0.26s; }
.dashboard-kpi-grid .metric-card:nth-child(6) { animation-delay: 0.32s; }

@keyframes dashboard-card-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.metric-trend {
    display: inline-block;
    margin-left: 0.4rem;
    font-weight: 800;
}

.metric-trend-up {
    color: #0f6e56;
}

.metric-trend-down {
    color: #a32d2d;
}

.app-management-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.sale-search-panel {
    position: relative;
}

#productResults {
    position: absolute;
    right: 1rem;
    left: 1rem;
    z-index: 20;
    overflow: hidden;
    border: 1px solid var(--app-border-strong);
    border-radius: 8px;
    box-shadow: var(--app-shadow);
}

#productResults .list-group-item {
    border-color: #eee6da;
}

.client-picker {
    position: relative;
}

.client-picker #clientResults {
    position: absolute;
    right: 0;
    left: 0;
    z-index: 21;
    overflow: hidden;
    margin-top: 0.45rem;
    border: 1px solid var(--app-border-strong);
    border-radius: 8px;
    box-shadow: var(--app-shadow);
}

.client-result-item {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
}

.client-modal-results {
    margin-top: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-shadow: var(--app-shadow-soft);
}

.selected-client-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 56px;
    padding: 0.55rem 0.6rem 0.55rem 0.78rem;
    background: #f8f4ec;
    border: 1px solid var(--app-border);
    border-radius: 8px;
}

.selected-client-main {
    min-width: 0;
}

.selected-client-card strong {
    display: block;
    overflow: hidden;
    max-width: 18rem;
    color: var(--app-text);
    font-size: 1rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selected-client-balance {
    display: block;
    margin-top: 1px;
    font-size: 0.78rem;
    font-weight: 800;
}

.selected-client-balance.is-debit {
    color: var(--app-danger);
}

.selected-client-balance.is-credit {
    color: var(--app-success);
}

.selected-client-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 0.4rem;
}

.client-modal .modal-header {
    align-items: flex-start;
}

.client-profile {
    overflow: hidden;
}

.client-profile-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
    gap: 1rem;
    align-items: stretch;
    padding: 1.1rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(248, 244, 236, 0.96));
}

.client-profile-main {
    display: flex;
    min-width: 0;
    gap: 1rem;
    align-items: center;
}

.client-avatar {
    display: inline-grid;
    width: 104px;
    height: 104px;
    flex: 0 0 auto;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--app-primary-dark), var(--app-accent));
    border: 1px solid rgba(23, 32, 38, 0.08);
    border-radius: 8px;
    font-size: 2.25rem;
    font-weight: 900;
}

.client-profile-info {
    min-width: 0;
}

.client-status-row,
.client-contact-line {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem 1rem;
    align-items: center;
}

.client-profile-info h2 {
    margin: 0.35rem 0 0.65rem;
    color: var(--app-primary-dark);
    font-size: 2.35rem;
    line-height: 1.05;
    overflow-wrap: anywhere;
}

.client-contact-line {
    color: var(--app-muted);
    font-size: 0.95rem;
}

.client-contact-line strong {
    color: var(--app-text);
}

.client-profile-side {
    display: grid;
    gap: 0.75rem;
}

.client-identity-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

.client-identity-grid > div {
    min-height: 66px;
    padding: 0.75rem;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
}

.client-identity-grid span,
.client-balance span {
    display: block;
    color: var(--app-muted);
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
}

.client-identity-grid strong {
    display: block;
    margin-top: 0.25rem;
    overflow-wrap: anywhere;
}

.client-balance {
    padding: 1rem;
    color: var(--app-text);
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
}

.client-balance strong {
    display: block;
    margin-top: 0.3rem;
    font-size: 2rem;
    font-weight: 900;
    line-height: 1;
}

.client-balance small {
    display: block;
    margin-top: 0.45rem;
    color: var(--app-muted);
    font-weight: 800;
}

.client-balance.is-debit strong {
    color: var(--app-danger);
}

.client-balance.is-credit strong {
    color: var(--app-success);
}

.client-quick-pay {
    padding: 1rem 1.1rem 1.1rem;
    border-top: 1px solid var(--app-border);
}

.client-quick-pay-form {
    display: grid;
    grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
    gap: 0.8rem;
    align-items: end;
}

.client-payment-buttons {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.55rem;
}

.client-payment-buttons .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 48px;
    white-space: normal;
}

.client-payment-buttons .btn .nav-ic {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.client-quick-pay-note {
    padding: 0.85rem 1rem;
    color: #134d4e;
    background: var(--app-primary-soft);
    border-radius: 8px;
    font-weight: 800;
}

.client-lines-cell {
    max-width: 34rem;
    color: #3d433f;
    font-size: 0.86rem;
    line-height: 1.35;
}

.client-metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.sale-table td {
    vertical-align: middle;
}

.sale-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.sale-table th:nth-child(1),
.sale-table td:nth-child(1) {
    width: 29%;
}

.sale-table th:nth-child(2),
.sale-table td:nth-child(2) {
    width: 12%;
}

.sale-table th:nth-child(3),
.sale-table td:nth-child(3) {
    width: 18%;
}

.sale-table th:nth-child(4),
.sale-table td:nth-child(4),
.sale-table th:nth-child(5),
.sale-table td:nth-child(5),
.sale-table th:nth-child(6),
.sale-table td:nth-child(6) {
    width: 10%;
}

.sale-table th:nth-child(7),
.sale-table td:nth-child(7) {
    width: 11%;
}

.sale-input {
    width: 100%;
    min-width: 0;
    text-align: left;
}

.sale-quantity-cell {
    min-width: 0;
}

.quantity-stepper {
    display: grid;
    grid-template-columns: 30px minmax(64px, 1fr) 30px;
    gap: 0.3rem;
    align-items: center;
}

.quantity-stepper .btn {
    width: 30px;
    height: 34px;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
}

.quantity-stepper .quantity-input {
    min-width: 0;
}

.sale-input[type="number"] {
    appearance: textfield;
}

.sale-input[type="number"]::-webkit-outer-spin-button,
.sale-input[type="number"]::-webkit-inner-spin-button {
    margin: 0;
    appearance: none;
}

.delivery-choices,
.delivery-more-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.delivery-more-panel {
    margin-top: 0.6rem;
}

.delivery-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 13rem;
    padding: 0.6rem 0.9rem;
    border: 1.5px solid var(--app-border);
    border-radius: 0.85rem;
    background: var(--app-surface);
    color: var(--app-text);
    text-align: left;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.delivery-chip:hover {
    border-color: var(--app-border-strong);
    background: var(--app-surface-2);
}

.delivery-chip:focus-visible {
    outline: none;
    border-color: var(--app-primary);
    box-shadow: 0 0 0 3px rgba(12, 116, 118, 0.18);
}

.delivery-chip.is-active {
    border-color: var(--app-primary);
    background: var(--app-primary-soft);
    box-shadow: var(--app-shadow-soft);
}

.delivery-chip-ic {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 0.7rem;
    background: var(--app-primary-soft);
    color: var(--app-primary);
}

.delivery-chip-ic .nav-ic {
    width: 22px;
    height: 22px;
}

.delivery-chip-ic-store {
    background: var(--app-accent-soft);
    color: var(--app-accent);
}

.delivery-chip.is-active .delivery-chip-ic {
    background: var(--app-primary);
    color: #fff;
}

.delivery-chip.is-active .delivery-chip-ic-store {
    background: var(--app-accent);
    color: #fff;
}

.delivery-chip-body {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.delivery-chip-title {
    font-weight: 600;
}

.delivery-chip-sub {
    font-size: 0.8rem;
    color: var(--app-muted);
}

.delivery-chip-more {
    border-style: dashed;
}

.delivery-chip-more.is-open .delivery-chip-ic {
    background: var(--app-primary);
    color: #fff;
}

@media (max-width: 575.98px) {
    .delivery-chip {
        min-width: 100%;
    }
}

.sale-summary {
    position: sticky;
    top: 5.6rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(250, 247, 241, 0.96)) !important;
}

.sale-total-box {
    padding: 1rem;
    color: #fff;
    background: linear-gradient(135deg, var(--app-ink), var(--app-primary-dark));
    border-radius: 8px;
}

.sale-total-box span,
.sale-total-box strong {
    color: #fff;
}

.audit-detail-cell {
    max-width: 22rem;
}

.audit-detail-cell summary {
    cursor: pointer;
    font-size: 0.85rem;
}

.audit-detail-body {
    margin-top: 0.35rem;
    padding: 0.5rem 0.65rem;
    font-size: 0.82rem;
    line-height: 1.4;
    word-break: break-word;
    background: #f8f4ec;
    border: 1px solid var(--app-border);
    border-radius: 8px;
}

.login-shell {
    min-height: calc(100vh - 11rem);
    display: grid;
    align-items: center;
}

.login-card {
    overflow: hidden;
}

.login-card-header {
    padding: 1.2rem;
    color: #fff;
    background:
        linear-gradient(135deg, rgba(23, 32, 38, 0.98), rgba(12, 116, 118, 0.92)),
        var(--app-ink);
}

.modal-header {
    background: #fbfaf7;
    border-bottom-color: var(--app-border);
}

.modal-body {
    background: #fffdf9;
}

.product-catalog-dialog {
    --bs-modal-width: min(1420px, calc(100vw - 3rem));
}

.product-catalog-modal {
    overflow: hidden;
}

.product-catalog-modal .modal-header {
    align-items: flex-start;
    padding: 1.15rem 1.25rem;
}

.product-catalog-modal .modal-header .text-muted {
    margin-top: 0.18rem;
    font-size: 0.9rem;
}

.product-catalog-modal .modal-body {
    padding: 1rem 1.25rem 1.25rem;
}

.catalog-filter-bar {
    padding: 0.9rem;
    background: #f8f4ec;
    border: 1px solid var(--app-border);
    border-radius: 8px;
}

.catalog-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 0.65rem;
}

.product-catalog-table-wrap {
    max-height: min(58vh, 560px);
    overflow: auto;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
}

.product-catalog-table {
    min-width: 1040px;
    table-layout: fixed;
}

.product-catalog-table > :not(caption) > * > * {
    padding: 0.72rem 0.78rem;
}

.product-catalog-table thead th {
    position: sticky;
    top: 0;
    z-index: 4;
    background: #f1ebdf;
    box-shadow: inset 0 -1px 0 var(--app-border);
}

.product-catalog-table th:nth-child(1),
.product-catalog-table td:nth-child(1) {
    width: 14%;
}

.product-catalog-table th:nth-child(2),
.product-catalog-table td:nth-child(2) {
    width: 24%;
}

.product-catalog-table th:nth-child(3),
.product-catalog-table td:nth-child(3) {
    width: 9%;
}

.product-catalog-table th:nth-child(4),
.product-catalog-table td:nth-child(4) {
    width: 7%;
}

.product-catalog-table th:nth-child(5),
.product-catalog-table td:nth-child(5),
.product-catalog-table th:nth-child(6),
.product-catalog-table td:nth-child(6),
.product-catalog-table th:nth-child(7),
.product-catalog-table td:nth-child(7),
.product-catalog-table th:nth-child(8),
.product-catalog-table td:nth-child(8) {
    width: 8%;
}

.product-catalog-table th:nth-child(9),
.product-catalog-table td:nth-child(9) {
    width: 12%;
}

.product-catalog-table th:last-child {
    position: sticky;
    right: 0;
    z-index: 6;
    background: #f1ebdf;
    box-shadow: -10px 0 16px rgba(33, 35, 32, 0.06), inset 0 -1px 0 var(--app-border);
}

.catalog-ref strong,
.catalog-product-name strong {
    overflow-wrap: anywhere;
}

.catalog-ref small {
    display: block;
    margin-top: 0.22rem;
}

.catalog-actions-cell {
    position: sticky;
    right: 0;
    z-index: 2;
    background: #fff;
    box-shadow: -10px 0 16px rgba(33, 35, 32, 0.05);
}

.product-catalog-table tbody tr:hover .catalog-actions-cell {
    background: var(--bs-table-hover-bg);
}

.product-catalog-table thead .catalog-actions-cell,
.product-catalog-table thead th:last-child {
    z-index: 5;
}

.catalog-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.35rem;
    min-width: 104px;
}

.catalog-actions .btn {
    min-height: 32px;
    padding: 0.3rem 0.55rem;
    font-size: 0.78rem;
    line-height: 1.15;
    white-space: nowrap;
}

.catalog-actions .btn-outline-primary {
    background: #fff;
}

.catalog-add-warning {
    --bs-btn-bg: var(--app-danger);
    --bs-btn-border-color: var(--app-danger);
    --bs-btn-hover-bg: #8f2d25;
    --bs-btn-hover-border-color: #8f2d25;
}

.catalog-warning-icon {
    display: inline-grid;
    width: 1rem;
    height: 1rem;
    place-items: center;
    margin-right: 0.25rem;
    color: var(--app-danger);
    background: #fff;
    border-radius: 50%;
    font-size: 0.72rem;
    font-weight: 900;
}

@media (max-width: 1199.98px) {
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .quick-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-metric-grid,
    .dashboard-quick-actions,
    .client-metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .client-profile-header {
        grid-template-columns: 1fr;
    }

    .client-quick-pay-form,
    .client-payment-buttons {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sale-summary {
        position: static;
    }
}

@media (max-width: 767.98px) {
    .app-main {
        padding-right: 0.85rem;
        padding-left: 0.85rem;
    }

    .app-page-header {
        padding: 1rem;
    }

    .app-page-title {
        align-items: flex-start;
    }

    .app-actions,
    .app-actions .btn {
        width: 100%;
    }

    .metric-grid,
    .quick-actions,
    .client-metric-grid {
        grid-template-columns: 1fr;
    }

    .metric-card,
    .quick-action {
        min-height: auto;
    }

    #productResults {
        position: static;
        margin-top: 0.75rem;
    }

    #clientResults {
        position: static;
    }

    .selected-client-card {
        align-items: stretch;
        flex-direction: column;
    }

    .selected-client-actions,
    .selected-client-actions .btn {
        width: 100%;
    }

    .client-profile-header {
        padding: 0.9rem;
    }

    .client-profile-main {
        align-items: stretch;
        flex-direction: column;
    }

    .client-avatar {
        width: 72px;
        height: 72px;
        font-size: 1.45rem;
    }

    .client-profile-info h2 {
        font-size: 1.65rem;
    }

    .client-identity-grid,
    .client-quick-pay-form,
    .client-payment-buttons {
        grid-template-columns: 1fr;
    }

    .sale-table {
        min-width: 860px;
    }

    .product-catalog-dialog {
        --bs-modal-width: calc(100vw - 1rem);
        margin-right: 0.5rem;
        margin-left: 0.5rem;
    }

    .product-catalog-modal .modal-body {
        padding: 0.85rem;
    }

    .catalog-status-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .catalog-status-bar .btn {
        width: 100%;
    }
}
