:root {
    --app-canvas: #f4f6f2;
    --app-surface: #ffffff;
    --app-surface-soft: #f8faf7;
    --app-ink: #1d2927;
    --app-muted: #66736f;
    --app-border: #dfe5df;
    --app-brand: #276457;
    --app-brand-dark: #173e36;
    --app-brand-soft: #e1efeb;
    --app-accent: #d68b56;
    --app-danger: #b94a48;
    --app-danger-soft: #fbe9e8;
    --app-warning: #946b20;
    --app-warning-soft: #fff3d7;
    --app-success: #24704f;
    --app-success-soft: #e3f3eb;
    --app-info: #386a86;
    --app-info-soft: #e5f1f7;
    --app-purple: #76558e;
    --app-purple-soft: #f0e9f6;
    --app-shadow: 0 12px 32px rgba(25, 55, 47, .07);
    --app-shadow-sm: 0 5px 16px rgba(25, 55, 47, .06);
    --app-radius: 18px;
    --app-sidebar-width: 272px;
    --bs-primary: #276457;
    --bs-primary-rgb: 39, 100, 87;
    --bs-link-color: #276457;
    --bs-link-hover-color: #173e36;
    --bs-border-color: #dfe5df;
    --bs-body-color: #1d2927;
    --bs-body-bg: #f4f6f2;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--app-ink);
    background: var(--app-canvas);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: .95rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    text-underline-offset: .16em;
}

button,
input,
select,
textarea {
    font: inherit;
}

.skip-link {
    position: fixed;
    z-index: 2000;
    top: .75rem;
    left: .75rem;
    padding: .65rem 1rem;
    color: #fff;
    background: var(--app-brand-dark);
    border-radius: .6rem;
    transform: translateY(-160%);
    transition: transform .18s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

.app-icon {
    width: 1.2rem;
    height: 1.2rem;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
}

.app-shell {
    min-height: 100vh;
}

.app-sidebar {
    width: var(--app-sidebar-width) !important;
    color: rgba(255, 255, 255, .82);
    background:
        radial-gradient(circle at 10% 8%, rgba(96, 178, 150, .16), transparent 28%),
        linear-gradient(165deg, #173e36 0%, #102d28 100%);
    border: 0;
}

.sidebar-inner {
    display: flex;
    min-height: 100%;
    padding: 1.35rem 1rem 1rem;
    flex-direction: column;
}

.brand {
    display: flex;
    align-items: center;
    gap: .8rem;
    margin: 0 .35rem 1.75rem;
    color: #fff;
    text-decoration: none;
}

.brand:hover {
    color: #fff;
}

.brand-mark {
    display: grid;
    width: 2.6rem;
    height: 2.6rem;
    color: #163d34;
    background: #b9e1d2;
    border-radius: 14px;
    place-items: center;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .45);
}

.brand-mark .app-icon {
    width: 1.35rem;
    height: 1.35rem;
}

.brand-wordmark,
.brand-subtitle {
    display: block;
}

.brand-wordmark {
    font-size: 1.08rem;
    font-weight: 760;
    letter-spacing: -.02em;
}

.brand-subtitle {
    color: rgba(255, 255, 255, .58);
    font-size: .73rem;
    letter-spacing: .02em;
}

.sidebar-nav {
    flex: 1;
}

.nav-section-label {
    margin: 1.35rem .75rem .45rem;
    color: rgba(255, 255, 255, .42);
    font-size: .67rem;
    font-weight: 750;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.nav-section-label:first-child {
    margin-top: 0;
}

.nav-item {
    display: flex;
    min-height: 43px;
    align-items: center;
    gap: .75rem;
    margin: .12rem 0;
    padding: .62rem .75rem;
    color: rgba(255, 255, 255, .72);
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: .88rem;
    font-weight: 580;
    text-decoration: none;
    transition: background .16s ease, color .16s ease, transform .16s ease;
}

.nav-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, .07);
}

.nav-item.active {
    color: #fff;
    background: rgba(183, 224, 209, .14);
    border-color: rgba(183, 224, 209, .16);
}

.nav-item.active::before {
    width: 3px;
    height: 18px;
    margin-left: -.76rem;
    background: #91d2bd;
    border-radius: 999px;
    content: "";
}

.nav-item.active .app-icon {
    color: #aee0d0;
}

.nav-counter {
    margin-left: auto;
    padding: .12rem .42rem;
    color: #ffd9d5;
    background: rgba(206, 78, 73, .25);
    border-radius: 999px;
    font-size: .67rem;
    font-weight: 720;
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, .09);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .55rem .4rem .8rem;
}

.avatar {
    display: grid;
    width: 2.15rem;
    height: 2.15rem;
    color: #14352f;
    background: #d7ede5;
    border-radius: 50%;
    font-size: .78rem;
    font-weight: 800;
    place-items: center;
}

.user-chip-copy {
    min-width: 0;
}

