@import url("tokens-8St03KR.css");

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 120px; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'ss01', 'cv11';
}
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.2; margin: 0 0 .5em; color: var(--ink); }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0 0 1em; }
a { color: var(--brand-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--brand); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.mono { font-variant-numeric: tabular-nums; }
.code { font-family: var(--font-mono); font-size: .92em; }
.money { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.money.neg { color: var(--danger); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; background: var(--surface); padding: 10px 16px; border-radius: var(--radius-pill); z-index: var(--z-skip); }
.skip-link:focus { top: 12px; }
.icon { flex: none; vertical-align: -0.2em; }

/* --- Gabarit application ------------------------------------------------------------------ */
.app { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
    padding: 18px 12px 14px; background: var(--sidebar-bg); border-right: 1px solid var(--line); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px 18px; text-decoration: none; color: var(--ink); }
.brand img, .brand svg { width: 30px; height: 30px; }
.brand span { font-weight: 750; font-size: 19px; letter-spacing: -0.04em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 16px 12px 6px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.nav a {
    position: relative; display: flex; align-items: center; gap: 11px; min-height: 36px; padding: 0 12px; border-radius: 9px;
    color: var(--ink-2); text-decoration: none; font-weight: 550; font-size: 13.5px;
}
.nav a .icon { color: var(--muted); }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a:hover .icon { color: var(--ink-2); }
.nav a[aria-current='page'] { background: var(--brand-soft); color: var(--brand-ink); }
.nav a[aria-current='page'] .icon { color: var(--brand); }
.nav a[aria-current='page']::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: 12px; border-top: 1px solid var(--line); }
.who { padding: 0 8px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.who strong { display: block; color: var(--ink); font-size: 14px; }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: var(--z-header); display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 28px;
    background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.crumbs strong { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.crumbs .icon { opacity: .6; }
.topbar-spacer { flex: 1; }
.search-trigger {
    display: inline-flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px 0 12px; min-width: 260px; border-radius: 10px;
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); font: 500 13px var(--font); cursor: pointer;
}
.search-trigger:hover { border-color: var(--muted); color: var(--ink-2); }
.search-trigger span { flex: 1; text-align: left; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent;
    background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface); border-color: var(--line-strong); }
.icon-moon { display: none; }
:root[data-theme='dark'] .icon-sun { display: none; }
:root[data-theme='dark'] .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) .icon-sun { display: none; }
    :root:not([data-theme='light']) .icon-moon { display: inline; }
}
.only-mobile { display: none; }
.avatar {
    display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; border: 0;
    background: var(--brand-soft); color: var(--brand-ink); font: 700 13px var(--font); cursor: pointer;
}
.avatar:hover { box-shadow: 0 0 0 3px var(--brand-soft); }
.pop-menu {
    margin: 0; inset: auto; position: fixed; top: 60px; right: 24px; min-width: 230px; padding: 6px; border: 1px solid var(--line-strong);
    border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop);
}
.pop-menu .who-block { padding: 10px 12px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.pop-menu .who-block strong { display: block; font-size: 14px; }
.pop-menu .who-block span { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.pop-menu a, .pop-menu button.menu-link {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 12px; border: 0; border-radius: 8px; background: none;
    color: var(--ink-2); text-decoration: none; font: 550 13.5px var(--font); text-align: left; cursor: pointer;
}
.pop-menu a:hover, .pop-menu button.menu-link:hover { background: var(--surface-2); color: var(--ink); }

/* Onglets de section (barre sous l'en-tête) et sous-onglets */
.tabs { position: sticky; top: 56px; z-index: var(--z-sticky); display: flex; gap: 2px; padding: 0 28px; background: var(--bg); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
    position: relative; display: inline-flex; align-items: center; height: 44px; padding: 0 14px; color: var(--muted); text-decoration: none;
    font-weight: 600; font-size: 13.5px; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current='page'] { color: var(--ink); }
.tabs a[aria-current='page']::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--brand); }
.subtabs { display: flex; gap: 6px; padding: 12px 28px 0; overflow-x: auto; scrollbar-width: none; }
.subtabs a { flex: none; white-space: nowrap; }
.subtabs a {
    display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: var(--radius-pill); color: var(--ink-2); text-decoration: none;
    font-weight: 550; font-size: 13px; border: 1px solid var(--line-strong); background: var(--surface);
}
.subtabs a:hover { border-color: var(--muted); }
.subtabs a[aria-current='page'] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.main { padding: 24px 28px 96px; max-width: 1320px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.mobile-nav { display: none; }

/* --- Composants --------------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 16px;
    border: 1px solid transparent; border-radius: 10px; font: 600 13.5px var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
    background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-sm); transition: background .15s, transform .05s;
}
.btn:hover { background: var(--brand-hover); color: var(--on-brand); }
.btn:active { transform: translateY(1px); }
.btn-dark { background: var(--dark-btn); color: var(--on-dark-btn); }
.btn-dark:hover { background: var(--dark-btn); filter: brightness(1.15); color: var(--on-dark-btn); }
.btn-neutral { background: var(--surface); color: var(--ink); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.btn-neutral:hover { background: var(--surface-2); border-color: var(--muted); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); color: #fff; }
.btn-sm { min-height: 30px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
form.btn-row { margin: 0; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: var(--radius-pill); font-size: 11.5px; font-weight: 650; line-height: 1.6; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-success { background: var(--brand-soft); color: var(--brand-ink); }
.badge-pending { background: var(--accent-soft); color: var(--accent-ink); }
.badge-late { background: var(--danger-soft); color: var(--danger); }
.badge-draft { background: var(--line); color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-sm); padding: 20px; }
.card + .card { margin-top: 16px; }
.grid > .card, .grid > .card + .card, .kpis > .card, .kpis > .card + .card, .dash > .card + .card { margin-top: 0; }
.card > h2:first-child, .card-head h2 { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card-accent { background: var(--accent-soft); color: var(--accent-ink); box-shadow: none; border-color: transparent; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; }
.stat-label { font-size: 12.5px; font-weight: 550; color: var(--muted); }
.stat-value { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 22px; letter-spacing: -0.02em; line-height: 1.25; }
.stat-note { font-size: 12px; font-weight: 500; color: var(--muted); }
.stat-note a { color: var(--muted); }
.card-accent .stat-label, .card-accent .stat-note { color: var(--accent-ink); }

.gauge { height: 8px; border-radius: var(--radius-pill); background: var(--line); overflow: hidden; }
.gauge > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }

.table-wrap { overflow: auto; max-height: 70vh; border-radius: var(--radius-card); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.card .table-wrap { border: 0; box-shadow: none; border-radius: 0; margin: 0 -20px -20px; max-height: 60vh; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table thead th { position: sticky; top: 0; background: var(--surface-2); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); z-index: var(--z-base); white-space: nowrap; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td a { font-weight: 550; color: var(--ink); text-decoration: none; }
.table td a:hover { color: var(--brand-ink); text-decoration: underline; }
.table td:last-child:has(.btn) { white-space: nowrap; }
.table td .btn + .btn, .table td .btn + form, .table td form + .btn, .table td form + form { margin-left: 4px; }
.table td form { display: inline-block; margin: 0; }
h1 small, h1 .count { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.table-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label, .field legend { font-weight: 600; font-size: 13px; padding: 0; color: var(--ink-2); }
.field .help { font-size: 12.5px; color: var(--muted); }
.field .error, .form-errors { font-size: 12.5px; color: var(--danger); font-weight: 600; }
input[type='text'], input[type='email'], input[type='password'], input[type='number'], input[type='search'], input[type='date'], input[type='month'], select, textarea {
    min-height: 38px; padding: 0 12px; width: 100%; font: 500 14px var(--font); color: var(--ink);
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-field); transition: border-color .15s, box-shadow .15s;
}
textarea { padding: 10px 12px; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.btn-row input, .btn-row select, .table-filters input, .table-filters select { width: auto; }
.field-money { position: relative; }
.field-money input { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; padding-right: 34px; }
.field-money::after { content: '€'; position: absolute; right: 13px; bottom: 8px; color: var(--muted); font-weight: 600; }
fieldset.field { border: 0; margin: 0 0 16px; padding: 0; }
.choice { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.choice input { width: 17px; height: 17px; accent-color: var(--brand); }
.choice label { font-weight: 500; }

.dropzone {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px; text-align: center; cursor: pointer;
    border: 1.5px dashed var(--line-strong); border-radius: var(--radius-card); color: var(--muted); background: var(--surface-2);
}
.dropzone.is-over, .dropzone:hover { border-color: var(--brand); color: var(--brand-ink); background: var(--brand-soft); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.card-head .period { margin-bottom: 0; }
.period { max-width: 100%; overflow-x: auto; scrollbar-width: thin; }
.card .table-wrap { max-height: none; }
.table td.btn-row { display: table-cell; white-space: nowrap; }
.period { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 10px; background: var(--line); margin-bottom: 12px; }
.period a, .period button { min-height: 28px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font: 600 12.5px var(--font); text-decoration: none; display: inline-flex; align-items: center; cursor: pointer; }
.period a:hover { color: var(--ink); }
.period [aria-current='true'] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

dialog { border: 1px solid var(--line-strong); border-radius: 16px; padding: 24px; max-width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); }
dialog::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
dialog h2 { margin-bottom: 8px; }

.toasts { position: fixed; z-index: var(--z-popover); right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; background: var(--dark-btn); color: var(--on-dark-btn); box-shadow: var(--shadow-pop); font-weight: 500; font-size: 13.5px; }
.toast-success { border-left: 4px solid var(--brand); }
.toast-danger { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--info); }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; font-size: 18px; cursor: pointer; min-width: 28px; min-height: 28px; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 40px 24px; text-align: center; color: var(--muted); }
.empty img { opacity: .9; }
.empty h3 { color: var(--ink); font-size: 15px; }
.empty p { max-width: 460px; margin-bottom: 8px; }
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--line), var(--surface-2), var(--line)); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; min-height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.palette { padding: 0; width: min(580px, calc(100vw - 32px)); margin-top: 12vh; }
.palette input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; min-height: 52px; padding: 0 20px; font-size: 16px; box-shadow: none !important; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto; }
.palette li a { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 12px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 550; }
.palette li a:hover, .palette li a:focus { background: var(--brand-soft); color: var(--brand-ink); }
.palette .palette-group { padding: 10px 12px 4px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.palette-results:empty { display: none; }
.palette li a .pl-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette li a small { flex: none; white-space: nowrap; font-weight: 500; }
.palette input[type='search']::-webkit-search-cancel-button { display: none; }
kbd { font: 600 11px var(--font-mono); padding: 2px 6px; border-radius: 5px; background: var(--line); color: var(--ink-2); border: 1px solid var(--line-strong); border-bottom-width: 2px; }

/* --- Pages d'authentification ------------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(900px 500px at 50% -10%, var(--brand-soft), transparent 70%), var(--bg); }
.auth-card { width: min(420px, 100%); }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 20px; text-align: center; }
.auth-brand img { width: 52px; height: 52px; }
.auth-brand span { font-weight: 750; font-size: 28px; letter-spacing: -0.045em; }
.auth-card .card { padding: 28px; box-shadow: var(--shadow); }
.auth-card .btn { width: 100%; min-height: 40px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 13px; }
.alert { padding: 10px 14px; border-radius: var(--radius-field); margin-bottom: 16px; font-weight: 600; font-size: 13.5px; }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--brand-soft); color: var(--brand-ink); }
.alert-warning { background: var(--accent-soft); color: var(--accent-ink); }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 16px 0; font-family: var(--font-mono); font-weight: 600; }
.codes li { list-style: none; padding: 8px 12px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-ink); text-align: center; }
.qr { display: flex; justify-content: center; padding: 16px; background: #fff; border-radius: 14px; margin-bottom: 16px; }
.inline-form { display: inline; margin: 0; }

.todo { list-style: none; margin: 0; padding: 0; }
.todo li { padding: 0; border-bottom: 1px solid var(--line); }
.todo li:last-child { border-bottom: 0; }
.todo a { display: flex; align-items: center; gap: 10px; padding: 9px 0; color: var(--ink); text-decoration: none; font-weight: 500; }
.todo a:hover { color: var(--brand-ink); }
.todo .icon { margin-left: auto; color: var(--muted); }

/* --- Graphiques ---------------------------------------------------------------------------- */
.chart { position: relative; margin: 0; }
.chart-svg { display: block; width: 100%; overflow: visible; touch-action: pan-y; }
.chart-svg text { font: 500 11px var(--font); fill: var(--chart-text); }
.chart-grid line { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-axis line { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart-cursor { stroke: var(--chart-axis); stroke-width: 1; pointer-events: none; }
.chart-mark { transition: opacity .15s; }
.chart-mark.is-dim { opacity: .35; }
.chart-tip {
    position: absolute; z-index: var(--z-raised); min-width: 150px; max-width: 260px; padding: 9px 11px; border-radius: 10px; pointer-events: none;
    background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); box-shadow: var(--shadow-pop); font-size: 12.5px; opacity: 0;
    transform: translateY(4px); transition: opacity .12s, transform .12s;
}
.chart-tip.is-on { opacity: 1; transform: none; }
.chart-tip .tip-title { font-weight: 650; margin-bottom: 4px; color: var(--ink); }
.chart-tip .tip-row { display: flex; align-items: center; gap: 8px; padding: 1px 0; }
.chart-tip .tip-key { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.chart-tip .tip-label { color: var(--muted); flex: 1; }
.chart-tip .tip-value { font-weight: 650; font-variant-numeric: tabular-nums; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 8px; padding: 0; list-style: none; }
.chart-legend button { display: inline-flex; align-items: center; gap: 7px; padding: 2px 4px; border: 0; border-radius: 6px; background: none; color: var(--ink-2); font: 550 12.5px var(--font); cursor: pointer; }
.chart-legend button:hover { background: var(--surface-2); }
.chart-legend button[aria-pressed='false'] { opacity: .45; text-decoration: line-through; }
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.chart-legend .swatch-line { height: 3px; width: 14px; border-radius: 2px; }
.chart-legend .legend-value { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.chart-table { margin-top: 8px; font-size: 12.5px; }
.chart-table summary { cursor: pointer; color: var(--muted); font-weight: 550; }
.chart-table table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.chart-table th, .chart-table td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.chart-table th:first-child, .chart-table td:first-child { text-align: left; }
.chart-anim .chart-line { stroke-dasharray: var(--len, 2000); stroke-dashoffset: var(--len, 2000); animation: draw .9s cubic-bezier(.3, .7, .2, 1) forwards; }
.chart-anim .chart-area { opacity: 0; animation: fade .6s .35s ease forwards; }
.chart-anim .chart-bar { transform-box: fill-box; transform-origin: 50% 100%; animation: grow .6s cubic-bezier(.3, .7, .2, 1) both; }
.chart-anim .chart-bar.is-neg { transform-origin: 50% 0; }
.chart-anim .chart-arc { animation: fade .6s ease both; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: 1; } from { opacity: 0; } }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) { .chart-anim .chart-line, .chart-anim .chart-area, .chart-anim .chart-bar, .chart-anim .chart-arc { animation: none; stroke-dashoffset: 0; opacity: 1; } }
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut-wrap .chart-svg { width: 168px; flex: none; }
.donut-legend { flex: 1; min-width: 170px; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.donut-legend button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 4px 6px; border: 0; border-radius: 6px; background: none; color: var(--ink-2); font: 550 12.5px var(--font); cursor: pointer; text-align: left; }
.donut-legend button:hover, .donut-legend button.is-active { background: var(--surface-2); }
.donut-legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.donut-legend .legend-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend .legend-value { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.donut-legend .legend-pct { color: var(--muted); width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.spark { display: block; width: 100%; height: 34px; }
.spark path { fill: none; stroke: var(--chart-axis); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.spark .spark-area { stroke: none; fill: var(--brand); opacity: .1; }
.spark .spark-now { stroke: none; fill: var(--brand); }
.spark .spark-line { stroke: var(--brand); }

/* --- Tableau de bord ----------------------------------------------------------------------- */
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.hero h1 { font-size: 24px; margin-bottom: 2px; }
.hero-figure { font-size: 44px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.05; }
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 14px; }
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px 12px; text-decoration: none; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
a.kpi:hover { border-color: var(--line-strong); box-shadow: var(--shadow); color: var(--ink); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 550; }
.kpi-chip { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-ink); }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.15; }
.kpi > [data-controller], .kpi .gauge { margin-top: auto; }
.kpi-note { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 650; font-size: 12px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--danger); }
.dash { display: grid; gap: 14px; grid-template-columns: repeat(12, minmax(0, 1fr)); margin-bottom: 14px; }
.dash > .card { margin: 0; min-width: 0; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { flex: none; width: 46px; text-align: center; line-height: 1.1; }
.timeline .when strong { display: block; font-size: 17px; font-weight: 650; }
.timeline .when span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }
.timeline .what { flex: 1; min-width: 0; }
.timeline .what a { color: var(--ink); font-weight: 550; text-decoration: none; }
.timeline .what a:hover { color: var(--brand-ink); }
.timeline .what small { display: block; color: var(--muted); }
.meter-list { display: flex; flex-direction: column; gap: 12px; }
.meter-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; font-size: 13px; }
.meter-row .gauge { grid-column: 1 / -1; height: 6px; }
.meter-row .gauge > span { background: var(--c1); }

