/* RealStock — design system */
:root {
    --rs-ink: #0b1220;
    --rs-ink-soft: #152033;
    --rs-slate: #64748b;
    --rs-mist: #eef2f7;
    --rs-surface: #ffffff;
    --rs-line: rgba(15, 23, 42, 0.08);
    --rs-accent: #0f9d8a;
    --rs-accent-deep: #0b7a6b;
    --rs-accent-soft: rgba(15, 157, 138, 0.12);
    --rs-warn: #d97706;
    --rs-danger: #dc2626;
    --rs-radius: 14px;
    --rs-radius-sm: 10px;
    --rs-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    --rs-shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.12);
    --rs-sidebar-w: 260px;
    --rs-sidebar-w-collapsed: 72px;
    --rs-topbar-h: 64px;
    --rs-font: "Manrope", system-ui, sans-serif;
    --rs-display: "Sora", "Manrope", system-ui, sans-serif;
    --bs-primary: #0f9d8a;
    --bs-primary-rgb: 15, 157, 138;
    --bs-link-color: #0b7a6b;
    --bs-link-hover-color: #086257;
    --bs-border-radius: 10px;
    --bs-border-radius-lg: 14px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--rs-font);
    color: var(--rs-ink);
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(15, 157, 138, 0.12), transparent 55%),
        radial-gradient(900px 500px at 100% 0%, rgba(37, 99, 235, 0.08), transparent 50%),
        linear-gradient(180deg, #f4f7fb 0%, var(--rs-mist) 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: rgba(15, 157, 138, 0.15);
}

body.sidebar-locked {
    overflow: hidden;
}

h1, h2, h3, h4, .page-title, .brand-wordmark {
    font-family: var(--rs-display);
    letter-spacing: -0.02em;
}

a {
    text-decoration: none;
}

/* ---------- App shell ---------- */
.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: clip;
    display: flex;
    flex-direction: column;
}

.auth-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.auth-shell > .login-page {
    flex: 1 1 auto;
    min-height: 0;
}

/* ---------- Footer ---------- */
.app-footer {
    margin-top: auto;
    border-top: 1px solid var(--rs-line);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(10px);
    padding: 0.85rem 1.25rem;
    padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
}

.app-shell .app-footer {
    margin-left: var(--rs-sidebar-w);
    transition: margin-left 0.2s ease;
}

body.sidebar-collapsed .app-shell .app-footer {
    margin-left: var(--rs-sidebar-w-collapsed);
}

.app-footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem 1.25rem;
    max-width: 1100px;
    margin: 0 auto;
}

.app-footer-copy {
    margin: 0;
    font-size: 0.86rem;
    color: var(--rs-slate);
}

.app-footer-copy strong {
    color: var(--rs-ink);
    font-weight: 700;
}

.app-footer-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.86rem;
}

.app-footer-nav a {
    color: var(--rs-slate);
    font-weight: 600;
}

.app-footer-nav a:hover {
    color: var(--rs-accent-deep);
}

.app-footer-sep {
    color: #94a3b8;
}

.legal-public {
    flex: 1 1 auto;
    width: min(820px, 100%);
    margin: 0 auto;
    padding: 2rem 1.25rem 2.5rem;
}

.legal-doc-head {
    margin-bottom: 1.25rem;
}

.legal-doc-body {
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--rs-line);
    border-radius: var(--rs-radius);
    box-shadow: var(--rs-shadow);
    padding: 1.5rem 1.6rem 1.75rem;
    line-height: 1.65;
    color: #334155;
}

.legal-doc-body h2 {
    margin: 1.5rem 0 0.55rem;
    font-size: 1.05rem;
    color: var(--rs-ink);
}

.legal-doc-body p,
.legal-doc-body ul {
    margin: 0 0 0.75rem;
}

.legal-doc-body ul {
    padding-left: 1.2rem;
}

.legal-doc-body li + li {
    margin-top: 0.25rem;
}

.app-topbar {
    height: var(--rs-topbar-h);
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--rs-line);
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    padding-left: max(1.25rem, env(safe-area-inset-left));
    padding-right: max(1.25rem, env(safe-area-inset-right));
    gap: 1rem;
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--rs-ink);
    font-family: var(--rs-display);
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 0;
    text-decoration: none;
}

.app-brand-logo {
    display: block;
    background: transparent;
    height: 40px;
    width: auto;
    max-width: min(220px, 48vw);
    object-fit: contain;
    object-position: left center;
}

.app-brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(145deg, var(--rs-accent) 0%, #0b6e8a 100%);
    box-shadow: 0 8px 18px rgba(15, 157, 138, 0.28);
}

.app-topbar-spacer {
    flex: 1;
}

/* ---------- Notifications ---------- */
.app-notif-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--rs-line);
    background: #fff;
    color: var(--rs-ink);
    display: grid;
    place-items: center;
    font-size: 1.15rem;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.app-notif-btn:hover {
    background: #f8fafc;
    border-color: rgba(15, 23, 42, 0.16);
    transform: translateY(-1px);
}

.app-notif.has-alerts .app-notif-btn {
    border-color: rgba(220, 38, 38, 0.35);
    color: var(--rs-danger);
}

.app-notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--rs-danger);
    color: #fff;
    border: 2px solid #fff;
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.app-notif-menu {
    width: 340px;
    max-width: calc(100vw - 1.5rem);
    padding: 0;
    margin-top: 0.6rem;
    border: 1px solid var(--rs-line);
    border-radius: var(--rs-radius);
    box-shadow: var(--rs-shadow-lg);
    overflow: hidden;
}