.user-chip-copy strong,
.user-chip-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chip-copy strong {
    color: #fff;
    font-size: .82rem;
}

.user-chip-copy small {
    color: rgba(255, 255, 255, .5);
    font-size: .69rem;
}

.btn-sidebar {
    display: flex;
    width: 100%;
    align-items: center;
    gap: .65rem;
    padding: .65rem .45rem;
    color: rgba(255, 255, 255, .58);
    border: 0;
    font-size: .8rem;
}

.btn-sidebar:hover {
    color: #fff;
    background: rgba(255, 255, 255, .06);
}

.app-stage {
    min-width: 0;
    min-height: 100vh;
}

.app-topbar {
    position: sticky;
    z-index: 900;
    top: 0;
    display: flex;
    height: 74px;
    align-items: center;
    gap: .85rem;
    padding: .85rem clamp(1rem, 3vw, 2.25rem);
    background: rgba(244, 246, 242, .9);
    border-bottom: 1px solid rgba(211, 219, 212, .75);
    backdrop-filter: blur(16px);
}

.top-search {
    display: flex;
    width: min(540px, 48vw);
    height: 44px;
    align-items: center;
    gap: .65rem;
    padding: 0 .85rem;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 12px;
    box-shadow: 0 2px 9px rgba(21, 56, 48, .025);
}

.top-search:focus-within {
    border-color: #6fa99a;
    box-shadow: 0 0 0 3px rgba(39, 100, 87, .11);
}

.top-search .app-icon {
    color: #7d8985;
}

.top-search input {
    min-width: 0;
    flex: 1;
    color: var(--app-ink);
    background: transparent;
    border: 0;
    outline: 0;
}

.top-search input::placeholder {
    color: #9aa39f;
}

.top-search kbd {
    min-width: 1.4rem;
    justify-content: center;
    color: #7f8b87;
    background: #f1f4f1;
    border: 1px solid #e0e6e0;
    border-radius: 5px;
    box-shadow: none;
    font-family: inherit;
    font-size: .68rem;
}

.topbar-action {
    min-height: 44px;
    margin-left: auto;
}

.app-content {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: clamp(1.25rem, 3vw, 2.35rem);
    padding-bottom: 3rem;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-heading h1,
.page-heading h2,
.section-heading h2,
.section-heading h3 {
    margin: 0;
    color: var(--app-ink);
    font-weight: 740;
    letter-spacing: -.035em;
}

.page-heading h1 {
    font-size: clamp(1.65rem, 3vw, 2.25rem);
}

.page-heading p {
    max-width: 720px;
    margin: .38rem 0 0;
    color: var(--app-muted);
}

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

.eyebrow {
    display: inline-flex;
    align-items: center;
    margin-bottom: .48rem;
    color: var(--app-brand);
    font-size: .7rem;
    font-weight: 780;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.eyebrow-light {
    color: #a9d9ca;
}

.app-card {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-sm);
}

.app-card-header {
    display: flex;
    min-height: 66px;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--app-border);
}

.app-card-header h2,
.app-card-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 720;
    letter-spacing: -.015em;
}

.app-card-body {
    padding: 1.2rem;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .85rem;
}

.section-heading h2 {
    font-size: 1.08rem;
}

.section-link {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    color: var(--app-brand);
    font-size: .8rem;
    font-weight: 680;
    text-decoration: none;
}

.section-link .app-icon {
    width: .9rem;
    height: .9rem;
}

.btn {
    --bs-btn-border-radius: 11px;
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: .48rem;
    font-size: .84rem;
    font-weight: 670;
}

.btn-sm {
    min-height: 34px;
    border-radius: 9px;
    font-size: .76rem;
}

.btn-lg {
    min-height: 50px;
    border-radius: 13px;
}

.btn-primary {
    --bs-btn-bg: var(--app-brand);
    --bs-btn-border-color: var(--app-brand);
    --bs-btn-hover-bg: var(--app-brand-dark);
    --bs-btn-hover-border-color: var(--app-brand-dark);
    --bs-btn-active-bg: #12342d;
    --bs-btn-active-border-color: #12342d;
    box-shadow: 0 6px 14px rgba(39, 100, 87, .15);
}

.btn-outline-primary {
    --bs-btn-color: var(--app-brand);
    --bs-btn-border-color: #86ab9f;
    --bs-btn-hover-bg: var(--app-brand);
    --bs-btn-hover-border-color: var(--app-brand);
}

.btn-light {
    --bs-btn-bg: #fff;
    --bs-btn-border-color: var(--app-border);
    --bs-btn-hover-bg: #f7f9f6;
    --bs-btn-hover-border-color: #cad4cc;
}

.icon-button {
    width: 42px;
    min-height: 42px;
    padding: 0;
    background: #fff;
    border: 1px solid var(--app-border);
}

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

.kpi-card {
    position: relative;
    min-height: 142px;
    overflow: hidden;
    padding: 1.15rem 1.2rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-sm);
}