/* --- Adaptation ---------------------------------------------------------------------------- */
.drawer { margin: 0; padding: 0; width: min(300px, 86vw); height: 100vh; max-height: 100vh; border: 0; border-radius: 0 16px 16px 0; inset: 0 auto 0 0; background: var(--sidebar-bg); }
.drawer .drawer-inner { display: flex; flex-direction: column; gap: 4px; padding: 18px 12px; min-height: 100%; }
.drawer::backdrop { background: var(--overlay); }
@media (pointer: coarse) {
    .btn { min-height: 44px; }
    .btn-sm { min-height: 38px; }
    input[type='text'], input[type='email'], input[type='password'], input[type='number'], input[type='search'], input[type='date'], input[type='month'], select { min-height: 44px; }
}
@media (max-width: 1180px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
    .search-trigger { min-width: 0; }
    .search-trigger kbd { display: none; }
}
@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .only-mobile { display: inline-flex; }
    .topbar { padding: 0 14px; }
    .tabs { padding: 0 8px; top: 56px; }
    .subtabs { padding: 10px 14px 0; overflow-x: auto; }
    .main { padding: 18px 14px 110px; }
    .search-trigger span, .search-trigger kbd { display: none; }
    .search-trigger { min-width: 0; width: 36px; padding: 0; justify-content: center; }
    .crumbs .crumb-section { display: none; }
    .mobile-nav {
        display: flex; position: fixed; z-index: var(--z-nav); left: 50%; bottom: 14px; transform: translateX(-50%); gap: 2px; padding: 5px;
        border-radius: var(--radius-pill); background: var(--dark-btn); box-shadow: var(--shadow-pop);
    }
    .mobile-nav a, .mobile-nav button {
        display: flex; align-items: center; gap: 6px; min-height: 42px; min-width: 42px; padding: 0 14px; border: 0; border-radius: var(--radius-pill);
        background: transparent; color: var(--on-dark-btn); font: 600 13px var(--font); text-decoration: none; cursor: pointer;
    }
    .mobile-nav [aria-current='page'] { background: var(--brand); color: var(--on-brand); }
    .toasts { bottom: 84px; }
    h1 { font-size: 20px; }
    .card .table-wrap { margin: 0 -20px -20px; }
    .hero-figure { font-size: 34px; }
}
@media (max-width: 560px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .kpi { padding: 12px 12px 10px; }
    .kpi-value { font-size: 18px; }
    .kpi-note { font-size: 11px; }
}
@media print { .sidebar, .mobile-nav, .toasts, .topbar, .tabs, .subtabs { display: none; } .app { display: block; } .card { box-shadow: none; } }