.app-notif-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    font-family: var(--rs-display);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--rs-ink);
    border-bottom: 1px solid var(--rs-line);
    background: linear-gradient(180deg, rgba(217, 119, 6, 0.08) 0%, transparent 100%);
}

.app-notif-head i {
    color: var(--rs-warn);
}

.app-notif-count {
    margin-left: auto;
    min-width: 22px;
    padding: 0 6px;
    height: 20px;
    border-radius: 999px;
    background: var(--rs-danger);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.app-notif-list {
    max-height: 360px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.app-notif-demandes {
    max-height: 180px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.app-notif-demande {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 1rem;
    border: 0;
    border-bottom: 1px solid var(--rs-line);
    background: #fff;
    color: var(--rs-ink);
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.app-notif-demande:hover {
    background: #f8fafc;
}

.app-notif-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--rs-line);
    color: var(--rs-ink);
    transition: background 0.15s ease;
}

.app-notif-item:last-child {
    border-bottom: none;
}

.app-notif-item:hover {
    background: #f8fafc;
}

.app-notif-item-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    background: rgba(217, 119, 6, 0.12);
    color: var(--rs-warn);
    font-size: 1rem;
}

.app-notif-item.is-critical .app-notif-item-icon {
    background: rgba(220, 38, 38, 0.12);
    color: var(--rs-danger);
}

.app-notif-item-body {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.app-notif-item-name {
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-notif-item-meta {
    font-size: 0.76rem;
    color: var(--rs-slate);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-notif-item-qty {
    flex-shrink: 0;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--rs-warn);
}

.app-notif-item.is-critical .app-notif-item-qty {
    color: var(--rs-danger);
}

.app-notif-item-qty small {
    color: var(--rs-slate);
    font-weight: 600;
    font-size: 0.72rem;
}

.app-notif-empty,
.app-notif-loader {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--rs-slate);
    font-size: 0.85rem;
}

.app-notif-empty i {
    color: var(--rs-accent);
}

.app-notif-loader {
    padding: 0.9rem 1rem;
    border-top: 1px solid var(--rs-line);
}

/* ---------- Menu utilisateur ---------- */
.app-user {
    position: relative;
}

.app-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--rs-accent-soft);
    color: var(--rs-accent-deep);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    flex-shrink: 0;
}

.app-user-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.3rem 0.6rem 0.3rem 0.3rem;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 999px;
    color: var(--rs-ink);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.app-user-trigger:hover,
.app-user-trigger[aria-expanded="true"] {
    background: #f8fafc;
    border-color: var(--rs-line);
}

.app-user-name {
    white-space: nowrap;
}

.app-user-identity {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    min-width: 0;
    line-height: 1.15;
}

.app-user-context {
    max-width: 190px;
    overflow: hidden;
    color: var(--rs-slate);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.app-user-caret {
    font-size: 0.75rem;
    color: var(--rs-slate);
    transition: transform 0.2s ease;
}

.app-user-trigger[aria-expanded="true"] .app-user-caret {
    transform: rotate(180deg);
}

.app-user-menu {
    min-width: 260px;
    padding: 0;
    margin-top: 0.6rem;
    border: 1px solid var(--rs-line);
    border-radius: var(--rs-radius);
    box-shadow: var(--rs-shadow-lg);
    overflow: hidden;
}

.app-user-menu-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.25rem;
    padding: 1.25rem 1rem 1rem;
    background: linear-gradient(180deg, var(--rs-accent-soft) 0%, transparent 100%);
}

.app-user-avatar-lg {
    width: 64px;
    height: 64px;
    font-size: 1.4rem;
    margin-bottom: 0.35rem;
    background: linear-gradient(145deg, var(--rs-accent) 0%, #0b6e8a 100%);
    color: #fff;
    box-shadow: 0 8px 18px rgba(15, 157, 138, 0.28);
}

.app-user-menu-name {
    font-family: var(--rs-display);
    font-weight: 700;
    font-size: 1.02rem;
    color: var(--rs-ink);
}

.app-user-menu-email {
    font-size: 0.82rem;
    color: var(--rs-slate);
    word-break: break-all;
}

.app-user-menu-role {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--rs-ink);
}

.app-user-menu .dropdown-item i {
    font-size: 1rem;
    color: var(--rs-slate);
    width: 1.1rem;
    text-align: center;
}

.app-user-menu .dropdown-item:hover,
.app-user-menu .dropdown-item:focus {
    background: #f8fafc;
    color: var(--rs-ink);
}

.app-user-menu .dropdown-item.text-danger i {
    color: var(--rs-danger);
}

.app-user-menu .dropdown-item.text-danger:hover,
.app-user-menu .dropdown-item.text-danger:focus {
    background: rgba(220, 38, 38, 0.08);
    color: var(--rs-danger);
}

.app-badge-super {
    color: #422006;
    border: none;
    font-weight: 700;
    font-size: 0.68rem;
    letter-spacing: 0.02em;
    padding: 0px;
}

.app-layout {
    display: grid;
    grid-template-columns: var(--rs-sidebar-w) minmax(0, 1fr);
    flex: 1 1 auto;
    min-height: 0;
}

.app-sidebar {
    background: linear-gradient(180deg, var(--rs-ink) 0%, var(--rs-ink-soft) 100%);
    color: #cbd5e1;
    padding: 1.1rem 0.75rem 2rem;
    position: sticky;
    top: var(--rs-topbar-h);
    height: calc(100vh - var(--rs-topbar-h));
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.app-sidebar .nav {
    gap: 0.15rem;
}

.app-sidebar .nav-header {
    display: block;
    margin: 1.1rem 0 0.35rem;
    padding: 0 0.85rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}

.app-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: #cbd5e1;
    border-radius: 10px;
    margin: 0.08rem 0.25rem;
    padding: 0.62rem 0.85rem;
    font-weight: 600;
    font-size: 0.92rem;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.app-sidebar .nav-link i {
    font-size: 1.05rem;
    opacity: 0.9;
    width: 1.2rem;
    text-align: center;
}

.app-sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    transform: translateX(2px);
}