.kpi-card::after {
    position: absolute;
    right: -24px;
    bottom: -38px;
    width: 105px;
    height: 105px;
    background: var(--kpi-tint, var(--app-brand-soft));
    border-radius: 50%;
    content: "";
}

.kpi-card-danger { --kpi-tint: #fae2df; }
.kpi-card-success { --kpi-tint: #dff2e8; }
.kpi-card-accent { --kpi-tint: #f9eadf; }

.kpi-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    color: var(--app-muted);
    font-size: .76rem;
    font-weight: 650;
}

.kpi-icon {
    display: grid;
    width: 2.25rem;
    height: 2.25rem;
    color: var(--app-brand);
    background: var(--app-brand-soft);
    border-radius: 11px;
    place-items: center;
}

.kpi-card-danger .kpi-icon { color: var(--app-danger); background: var(--app-danger-soft); }
.kpi-card-success .kpi-icon { color: var(--app-success); background: var(--app-success-soft); }
.kpi-card-accent .kpi-icon { color: #98603c; background: #f7e9df; }

.kpi-value {
    position: relative;
    z-index: 1;
    margin: .8rem 0 .12rem;
    color: var(--app-ink);
    font-size: clamp(1.55rem, 2.7vw, 2rem);
    font-weight: 780;
    letter-spacing: -.045em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.kpi-note {
    position: relative;
    z-index: 1;
    margin: .35rem 0 0;
    color: var(--app-muted);
    font-size: .73rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, .85fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dashboard-stack {
    display: grid;
    gap: 1rem;
}

.finance-strip {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    margin-bottom: 1.5rem;
    background: var(--app-brand-dark);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
}

.finance-metric {
    position: relative;
    padding: 1.05rem 1rem;
    color: #fff;
}

.finance-metric + .finance-metric::before {
    position: absolute;
    top: 20%;
    bottom: 20%;
    left: 0;
    width: 1px;
    background: rgba(255, 255, 255, .12);
    content: "";
}

.finance-metric span,
.finance-metric strong {
    display: block;
}

.finance-metric span {
    min-height: 2.2em;
    color: rgba(255, 255, 255, .57);
    font-size: .68rem;
    line-height: 1.2;
}

.finance-metric strong {
    margin-top: .32rem;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

.money {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.money-strong {
    color: var(--app-ink);
    font-size: 1.03rem;
    font-weight: 760;
}

.money-danger { color: var(--app-danger); }
.money-success { color: var(--app-success); }

.app-table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: #f8faf7;
    margin: 0;
    vertical-align: middle;
}

.app-table thead th {
    padding: .78rem .85rem;
    color: #78847f;
    background: #f8faf7;
    border-bottom-width: 1px;
    font-size: .65rem;
    font-weight: 760;
    letter-spacing: .075em;
    text-transform: uppercase;
    white-space: nowrap;
}

.app-table tbody td {
    padding: .85rem;
    border-color: #edf0ed;
}

.app-table tbody tr:last-child td {
    border-bottom: 0;
}

.table-person {
    display: flex;
    min-width: 150px;
    align-items: center;
    gap: .65rem;
}

.avatar-sm {
    display: grid;
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    color: var(--app-brand-dark);
    background: var(--app-brand-soft);
    border-radius: 10px;
    font-size: .72rem;
    font-weight: 780;
    place-items: center;
}

.table-primary,
.table-secondary-copy {
    display: block;
}

.table-primary {
    color: var(--app-ink);
    font-size: .84rem;
    font-weight: 680;
    text-decoration: none;
}

.table-primary:hover {
    color: var(--app-brand);
}

.table-secondary-copy {
    margin-top: .08rem;
    color: var(--app-muted);
    font-size: .71rem;
}

.status-badge {
    display: inline-flex;
    min-height: 26px;
    align-items: center;
    gap: .4rem;
    padding: .22rem .55rem;
    color: #596560;
    background: #eef1ee;
    border: 1px solid rgba(0, 0, 0, .035);
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 720;
    white-space: nowrap;
}

.status-dot {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
}

.status-paye,
.status-payee,
.status-actif { color: var(--app-success); background: var(--app-success-soft); }
.status-en_retard { color: var(--app-danger); background: var(--app-danger-soft); }
.status-partiel,
.status-en_attente,
.status-a_payer { color: var(--app-warning); background: var(--app-warning-soft); }
.status-a_venir { color: var(--app-info); background: var(--app-info-soft); }
.status-offert { color: var(--app-purple); background: var(--app-purple-soft); }
.status-exonere { color: #4f6c69; background: #e4efee; }
.status-annule,
.status-annulee,
.status-termine { color: #727b78; background: #ecefed; }
.status-en_pause,
.status-brouillon { color: #7c6743; background: #f4eddf; }

.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .4rem;
}

.action-menu .dropdown-menu {
    min-width: 220px;
    padding: .4rem;
    border-color: var(--app-border);
    border-radius: 12px;
    box-shadow: var(--app-shadow);
}

.action-menu .dropdown-item {
    padding: .58rem .65rem;
    border-radius: 8px;
    font-size: .8rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(280px, .65fr);
    gap: 1rem;
}

.detail-list {
    display: grid;
    margin: 0;
}

.detail-row {
    display: grid;
    grid-template-columns: minmax(110px, .7fr) minmax(0, 1fr);
    gap: 1rem;
    padding: .72rem 0;
    border-bottom: 1px solid #edf0ed;
}

.detail-row:last-child {
    border-bottom: 0;
}

.detail-row dt {
    color: var(--app-muted);
    font-size: .75rem;
    font-weight: 560;
}

.detail-row dd {
    margin: 0;
    color: var(--app-ink);
    font-size: .82rem;
    font-weight: 630;
    text-align: right;
}

.amount-breakdown {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: hidden;
    background: var(--app-surface-soft);
    border: 1px solid var(--app-border);
    border-radius: 14px;
}

.amount-breakdown-item {
    padding: .9rem 1rem;
}

.amount-breakdown-item + .amount-breakdown-item {
    border-left: 1px solid var(--app-border);
}

.amount-breakdown-item span,
.amount-breakdown-item strong {
    display: block;
}

.amount-breakdown-item span {
    color: var(--app-muted);
    font-size: .68rem;
}

.amount-breakdown-item strong {
    margin-top: .15rem;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

.filter-panel {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 15px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    align-items: end;
    gap: .75rem;
}

.filter-grid .form-label {
    margin-bottom: .3rem;
    color: var(--app-muted);
    font-size: .68rem;
    font-weight: 680;
}

.filter-actions {
    display: flex;
    gap: .45rem;
}

.form-control,
.form-select {
    min-height: 43px;
    color: var(--app-ink);
    background-color: #fff;
    border-color: #ccd6cf;
    border-radius: 10px;
    font-size: .84rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #69a391;
    box-shadow: 0 0 0 .2rem rgba(39, 100, 87, .11);
}

textarea.form-control {
    min-height: 96px;
}

.form-label {
    color: #3e4a47;
    font-size: .78rem;
    font-weight: 680;
}

.form-text {
    color: #7b8782;
    font-size: .7rem;
}

.required-mark {
    margin-left: .15rem;
    color: var(--app-danger);
}

.form-shell {
    max-width: 960px;
    margin: 0 auto;
}

.form-card {
    overflow: hidden;
}

.form-card-body {
    padding: clamp(1.1rem, 3vw, 1.65rem);
}

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

.form-field-wide,
.form-field-check {
    grid-column: 1 / -1;
}

.form-field-check {
    padding: .85rem 1rem;
    background: var(--app-surface-soft);
    border: 1px solid var(--app-border);
    border-radius: 11px;
}

.form-actions-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .65rem;
    margin-top: 1.35rem;
    padding-top: 1.15rem;
    border-top: 1px solid var(--app-border);
}

.form-context {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: 1.15rem;
    padding: .9rem 1rem;
    color: #3d5e55;
    background: var(--app-brand-soft);
    border: 1px solid #cee1db;
    border-radius: 12px;
    font-size: .8rem;
}

.form-context .app-icon {
    margin-top: .06rem;
}

.empty-state {
    display: flex;
    min-height: 260px;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    flex-direction: column;
}

.empty-state-icon {
    display: grid;
    width: 3.5rem;
    height: 3.5rem;
    margin-bottom: .85rem;
    color: var(--app-brand);
    background: var(--app-brand-soft);
    border-radius: 18px;
    place-items: center;
}

.empty-state-icon .app-icon {
    width: 1.55rem;
    height: 1.55rem;
}

.empty-state h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 720;
}

.empty-state p {
    max-width: 430px;
    margin: .4rem 0 1rem;
    color: var(--app-muted);
    font-size: .8rem;
}

.flash-stack {
    position: relative;
    z-index: 950;
    display: grid;
    gap: .6rem;
    margin-bottom: 1rem;
}

.app-alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    border-radius: 12px;
    box-shadow: var(--app-shadow-sm);
}

.pagination-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.2rem;
    border-top: 1px solid var(--app-border);
}

.pagination-summary {
    margin: 0;
    color: var(--app-muted);
    font-size: .75rem;
}

.pagination {
    --bs-pagination-color: var(--app-brand);
    --bs-pagination-active-bg: var(--app-brand);
    --bs-pagination-active-border-color: var(--app-brand);
    --bs-pagination-border-color: var(--app-border);
    gap: .2rem;
}

.page-link {
    min-width: 34px;
    text-align: center;
    border-radius: 8px !important;
}

.timeline {
    position: relative;
    display: grid;
    gap: .9rem;
}

.timeline::before {
    position: absolute;
    top: .55rem;
    bottom: .55rem;
    left: .45rem;
    width: 1px;
    background: var(--app-border);
    content: "";
}

.timeline-item {
    position: relative;
    display: grid;
    grid-template-columns: 1rem minmax(0, 1fr);
    gap: .8rem;
}

.timeline-dot {
    z-index: 1;
    width: .9rem;
    height: .9rem;
    margin-top: .28rem;
    background: var(--app-brand);
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--app-border);
}

.timeline-card {
    padding: .85rem 1rem;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 12px;
}

.timeline-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .28rem;
}

.timeline-meta strong {
    font-size: .8rem;
}

.timeline-meta time {
    color: var(--app-muted);
    font-size: .68rem;
}

.timeline-card p {
    margin: .2rem 0 0;
    color: var(--app-muted);
    font-size: .76rem;
}

.calendar-legend {
    display: flex;
    align-items: center;
    gap: .55rem;
    flex-wrap: wrap;
}

.legend-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    color: var(--app-muted);
    font-size: .7rem;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.calendar-agenda {
    display: grid;
}

.agenda-day {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--app-border);
}

.agenda-day:last-child {
    border-bottom: 0;
}

.agenda-date {
    color: var(--app-muted);
    font-size: .73rem;
    font-weight: 670;
}

.agenda-date strong {
    display: block;
    color: var(--app-ink);
    font-size: 1.55rem;
    line-height: 1;
}

.agenda-events {
    display: grid;
    gap: .5rem;
}

.agenda-event {
    display: flex;
    align-items: center;
    gap: .7rem;
    min-height: 48px;
    padding: .65rem .8rem;
    background: var(--app-surface-soft);
    border: 1px solid var(--app-border);
    border-left: 4px solid var(--event-color, var(--app-info));
    border-radius: 10px;
}

.agenda-event.event-fournisseur { --event-color: var(--app-accent); }
.agenda-event.event-creance { --event-color: var(--app-info); }
.agenda-event.event-paiement { --event-color: var(--app-success); }

.agenda-event-main {
    min-width: 0;
    flex: 1;
}

.agenda-event-main strong,
.agenda-event-main small {
    display: block;
}

.agenda-event-main strong {
    font-size: .8rem;
}

.agenda-event-main small {
    color: var(--app-muted);
    font-size: .68rem;
}

.allocation-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: start;
    gap: 1rem;
}

.allocation-layout > .dashboard-stack {
    min-width: 0;
}

.allocation-summary {
    position: sticky;
    top: 90px;
    padding: 1.1rem;
    color: #fff;
    background: var(--app-brand-dark);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
}

.allocation-summary h3 {
    margin: 0 0 .85rem;
    font-size: .95rem;
}

.allocation-total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    padding: .55rem 0;
    color: rgba(255, 255, 255, .63);
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    font-size: .75rem;
}