/* Finitions : pages d'erreur, rythme typographique, retours d'interaction, échelle de couches */
.error-code { margin: 0 0 4px; font: 700 44px/1 var(--font-mono, var(--font)); letter-spacing: -0.04em; color: var(--brand); font-variant-numeric: tabular-nums; }
.error-actions { margin-top: 18px; }
.auth-card .error-actions .btn { width: auto; }
h1, h2, h3 { text-wrap: balance; }
p, li, .muted, .empty p { text-wrap: pretty; }
.card, .tabs a, .subtabs a, .nav a, .icon-btn, .pop-menu a, .table tbody td { transition: background-color .15s, border-color .15s, color .15s, box-shadow .2s, transform .1s; }
.icon-btn:active, .tabs a:active, .subtabs a:active, .nav a:active { transform: translateY(1px); }
a.card:hover, .card.is-link:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.turbo-progress-bar { background: var(--brand); height: 2px; }
@media (prefers-reduced-motion: no-preference) {
    @keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
    .dash > .card, .kpis > .card, .page-head, .main > .card { animation: rise .35s cubic-bezier(.2, .7, .2, 1) both; }
    .dash > .card:nth-child(2), .kpis > .card:nth-child(2) { animation-delay: .04s; }
    .dash > .card:nth-child(3), .kpis > .card:nth-child(3) { animation-delay: .08s; }
    .dash > .card:nth-child(4), .kpis > .card:nth-child(4) { animation-delay: .12s; }
    .dash > .card:nth-child(n+5) { animation-delay: .16s; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
html { scroll-behavior: smooth; }
.w-auto { width: auto; } .text-sm { font-size: 12px; } .fw-600 { font-weight: 600; }
.mt-8 { margin-top: 8px; } .mt-14 { margin-top: 14px; } .mt-16 { margin-top: 16px; }
/* Lecture immédiate d'un document : champs remplis automatiquement et message d'état. */
.is-autofilled { border-color: var(--brand) !important; box-shadow: 0 0 0 3px var(--brand-soft) !important; }
.read-status { margin: 8px 0 0; padding: 8px 12px; border-radius: var(--radius-field); background: var(--brand-soft); color: var(--ink); font-size: 13px; }
.read-status[data-kind="warn"] { background: var(--surface-2); border-left: 3px solid var(--accent); }
.read-status[data-kind="pending"] { background: var(--surface-2); color: var(--muted); }
/* Tri des colonnes : l'en-tête devient un bouton ; la flèche indique le sens du tri. */
.table th .th-sort { all: unset; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; }
.table th.num .th-sort { flex-direction: row-reverse; }
.table th .th-sort::after { content: '↕'; font-size: 11px; opacity: .35; transition: opacity .15s; }
.table th .th-sort:hover::after { opacity: .8; }
.table th .th-sort:hover { color: var(--ink); }
.table th .th-sort:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.table th[aria-sort="ascending"] .th-sort::after { content: '↑'; opacity: 1; color: var(--brand); }
.table th[aria-sort="descending"] .th-sort::after { content: '↓'; opacity: 1; color: var(--brand); }
.table th[aria-sort="ascending"], .table th[aria-sort="descending"] { color: var(--ink); }
.table th a.th-sort { text-decoration: none; }
/* Arrêté des comptes : frise du cycle annuel, confirmations et rapport. */
.cycle { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; counter-reset: step; }
.timeline-step { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 0 12px 4px 0; }
.timeline-step::before { content: ''; position: absolute; top: 15px; left: 32px; right: 0; height: 2px; background: var(--line-strong); }
.timeline-step:last-child::before { display: none; }
.timeline-step.is-done::before { background: var(--brand); }
.timeline-dot { position: relative; z-index: 1; display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); color: var(--muted); font: 700 13px var(--font); }
.timeline-step.is-done .timeline-dot { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.timeline-step.is-current .timeline-dot { border-color: var(--brand); color: var(--brand-ink); box-shadow: 0 0 0 4px var(--brand-soft); }
.timeline-step.is-late .timeline-dot { border-color: var(--danger); background: var(--danger); color: #fff; }
.timeline-label { margin-top: 6px; font-weight: 650; color: var(--ink); }
.timeline-date { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline-state { font-size: 12px; font-weight: 600; color: var(--muted); }
.timeline-step.is-current .timeline-state { color: var(--brand-ink); }
.timeline-step.is-late .timeline-state { color: var(--danger); }
.timeline-step.is-done .timeline-state { color: var(--brand-ink); }
@media (max-width: 760px) {
    .cycle { grid-template-columns: 1fr; gap: 14px; }
    .timeline-step { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 10px; padding: 0; }
    .timeline-step::before { display: none; }
    .timeline-label { margin-top: 0; }
    .timeline-date, .timeline-state { width: 100%; padding-left: 40px; }
}
.check-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-field); margin-top: 8px; background: var(--surface-2); cursor: pointer; }
.check-row input { margin-top: 3px; flex: none; }
.report { white-space: normal; line-height: 1.6; max-width: 75ch; }
/* Liste libellé / valeur (paramètres). */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0 0 14px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; }
.timeline-step { border: 0; }
/* États de l'arrêté : tableaux côte à côte dans la carte, sans la marge négative des tableaux de bas de carte. */
.states .table-wrap { margin: 0 0 8px; }
.states .grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* Aide contextuelle (Fiscalité) : « i » dépliable, règle de la notice et source du calcul. */
.hint { display: inline-block; vertical-align: middle; position: relative; }
.hint > summary { list-style: none; display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; border: 1px solid var(--line-strong); color: var(--muted); font: 700 11px/1 var(--font); cursor: pointer; text-transform: none; letter-spacing: 0; }
.hint > summary::-webkit-details-marker { display: none; }
.hint[open] > summary, .hint > summary:hover { border-color: var(--brand); color: var(--brand-ink); }
.hint-body { position: absolute; z-index: 30; top: 22px; left: 50%; transform: translateX(-50%); width: min(380px, calc(100vw - 32px)); padding: 10px 12px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-field); box-shadow: 0 8px 24px rgba(11, 18, 32, .14); font-size: 12.5px; font-weight: 400; line-height: 1.45; color: var(--ink); text-align: left; text-transform: none; letter-spacing: 0; white-space: normal; }
.hint-body p { margin: 6px 0 0; }
/* Dans un tableau défilant, l'aide se déplie dans la cellule (une bulle absolue serait rognée). */
.table-wrap .hint { display: inline; position: static; }
.table-wrap .hint-body { position: static; display: block; transform: none; width: auto; max-width: 420px; margin-top: 6px; box-shadow: none; }