.app-sidebar .nav-link.active {
    background: linear-gradient(135deg, rgba(15, 157, 138, 0.95), rgba(11, 110, 138, 0.95));
    color: #fff;
    box-shadow: 0 8px 20px rgba(15, 157, 138, 0.25);
}

.app-main {
    padding: 1.15rem 1.75rem 2rem;
    animation: rs-fade-in 0.45s ease both;
    min-width: 0;
    max-width: 100%;
}

.app-context-strip {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    color: var(--rs-slate);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1.2;
}

.app-context-strip .bi {
    font-size: 0.85rem;
    color: var(--rs-accent, currentColor);
}

.app-context-strip-agence {
    color: var(--rs-ink);
}

.app-context-strip-sep {
    opacity: 0.5;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.65rem;
    flex-wrap: wrap;
}

.page-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--rs-ink);
}

.page-subtitle {
    margin: 0.15rem 0 0;
    color: var(--rs-slate);
    font-size: 0.82rem;
    line-height: 1.3;
}

.btn-text-link,
.page-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    color: var(--rs-slate);
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
}

.btn-text-link:hover,
.btn-text-link:focus,
.page-back-link:hover,
.page-back-link:focus {
    color: var(--rs-accent-deep);
    background: transparent;
    border: none;
    box-shadow: none;
    text-decoration: none;
}

.btn-text-link-success {
    color: #059669;
}

.btn-text-link-success:hover,
.btn-text-link-success:focus {
    color: #047857;
}

.btn-text-link-danger {
    color: var(--rs-danger);
}

.btn-text-link-danger:hover,
.btn-text-link-danger:focus {
    color: #b91c1c;
}

.page-header > a.btn-outline-secondary {
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    color: var(--rs-slate);
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.2;
}

.page-header > a.btn-outline-secondary:hover,
.page-header > a.btn-outline-secondary:focus {
    color: var(--rs-accent-deep);
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

/* ---------- Components ---------- */
.card {
    border: 1px solid var(--rs-line);
    border-radius: var(--rs-radius);
    box-shadow: var(--rs-shadow);
    background: var(--rs-surface);
    overflow: hidden;
}

.card.shadow-sm {
    box-shadow: var(--rs-shadow);
}

.card-header {
    background: rgba(248, 250, 252, 0.9);
    border-bottom: 1px solid var(--rs-line);
    font-family: var(--rs-display);
    font-weight: 600;
}

.table {
    --bs-table-hover-bg: rgba(15, 157, 138, 0.04);
    margin-bottom: 0;
}

.table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--rs-slate);
    font-weight: 700;
    border-bottom-width: 1px;
    background: #f8fafc !important;
    white-space: nowrap;
}

.table > :not(caption) > * > * {
    padding: 0.9rem 1rem;
    vertical-align: middle;
}

.reference-format-column {
    min-width: 28rem;
}

.table code {
    background: #f1f5f9;
    color: #0f172a;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    font-size: 0.85em;
}

.badge {
    font-weight: 600;
    letter-spacing: 0.01em;
    border-radius: 999px;
    padding: 0.35em 0.65em;
}

.btn {
    font-weight: 600;
    border-radius: 10px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    --bs-btn-bg: var(--rs-accent);
    --bs-btn-border-color: var(--rs-accent);
    --bs-btn-hover-bg: var(--rs-accent-deep);
    --bs-btn-hover-border-color: var(--rs-accent-deep);
    --bs-btn-active-bg: var(--rs-accent-deep);
    --bs-btn-active-border-color: var(--rs-accent-deep);
    box-shadow: 0 8px 18px rgba(15, 157, 138, 0.22);
}

.btn-outline-primary {
    --bs-btn-color: var(--rs-accent-deep);
    --bs-btn-border-color: rgba(15, 157, 138, 0.45);
    --bs-btn-hover-bg: var(--rs-accent);
    --bs-btn-hover-border-color: var(--rs-accent);
    --bs-btn-hover-color: #fff;
}

.btn-outline-secondary,
.btn-outline-danger {
    background: #fff;
}