.allocation-total-row strong {
    color: #fff;
    font-size: .9rem;
    font-variant-numeric: tabular-nums;
}

.allocation-total-row:last-of-type {
    border-bottom: 0;
}

.allocation-input {
    width: 116px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.allocation-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .8rem 1rem;
    background: #f8faf7;
    border-bottom: 1px solid var(--app-border);
}

@media (max-width: 1399.98px) {
    .allocation-layout { grid-template-columns: 1fr; }
    .allocation-summary { position: static; }
}

.adjustment-preview {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 1.2rem;
    overflow: hidden;
    background: var(--app-surface-soft);
    border: 1px solid var(--app-border);
    border-radius: 14px;
}

.adjustment-preview > div {
    padding: .9rem 1rem;
}

.adjustment-preview > div + div {
    border-left: 1px solid var(--app-border);
}

.adjustment-preview span,
.adjustment-preview strong {
    display: block;
}

.adjustment-preview span {
    min-height: 2em;
    color: var(--app-muted);
    font-size: .66rem;
}

.adjustment-preview strong {
    margin-top: .2rem;
    font-variant-numeric: tabular-nums;
}

.decision-list {
    display: grid;
    gap: .7rem;
}

.decision-row {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) 120px 150px minmax(260px, 1.25fr);
    align-items: center;
    gap: .9rem;
    padding: .9rem 1rem;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 13px;
}

