:root {
    color-scheme: light;
    --bg: #f3efe6;
    --panel: #fffcf7;
    --line: #ddd4c6;
    --line-2: #cfc6b6;
    --text: #1b2430;
    --muted: #66707c;
    --navy: #10243a;
    --navy-2: #1a3a58;
    --teal: #1a7a86;
    --teal-2: #2b7de9;
    --amber: #b8862c;
    --plus: #1f6b4a;
    --minus: #a33b3b;
    --minus-soft: #fbe9e9;
    --navy-3: #0b1a2b;
    --soft: #f7f3ea;
    --soft-2: #efe8d8;
    --track: #ece6d8;
    --tab: #ebe5d9;
    --tab-hover: #f2ece0;
    --zero: #b3ab9e;
    --ok-bg: #e8f5ee;
    --ok-line: #c9e4d3;
    --warn-bg: #fdf7e8;
    --warn-chip: #fbeccd;
    --warn-text: #8a5f13;
    --edit-bg: #fff8e3;
    --mark: #ffeeb4;
    --mark-2: #ffe79b;
    --side-muted: #9aabbd;
    --teal-soft: #eef6f4;
    --sticky-bg: #fffcf7;
    --shadow: 0 10px 28px rgba(28, 24, 16, .08);
    --sans: "Source Sans 3", "Segoe UI", sans-serif;
    --display: "Source Sans 3", "Segoe UI", sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, monospace;
    --side: 248px;
    --radius: 10px;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0e1620;
    --panel: #17222e;
    --line: #2a3745;
    --line-2: #354555;
    --text: #e7edf3;
    --muted: #94a3b2;
    --navy: #0a121b;
    --navy-2: #1d3247;
    --navy-3: #060b12;
    --teal: #37a9b5;
    --teal-2: #4b93ef;
    --amber: #d7a441;
    --plus: #4cc38a;
    --minus: #ef6f6f;
    --minus-soft: #341c1c;
    --soft: #131d28;
    --soft-2: #1f2b38;
    --track: #25323f;
    --tab: #141e29;
    --tab-hover: #1b2734;
    --zero: #5b6875;
    --ok-bg: #16302a;
    --ok-line: #24503f;
    --warn-bg: #2a2416;
    --warn-chip: #3c3119;
    --warn-text: #dfba63;
    --edit-bg: #33290f;
    --mark: #4d3d0d;
    --mark-2: #604c10;
    --side-muted: #8595a6;
    --teal-soft: #12292d;
    --sticky-bg: #17222e;
    --shadow: 0 12px 30px rgba(0, 0, 0, .45);
}
:root[data-theme="dark"] .ledger td.heat { color: #f2f6fa; }
:root[data-theme="dark"] .pick-bar { background: #05306b; }

* { box-sizing: border-box; }
/* garde-fou : un display posé par une classe ne doit jamais réafficher un élément masqué en JS */
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
    background:
        linear-gradient(180deg, var(--soft) 0%, var(--bg) 220px);
    color: var(--text);
    font: 15px/1.5 var(--sans);
}

.sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: var(--side);
    padding: 22px 16px;
    display: flex; flex-direction: column; gap: 22px;
    background: var(--navy);
    border-right: 1px solid var(--navy-3);
    z-index: 30;
}
.brand {
    display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
    text-decoration: none; color: inherit; padding: 0;
}
.brand .logo {
    width: 100%;
    height: auto;
    display: block;
    background: transparent;
    border-radius: 0;
    padding: 4px 2px;
}
.brand small { color: #b7c3d1; padding: 0 4px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a,
.sidebar nav a:link,
.sidebar nav a:visited {
    display: flex; align-items: center; gap: 12px;
    color: #d5deea; text-decoration: none;
    padding: 10px 12px; border-radius: 8px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav .nav-btn {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 10px 12px; border: 0; border-radius: 8px;
    font: inherit; text-align: left; color: #d5deea; background: transparent; cursor: pointer;
}
.sidebar nav .nav-btn:hover { background: rgba(255,255,255,.06); color: #fff; }
/* switch « Masquer budget » : colonnes Budget / Écart de tous les tableaux */
body.hide-budget .ledger .col-bud { display: none; }
.sidebar nav a.is-on,
.sidebar nav a.is-on:link,
.sidebar nav a.is-on:visited {
    background: #fff;
    color: var(--navy);
    font-weight: 600;
}
.ico {
    width: 18px; height: 18px; display: inline-block;
    background: currentColor; opacity: .9;
    -webkit-mask-size: contain; mask-size: contain;
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    -webkit-mask-position: center; mask-position: center;
}
.ico-bulb { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M12 2a6.5 6.5 0 00-3.9 11.7c.5.4.8 1 .9 1.6l.1.7h5.8l.1-.7c.1-.6.4-1.2.9-1.6A6.5 6.5 0 0012 2zm-2.8 15.6h5.6v1.6H9.2v-1.6zm1 3.2h3.6V22h-3.6v-1.2z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M12 2a6.5 6.5 0 00-3.9 11.7c.5.4.8 1 .9 1.6l.1.7h5.8l.1-.7c.1-.6.4-1.2.9-1.6A6.5 6.5 0 0012 2zm-2.8 15.6h5.6v1.6H9.2v-1.6zm1 3.2h3.6V22h-3.6v-1.2z'/></svg>"); }
.ico-key { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M3 6h18a1 1 0 011 1v10a1 1 0 01-1 1H3a1 1 0 01-1-1V7a1 1 0 011-1zm2 3v2h2V9H5zm4 0v2h2V9H9zm4 0v2h2V9h-2zm4 0v2h2V9h-2zM5 13v2h2v-2H5zm4 0v2h6v-2H9zm8 0v2h2v-2h-2z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M3 6h18a1 1 0 011 1v10a1 1 0 01-1 1H3a1 1 0 01-1-1V7a1 1 0 011-1zm2 3v2h2V9H5zm4 0v2h2V9H9zm4 0v2h2V9h-2zm4 0v2h2V9h-2zM5 13v2h2v-2H5zm4 0v2h6v-2H9zm8 0v2h2v-2h-2z'/></svg>"); }
.ico-grid { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M3 3h8v8H3V3zm10 0h8v8h-8V3zM3 13h8v8H3v-8zm10 0h8v8h-8v-8z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M3 3h8v8H3V3zm10 0h8v8h-8V3zM3 13h8v8H3v-8zm10 0h8v8h-8v-8z'/></svg>"); }
.ico-up { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M11 16V7.8L7.4 11.4 6 10l6-6 6 6-1.4 1.4L13 7.8V16h-2zm-7 4v-2h16v2H4z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M11 16V7.8L7.4 11.4 6 10l6-6 6 6-1.4 1.4L13 7.8V16h-2zm-7 4v-2h16v2H4z'/></svg>"); }
.ico-aim { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M12 2a10 10 0 1010 10h-2a8 8 0 11-8-8V2zm0 6a4 4 0 100 8 4 4 0 000-8zm0 2a2 2 0 110 4 2 2 0 010-4z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M12 2a10 10 0 1010 10h-2a8 8 0 11-8-8V2zm0 6a4 4 0 100 8 4 4 0 000-8zm0 2a2 2 0 110 4 2 2 0 010-4z'/></svg>"); }
.ico-list { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M4 6h16v2H4V6zm0 5h16v2H4v-2zm0 5h16v2H4v-2z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M4 6h16v2H4V6zm0 5h16v2H4v-2zm0 5h16v2H4v-2z'/></svg>"); }
.ico-user { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M12 12a4 4 0 100-8 4 4 0 000 8zm0 2c-4.4 0-8 2.2-8 5v1h16v-1c0-2.8-3.6-5-8-5z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M12 12a4 4 0 100-8 4 4 0 000 8zm0 2c-4.4 0-8 2.2-8 5v1h16v-1c0-2.8-3.6-5-8-5z'/></svg>"); }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.create-bar {
    display: flex; gap: 8px; align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 8px 8px 8px 12px;
    box-shadow: var(--shadow);
}
.create-bar .field { border: 0; min-width: 220px; background: transparent; }
.company-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 18px; }
.company-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 20px 20px 16px;
    display: flex; flex-direction: column; gap: 16px;
}
.company-card.is-on {
    border-color: transparent;
    box-shadow: 0 0 0 1px var(--teal), 0 16px 36px rgba(16,36,58,.08);
}
.company-top { display: flex; align-items: center; gap: 12px; }
.avatar {
    width: 46px; height: 46px; flex: 0 0 auto;
    display: grid; place-items: center;
    border-radius: 14px;
    background: var(--navy); color: #fff;
    font-weight: 700; letter-spacing: .04em;
}
.company-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.name-edit {
    width: 100%; font: inherit; font-size: 18px; font-weight: 700;
    border: 0; background: transparent; color: var(--text);
    padding: 2px 0; letter-spacing: -.02em;
}
.name-edit:focus { outline: none; box-shadow: 0 1px 0 var(--teal); }
.link-btn {
    border: 0; background: none; color: var(--teal);
    font: inherit; font-size: 12px; font-weight: 700;
    padding: 0; cursor: pointer; white-space: nowrap;
}
.company-name .link-btn { opacity: 0; pointer-events: none; }
.company-name:focus-within .link-btn { opacity: 1; pointer-events: auto; }
.link-btn.danger, .btn.danger { color: var(--minus); }
.company-metrics {
    display: grid; grid-template-columns: 1.1fr 1.6fr .7fr; gap: 12px;
    padding: 14px 14px 12px;
    background: var(--soft);
    border-radius: 12px;
}
.company-metrics small {
    display: block; color: var(--muted);
    font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.company-metrics strong {
    display: block; margin-top: 4px;
    font-family: var(--mono); font-size: 18px; font-weight: 500;
    white-space: nowrap;
}
.year-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.year-list li { display: grid; grid-template-columns: 46px 1fr auto auto; gap: 10px; align-items: center; }
.year-list .year { font-weight: 700; color: var(--text); }
.year-list .qty { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.year-list .track {
    height: 6px; border-radius: 99px; background: var(--track); overflow: hidden;
}
.year-list .track i {
    display: block; height: 100%;
    background: linear-gradient(90deg, var(--teal), var(--navy-2));
}
.empty-line { margin: 0; color: var(--muted); font-size: 14px; }
.company-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.side-meta { margin-top: auto; padding: 12px; color: var(--side-muted); font-size: 12px; }
.side-meta small { display: block; margin-top: 4px; }
.side-meta .user-line { color: #fff; font-weight: 700; margin-top: 10px; }
.side-meta .link-btn { color: var(--side-muted); margin-top: 4px; }
.login-body {
    min-height: 100vh;
    padding: 0;
    background:
        radial-gradient(circle at top, var(--navy-2) 0%, var(--navy) 46%, var(--navy-3) 100%);
}
.gate-stage {
    min-height: 100vh;
    display: grid;
    place-items: center;
    position: relative;
    padding: 32px 16px;
}
.gate-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
}
.gate-hero[hidden] { display: none; }
.gate-hero .logo {
    width: 220px; height: auto;
    background: transparent;
    border-radius: 0;
    padding: 0;
}
html[data-theme="dark"] .gate-hero .logo--light,
html[data-theme="dark"] .gate-brand-logo--light { display: none; }
.gate-box {
    width: min(440px, calc(100vw - 48px));
    z-index: 1;
}
.gate-box[hidden] { display: none; }
.gate-box.is-pinned { position: fixed; margin: 0; }
.gate-box .km-modal-header { cursor: grab; }
.gate-box.is-max .km-modal-header,
.gate-box.is-min .km-modal-header { cursor: default; }
.gate-brand-logo {
    width: 180px; height: auto;
    display: block;
    align-self: center;
    background: transparent;
    border-radius: 0;
    padding: 0;
    margin: 0 auto 8px;
}
.gate-hero .logo--dark,
.gate-brand-logo--dark { display: none; }
html[data-theme="dark"] .gate-hero .logo--dark,
html[data-theme="dark"] .gate-brand-logo--dark {
    display: block;
    background: transparent;
    padding: 0;
}
.gate-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 22px 24px 24px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: auto;
}
.gate-form .eyebrow { margin: 0; letter-spacing: .08em; text-transform: uppercase; font-size: 11px; color: var(--muted); font-weight: 700; }
.gate-form > p { margin: 0; color: var(--muted); line-height: 1.45; }
.gate-form .fld { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.gate-form .field { width: 100%; }
.gate-form .btn { justify-content: center; margin-top: 4px; }
.gate-form .flash { margin: 0; }
.gate-box.is-max {
    position: fixed;
    inset: 12px;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    margin: 0;
    z-index: 20;
}
.gate-box.is-max .gate-form {
    flex: 1;
    justify-content: center;
    width: min(480px, 100%);
    margin-inline: auto;
}
.gate-box.is-max .km-modal-header { padding-right: 72px; }
.gate-box.is-max .km-modal-resize { display: none; }
.gate-box.is-min {
    position: fixed;
    left: 14px;
    bottom: 70px; /* au-dessus du bouton Delta-Tech */
    width: auto;
    height: auto;
    max-height: none;
    border-radius: 999px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}
.gate-box.is-min .gate-form,
.gate-box.is-min .km-modal-resize { display: none; }
.gate-box.is-min .km-modal-header {
    border: 0;
    border-radius: 999px;
    padding: 8px 12px;
    background: var(--panel);
}

/* Fenêtre déplaçable (login + dialogs) — style Kommandia */
.km-modal-box {
    position: relative;
    z-index: 1;
    background: var(--panel);
    max-height: min(86vh, 860px);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(16, 36, 58, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.km-modal-box.is-pinned {
    position: fixed;
    max-height: none;
    margin: 0;
}
.km-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    background: #eef3f9;
    border-bottom: 1px solid var(--line);
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}
html[data-theme="dark"] .km-modal-header {
    background: #1a2744;
    border-color: var(--line);
}
.km-modal-header h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 650;
    flex: 1;
    min-width: 0;
}
.km-modal-win {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-left: auto;
    flex-shrink: 0;
}
.km-win {
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    box-shadow:
        0 2px 3px rgba(0, 0, 0, 0.28),
        0 1px 0 rgba(255, 255, 255, 0.45) inset,
        0 -1px 1px rgba(0, 0, 0, 0.18) inset;
    transition: transform 0.12s ease, filter 0.12s ease;
}
.km-win:hover { transform: scale(1.1); filter: brightness(1.05); }
.km-win:active { transform: scale(0.96); filter: brightness(0.96); }
.km-win-min {
    background: radial-gradient(120% 90% at 30% 18%, #ffe27a 0%, #ffc53d 38%, #f5a623 72%, #d8890c 100%);
}
.km-win-max {
    background: radial-gradient(120% 90% at 30% 18%, #7dff8f 0%, #3fd65a 38%, #22c53e 72%, #14a32e 100%);
}
.km-win-close {
    background: radial-gradient(120% 90% at 30% 18%, #ff9a93 0%, #ff6b63 38%, #ff3b30 72%, #d92018 100%);
}
.km-win::before {
    content: "";
    position: absolute;
    left: 14%;
    right: 14%;
    top: 8%;
    height: 38%;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0));
    pointer-events: none;
}
.km-win::after {
    content: "";
    position: absolute;
    inset: 3px;
    background: center / 11px 11px no-repeat;
    opacity: 1;
    pointer-events: none;
}
.km-win-min::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.2 6h7.6' stroke='%231a1a1a' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
}
.km-win-max::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Crect x='2.6' y='2.6' width='6.8' height='6.8' rx='0.6' fill='none' stroke='%23fff' stroke-width='1.7'/%3E%3C/svg%3E");
}
.km-win-max.is-restore::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4.2 2.8h5v5' fill='none' stroke='%23fff' stroke-width='1.5'/%3E%3Crect x='2.4' y='4' width='5.2' height='5.2' rx='0.4' fill='none' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E");
}
.km-win-close::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 3l6 6M9 3L3 9' stroke='%23fff' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}
.km-modal-resize {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    z-index: 2;
}
.km-modal-resize::after {
    content: "";
    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 8px;
    height: 8px;
    border-right: 2px solid #9bb3d0;
    border-bottom: 2px solid #9bb3d0;
}

/* ancien login-card (pages mobiles) */
.login-card {
    width: min(420px, 100%);
    background: var(--panel);
    border-radius: 18px;
    padding: 32px 28px 28px;
    box-shadow: 0 24px 60px rgba(0,0,0,.28);
}
.login-card .logo {
    width: 180px; height: auto;
    display: block; margin-bottom: 18px;
    background: #fff; border-radius: 8px; padding: 8px 10px;
}
.login-card h1 { margin: 0 0 6px; font-size: 32px; }
.login-card > p { margin: 0 0 18px; color: var(--muted); }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.login-card .field { width: 100%; }
.login-card .btn { justify-content: center; margin-top: 6px; }
.login-card .flash { margin: 0 0 12px; }

.app { margin-left: var(--side); min-height: 100vh; }
.wrap { padding: 32px 36px 48px; max-width: 1680px; }
.flash {
    margin: 20px 36px 0;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
}
.success {
    position: relative;
    max-width: 860px;
    margin: 24px auto 40px;
    padding: 48px 40px 36px;
    background: var(--panel);
    border: 1px solid #d8c39a;
    border-radius: 16px;
    box-shadow: var(--shadow);
    text-align: center;
}
.success::before {
    content: "";
    position: absolute; inset: 10px;
    border: 1px solid #eadcc2;
    border-radius: 10px;
    pointer-events: none;
}
.success-ribbon {
    position: absolute; top: 22px; right: 28px;
    color: var(--amber);
    font-size: 11px; font-weight: 700;
    letter-spacing: .08em; text-transform: uppercase;
}
.success-mark {
    width: 72px; height: 72px; margin: 0 auto 18px;
    display: grid; place-items: center;
    border-radius: 50%;
    color: var(--plus);
    background: var(--ok-bg);
    box-shadow: inset 0 0 0 1px var(--ok-line);
}
.success-mark .tick {
    stroke-dasharray: 36;
    stroke-dashoffset: 36;
    animation: tick .7s .2s ease forwards;
}
@keyframes tick { to { stroke-dashoffset: 0; } }
.success h1 { margin: 0 0 10px; font-size: 36px; }
.success > p { margin: 0 auto 28px; max-width: 540px; color: var(--muted); position: relative; }
.success-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    text-align: left;
    margin-bottom: 28px;
}
.success-stats article {
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
}
.success-stats small {
    display: block; color: var(--muted);
    font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    margin-bottom: 6px;
}
.success-stats strong { font-size: 20px; font-weight: 700; word-break: break-word; font-family: var(--mono); }
.success-actions { position: relative; z-index: 1; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.loader {
    position: fixed; inset: 0; z-index: 80;
    background: rgba(16, 36, 58, .48);
    display: none; place-items: center;
    backdrop-filter: blur(4px);
}
.loader.is-on { display: grid; }
.loader-card {
    width: min(420px, calc(100% - 32px));
    background: var(--panel);
    border-radius: 16px;
    padding: 28px 26px 24px;
    text-align: center;
    box-shadow: 0 24px 60px rgba(16,36,58,.22);
}
.loader-spin {
    width: 42px; height: 42px; margin: 0 auto 16px;
    border: 3px solid #e6efe8;
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.loader h2 { margin: 0 0 6px; font-size: 22px; }
.loader p { margin: 0; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }
.flash-ok { border-color: #b7d7c4; color: var(--plus); background: #eef7f1; }
.flash-err { border-color: #efc2bd; color: var(--minus); background: #fdf1ef; }

.hero {
    display: flex; justify-content: space-between; align-items: flex-end; gap: 20px;
    margin-bottom: 24px;
}
.eyebrow {
    margin: 0 0 8px;
    color: var(--teal);
    font-size: 12px; font-weight: 700;
    letter-spacing: .12em; text-transform: uppercase;
}
.hero h1, .empty h2, .panel h2 {
    font-family: var(--display);
    letter-spacing: -.02em;
}
.hero h1 { margin: 0 0 8px; font-size: 38px; font-weight: 700; }
/* le contexte étant déjà dans les onglets, le titre du pilotage tient sur une ligne */
.hero-tight { align-items: center; margin-bottom: 14px; }
.hero-tight h1 { margin: 0; font-size: 24px; }
.hero h1 .company-mark { color: var(--teal); font-weight: 700; }
.hero p { margin: 0; color: var(--muted); max-width: 560px; }
.check-line {
    display: inline-flex; align-items: center; gap: 8px;
    color: var(--muted); font-weight: 600; cursor: pointer;
    user-select: none; white-space: nowrap;
}
.check-line input { width: 16px; height: 16px; accent-color: var(--teal); }
.log-tools { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.table-plain .filter-row th {
    background: var(--soft);
    padding: 6px 8px;
    white-space: nowrap;
}
.table-plain .filter-row .field-mini { width: 100%; min-width: 92px; font-size: 12px; }
.table-plain .filter-row th:first-child,
.table-plain .filter-row th:last-child { display: flex; gap: 6px; align-items: center; }
.btn-mini { padding: 4px 10px; font-size: 12px; flex: 0 0 auto; }
.tabs-bar {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin: 0 4px 14px;
    border-bottom: 1px solid var(--line);
}
/* trois niveaux : société, jeu de données, vue affichée */
.tabs-l1 { margin-bottom: 0; border-bottom: 0; }
.tabs-l1 .tab {
    font-size: 15px; padding: 10px 20px;
    background: transparent; border-color: transparent;
    color: var(--muted);
}
.tabs-l1 .tab:hover { background: var(--tab-hover); border-color: var(--line); }
.tabs-l1 .tab.is-on {
    background: var(--tab); border-color: var(--line);
    color: var(--text); box-shadow: none;
    font-weight: 700; padding-bottom: 10px;
}
.tabs-l2 { background: var(--tab); border-radius: 0 10px 0 0; padding: 4px 8px 0; margin-bottom: 0; }
.tabs-last {
    border-bottom: 1px solid var(--line); border-radius: 0 10px 0 0;
    margin-bottom: 18px; padding-bottom: 4px;
}
.tabs-l2 .tab:not(.is-on) { background: transparent; border-color: transparent; }
.tabs-l2 .tab:not(.is-on):hover { background: var(--tab-hover); border-color: var(--line); }
.tabs-l3 {
    background: var(--panel); border: 1px solid var(--line); border-top: 0;
    border-radius: 0 0 10px 10px; padding: 8px 10px; margin-bottom: 18px;
    align-items: center;
}
.tabs-l3 .tabs { gap: 6px; }
.tabs-l3 .tab {
    border-radius: 99px; border: 1px solid transparent; background: transparent;
    padding: 6px 14px; font-size: 13px; transform: none;
    text-decoration: none;
}
.tabs-l3 .tab:hover { background: var(--soft); color: var(--text); }
.tabs-l3 .tab.is-on {
    background: var(--teal); color: #fff; box-shadow: none;
    padding-bottom: 6px;
}
.tabs-l3 .tabs-side { padding-bottom: 0; }
.tabs { display: flex; align-items: flex-end; gap: 4px; flex-wrap: wrap; }
.tabs form { margin: 0; }
.tab,
.tab:link,
.tab:visited {
    font: inherit; font-size: 13px; font-weight: 600; color: var(--muted);
    display: inline-block; text-decoration: none;
    background: var(--tab); border: 1px solid var(--line); border-bottom: 0;
    border-radius: 9px 9px 0 0; padding: 8px 16px; cursor: pointer;
    transform: translateY(1px);
}
.tab:hover { color: var(--text); background: var(--tab-hover); }
.tab.is-on {
    background: var(--panel); color: var(--text);
    box-shadow: inset 0 3px 0 var(--teal);
    padding-bottom: 10px;
}
.tab-add { background: transparent; border-style: dashed; color: var(--teal); }
.tab-edit {
    font: inherit; font-size: 13px; font-weight: 600; color: var(--text);
    background: var(--panel); border: 1px solid var(--teal); border-bottom: 0;
    border-radius: 9px 9px 0 0; padding: 8px 12px 10px;
    transform: translateY(1px);
}
.tab-edit:focus { outline: none; box-shadow: inset 0 3px 0 var(--teal); }
.brand-row { position: relative; }
/* jour / nuit — haut droite, comme QualitIA / Delta */
.theme-btn {
    position: fixed;
    top: 0.85rem;
    right: 0.85rem;
    z-index: 9999;
    width: 2.45rem;
    height: 2.45rem;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    cursor: pointer;
    color: #fbbf24;
    border: 2px solid rgba(251, 191, 36, 0.45);
    background: rgba(14, 22, 40, 0.88);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(8px);
    transition: filter .15s ease;
}
.theme-btn:hover { filter: brightness(1.08); }
:root[data-theme="light"] .theme-btn {
    color: #b45309;
    border-color: rgba(180, 83, 9, 0.4);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
}
.theme-btn svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.theme-btn .ico-moon { display: none; fill: currentColor; stroke: none; }
:root[data-theme="dark"] .theme-btn .ico-sun { display: none; }
:root[data-theme="dark"] .theme-btn .ico-moon { display: block; }
.ledger td.num { position: relative; }
.ledger td.is-pick { box-shadow: inset 0 0 0 1px var(--teal); }
.ledger td.is-pick::after {
    content: ''; position: absolute; inset: 0;
    background: rgba(26,122,134,.12); pointer-events: none;
}
.ledger td.is-fill::after {
    content: ''; position: absolute; inset: 0;
    background: rgba(26,122,134,.08);
    outline: 1px dashed var(--teal); outline-offset: -1px;
    pointer-events: none;
}
.pick-bar {
    position: fixed; right: 18px; bottom: 16px; z-index: 70;
    display: flex; align-items: center; gap: 16px;
    background: var(--navy); color: #fff;
    border-radius: 10px; padding: 9px 16px;
    font-size: 13px; font-variant-numeric: tabular-nums;
    box-shadow: 0 10px 26px rgba(16,36,58,.28);
}
.pick-bar b { font-weight: 700; margin-left: 5px; }
.pick-hint { color: rgba(255,255,255,.6); font-size: 12px; }
.fx-tip {
    position: absolute; z-index: 60;
    padding: 5px 10px; border-radius: 8px;
    background: var(--navy); color: #fff;
    font-size: 12px; font-weight: 700; letter-spacing: .01em;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .28);
    pointer-events: none; white-space: nowrap;
}
.fx-tip.is-bad { background: #b4232a; }
.ledger td.is-fx {
    outline: 2px dashed var(--teal); outline-offset: -2px;
    background: var(--teal-soft);
}
.pick-grip {
    position: absolute; z-index: 60;
    width: 9px; height: 9px; border: 1px solid #fff;
    background: var(--teal); border-radius: 2px;
    cursor: crosshair;
}
.block-bar { display: flex; align-items: center; gap: 8px; margin: 0 4px 8px; }
.block-toggle {
    border: 1px solid var(--line); background: var(--panel); color: var(--muted);
    width: 22px; height: 22px; border-radius: 6px; line-height: 1;
    font-size: 12px; cursor: pointer; flex: 0 0 auto;
    transition: transform .15s ease;
}
.block-toggle:hover { color: var(--text); border-color: var(--teal); }
.panel h2 .block-toggle { margin-left: 8px; vertical-align: 3px; }
.is-folded > .block-toggle, .is-folded .block-toggle { transform: rotate(-90deg); }
.block.is-folded .kpis { display: none; }
.panel.is-folded { padding-bottom: 10px; }
.panel.is-folded > *:not(.panel-head) { display: none; }
.panel.is-folded .panel-head { margin-bottom: 0; align-items: center; }
.panel.is-folded .panel-head .note,
.panel.is-folded .panel-head .legend,
.panel.is-folded .panel-head .head-tools { display: none; }
.tabs-side { display: flex; align-items: center; gap: 12px; padding-bottom: 8px; }
.tabs-side form { margin: 0; }
.tabs-note { color: var(--muted); font-size: 12px; }
.row-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.row-actions form { margin: 0; }
.mono { font-family: var(--mono); font-size: 13px; }
.help code { font-family: var(--mono); font-size: 12px; color: var(--text); }
.log-query {
    display: block; margin-top: 2px;
    font-family: var(--mono); font-size: 11px; color: var(--muted);
    word-break: break-all;
}

.filters { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.filters select, .filters input, .btn, .field {
    font: inherit; color: var(--text);
    border: 1px solid var(--line-2);
    background: var(--panel);
    border-radius: 8px; padding: 9px 12px;
}
.filters select:focus, .field:focus, .filters input:focus {
    outline: 2px solid rgba(26,122,134,.25); border-color: var(--teal);
}
.btn {
    cursor: pointer; background: var(--navy); color: #fff;
    border-color: var(--navy); font-weight: 600;
    text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { background: var(--navy-2); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line-2); }
.btn.gold { background: var(--amber); border-color: var(--amber); color: #fff; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px 14px;
    box-shadow: var(--shadow);
}
.kpi-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.kpi .lbl { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.kpi .val {
    font-family: var(--mono); font-size: 30px; margin: 8px 0 10px;
    letter-spacing: -.03em; font-weight: 500;
}
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.is-good .val { color: var(--plus); }
.kpi.is-bad .val { color: var(--minus); }
.pill {
    font-size: 11px; font-weight: 700;
    padding: 3px 8px; border-radius: 999px;
    background: var(--soft-2); color: var(--muted);
}
.pill.up { background: #e5f3ea; color: var(--plus); }
.pill.down { background: #f8e6e5; color: var(--minus); }
.pill.soft { background: #eef2f6; color: #5b6b7c; }
.pill.role-admin { background: #10243a; color: #fff; }
.pill.role-user { background: #d7eef0; color: var(--teal); }
.pill.role-viewer { background: var(--soft-2); color: var(--muted); }
/* sociétés cochées dans la fiche utilisateur */
.access { margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px; }
.access legend { padding: 0 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
/* case à gauche du nom : on écrase le flex colonne des labels du modal */
.win-body label.access-item,
.access-item {
    display: flex !important; flex-direction: row !important; align-items: center;
    gap: 10px; padding: 5px 2px; font-weight: 500; cursor: pointer;
}
.access-item input { flex: 0 0 auto; width: 16px; height: 16px; margin: 0; }
.access-item span { flex: 1 1 auto; }
.access .help { margin: 8px 0 0; font-size: 13px; }
/* onglets d’une société, sous sa case */
.access-sub { margin: 0 0 6px 26px; padding: 2px 10px; border-left: 2px solid var(--line-2); font-size: 13px; }
.access-sub .access-item { padding: 3px 2px; font-weight: 400; }
.access-sub .access-item input { width: 14px; height: 14px; }
.company-chips .pill small { font-weight: 400; opacity: .8; }
.company-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.all-companies { color: var(--muted); }
/* comparaison d’exercices : un résumé par année, puis le tableau colonne par colonne */
.annual-kpis {
    display: flex; flex-wrap: wrap; gap: 10px;
    margin-bottom: 12px;
}
.annual-kpi {
    display: flex; flex-direction: column; gap: 2px;
    min-width: 200px; flex: 1 1 200px;
    padding: 10px 12px;
    background: var(--soft); border: 1px solid var(--line); border-radius: 12px;
}
.annual-kpi.is-last { background: var(--teal-soft, var(--soft-2)); border-color: var(--teal); }
.annual-kpi .lbl { color: var(--muted); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.annual-kpi .val { font-family: var(--mono); font-size: 19px; font-weight: 600; }
.annual-kpi .val.is-good { color: var(--plus); }
.annual-kpi .val.is-bad { color: var(--minus); }
.annual-kpi .sub { color: var(--muted); font-size: 12px; }
.ledger.is-annual .col-tot { min-width: 124px; }
.ledger td.is-drill { cursor: zoom-in; }
.drill-head {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    margin-bottom: 10px; font-size: 14px; color: var(--muted);
}
.drill-head strong { color: var(--text); font-family: var(--mono); font-size: 16px; }
.drill-table { max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.drill-table .table-plain { margin: 0; }
.drill-table thead th { position: sticky; top: 0; z-index: 1; }
.drill-foot { margin: 12px 0 0; }
.drill-sum { margin-top: 8px; }
/* .chart-box impose 220px plus bas dans la feuille : ici la hauteur suit le contenu (outils + légende + courbes) */
.chart-box.annual-chart { height: auto; margin: 4px 0 16px; }
.chart-box.annual-chart canvas { display: block; width: 100%; height: 220px; }
.annual-chart .legend { justify-content: flex-end; margin-bottom: 6px; }
.chart-box.annual-month-chart { height: auto; margin: 0 0 28px; padding-bottom: 20px; }
.chart-box.annual-month-chart canvas { display: block; width: 100%; height: 240px; margin-bottom: 8px; }
.annual-month-tools {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    flex-wrap: wrap; margin-bottom: 8px;
}
.annual-month-tools .eyebrow { margin: 0; }
.annual-month-chart .seg-item {
    border: 0; border-right: 1px solid var(--line); cursor: pointer; font: inherit;
}
.annual-month-chart .seg-item:last-child { border-right: 0; }
.annual-month-chart .legend { flex-wrap: wrap; gap: 10px 14px; margin-bottom: 8px; }
.annual-month-chart .legend .lg { width: 10px; height: 10px; border-radius: 50%; }
.user-line .pill { margin-left: 6px; font-size: 10px; vertical-align: 1px; }
.win {
    position: fixed; inset: 0; z-index: 70;
    display: grid; place-items: center;
    background: rgba(16, 36, 58, .48);
    backdrop-filter: blur(4px);
    padding: 20px;
}
.win[hidden] { display: none; }
.win-card {
    position: relative;
    display: flex; flex-direction: column;
    width: min(460px, 100%); max-height: 86vh;
    background: var(--panel);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(16,36,58,.3);
    overflow: hidden;
}
.win-card.is-wide { width: min(980px, 94vw); }
.win-card.is-free { position: fixed; margin: 0; }
.win.is-max .win-card {
    width: min(1080px, 96vw); height: 92vh; max-height: 92vh;
    left: auto; top: auto; position: relative;
}
.win-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 10px 12px 10px 16px;
    background: #eef3f9; color: var(--text);
    border-bottom: 1px solid var(--line);
    cursor: grab; user-select: none;
}
html[data-theme="dark"] .win-bar {
    background: #1a2744;
    color: #eef5ff;
    border-color: var(--line);
}
.win-bar h2 { margin: 0; font-size: 15px; font-weight: 650; flex: 1; min-width: 0; }
.win-bar .km-modal-win { margin-left: auto; }
/* rétrocompat si un vieux markup win-btn reste */
.win-btns { display: flex; gap: 9px; flex: 0 0 auto; }
.win-btn {
    width: 18px; height: 18px; padding: 0;
    border: 0; border-radius: 50%;
    cursor: pointer;
}
.win-btn.min { background: radial-gradient(120% 90% at 30% 18%, #ffe27a 0%, #ffc53d 38%, #f5a623 72%, #d8890c 100%); }
.win-btn.max { background: radial-gradient(120% 90% at 30% 18%, #7dff8f 0%, #3fd65a 38%, #22c53e 72%, #14a32e 100%); }
.win-btn.close { background: radial-gradient(120% 90% at 30% 18%, #ff9a93 0%, #ff6b63 38%, #ff3b30 72%, #d92018 100%); }
.win-body { padding: 18px 18px 20px; overflow: auto; }
.win-body h2 { margin: 0 0 14px; }
.win-body p { margin: 0 0 12px; }
.win-body label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.win-body .field { width: 100%; }
.win.is-min .win-body,
.win.is-min .win-grip { display: none; }
.win-grip {
    position: absolute; right: 2px; bottom: 2px;
    width: 18px; height: 18px;
    cursor: nwse-resize;
    background:
        linear-gradient(135deg, transparent 42%, var(--line-2) 42% 54%, transparent 54%),
        linear-gradient(135deg, transparent 66%, var(--line-2) 66% 78%, transparent 78%);
}
.bar {
    height: 4px; border-radius: 99px; background: var(--track);
    margin-bottom: 10px; overflow: hidden;
}
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--teal-2)); }

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 22px;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; padding: 0 2px; flex-wrap: wrap; }
.panel-head > div { min-width: 0; }
.panel h2 { margin: 0; font-size: 17px; font-weight: 700; white-space: nowrap; }
.panel .note { margin: 0; color: var(--muted); font-size: 13px; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; font-weight: 600; }
.lg { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.lg-ca { background: var(--teal); }
.lg-ch { background: var(--amber); }
.lg-re { background: var(--navy-2); }
.lg-cu {
    width: 14px; height: 0; border-radius: 0;
    border-top: 2px dashed var(--teal);
    transform: translateY(-2px);
}
.lg-rc {
    width: 14px; height: 0; border-radius: 0;
    border-top: 2px dotted var(--navy-2);
    transform: translateY(-2px);
}

.chart-box { position: relative; height: 220px; padding: 4px 4px 0; }
.chart-band {
    position: absolute; top: 8px; bottom: 34px;
    background: rgba(26,122,134,.09);
    border-radius: 6px; pointer-events: none;
}
.chart-tip {
    position: absolute; top: 6px; z-index: 6;
    display: flex; flex-direction: column; gap: 5px;
    min-width: 168px; padding: 10px 12px;
    background: var(--navy); color: #fff;
    border-radius: 10px;
    box-shadow: 0 14px 30px rgba(16,36,58,.28);
    font-size: 12px; pointer-events: none;
}
.chart-tip[hidden], .chart-band[hidden] { display: none; }
.chart-tip strong { font-size: 13px; }
.chart-tip span { display: flex; align-items: center; gap: 6px; color: #c5d0dc; }
.chart-tip b { margin-left: auto; font-family: var(--mono); color: #fff; }
canvas { width: 100%; height: 220px; display: block; }

.ledger-wrap {
    overflow: auto; max-height: 72vh;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
}
.ledger-caption { position: sticky; left: 0; padding: 10px 12px; font-weight: 700; color: var(--text); }
.ledger {
    border-collapse: separate; border-spacing: 0;
    min-width: 1680px; width: 100%;
    font-size: 12.5px;
}
.ledger thead th {
    position: sticky; top: 0; z-index: 5;
    background: var(--navy);
    color: #f4f7fb;
    font-weight: 600; text-align: right;
    padding: 10px 8px; white-space: nowrap;
    border-right: 1px solid var(--navy-2);
}
.ledger thead th.col-num,
.ledger thead th.col-code,
.ledger thead th.col-name { text-align: left; }
.ledger td {
    padding: 7px 8px;
    border-bottom: 1px solid #eee7d8;
    background: var(--sticky-bg);
    white-space: nowrap;
}
.ledger tbody tr:hover td { background: #f4efe4; }
.ledger .num {
    font-family: var(--mono);
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    white-space: nowrap;
}
.ledger .strong { font-weight: 600; }
.ledger .muted { color: #6d655a; }
.ledger .col-num { width: 62px; color: #8a8174; }
.ledger .col-code { width: 70px; font-family: var(--mono); color: var(--teal); }
.ledger .col-name { min-width: 230px; font-weight: 600; }
.ledger .sticky-1 { position: sticky; left: 0; z-index: 3; }
.ledger .sticky-2 { position: sticky; left: var(--sticky-2, 62px); z-index: 3; }
.ledger .sticky-3 { position: sticky; left: var(--sticky-3, 132px); z-index: 4; box-shadow: 8px 0 12px rgba(28,20,8,.04); }
.ledger.is-marc { --sticky-2: 90px; --sticky-3: 160px; }
.ledger .col-drag {
    width: 28px; min-width: 28px; max-width: 28px;
    padding: 4px 2px; text-align: center; vertical-align: middle;
}
.ledger .sticky-0 {
    position: sticky; left: 0; z-index: 3; background: inherit;
}
.ledger.is-marc .sticky-1 { left: 28px; }
.ledger thead .sticky-0 { z-index: 6; background: var(--navy); }
.ledger .marc-handle {
    display: inline-block; cursor: grab; color: var(--muted);
    font-size: 12px; letter-spacing: -2px; user-select: none; line-height: 1;
}
.ledger .marc-handle:active { cursor: grabbing; }
.ledger tr.is-marc-row.is-dragging { opacity: .45; }
.ledger tr.is-marc-row.is-drag-over > td { box-shadow: inset 0 2px 0 var(--teal); }
.ledger thead th.sticky-1,
.ledger thead th.sticky-2 { border-right-color: var(--navy); }
.ledger thead .sticky-1,
.ledger thead .sticky-2,
.ledger thead .sticky-3 { z-index: 6; background: var(--navy); color: #fff; }
.ledger .is-plus { color: var(--plus); }
.ledger .is-minus { color: var(--minus); }
.ledger .is-zero { color: var(--zero); }
.ledger .row-subtotal_produits td,
.ledger .row-subtotal_charges td {
    background: #e7eef2;
    font-weight: 700;
}
.ledger .row-resultat td {
    background: var(--navy);
    color: #f6efe2;
    font-weight: 700;
    font-size: 13px;
}
.ledger .row-resultat .is-plus { color: #b7e4c7; }
.ledger .row-resultat .is-minus { color: #ffc3bc; }
.ledger .row-resultat .muted { color: #c9d6e0; }
.ledger .row-cumul td {
    background: #1c4368;
    color: #e7eff6;
    font-weight: 700;
    border-top: 1px solid rgba(255,255,255,.18);
}
.ledger .row-cumul .is-plus { color: #b7e4c7; }
.ledger .row-cumul .is-minus { color: #ffc3bc; }
.ledger .row-cumul .is-zero { color: #8fa4b8; }
.ledger .row-cumul .muted { color: #c9d6e0; }
.row-add td {
    background: var(--warn-bg);
    border-top: 2px solid var(--amber);
    padding: 8px;
    color: var(--amber); font-weight: 700;
    white-space: nowrap;
}
.row-add .btn { padding: 6px 10px; }
.row-plus {
    width: 18px; height: 18px; padding: 0;
    margin-left: 4px;
    display: inline-grid; place-items: center;
    border: 1px solid var(--line-2); border-radius: 50%;
    background: var(--panel); color: var(--teal);
    font: 700 13px/1 var(--sans);
    cursor: pointer;
}
.row-plus:hover { background: var(--teal); border-color: var(--teal); color: #fff; }
.row-reset {
    width: 18px; height: 18px; padding: 0;
    margin-left: 4px;
    display: inline-grid; place-items: center;
    border: 1px solid #e2cfa3; border-radius: 50%;
    background: var(--edit-bg); color: var(--warn-text);
    font: 700 12px/1 var(--sans);
    cursor: pointer;
}
.row-reset:hover { background: var(--amber); border-color: var(--amber); color: #fff; }
.row-fold {
    width: 18px; height: 18px; padding: 0;
    display: inline-grid; place-items: center;
    border: 1px solid var(--line-2); border-radius: 4px;
    background: var(--panel); color: var(--text);
    font: 700 10px/1 var(--sans);
    cursor: pointer;
}
.row-fold:hover { background: var(--navy); border-color: var(--navy); color: #fff; }
.is-folded .row-fold { color: var(--amber); }
.row-del {
    width: 18px; height: 18px; padding: 0;
    margin-left: 4px;
    display: inline-grid; place-items: center;
    border: 1px solid #e6c9c5; border-radius: 50%;
    background: var(--panel); color: var(--minus);
    font: 700 12px/1 var(--sans);
    cursor: pointer; vertical-align: middle;
}
.ledger .row-del { opacity: 0; transition: opacity .12s ease; }
.ledger tr:hover .row-del, .ledger .row-del:focus-visible { opacity: 1; }
.ledger td[data-edit] { cursor: cell; }
.ledger td.is-edited {
    background: var(--mark);
    box-shadow: inset 0 0 0 1px rgba(184,134,44,.45);
}
.ledger tbody tr:hover td.is-edited { background: var(--mark-2); }
@keyframes cell-saved {
    from { box-shadow: inset 0 0 0 2px var(--teal); }
    to { box-shadow: inset 0 0 0 2px rgba(26,122,134,0); }
}
.ledger td.is-just-saved { animation: cell-saved 1.6s ease-out; }
.ledger td.is-editing { padding: 0; }
.ledger td.is-editing input {
    width: 100%;
    padding: 7px 8px;
    font: inherit; font-family: var(--mono); font-size: 12px;
    text-align: right; color: inherit;
    background: var(--panel); border: 0; border-radius: 0;
    outline: 2px solid rgba(26,122,134,.45); outline-offset: -2px;
}
.row-del:hover { background: var(--minus); border-color: var(--minus); color: #fff; }
.row-new td { padding: 0; }
.row-new input {
    width: 100%; min-width: 0;
    padding: 7px 8px;
    font: inherit; color: inherit;
    background: transparent;
    border: 0; border-radius: 0;
    text-align: inherit;
}
.row-new input::placeholder { color: var(--zero); }
.row-new input:focus {
    background: var(--panel);
    outline: 2px solid rgba(26,122,134,.35); outline-offset: -2px;
}
.row-new .num input { text-align: right; font-family: var(--mono); font-size: 12px; }
.row-new .col-code input { font-family: var(--mono); color: var(--teal); }
.row-new .col-name input { font-weight: 600; }
.row-new .row-tools { display: flex; gap: 6px; padding: 4px 8px; }
.row-new .btn { padding: 4px 10px; font-size: 12px; }
.pill.manual { background: var(--warn-chip); color: var(--warn-text); margin-left: 6px; }
.table-plain tr.is-manual > td { background: var(--warn-bg); }
.table-plain tr.is-manual > td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.table-plain tr.is-group > td { background: var(--soft); font-weight: 600; }
.table-plain tr.is-group:hover > td { background: var(--line); }
.table-plain .group-link {
    color: inherit; text-decoration: none; display: inline-block;
}
.table-plain .group-link:hover { color: var(--teal); }
.table-plain.is-grouped tr.is-group td:first-child small {
    font-weight: 500; color: var(--muted); margin-left: 6px;
}
.table-plain.is-grouped { table-layout: fixed; }
.table-plain.is-grouped th:nth-child(1),
.table-plain.is-grouped td:nth-child(1) { width: 22%; }
.table-plain.is-grouped th:nth-child(2),
.table-plain.is-grouped td:nth-child(2) { width: 14%; }
.table-plain.is-grouped th:nth-child(3),
.table-plain.is-grouped td:nth-child(3) { width: 36%; }
.table-plain.is-grouped th:nth-child(4),
.table-plain.is-grouped td:nth-child(4),
.table-plain.is-grouped th:nth-child(5),
.table-plain.is-grouped td:nth-child(5) { width: 14%; }
.table-plain.is-grouped .group-link { display: block; }
.m-entry-group {
    display: block; text-decoration: none; color: inherit;
    border-left: 3px solid var(--teal);
}
.m-entry-group:hover { border-color: var(--text); }
.m-line.is-manual, .m-entry.is-manual {
    border-color: var(--amber);
    background: var(--warn-bg);
}
.field-mini {
    font: inherit; font-size: 12px;
    width: 100%; min-width: 96px;
    padding: 6px 8px;
    color: var(--text); background: var(--panel);
    border: 1px solid var(--line-2); border-radius: 6px;
}
.field-mini:focus { outline: 2px solid rgba(26,122,134,.25); border-color: var(--teal); }
/* œil greffé sur les champs de mot de passe */
.pass-wrap { position: relative; display: block; }
.pass-wrap .field { width: 100%; padding-right: 40px; }
.pass-eye {
    position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; padding: 0;
    background: transparent; border: 0; border-radius: 8px;
    color: var(--muted); cursor: pointer;
}
.pass-eye svg { width: 18px; height: 18px; fill: currentColor; }
.pass-eye:hover { color: var(--teal); background: var(--soft); }
.pass-eye:focus-visible { outline: 2px solid rgba(26,122,134,.35); color: var(--teal); }
.pass-eye[aria-pressed="true"] { color: var(--teal); }
.panel-head .btn { flex: 0 0 auto; }
.ask {
    position: fixed; inset: 0; z-index: 90;
    display: flex; align-items: center; justify-content: center; padding: 20px;
    background: rgba(16,36,58,.42);
    backdrop-filter: blur(2px);
    animation: ask-in .12s ease-out;
}
@keyframes ask-in { from { opacity: 0; } to { opacity: 1; } }
.ask-card {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(16,36,58,.28);
    overflow: hidden;
}
.ask-body { padding: 20px 22px 4px; }
.ask-body strong { display: block; font-size: 17px; color: var(--navy); }
.ask-body p { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.ask-card.is-danger .ask-body strong { color: var(--minus); }
.ask-foot {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 18px 22px 20px;
}
.ask-foot .btn { min-width: 104px; justify-content: center; }
.ask-foot .btn.danger { background: var(--minus); border-color: var(--minus); color: #fff; }
.ask-foot .btn.danger:hover { background: #8c3232; border-color: #8c3232; }
.head-tools { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.toggle {
    display: inline-flex; align-items: center; gap: 8px;
    color: var(--muted); font-size: 13px; font-weight: 600;
    cursor: pointer; user-select: none; white-space: nowrap;
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i {
    position: relative; width: 34px; height: 18px; flex: 0 0 auto;
    background: var(--line-2); border-radius: 999px; transition: background .15s ease;
}
.toggle i::after {
    content: ""; position: absolute; top: 2px; left: 2px;
    width: 14px; height: 14px; border-radius: 50%; background: #fff;
    box-shadow: 0 1px 2px rgba(16,36,58,.3); transition: transform .15s ease;
}
.toggle input:checked + i { background: var(--teal); }
.toggle input:checked + i::after { transform: translateX(16px); }
.toggle input:focus-visible + i { outline: 2px solid rgba(26,122,134,.45); outline-offset: 2px; }
.toggle input:checked ~ span { color: var(--text); }
.ledger td.heat { color: #17293c; font-weight: 600; }
.ledger td.is-out { opacity: .32; font-style: italic; }
.ledger thead th.col-m.is-out { opacity: .5; }
.ledger tr.row-resultat td.is-out, .ledger tr.row-cumul td.is-out { opacity: .4; }

.empty {
    text-align: center; padding: 72px 20px;
    background: var(--panel); border: 1px dashed var(--line-2); border-radius: 12px;
}
.empty h2 { font-size: 34px; margin: 0 0 8px; }
.empty p { color: var(--muted); }
.empty .actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }

.grid-2 { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; }
.drop {
    border: 1.5px dashed var(--line-2);
    border-radius: 10px;
    padding: 32px 24px;
    background: var(--soft);
    text-align: center;
    cursor: pointer;
    display: block;
}
.drop.is-over { border-color: var(--teal); background: var(--teal-soft); }
.company-card.is-over { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(26,122,134,.18); }
.company-card.is-over .drop { border-color: var(--teal); background: var(--teal-soft); }
.company-card.is-ready .drop { border-style: solid; border-color: var(--teal); background: var(--teal-soft); }
.company-card.is-ready .drop strong { color: var(--teal); }
.drop .btn { margin-top: 16px; }
.drop-mini {
    padding: 18px 16px 16px;
    margin: 0;
    text-align: left;
}
.drop-mini strong { display: block; font-size: 15px; }
.drop-mini span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.drop-mini .btn { margin-top: 12px; }
.import-mini { overflow: auto; }
/* bout de ligne de l’historique : le retrait d’un dépôt reste discret jusqu’au survol */
.import-mini .row-end { width: 1%; text-align: right; white-space: nowrap; }
.import-mini .row-end form { display: inline; }
.import-mini .row-note { color: var(--muted); font-family: var(--mono); }
.row-x {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; padding: 0;
    background: transparent; border: 0; border-radius: 6px;
    color: var(--minus); cursor: pointer;
    opacity: .35; transition: opacity .12s ease, background .12s ease;
}
.row-x svg { width: 14px; height: 14px; fill: currentColor; }
.row-x:hover, .row-x:focus-visible { opacity: 1; background: var(--minus-soft); }
tr:hover .row-x { opacity: .75; }
.company-drop { display: flex; flex-direction: column; gap: 8px; }
.drop-tools {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    color: var(--muted); font-size: 13px;
}
.import-banner {
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding: 16px 20px;
    background: var(--ok-bg);
    border: 1px solid var(--ok-line);
    border-radius: 14px;
    color: var(--plus);
}
.import-banner .eyebrow { color: var(--plus); }
.import-banner ul { display: flex; gap: 16px; list-style: none; margin: 0; padding: 0; color: var(--muted); }
.file-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.help { color: var(--muted); font-size: 14px; }
.help code { font-family: var(--mono); background: var(--soft-2); padding: 1px 5px; border-radius: 4px; color: var(--navy); }
.table-scroll {
    overflow: auto;
    max-height: calc(100vh - 230px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}
.table-plain { width: 100%; border-collapse: separate; border-spacing: 0; }
.table-plain th, .table-plain td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.table-plain th { color: var(--muted); font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
.table-plain thead { position: sticky; top: 0; z-index: 6; }
.table-plain thead th { background: var(--panel); }
.table-plain .num,
.kpi .val {
    white-space: nowrap;
}
.table-plain .num { text-align: right; font-family: var(--mono); }
.table-plain tbody tr:hover td { background: var(--soft); }
.table-plain tfoot td {
    position: sticky; bottom: 0; z-index: 5;
    padding: 11px 10px;
    background: var(--panel);
    border-top: 2px solid var(--line-2);
    font-weight: 700;
}
.table-plain tfoot .is-total td { background: var(--soft); }
.m-total {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin: 12px 0; padding: 12px 14px;
    background: var(--soft); border: 1px solid var(--line); border-radius: 10px;
    font-weight: 700; font-family: var(--mono); font-size: 14px;
}
.m-total span:first-child { font-family: inherit; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-size: 12px; }
.th-sort {
    color: inherit; text-decoration: none;
    display: inline-flex; align-items: center; gap: 4px;
    white-space: nowrap;
}
.th-sort:hover { color: var(--text); }
.th-sort.is-on { color: var(--text); font-weight: 700; }
.col-filters th {
    padding: 4px 6px 10px;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    vertical-align: top;
    background: var(--soft);
}
.col-filters input {
    width: 100%; min-width: 0;
    font: inherit; font-size: 13px;
    padding: 6px 8px;
    border: 1px solid var(--line-2);
    border-radius: 6px;
    background: var(--panel);
    color: var(--text);
}
.col-filters input:focus {
    outline: 2px solid rgba(26,122,134,.25); border-color: var(--teal);
}
.col-filters .dates {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
    min-width: 168px;
}
.col-filters .dates input { min-width: 0; }
.th-date {
    display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
/* bouton période compact, à côté du titre Date */
.period-wrap { position: relative; display: inline-block; vertical-align: middle; z-index: 2; }
.period-btn {
    display: inline-flex; align-items: center; gap: 2px;
    max-width: 88px; padding: 2px 7px;
    font: inherit; font-size: 11px; font-weight: 600; line-height: 1.2;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: var(--teal); background: var(--panel);
    border: 1px solid var(--line-2); border-radius: 999px; cursor: pointer;
}
.period-btn span { overflow: hidden; text-overflow: ellipsis; }
.period-btn:hover, .period-btn[aria-expanded="true"] { border-color: var(--teal); }
.period-btn.is-on { background: var(--teal-soft); border-color: var(--teal); color: var(--text); }
.period-menu {
    position: absolute; z-index: 300; top: calc(100% + 4px); left: 0; min-width: 200px;
    margin: 0; padding: 4px; list-style: none;
    background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px;
    box-shadow: 0 10px 28px rgba(16, 36, 58, .14);
    overflow: auto; max-height: 360px;
}
.period-heading {
    padding: 8px 10px 4px;
    font-size: 11px; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: var(--muted); list-style: none;
}
.period-opt {
    display: block; width: 100%; padding: 7px 10px;
    font: inherit; font-size: 13px; text-align: left;
    color: var(--text); background: transparent; border: 0; border-radius: 6px; cursor: pointer;
}
.period-opt:hover { background: var(--soft); }
.period-opt.is-on { background: var(--teal-soft); color: var(--teal); font-weight: 600; }
.period-clear { color: var(--muted); }
.period-sep { height: 1px; margin: 4px 6px; background: var(--line); list-style: none; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; color: var(--muted); }
.more-status {
    margin: 14px 0 0;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}
.more-status.is-loading { color: var(--teal); }

@media (max-width: 980px) {
    .sidebar {
        position: sticky; top: 0; inset: auto;
        width: auto; height: auto;
        flex-direction: row; align-items: center;
        padding: 12px;
    }
    .sidebar nav { flex-direction: row; overflow: auto; }
    .side-meta, .brand small { display: none; }
    .brand { width: 148px; flex: 0 0 auto; }
    .brand .logo { padding: 6px 8px; }
    .app { margin-left: 0; }
    .kpis, .grid-2 { grid-template-columns: 1fr; }
    .hero { flex-direction: column; align-items: flex-start; }
    .hero h1 { font-size: 32px; }
    .wrap { padding: 18px; }
    .success { padding: 28px 18px; }
    .success-stats { grid-template-columns: 1fr; }
    .company-metrics { grid-template-columns: 1fr; }
    .create-bar { width: 100%; }
}

@media print {
    .sidebar, .filters, .btn, .flash { display: none !important; }
    .app { margin: 0; }
    body { background: #fff; }
    .panel, .kpi { box-shadow: none; }
    .ledger-wrap { max-height: none; overflow: visible; }
}

/* ---- analyse IA */
.ai-btn { display: inline-flex; align-items: center; gap: 7px; }
.ai-btn svg { width: 16px; height: 16px; fill: currentColor; }
.ai { display: grid; gap: 14px; }
.ai-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.ai-ctx { margin: 0 0 4px; font-weight: 700; color: var(--teal); }
.ai-progress { display: grid; gap: 6px; }
.ai-bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.ai-bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--teal); transition: width .35s ease; }
.ai-step { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.ai-notice {
    margin: 0; padding: 10px 12px; border-radius: 10px;
    background: var(--soft); color: var(--text); font-weight: 600; font-size: 13px;
    border-left: 4px solid var(--line-2);
}
.ai-notice.is-ok { border-left-color: var(--plus); background: var(--ok-bg); }
.ai-notice.is-warn { border-left-color: var(--amber); background: var(--warn-bg); color: var(--warn-text); }
.ai-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 18px; align-items: start; }
.ai-text { max-height: 58vh; overflow: auto; padding-right: 8px; }
.ai-text h3 { margin: 18px 0 8px; font-size: 16px; }
.ai-text h4 { margin: 14px 0 6px; font-size: 14px; }
.ai-text h3:first-child { margin-top: 0; }
.ai-text p, .ai-text li { line-height: 1.55; }
.ai-text ul, .ai-text ol { margin: 8px 0; padding-left: 22px; }
.ai-text li { margin: 4px 0; }
.ai-text .md-table { overflow: auto; margin: 10px 0; }
.ai-text .md-table table { border-collapse: collapse; font-size: 13px; }
.ai-text .md-table th, .ai-text .md-table td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
.ai-text .md-table th { background: var(--soft); }
.ai-meta { margin: 0 0 10px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.ai-list h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.ai-item { display: flex; align-items: stretch; gap: 4px; margin-bottom: 6px; }
.ai-item > button:first-child {
    flex: 1; display: grid; gap: 2px; text-align: left; cursor: pointer;
    font: inherit; color: var(--text); background: var(--soft);
    border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px;
}
.ai-item > button:first-child:hover { border-color: var(--teal); }
.ai-item strong { font-size: 13px; }
.ai-item span { font-size: 11px; color: var(--muted); }
.ai-item.is-other > button:first-child { opacity: .7; }
.ai-del {
    width: 28px; cursor: pointer; font: inherit; color: var(--muted);
    background: transparent; border: 1px solid var(--line); border-radius: 9px;
}
.ai-del:hover { color: var(--minus); border-color: var(--minus); }
@media (max-width: 860px) {
    .ai-layout { grid-template-columns: 1fr; }
}

/* ---- cellules portant une formule mémorisée */
.ledger td.has-fx { position: relative; }
.ledger td.has-fx::after {
    content: ''; position: absolute; top: 2px; right: 2px;
    border: 4px solid transparent; border-top-color: var(--teal); border-right-color: var(--teal);
    border-radius: 1px; opacity: .8;
}
.ledger td.is-stale { box-shadow: inset 0 0 0 2px var(--amber); }

/* ---- messages passagers en bas à droite */
.toasts {
    position: fixed; right: 18px; bottom: 18px; z-index: 120;
    display: grid; gap: 8px; max-width: min(420px, calc(100vw - 36px));
}
.toast {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 12px 12px 14px;
    border-radius: 12px; border: 1px solid var(--line);
    background: var(--panel); color: var(--text);
    box-shadow: var(--shadow);
    font-size: 14px; line-height: 1.45;
    border-left: 4px solid var(--teal);
    animation: toast-in .25s ease;
}
.toast.is-off { animation: toast-out .3s ease forwards; }
.toast-ok { border-left-color: var(--plus); }
.toast-err { border-left-color: var(--minus); }
.toast span { flex: 1; }
.toast button {
    cursor: pointer; font: inherit; font-size: 18px; line-height: 1;
    color: var(--muted); background: transparent; border: 0; padding: 0 2px;
}
.toast button:hover { color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
@media (max-width: 860px) {
    .toasts { right: 12px; bottom: 12px; left: 12px; max-width: none; }
}

/* ---- filtre de lignes et aide des raccourcis */
.row-filter {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--panel); border: 1px solid var(--line-2);
    border-radius: 999px; padding: 4px 10px 4px 9px;
}
.row-filter .ico-find {
    width: 14px; height: 14px; flex: none; background: var(--muted);
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M10 2a8 8 0 105.3 14l5 5 1.4-1.4-5-5A8 8 0 0010 2zm0 2a6 6 0 110 12 6 6 0 010-12z'/></svg>") center/contain no-repeat;
}
.row-filter input {
    width: 150px; font: inherit; font-size: 13px; color: var(--text);
    background: transparent; border: 0; padding: 2px 0;
}
.row-filter input:focus { outline: none; }
.row-filter:focus-within { border-color: var(--teal); }
.row-filter-count { font-size: 12px; font-weight: 700; color: var(--muted); }
.ledger.is-filtered tr.row-section td { background: var(--soft); }

.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 20px 28px; }
.keys h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.keys dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; margin: 0; align-items: baseline; }
.keys dt {
    font-family: var(--mono); font-size: 12px; white-space: nowrap;
    background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px;
}
.keys dd { margin: 0; font-size: 13px; line-height: 1.45; min-width: 0; }
.keys .note { grid-column: 1 / -1; margin: 0; }
@media (max-width: 860px) {
    .keys { grid-template-columns: 1fr; }
    .row-filter input { width: 120px; }
}

/* Titre de page fondu dans la barre du premier bloc affiché : tout tient sur une ligne */
.title-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.page-title {
    margin: 0; font-family: var(--display); font-size: 17px; font-weight: 700;
    letter-spacing: -.02em; white-space: nowrap;
}
.page-title .company-mark { color: var(--teal); }
.title-sep { color: var(--line-2); font-weight: 700; }
.block-bar { flex-wrap: wrap; }
.block-bar .head-tools { margin-left: auto; }
.block-bar .eyebrow { margin: 0; }
.panel { padding: 12px 14px; margin-bottom: 14px; }
.head-tools { gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

/* Impression PDF : options à gauche, aperçu de la feuille à droite */
.pdf-btn, .xls-btn { display: inline-flex; align-items: center; gap: 6px; }
.pdf-btn svg, .xls-btn svg { width: 16px; height: 16px; fill: currentColor; }
.pdf-btn img { width: 15px; height: 18px; display: block; }
.xls-btn { text-decoration: none; }
.xls-btn svg { fill: var(--plus); }
.pdf { display: grid; grid-template-columns: 270px 1fr; gap: 18px; align-items: start; }
.pdf-opts { display: flex; flex-direction: column; gap: 14px; }
.pdf-opts fieldset {
    margin: 0; padding: 10px 12px 12px;
    border: 1px solid var(--line); border-radius: 10px; background: var(--soft);
}
.pdf-opts legend {
    padding: 0 6px; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
}
.pdf-opts label { display: block; font-size: 13px; color: var(--muted); }
.pdf-opts label + label { margin-top: 8px; }
.pdf-opts .field { width: 100%; margin-top: 3px; }
.pdf-opts textarea.field { resize: vertical; font: inherit; font-size: 13px; }
.pdf-opts .check-line { display: flex; align-items: center; gap: 8px; color: var(--text); }
.pdf-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pdf-pair label + label { margin-top: 0; }
.pdf-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.pdf-actions .btn { width: 100%; justify-content: center; }
.pdf-preview { min-width: 0; }
.pdf-frame-wrap {
    height: min(70vh, 720px); overflow: auto;
    background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 8px;
}
.pdf-frame-wrap iframe { display: block; width: 1120px; height: 900px; border: 0; background: #fff; }
.pdf.is-busy .pdf-frame-wrap { opacity: .55; }
[data-win="pdf"] .win-card { width: min(1280px, 96vw); }
@media (max-width: 1000px) {
    .pdf { grid-template-columns: 1fr; }
    .pdf-frame-wrap { height: 50vh; }
}

/* en thème sombre, les pastilles suivent les couleurs réellement tracées sur le canvas */
:root[data-theme="dark"] .lg-re { background: #7fb2e8; }
:root[data-theme="dark"] .lg-rc { border-top-color: #7fb2e8; }

/* Visite guidée : bouton ampoule, projecteur et bulle d’explication */
.sidebar nav .tour-btn {
    display: flex; align-items: center; gap: 12px; width: 100%;
    margin-top: 6px; padding: 10px 12px;
    font: inherit; text-align: left;
    color: var(--amber); background: rgba(255,255,255,.04);
    border: 1px dashed rgba(215,164,65,.45); border-radius: 8px;
    cursor: pointer;
}
.sidebar nav .tour-btn:hover { background: rgba(215,164,65,.16); color: #fff; }
.sidebar nav .tour-btn .ico { width: 18px; height: 18px; }
.tour-btn.is-new { animation: tour-wink 2.6s ease-in-out infinite; }
@keyframes tour-wink {
    0%, 65%, 100% { box-shadow: 0 0 0 0 rgba(215,164,65,0); }
    82% { box-shadow: 0 0 0 5px rgba(215,164,65,.28); }
}

.tour { position: fixed; inset: 0; z-index: 120; }
.tour-hole {
    position: fixed; border-radius: 10px;
    box-shadow: 0 0 0 9999px rgba(11,24,38,.72);
    outline: 2px solid var(--teal); outline-offset: 0;
    pointer-events: none;
    transition: left .22s ease, top .22s ease, width .22s ease, height .22s ease;
}
.tour-tip {
    position: fixed; width: min(360px, calc(100vw - 20px));
    padding: 14px 16px 12px;
    background: var(--panel); color: var(--text);
    border: 1px solid var(--line-2); border-radius: 12px;
    box-shadow: 0 20px 50px rgba(11,24,38,.35);
    transition: left .22s ease, top .22s ease;
}
.tour-count { font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--teal); }
.tour-tip h3 { margin: 4px 0 6px; font-family: var(--display); font-size: 17px; }
.tour-tip p { margin: 0 0 12px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.tour-btns { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tour-spacer { flex: 1 1 auto; }
.tour-btns .btn { padding: 6px 12px; font-size: 13px; }
.tour-btns .btn[disabled] { opacity: .45; cursor: default; }
.tour-step-bar {
    height: 4px; margin: 0 0 10px; border-radius: 99px;
    background: var(--line); overflow: hidden;
}
.tour-step-bar > span { display: block; height: 100%; width: 0; background: var(--teal); }
.tour-eta { margin: 8px 0 0; min-height: 1em; font-size: 11px; color: var(--muted); }
.tour-voice.is-on { color: var(--teal); font-weight: 700; }

/* Logs : frise de présence, une piste par utilisateur */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg-item {
    padding: 6px 12px; font-size: 13px; font-weight: 600;
    color: var(--muted); text-decoration: none; background: var(--panel);
    border-right: 1px solid var(--line);
}
.seg-item:last-child { border-right: 0; }
.seg-item:hover { background: var(--soft); color: var(--text); }
.seg-item.is-on { background: var(--teal); color: #fff; }

.presence { display: flex; flex-direction: column; gap: 4px; }
.presence-row { display: grid; grid-template-columns: 130px 1fr 90px; align-items: center; gap: 10px; }
.presence-name {
    font-size: 13px; font-weight: 600; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.presence-total { font-size: 12px; font-weight: 700; color: var(--muted); text-align: right; }
.presence-track {
    position: relative; height: 24px;
    background: var(--soft); border: 1px solid var(--line); border-radius: 6px;
}
.presence-row.is-head .presence-track { height: 18px; background: transparent; border: 0; }
.presence-row.is-head .presence-total { color: var(--muted); font-weight: 600; }
.presence-tick { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--line); }
.presence-tick span {
    position: absolute; left: 3px; top: 2px;
    font-size: 10px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.presence-grid { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dashed var(--line); opacity: .8; }
.presence-span {
    position: absolute; top: 3px; bottom: 3px;
    min-width: 3px; border-radius: 3px;
    background: var(--teal);
    box-shadow: 0 0 0 1px rgba(255,255,255,.35) inset;
}
.presence-row[data-tone="1"] .presence-span { background: var(--amber); }
.presence-row[data-tone="2"] .presence-span { background: var(--navy-2); }
.presence-row[data-tone="3"] .presence-span { background: #7b5ea7; }
.presence-row[data-tone="4"] .presence-span { background: #3f8f5f; }
@media (max-width: 760px) {
    .presence-row { grid-template-columns: 90px 1fr 70px; }
}
/* Logs · Graphiques : connexions par période, une rangée de barres par utilisateur */
.activity { display: flex; flex-direction: column; gap: 6px; }
.activity-row { display: grid; grid-template-columns: 130px 1fr 60px; align-items: end; gap: 10px; }
.activity-name {
    font-size: 13px; font-weight: 600; color: var(--text); padding-bottom: 6px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.activity-total { font-size: 12px; font-weight: 700; color: var(--muted); text-align: right; padding-bottom: 6px; }
.activity-bars {
    display: flex; align-items: flex-end; gap: 3px; height: 46px; padding: 0 2px;
    border-bottom: 1px solid var(--line); background: linear-gradient(to top, var(--soft), transparent 60%);
}
.activity-row.is-all .activity-bars { height: 64px; }
.activity-row.is-all .activity-name, .activity-row.is-all .activity-total { color: var(--teal); }
.activity-bar {
    flex: 1 1 0; min-width: 4px; display: block; border-radius: 3px 3px 0 0;
    background: var(--teal); transition: filter .12s ease; cursor: default;
}
.activity-bar.is-zero { height: 2px !important; background: var(--line); border-radius: 0; }
.activity-bar:hover { filter: brightness(.85); }
.activity-row[data-tone="1"] .activity-bar:not(.is-zero) { background: var(--amber); }
.activity-row[data-tone="2"] .activity-bar:not(.is-zero) { background: var(--navy-2); }
.activity-row[data-tone="3"] .activity-bar:not(.is-zero) { background: #7b5ea7; }
.activity-row[data-tone="4"] .activity-bar:not(.is-zero) { background: #3f8f5f; }
.activity-row.is-axis .activity-bars { height: auto; border: 0; background: none; align-items: start; }
.activity-row.is-axis .activity-total { color: var(--muted); font-weight: 600; }
.activity-label {
    flex: 1 1 0; min-width: 4px; font-size: 10px; font-weight: 600; color: var(--muted);
    text-align: center; white-space: nowrap; overflow: visible;
}
@media (max-width: 760px) {
    .activity-row { grid-template-columns: 90px 1fr 44px; }
}

/* Application installée sur l’écran d’accueil : on respecte encoche et barre système */
@supports (padding: env(safe-area-inset-top)) {
    .sidebar {
        padding-top: calc(22px + env(safe-area-inset-top));
        padding-bottom: calc(22px + env(safe-area-inset-bottom));
        padding-left: max(16px, env(safe-area-inset-left));
    }
    .app { padding-right: env(safe-area-inset-right); }
}

/* ---- sélection : cadre complet et net, comme Excel (prime sur is-edited / is-stale) */
.ledger td.num.is-pick,
.ledger td.num.is-edited.is-pick,
.ledger td.num.is-stale.is-pick {
    box-shadow: inset 0 0 0 2px var(--teal);
}
.ledger td.num.is-pick::before {
    content: ''; position: absolute; inset: 0;
    background: rgba(26,122,134,.10); pointer-events: none;
}
.ledger td.is-pick::after { content: none; }
.ledger td.has-fx.is-pick::after {
    content: ''; position: absolute; top: 2px; right: 2px;
    border: 4px solid transparent; border-top-color: var(--teal); border-right-color: var(--teal);
    border-radius: 1px; opacity: .8;
}

/* ---- cellules sources d’une formule : une couleur par référence */
:root {
    --ref-0: #2563eb; --ref-1: #dc2626; --ref-2: #7c3aed;
    --ref-3: #16a34a; --ref-4: #ea580c; --ref-5: #0891b2;
}
.ledger td.num.is-ref { position: relative; }
.ledger td.num.is-ref-0 { box-shadow: inset 0 0 0 2px var(--ref-0); background: rgba(37,99,235,.10); }
.ledger td.num.is-ref-1 { box-shadow: inset 0 0 0 2px var(--ref-1); background: rgba(220,38,38,.10); }
.ledger td.num.is-ref-2 { box-shadow: inset 0 0 0 2px var(--ref-2); background: rgba(124,58,237,.10); }
.ledger td.num.is-ref-3 { box-shadow: inset 0 0 0 2px var(--ref-3); background: rgba(22,163,74,.10); }
.ledger td.num.is-ref-4 { box-shadow: inset 0 0 0 2px var(--ref-4); background: rgba(234,88,12,.12); }
.ledger td.num.is-ref-5 { box-shadow: inset 0 0 0 2px var(--ref-5); background: rgba(8,145,178,.10); }
.fx-chip {
    display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 5px;
    font-family: var(--mono); font-size: 11px; font-weight: 700; color: #fff;
}
.fx-chip.is-ref-0 { background: var(--ref-0); }
.fx-chip.is-ref-1 { background: var(--ref-1); }
.fx-chip.is-ref-2 { background: var(--ref-2); }
.fx-chip.is-ref-3 { background: var(--ref-3); }
.fx-chip.is-ref-4 { background: var(--ref-4); }
.fx-chip.is-ref-5 { background: var(--ref-5); }

/* ---- modal écritures : recherche et tri */
.drill-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.drill-search {
    flex: 1 1 220px; min-width: 180px; padding: 6px 10px;
    border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px;
    background: var(--sticky-bg); color: var(--text);
}
.drill-search:focus { outline: 2px solid var(--teal); outline-offset: -1px; }
.drill-table th.is-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.drill-table th.is-sortable:hover { color: #fff; }
.drill-table th .sort-mark { display: inline-block; width: 12px; margin-left: 3px; opacity: .85; }
.drill-table th.is-asc .sort-mark::after { content: '▲'; font-size: 9px; }
.drill-table th.is-desc .sort-mark::after { content: '▼'; font-size: 9px; }

/* ---- corbeille des lignes ajoutées à la main : à côté du +, toujours visible */
.ledger .row-del.is-added { opacity: .8; font-size: 11px; }
.ledger tr:hover .row-del.is-added { opacity: 1; }

/* Détail mensuel : poignée de déplacement des lignes */
.ledger .row-move {
    display: inline-block; cursor: grab; color: var(--muted); opacity: 0;
    font-size: 12px; letter-spacing: -2px; user-select: none; line-height: 1; margin-right: 2px;
    transition: opacity .12s ease;
}
.ledger tr:hover .row-move { opacity: .85; }
.ledger .row-move:active { cursor: grabbing; }
.ledger tr.is-move-row.is-dragging { opacity: .45; }
.ledger tr.is-move-row.is-drag-over > td { box-shadow: inset 0 2px 0 var(--teal); }

/* fenêtre Prévoir un exercice */
.win-body p.warn {
    margin: 0 0 10px; padding: 8px 10px; border-radius: 8px;
    background: var(--warn-bg, #fff4e0); border: 1px solid rgba(215,164,65,.5); font-size: 13px;
}
[data-forecast] .check-line {
    display: flex; flex-direction: row; align-items: flex-start; gap: 8px; margin: 0 0 12px;
    color: var(--text); font-weight: 600; white-space: normal; line-height: 1.35;
}
[data-forecast] .check-line input { flex: none; width: 16px; height: 16px; margin: 2px 0 0; }

/* Barre du haut, même rythme que TalentIA : libellé à gauche, compte à droite. */
.app-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1.5rem;
  background: color-mix(in srgb, var(--panel) 95%, transparent);
  backdrop-filter: blur(8px);
}
.app-kicker {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-rule {
  height: 0;
  margin: 0;
  border: 0;
  border-top: 1px solid var(--line);
}
.app .delta-who,
.m-top .delta-who {
  margin-left: auto;
  flex-shrink: 0;
}
.delta-who__logout-form { display: contents; }
:root[data-theme="light"] .app-top {
  background: rgba(255, 255, 255, 0.95);
}