.form-control,
.form-select {
    border-radius: 10px;
    border-color: rgba(15, 23, 42, 0.12);
    padding: 0.65rem 0.85rem;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.form-control-sm,
.form-select-sm {
    border-radius: 10px;
    padding: 0.35rem 0.65rem;
    font-size: 0.875rem;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(15, 157, 138, 0.55);
    box-shadow: 0 0 0 0.22rem rgba(15, 157, 138, 0.15);
}

.form-label {
    font-weight: 600;
    font-size: 0.88rem;
    color: #334155;
}

.alert {
    border: none;
    border-radius: 12px;
    box-shadow: var(--rs-shadow);
}

.messages-zone {
    margin-bottom: 1rem;
}

.messages-zone--toast {
    position: fixed;
    top: calc(var(--rs-topbar-h, 56px) + 0.75rem);
    right: 1rem;
    left: auto;
    width: min(420px, calc(100vw - 2rem));
    z-index: 2000;
    margin: 0;
    pointer-events: none;
}

.messages-zone--toast .alert {
    pointer-events: auto;
    margin-bottom: 0.5rem;
    animation: rs-toast-in 0.35s ease both;
}

.messages-zone--toast .alert.is-hiding {
    opacity: 0;
    transform: translateX(12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

body:not(:has(.app-shell)) .messages-zone--toast {
    top: 1rem;
    left: 1rem;
    right: 1rem;
    width: auto;
    max-width: 420px;
    margin-inline: auto;
}

@keyframes rs-toast-in {
    from {
        opacity: 0;
        transform: translateX(16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.app-caisse-bar {
    margin-bottom: 0.65rem;
    border-radius: var(--rs-radius-sm);
    font-size: 0.85rem;
}

.app-caisse-bar-inner {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.45rem 0.75rem;
}

.app-caisse-bar-open {
    background: var(--rs-accent-soft);
    border: 1px solid rgba(15, 157, 138, 0.25);
}

.app-caisse-bar-closed {
    background: #fff7ed;
    border: 1px solid #fed7aa;
}

.app-caisse-bar-warn {
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.app-caisse-bar-icon {
    color: var(--rs-accent-deep);
}

/* Détail caisse : colonnes mouvements / sous-caisses */
.caisse-detail-split .caisse-mvt-row.is-active,
.caisse-detail-split .btn-voir-mouvements.is-active {
    background: var(--rs-accent-soft);
    border-color: rgba(15, 157, 138, 0.2);
}

.caisse-detail-split .caisse-sub-row {
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
}

.caisse-detail-split .caisse-mvt-row {
    cursor: pointer;
}

.caisse-detail-split .list-group-item {
    border-inline: none;
}

.caisse-fil {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    color: var(--rs-muted, #64748b);
}

.caisse-fil-link {
    color: inherit;
    text-decoration: none;
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.caisse-fil-link:hover {
    color: var(--rs-accent-deep, #0f9d8a);
    text-decoration: underline;
}

.caisse-fil-sep {
    opacity: 0.55;
    user-select: none;
}

.caisse-fil-current {
    color: var(--rs-ink, #0f172a);
    font-weight: 600;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.caisse-chemin {
    line-height: 1.35;
}

/* KPI cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    position: relative;
    overflow: hidden;
    border-radius: var(--rs-radius);
    padding: 1.15rem 1.2rem;
    color: #fff;
    min-height: 118px;
    box-shadow: var(--rs-shadow);
    animation: rs-fade-up 0.5s ease both;
}

.kpi-card:nth-child(1) { animation-delay: 0.05s; background: linear-gradient(145deg, #0f9d8a, #0b6e8a); }
.kpi-card:nth-child(2) { animation-delay: 0.1s; background: linear-gradient(145deg, #059669, #047857); }
.kpi-card:nth-child(3) { animation-delay: 0.15s; background: linear-gradient(145deg, #1e293b, #0f172a); }
.kpi-card:nth-child(4) { animation-delay: 0.2s; background: linear-gradient(145deg, #d97706, #b45309); }
.kpi-card:nth-child(5) { animation-delay: 0.25s; background: linear-gradient(145deg, #4f46e5, #3730a3); }

/* Stats : 5 KPI lisibles, texte toujours clair sur fond coloré */
.kpi-grid-stats {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}
.kpi-grid-stats .kpi-card,
.kpi-card-ca,
.kpi-card-benefice,
.kpi-card-ventes,
.kpi-card-depenses,
.kpi-card-panier {
    color: #fff;
}
.kpi-card-ca { background: linear-gradient(145deg, #0f9d8a, #0b6e8a) !important; }
.kpi-card-benefice { background: linear-gradient(145deg, #047857, #065f46) !important; }
.kpi-card-ventes { background: linear-gradient(145deg, #1e293b, #0f172a) !important; }
.kpi-card-depenses { background: linear-gradient(145deg, #b45309, #92400e) !important; }
.kpi-card-panier { background: linear-gradient(145deg, #4f46e5, #3730a3) !important; }
.kpi-grid-stats .kpi-value,
.kpi-grid-stats .kpi-label,
.kpi-card-depenses .kpi-value,
.kpi-card-panier .kpi-value,
.kpi-card-benefice .kpi-value {
    color: #fff !important;
}

.kpi-card::after {
    content: "";
    position: absolute;
    inset: auto -20% -40% auto;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
}

.kpi-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    opacity: 0.92;
    font-weight: 600;
}

.kpi-value {
    margin-top: 0.55rem;
    font-family: var(--rs-display);
    font-size: clamp(1.4rem, 2vw, 1.9rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    position: relative;
    z-index: 1;
}

/* ---------- Login ---------- */
.login-page {
    min-height: 100%;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
}

.login-hero {
    position: relative;
    overflow: hidden;
    color: #fff;
    padding: clamp(2rem, 5vw, 4rem);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background-color: #0b1220;
    background-image:
        linear-gradient(180deg, rgba(11, 18, 32, 0.35) 0%, rgba(11, 18, 32, 0.78) 55%, rgba(11, 18, 32, 0.92) 100%),
        var(--login-hero-image);
    background-size: cover;
    background-position: center;
    animation: rs-fade-in 0.7s ease both;
}

.login-hero-content {
    position: relative;
    z-index: 1;
    max-width: 34rem;
}

.login-hero-logo {
    display: block;
    width: min(320px, 72%);
    height: auto;
    margin: 0 0 1rem;
    animation: rs-fade-up 0.65s ease 0.1s both;
    filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.35));
}

.login-hero-text {
    position: relative;
    z-index: 1;
    max-width: 28rem;
    font-size: 1.05rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.88);
    margin: 0;
    animation: rs-fade-up 0.65s ease 0.2s both;
}

.login-card-logo {
    display: block;
    height: 40px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    object-position: left center;
    margin: 0 0 1.1rem;
}

.login-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    padding: 2rem 1.25rem;
    background:
        radial-gradient(600px 300px at 80% 10%, rgba(15, 157, 138, 0.1), transparent 60%),
        #f7fafc;
}

.login-panel .app-footer {
    width: 100%;
    max-width: 420px;
    margin-top: 0;
    padding: 0.35rem 0.25rem 0;
    border-top: none;
    background: transparent;
    backdrop-filter: none;
}

.login-panel .app-footer-inner {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    text-align: center;
    max-width: none;
}

.login-card {
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--rs-line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    box-shadow: var(--rs-shadow-lg);
    padding: 2rem;
    animation: rs-fade-up 0.55s ease 0.15s both;
}

.login-card h1 {
    font-size: 1.45rem;
    font-weight: 700;
    margin: 0 0 0.35rem;
}

.login-card .lead-muted {
    color: var(--rs-slate);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.login-card .btn-primary {
    padding: 0.75rem 1rem;
    border-radius: 12px;
}

.sidebar-toggler {
    display: inline-flex;
    border: 1px solid var(--rs-line);
    background: #fff;
    border-radius: 10px;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    color: var(--rs-ink);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.sidebar-toggler:hover {
    background: #f8fafc;
    border-color: rgba(15, 23, 42, 0.16);
}

/* Desktop : sidebar réduite aux icônes */
@media (min-width: 992px) {
    body.sidebar-collapsed .app-layout {
        grid-template-columns: var(--rs-sidebar-w-collapsed) minmax(0, 1fr);
    }

    body.sidebar-collapsed .app-sidebar {
        padding: 0.85rem 0.4rem 1.5rem;
        overflow-x: hidden;
    }

    body.sidebar-collapsed .app-sidebar .nav-header {
        height: 1px;
        margin: 0.55rem 0.55rem;
        padding: 0;
        overflow: hidden;
        color: transparent;
        background: rgba(255, 255, 255, 0.1);
        letter-spacing: 0;
        font-size: 0;
    }

    body.sidebar-collapsed .app-sidebar .nav-link {
        justify-content: center;
        gap: 0;
        margin: 0.12rem 0.2rem;
        padding: 0.7rem 0.35rem;
        font-size: 0;
        transform: none;
    }

    body.sidebar-collapsed .app-sidebar .nav-link:hover {
        transform: none;
    }

    body.sidebar-collapsed .app-sidebar .nav-link i {
        font-size: 1.2rem;
        width: auto;
        opacity: 1;
    }
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(11, 18, 32, 0.45);
    backdrop-filter: blur(2px);
    z-index: 1035;
    animation: rs-fade-in 0.2s ease both;
}

/* ---------- Comptage des espèces à la clôture de caisse ---------- */
.cpt-table th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--rs-slate);
}

.cpt-table td {
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
}

.cpt-table .cpt-qte {
    text-align: right;
}

.cpt-ligne-montant {
    font-variant-numeric: tabular-nums;
    color: var(--rs-slate);
}

.cpt-recap {
    border: 1px solid var(--rs-line);
    border-radius: var(--rs-radius-sm);
    padding: 0.6rem 0.8rem;
    background: #f8fafc;
    font-size: 0.9rem;
}

/* ---------- Formulaire de vente ---------- */
.vente-layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 0.75rem;
    align-items: start;
}

.vente-col-gauche {
    position: sticky;
    top: calc(var(--rs-topbar-h) + 1rem);
}

.vente-catalogue .card-body {
    max-height: calc(100vh - var(--rs-topbar-h) - 8rem);
}

.vente-produits-scroll {
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--rs-line);
    border-radius: var(--rs-radius-sm);
    flex: 1;
    min-height: 200px;
}

.vente-table-produits thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 1;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--rs-slate);
}

.vente-produit-ligne {
    cursor: pointer;
}

.vente-prod-nom {
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vente-col-droite {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
}

.vente-layout-plein {
    grid-template-columns: minmax(0, 1fr);
}

.vente-layout-meta {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 20rem);
    grid-template-areas: "produits meta";
}

.vente-layout-meta > .vente-col-droite {
    grid-area: produits;
}

.vente-layout-meta > .vente-col-meta {
    grid-area: meta;
}

.vente-col-meta {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    max-height: calc(100vh - var(--rs-topbar-h) - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-left: 0.15rem;
}

.vente-layout-meta .vente-facture-lignes {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.vente-layout-meta .vente-facture-ligne {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 0.45rem;
}

.vente-layout-meta .vente-facture-champ,
.vente-layout-meta .vente-facture-champ-date,
.vente-layout-meta .vente-facture-champ-numero,
.vente-layout-meta .vente-facture-champ-type,
.vente-layout-meta .vente-facture-champ-aib,
.vente-layout-meta .vente-facture-champ-paiement {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
}

.vente-layout-meta .vente-facture-champ-aib {
    flex: 0 0 5.75rem;
}

.vente-layout-meta .vente-facture-ligne .form-label {
    white-space: normal;
}

.vente-layout-meta .vente-client-ligne {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.5rem;
}

.vente-layout-meta .vente-client-ligne .form-control {
    min-height: 2.75rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.vente-layout-meta .vente-client-actions {
    width: 100%;
    gap: 0.45rem;
}

.vente-layout-meta .vente-btn-parcourir {
    flex: 1 1 0;
    min-height: 2.5rem;
    justify-content: center;
}

.vente-layout-meta .vente-remise-ligne {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 0.45rem;
}

.transfert-layout .vente-col-droite {
    gap: 0.75rem;
}

/* Demande de produits : bloc Référence/Observation déplacé dans une colonne de droite */
.demande-layout {
    grid-template-columns: minmax(0, 1fr) minmax(210px, 15rem);
    align-items: start;
}

.demande-col-meta {
    position: sticky;
    top: calc(var(--rs-topbar-h) + 1rem);
    max-height: calc(100vh - var(--rs-topbar-h) - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.demande-col-meta .transfert-meta-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.6rem;
}

.demande-layout .vente-produit-champ-produit {
    flex: 1.35 1 9rem;
}

.demande-layout .vente-produit-champ-unite {
    flex: 1 1 8rem;
}

.demande-layout .vente-produit-champ-qte {
    flex: 0 0 5.5rem;
}

.demande-layout .vente-vendus-scroll {
    max-height: calc(100vh - var(--rs-topbar-h) - 20rem);
}

@media (max-width: 900px) {
    .demande-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .demande-col-meta {
        position: static;
        max-height: none;
        overflow: visible;
        order: -1;
    }

    .demande-col-meta .transfert-meta-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
    }
}

.transfert-meta-bloc {
    border-top: 3px solid var(--rs-accent);
}

.transfert-meta-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
    gap: 0.75rem;
    align-items: end;
}

.transfert-meta-field {
    min-width: 0;
}

.transfert-meta-field .form-label {
    color: var(--rs-slate);
    font-weight: 600;
}

.demande-lignes-saisie {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.demande-ligne-saisie {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr) minmax(9rem, 12rem);
    gap: 0.65rem;
    align-items: end;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--rs-line);
    border-radius: var(--rs-radius-sm);
    background: #fbfcfe;
}

.demande-ligne-numero {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--rs-accent-soft);
    color: var(--rs-accent-deep);
    font-size: 0.8rem;
    font-weight: 800;
}

.demande-ligne-produit,
.demande-ligne-quantite {
    min-width: 0;
}

.demande-ligne-saisie .form-label {
    color: var(--rs-slate);
    font-weight: 600;
}

@media (max-width: 519.98px) {
    .demande-ligne-saisie {
        grid-template-columns: 2rem minmax(0, 1fr);
    }

    .demande-ligne-quantite {
        grid-column: 2;
    }
}

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

@media (max-width: 519.98px) {
    .transfert-meta-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .transfert-meta-observation {
        grid-column: auto;
    }
}

.vente-col-principale {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
}

/* Liste déroulante produits (formulaire approvisionnement) */
.appro-produit-combobox {
    position: relative;
}

.appro-produit-select-btn {
    display: flex;
    align-items: center;
    width: 100%;
    cursor: pointer;
}

.appro-produit-select-label {
    flex: 1;
    min-width: 0;
}

.appro-produit-panel {
    position: fixed;
    z-index: 1080;
    min-width: 18rem;
    max-width: min(28rem, calc(100vw - 1rem));
    background: #fff;
    border: 1px solid var(--rs-line);
    border-radius: var(--rs-radius-sm);
    box-shadow: 0 0.75rem 1.5rem rgba(15, 23, 42, 0.18);
}

.appro-produit-panel-toolbar {
    padding: 0.5rem;
    border-bottom: 1px solid var(--rs-line);
    background: #f8fafc;
}

.appro-produit-panel-scroll {
    max-height: min(280px, 45vh);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.appro-produit-option {
    border: 0;
    border-bottom: 1px solid var(--rs-line);
    text-align: left;
    width: 100%;
}

.appro-produit-option:last-child {
    border-bottom: 0;
}

.appro-produit-option.active,
.appro-produit-option:hover,
.appro-produit-option:focus {
    background: rgba(37, 99, 235, 0.08);
}

.appro-produit-option-nom {
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.3;
}

.appro-produit-option-meta {
    margin-top: 0.1rem;
}

.vente-bloc-actions,
.vente-col-droite > .vente-bloc.text-center {
    margin: 0;
}

.vente-bloc-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.vente-bloc .card-header.vente-bloc-titre {
    background: #f8fafc;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--rs-ink);
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}

.vente-bloc-produit > .card-header.vente-produit-entete {
    background: #fff;
}

.vente-produit-entete {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.vente-produit-entete-gauche {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    min-width: 0;
    flex: 1 1 auto;
}

.vente-produit-entete-nom {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vente-produit-entete-stock {
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.vente-produit-entete-ttc {
    font-size: 0.95rem;
    color: var(--rs-accent-deep);
    white-space: nowrap;
    flex-shrink: 0;
}

.vente-produit-ligne-champs {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 0.45rem;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
}

.vente-produit-champ {
    flex: 1 1 0;
    min-width: 0;
}

.vente-produit-champ-unite {
    flex: 0 0 5.75rem;
}

.vente-produit-champ-produit {
    flex: 2 1 11rem;
    min-width: 9rem;
}

.vente-produit-champ-prix {
    flex: 1.6 1 8.5rem;
}

.vente-produit-champ-qte {
    flex: 0 0 3.6rem;
}

.vente-produit-champ-taux {
    flex: 0 0 3.6rem;
}

.vente-produit-champ-remise {
    flex: 1.5 1 7.25rem;
}

.vente-produit-champ-taxe {
    flex: 1.2 1 7rem;
}

.vente-produit-champ-spec {
    flex: 0 0 3.75rem;
}

.vente-produit-champ-action {
    flex: 0 0 auto;
    min-width: 2.5rem;
}

.vente-produit-champ-action .btn {
    white-space: nowrap;
    min-width: 2.35rem;
    font-weight: 700;
    font-size: 1.15rem;
    line-height: 1;
    padding-inline: 0.55rem;
}

.vente-produit-ligne-champs .form-label {
    white-space: nowrap;
    font-size: 0.72rem;
    margin-bottom: 0.15rem !important;
}

.vente-produit-ligne-champs .form-control,
.vente-produit-ligne-champs .form-select {
    width: 100%;
}

.vente-facture-ligne {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 0.65rem;
    min-width: 0;
}

.vente-facture-champ {
    flex: 1 1 0;
    min-width: 0;
}

.vente-facture-champ-date {
    flex: 0 0 9.5rem;
}

.vente-facture-champ-numero {
    flex: 1 1 8rem;
}

.vente-facture-champ-type {
    flex: 2 1 12rem;
}

.vente-facture-champ-aib {
    flex: 0 0 5.5rem;
}

.vente-facture-champ-paiement {
    flex: 1.2 1 9rem;
}

.vente-facture-ligne .form-label {
    white-space: nowrap;
}

.vente-facture-ligne .form-control,
.vente-facture-ligne .form-select {
    width: 100%;
}

.vente-client-remise-row {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    gap: 0.45rem;
    align-items: stretch;
}

.vente-bloc-client,
.vente-bloc-remise {
    height: 100%;
}

.vente-client-ligne {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.45rem;
}

.vente-client-ligne .form-control {
    flex: 1 1 auto;
    min-width: 0;
}

.vente-client-actions {
    display: inline-flex;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.35rem;
}

.vente-btn-parcourir {
    white-space: nowrap;
    border-radius: 10px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    padding-inline: 0.55rem;
}

.vente-remise-ligne {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.65rem;
    align-items: flex-end;
}

.vente-remise-champ {
    flex: 1 1 0;
    min-width: 0;
}

.vente-vendus-scroll {
    max-height: 420px;
    overflow-y: auto;
}

.vente-table-vendus thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 1;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--rs-slate);
    white-space: nowrap;
}

.vente-table-vendus tbody tr {
    cursor: default;
}

.vente-table-vendus .btn-retirer-ligne {
    padding: 0.15rem 0.4rem;
}

.vente-totaux {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.5rem;
    min-width: 0;
    overflow-x: auto;
}

.vente-total-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1 1 0;
    min-width: 5.5rem;
    padding: 0.35rem 0.55rem;
    border-radius: var(--rs-radius-sm);
    background: #f8fafc;
    font-size: 0.75rem;
    color: var(--rs-ink-soft);
}

.vente-total-item strong {
    font-size: 0.92rem;
    color: var(--rs-ink);
    font-variant-numeric: tabular-nums;
}

.vente-total-item.vente-total-ttc {
    background: var(--rs-accent-soft);
    font-weight: 700;
    color: var(--rs-ink);
}

.vente-total-item.vente-total-ttc strong {
    color: var(--rs-accent-deep);
    font-size: 1rem;
}

.vente-footer-sep {
    height: 1px;
    background: var(--rs-line);
    margin: 0.35rem 0 0.65rem;
}

.vente-bloc-footer {
    border: 1px solid rgba(15, 157, 138, 0.18);
}

.vente-paiement-ligne {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 0.75rem;
    min-width: 0;
}

.vente-paiement-check {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    padding-bottom: 0.35rem;
    flex-shrink: 0;
    white-space: nowrap;
}

.vente-paiement-check .form-check-input {
    margin: 0;
}

.vente-paiement-champ {
    flex: 1 1 8rem;
    min-width: 0;
}

.vente-paiement-champ .form-label {
    white-space: nowrap;
}

.vente-paiement-actions {
    flex-shrink: 0;
    margin-left: auto;
}

.vente-paiement-actions .btn {
    white-space: nowrap;
}

.vente-clients-scroll {
    max-height: 50vh;
    overflow-y: auto;
    overscroll-behavior: contain;
}

@media (max-width: 1199.98px) {
    .vente-layout,
    .vente-layout-meta {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: none;
    }

    .vente-layout-meta {
        grid-template-areas:
            "produits"
            "meta";
    }

    .vente-col-gauche {
        position: static;
    }

    .vente-col-meta {
        max-height: none;
        overflow: visible;
        padding-left: 0;
    }

    .vente-produits-scroll {
        max-height: 320px;
    }

    .vente-client-remise-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .vente-facture-ligne {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.55rem 0.65rem;
        align-items: end;
    }

    .vente-facture-champ-date,
    .vente-facture-champ-numero,
    .vente-facture-champ-type,
    .vente-facture-champ-aib,
    .vente-facture-champ-paiement {
        flex: none;
        width: 100%;
        min-width: 0;
    }

    .vente-facture-champ-type,
    .vente-facture-champ-paiement {
        grid-column: 1 / -1;
    }

    .vente-facture-ligne .form-label {
        white-space: normal;
        line-height: 1.25;
        word-break: break-word;
    }

    .vente-produit-ligne-champs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.55rem 0.65rem;
        align-items: end;
        overflow-x: visible;
    }

    .vente-produit-champ,
    .vente-produit-champ-unite,
    .vente-produit-champ-produit,
    .vente-produit-champ-prix,
    .vente-produit-champ-qte,
    .vente-produit-champ-taux,
    .vente-produit-champ-remise,
    .vente-produit-champ-taxe,
    .vente-produit-champ-spec,
    .vente-produit-champ-action {
        flex: none;
        width: 100%;
        min-width: 0;
    }

    .vente-produit-champ-unite,
    .vente-produit-champ-produit,
    .vente-produit-champ-taxe,
    .vente-produit-champ-action {
        grid-column: 1 / -1;
    }

    .vente-produit-ligne-champs .form-label {
        white-space: normal;
        line-height: 1.25;
        word-break: break-word;
    }

    .vente-client-ligne {
        flex-wrap: wrap;
    }

    .vente-client-actions {
        width: 100%;
    }

    .vente-client-actions .vente-btn-parcourir {
        flex: 1 1 0;
        justify-content: center;
    }

    .vente-remise-ligne {
        flex-wrap: wrap;
    }

    .vente-remise-champ .form-label {
        white-space: normal;
        line-height: 1.25;
    }

    .vente-paiement-ligne {
        flex-wrap: wrap;
    }

    .vente-paiement-champ {
        flex: 1 1 calc(50% - 0.4rem);
        min-width: 0;
    }

    .vente-paiement-champ .form-label {
        white-space: normal;
        line-height: 1.25;
    }

    .vente-paiement-actions {
        margin-left: 0;
        width: 100%;
    }

    .vente-paiement-actions .btn {
        width: 100%;
    }
}

@media (max-width: 519.98px) {
    .vente-facture-ligne,
    .vente-produit-ligne-champs {
        grid-template-columns: minmax(0, 1fr);
    }

    .vente-facture-champ-type,
    .vente-facture-champ-paiement,
    .vente-produit-champ-unite,
    .vente-produit-champ-taxe,
    .vente-produit-champ-action {
        grid-column: auto;
    }

    .vente-paiement-champ {
        flex: 1 1 100%;
    }

    .vente-paiement-check {
        white-space: normal;
        width: 100%;
        padding-bottom: 0;
    }
}

/* ---------- Motion ---------- */
@keyframes rs-fade-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes rs-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ---------- Responsive ---------- */

/* Tablette : KPI en 2 colonnes, contenu resserré */
@media (max-width: 1199.98px) {
    .kpi-grid,
    .kpi-grid-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Tablette & mobile : sidebar en tiroir */
@media (max-width: 991.98px) {
    .app-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .app-shell .app-footer,
    body.sidebar-collapsed .app-shell .app-footer {
        margin-left: 0;
    }

    .app-sidebar {
        position: fixed;
        left: 0;
        top: var(--rs-topbar-h);
        width: min(84vw, var(--rs-sidebar-w));
        height: calc(100vh - var(--rs-topbar-h));
        height: calc(100dvh - var(--rs-topbar-h));
        z-index: 1040;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        box-shadow: var(--rs-shadow-lg);
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }

    .app-sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-toggler {
        display: inline-flex;
    }

    .app-main {
        padding: 1.25rem;
        padding-left: max(1.25rem, env(safe-area-inset-left));
        padding-right: max(1.25rem, env(safe-area-inset-right));
    }

    .login-page {
        grid-template-columns: 1fr;
    }

    .login-hero {
        min-height: 34vh;
        justify-content: flex-end;
        padding: 1.75rem;
    }

    .login-hero-logo {
        width: min(240px, 70%);
    }
}

/* Mobile : pile verticale, cibles tactiles élargies */
@media (max-width: 767.98px) {
    :root {
        --rs-topbar-h: 58px;
    }

    .app-topbar {
        gap: 0.6rem;
        padding: 0 0.9rem;
    }

    .app-brand {
        font-size: 1rem;
    }

    .app-brand-logo {
        height: 32px;
        max-width: min(170px, 46vw);
    }

    .app-user-name,
    .app-user-caret {
        display: none;
    }

    .app-user-trigger {
        padding: 0.2rem;
        gap: 0;
    }

    .app-notif-btn {
        width: 38px;
        height: 38px;
        font-size: 1.05rem;
    }

    .page-header {
        align-items: center;
    }

    .page-title {
        font-size: 1.05rem;
    }

    .page-back-link,
    .page-header > a.btn-outline-secondary {
        width: auto;
    }

    /* Cibles tactiles plus grandes dans les tableaux */
    .table .btn-sm {
        padding: 0.45rem 0.6rem;
        font-size: 0.9rem;
    }

    .table > :not(caption) > * > * {
        padding: 0.75rem 0.75rem;
    }

    /* Défilement horizontal fluide + indice visuel */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    /* Empêche le zoom iOS au focus (police >= 16px) */
    .form-control,
    .form-select {
        font-size: 16px;
    }

    .kpi-card {
        min-height: 104px;
        padding: 1rem;
    }
}

/* Très petits écrans : KPI en une colonne */
@media (max-width: 519.98px) {
    .kpi-grid,
    .kpi-grid-stats {
        grid-template-columns: 1fr;
    }

    .app-main {
        padding: 1rem 0.85rem 2rem;
    }

    .login-card {
        padding: 1.5rem;
        border-radius: 16px;
    }

    .login-hero {
        min-height: 26vh;
        padding: 1.25rem;
    }

    .login-hero-logo {
        width: min(200px, 68%);
        margin-bottom: 0.65rem;
    }

    .login-hero-text {
        font-size: 0.95rem;
    }

    .login-card-logo {
        height: 34px;
    }
}

/* Dettes soldées / payées */
.dette-ligne-payee td {
    color: #146c43;
}
.dette-ligne-payee td .fw-bold {
    color: #146c43 !important;
}

/* Respect des préférences de mouvement réduit */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* Modal catégories au-dessus d'un autre modal (ex. nouveau produit) */
#modalCategories,
#modalCategoriesProduit {
    z-index: 1065;
}
body.modal-open .modal-backdrop.modal-backdrop-stacked {
    z-index: 1060;
}

.rs-qty-plus {
    color: var(--rs-accent-deep);
    font-weight: 700;
}

.rs-qty-minus {
    color: var(--rs-danger);
    font-weight: 700;
}