.decision-options {
    display: flex;
    align-items: center;
    gap: .35rem;
    flex-wrap: wrap;
}

.decision-options label {
    cursor: pointer;
}

.decision-options input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.decision-options span {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    padding: .35rem .55rem;
    color: var(--app-muted);
    background: #f6f8f5;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    font-size: .68rem;
    font-weight: 650;
}

.decision-options input:checked + span {
    color: var(--app-brand-dark);
    background: var(--app-brand-soft);
    border-color: #8eb9ad;
}

.bank-grid,
.entity-grid,
.search-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.entity-card {
    position: relative;
    display: flex;
    min-height: 180px;
    padding: 1.1rem;
    color: inherit;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-sm);
    text-decoration: none;
    flex-direction: column;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.entity-card:hover {
    color: inherit;
    border-color: #b9cac1;
    box-shadow: var(--app-shadow);
    transform: translateY(-2px);
}

.entity-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .8rem;
}

.entity-card h2,
.entity-card h3 {
    margin: 0;
    font-size: .98rem;
    font-weight: 730;
    letter-spacing: -.02em;
}

.entity-card p {
    margin: .3rem 0 0;
    color: var(--app-muted);
    font-size: .73rem;
}

.entity-card-bottom {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: .7rem;
    margin-top: auto;
    padding-top: 1rem;
}

.entity-metric span,
.entity-metric strong {
    display: block;
}

.entity-metric span {
    color: var(--app-muted);
    font-size: .65rem;
}

.entity-metric strong {
    margin-top: .08rem;
    font-size: 1.15rem;
    font-variant-numeric: tabular-nums;
}

.bank-accent {
    width: 38px;
    height: 7px;
    background: var(--bank-color, var(--app-brand));
    border-radius: 999px;
}

.tabs-wrap {
    overflow-x: auto;
    margin-bottom: 1rem;
    scrollbar-width: none;
}

.tabs-wrap::-webkit-scrollbar { display: none; }

.app-tabs {
    display: flex;
    min-width: max-content;
    gap: .3rem;
    padding: .25rem;
    background: #e9eeea;
    border-radius: 12px;
}

.app-tabs button,
.app-tabs a {
    padding: .48rem .75rem;
    color: var(--app-muted);
    background: transparent;
    border: 0;
    border-radius: 9px;
    font-size: .75rem;
    font-weight: 670;
    text-decoration: none;
}

.app-tabs .active {
    color: var(--app-ink);
    background: #fff;
    box-shadow: 0 2px 8px rgba(25, 55, 47, .07);
}

.secure-callout {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    padding: .85rem 1rem;
    color: #4d5d58;
    background: #f7faf7;
    border: 1px dashed #c8d5cd;
    border-radius: 11px;
    font-size: .75rem;
}

.secure-callout p {
    margin: 0;
}

.search-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .65rem;
}

.search-section-title h2 {
    margin: 0;
    font-size: .92rem;
    font-weight: 720;
}

.search-result-list {
    display: grid;
}

.search-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    min-height: 58px;
    padding: .65rem .8rem;
    color: inherit;
    border-bottom: 1px solid #edf0ed;
    text-decoration: none;
}

.search-result:last-child { border-bottom: 0; }
.search-result:hover { background: #f8faf7; }

.import-example {
    margin: 0;
    padding: 1rem;
    color: #dcece6;
    background: #173e36;
    border-radius: 12px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .75rem;
    line-height: 1.7;
    white-space: pre-wrap;
}

.mobile-tabbar {
    position: fixed;
    z-index: 1000;
    right: .7rem;
    bottom: max(.65rem, env(safe-area-inset-bottom));
    left: .7rem;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    min-height: 66px;
    padding: .35rem;
    background: rgba(255, 255, 255, .95);
    border: 1px solid rgba(210, 219, 212, .9);
    border-radius: 18px;
    box-shadow: 0 15px 45px rgba(21, 56, 48, .18);
    backdrop-filter: blur(18px);
}

.mobile-tab {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: center;
    gap: .1rem;
    padding: .25rem;
    color: #75807c;
    background: transparent;
    border: 0;
    border-radius: 12px;
    font-size: .6rem;
    font-weight: 650;
    text-decoration: none;
    flex-direction: column;
}

.mobile-tab.active {
    color: var(--app-brand);
    background: var(--app-brand-soft);
}

.mobile-tab .app-icon {
    width: 1.15rem;
    height: 1.15rem;
}

.mobile-tab-primary {
    color: var(--app-brand);
}

.mobile-plus {
    display: grid;
    width: 2.35rem;
    height: 2.35rem;
    margin-top: -.75rem;
    color: #fff;
    background: var(--app-brand);
    border: 4px solid #fff;
    border-radius: 50%;
    box-shadow: 0 7px 16px rgba(39, 100, 87, .25);
    place-items: center;
}

.auth-page {
    overflow-x: hidden;
    background: #edf2ee;
}

.auth-shell,
.login-layout {
    min-height: 100vh;
}

.login-layout {
    display: grid;
    grid-template-columns: minmax(380px, .95fr) minmax(480px, 1.05fr);
}

.login-story {
    position: relative;
    display: flex;
    overflow: hidden;
    padding: clamp(2rem, 5vw, 4.5rem);
    color: #fff;
    background:
        radial-gradient(circle at 10% 15%, rgba(130, 206, 181, .25), transparent 28%),
        radial-gradient(circle at 88% 85%, rgba(214, 139, 86, .18), transparent 30%),
        linear-gradient(145deg, #173e36, #0e2d27);
    flex-direction: column;
}

.login-story::after {
    position: absolute;
    right: -12%;
    bottom: 7%;
    width: 50%;
    aspect-ratio: 1;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 50%;
    box-shadow: 0 0 0 42px rgba(255, 255, 255, .025), 0 0 0 90px rgba(255, 255, 255, .02);
    content: "";
}

.brand-light {
    position: relative;
    z-index: 1;
    margin: 0;
}

.login-story-copy {
    position: relative;
    z-index: 1;
    width: min(560px, 100%);
    margin: auto 0;
}

.login-story-copy h1 {
    margin: 0;
    font-size: clamp(2.4rem, 5vw, 4.8rem);
    font-weight: 760;
    letter-spacing: -.065em;
    line-height: .98;
}

.login-story-copy > p {
    max-width: 520px;
    margin: 1.4rem 0 0;
    color: rgba(255, 255, 255, .68);
    font-size: 1rem;
}

.login-proof {
    display: flex;
    max-width: 460px;
    align-items: flex-start;
    gap: .8rem;
    margin-top: 2rem;
    padding: 1rem;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 14px;
    backdrop-filter: blur(10px);
}

.login-proof > span {
    display: grid;
    width: 2.2rem;
    height: 2.2rem;
    flex: 0 0 auto;
    color: #b9e1d2;
    background: rgba(185, 225, 210, .12);
    border-radius: 10px;
    place-items: center;
}

.login-proof p {
    margin: 0;
    color: rgba(255, 255, 255, .64);
    font-size: .76rem;
}

.login-proof strong { color: #fff; }

.login-story-foot {
    position: relative;
    z-index: 1;
    margin: 0;
    color: rgba(255, 255, 255, .36);
    font-size: .7rem;
}

.login-panel {
    display: grid;
    padding: 2rem;
    place-items: center;
}

.login-card {
    width: min(440px, 100%);
    padding: clamp(1.5rem, 5vw, 2.5rem);
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 24px;
    box-shadow: var(--app-shadow);
}

.login-card h2 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 760;
    letter-spacing: -.04em;
}

.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 5rem;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: .4rem;
    min-height: 34px;
    padding: .2rem .5rem;
    color: var(--app-brand);
    border: 0;
    transform: translateY(-50%);
}

.secure-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    margin: 1.1rem 0 0;
    color: var(--app-muted);
    font-size: .68rem;
}

.secure-note .app-icon { width: .85rem; height: .85rem; }

@media (min-width: 992px) {
    .app-sidebar {
        position: fixed;
        z-index: 1020;
        inset: 0 auto 0 0;
        visibility: visible !important;
        transform: none !important;
    }

    .app-stage {
        margin-left: var(--app-sidebar-width);
    }
}

@media (max-width: 1199.98px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .finance-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .finance-metric:nth-child(4)::before { display: none; }
    .filter-grid { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
    .decision-row { grid-template-columns: minmax(150px, 1fr) 100px minmax(230px, 1.3fr); }
    .decision-row > :nth-child(3) { display: none; }
}

@media (max-width: 991.98px) {
    .app-content { padding-bottom: 6.2rem; }
    .app-sidebar .offcanvas-header { color: #fff; }
    .sidebar-inner { padding-top: .25rem; }
    .sidebar-inner > .brand { display: none; }
    .dashboard-grid,
    .detail-grid { grid-template-columns: 1fr; }
    .allocation-layout { grid-template-columns: 1fr; }
    .allocation-summary { position: static; }
    .bank-grid,
    .entity-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .search-grid { grid-template-columns: 1fr 1fr; }
    .login-layout { grid-template-columns: 1fr; }
    .login-story { min-height: 370px; }
    .login-story-foot { display: none; }
}

@media (max-width: 767.98px) {
    body { font-size: .91rem; }
    .app-topbar { height: 66px; padding: .65rem .8rem; }
    .top-search { width: auto; min-width: 0; flex: 1; }
    .top-search input { font-size: .8rem; }
    .topbar-action { padding-right: .65rem; padding-left: .65rem; }
    .app-content { padding: 1.1rem .85rem 6.2rem; }
    .page-heading { align-items: flex-start; margin-bottom: 1.15rem; flex-direction: column; }
    .page-heading h1 { font-size: 1.65rem; }
    .page-actions { width: 100%; justify-content: flex-start; }
    .page-actions .btn-primary { flex: 1; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: .7rem; }
    .kpi-card { min-height: 126px; padding: .9rem; border-radius: 15px; }
    .kpi-topline { align-items: flex-start; }
    .kpi-icon { width: 2rem; height: 2rem; }
    .kpi-value { margin-top: .65rem; font-size: 1.45rem; }
    .kpi-note { font-size: .65rem; }
    .finance-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .finance-metric:nth-child(odd)::before { display: none; }
    .finance-metric:nth-child(even)::before { display: block; }
    .dashboard-grid { gap: .8rem; }
    .app-card { border-radius: 15px; }
    .app-card-header { min-height: 58px; padding: .8rem .9rem; }
    .app-card-body { padding: .9rem; }
    .filter-grid { grid-template-columns: 1fr 1fr; }
    .filter-actions { grid-column: 1 / -1; }
    .filter-actions .btn:first-child { flex: 1; }
    .form-grid { grid-template-columns: 1fr; }
    .form-field-wide,
    .form-field-check { grid-column: auto; }
    .form-actions-bar { position: sticky; z-index: 5; bottom: 4.85rem; margin-right: -.9rem; margin-bottom: -.9rem; margin-left: -.9rem; padding: .8rem .9rem; background: rgba(255, 255, 255, .96); box-shadow: 0 -8px 18px rgba(25, 55, 47, .05); backdrop-filter: blur(10px); }
    .form-actions-bar .btn-primary { flex: 1; }
    .responsive-table thead { display: none; }
    .responsive-table,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td { display: block; width: 100%; }
    .responsive-table tbody { display: grid; gap: .65rem; padding: .7rem; }
    .responsive-table tbody tr { padding: .75rem; background: #fff; border: 1px solid var(--app-border); border-radius: 12px; box-shadow: 0 3px 10px rgba(25, 55, 47, .035); }
    .responsive-table tbody td { display: flex; min-height: 34px; align-items: center; justify-content: space-between; gap: .8rem; padding: .35rem 0; border: 0; text-align: right; }
    .responsive-table tbody td::before { color: var(--app-muted); font-size: .64rem; font-weight: 700; letter-spacing: .04em; text-align: left; text-transform: uppercase; content: attr(data-label); }
    .responsive-table tbody td.mobile-card-title { justify-content: flex-start; padding-bottom: .6rem; border-bottom: 1px solid var(--app-border); text-align: left; }
    .responsive-table tbody td.mobile-card-title::before,
    .responsive-table tbody td.mobile-card-actions::before { display: none; }
    .responsive-table tbody td.mobile-card-actions { padding-top: .65rem; }
    .responsive-table .row-actions { width: 100%; justify-content: stretch; }
    .responsive-table .row-actions .btn { flex: 1; }
    .amount-breakdown { grid-template-columns: 1fr; }
    .amount-breakdown-item + .amount-breakdown-item { border-top: 1px solid var(--app-border); border-left: 0; }
    .adjustment-preview { grid-template-columns: 1fr 1fr; }
    .adjustment-preview > div:nth-child(3) { border-top: 1px solid var(--app-border); border-left: 0; }
    .adjustment-preview > div:nth-child(4) { border-top: 1px solid var(--app-border); }
    .decision-row { grid-template-columns: 1fr; }
    .decision-row > :nth-child(3) { display: block; }
    .decision-options { align-items: stretch; flex-direction: column; }
    .decision-options span { width: 100%; }
    .allocation-input { width: 105px; }
    .bank-grid,
    .entity-grid,
    .search-grid { grid-template-columns: 1fr; }
    .entity-card { min-height: 156px; }
    .agenda-day { grid-template-columns: 55px minmax(0, 1fr); gap: .65rem; }
    .agenda-date strong { font-size: 1.3rem; }
    .timeline-meta { align-items: flex-start; flex-direction: column; gap: .15rem; }
    .pagination-wrap { align-items: flex-start; flex-direction: column; }
    .pagination-summary { display: none; }
    .login-story { min-height: 305px; padding: 1.4rem; }
    .login-story-copy { margin-top: 3rem; }
    .login-story-copy h1 { font-size: 2.35rem; }
    .login-story-copy > p { margin-top: 1rem; font-size: .85rem; }
    .login-proof { display: none; }
    .login-panel { padding: 1rem; }
    .login-card { padding: 1.3rem; border-radius: 18px; }
}

@media (max-width: 420px) {
    .top-search { max-width: 45px; justify-content: center; }
    .top-search input { position: absolute; width: 1px; height: 1px; opacity: 0; }
    .top-search:focus-within { position: absolute; z-index: 2; right: .8rem; left: 3.8rem; max-width: none; justify-content: flex-start; }
    .top-search:focus-within input { position: static; width: auto; height: auto; opacity: 1; }
    .kpi-grid { grid-template-columns: 1fr; }
    .finance-strip { grid-template-columns: 1fr; }
    .finance-metric + .finance-metric::before { top: 0; right: 1rem; bottom: auto; left: 1rem; width: auto; height: 1px; display: block; }
    .adjustment-preview { grid-template-columns: 1fr; }
    .adjustment-preview > div + div { border-top: 1px solid var(--app-border); border-left: 0; }
}

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

@media print {
    .app-sidebar,
    .app-topbar,
    .mobile-tabbar,
    .page-actions,
    .filter-panel,
    .row-actions { display: none !important; }
    .app-stage { margin: 0 !important; }
    .app-content { max-width: none; padding: 0; }
    .app-card,
    .kpi-card { box-shadow: none; break-inside: avoid; }
}
