/* ==========================================================================
   ZAIN. — système visuel
   Jade signature · encre profonde · Inter · mouvement discret
   ========================================================================== */
@font-face { font-family: "Inter"; src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/fonts/inter-latin-ext-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap;
  unicode-range: U+0100-02AF, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  color-scheme: dark;
  --bg: #0B0F14;
  --bg-main: #0D1218;
  --surface: #121921;
  --surface-2: #161E28;
  --surface-3: #1D2733;
  --glass: rgba(18, 25, 33, .72);
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .13);
  --text: #E9EEF2;
  --text-2: #A2ADB9;
  --text-3: #6B7684;
  --accent: #19D3A2;
  --accent-strong: #12B894;
  --accent-hover: #2AE6B4;
  --accent-soft: rgba(25, 211, 162, .12);
  --accent-glow: rgba(25, 211, 162, .35);
  --on-accent: #032119;
  --good: #3DD68C; --good-soft: rgba(61, 214, 140, .12);
  --warn: #F2B544; --warn-soft: rgba(242, 181, 68, .12);
  --bad: #FF6B6B; --bad-soft: rgba(255, 107, 107, .12);
  --info: #6FA8FF; --info-soft: rgba(111, 168, 255, .12);
  --series-1: #3987e5;
  --series-2: #d95926;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 12px 32px -12px rgba(0, 0, 0, .55);
  --shadow-pop: 0 24px 64px -16px rgba(0, 0, 0, .7), 0 0 0 1px var(--border-strong);
  --radius: 14px;
  --radius-sm: 9px;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sidebar-w: 248px;
  --titlebar-h: 48px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F6F7F5; --bg-main: #F2F4F2; --surface: #FFFFFF; --surface-2: #F7F8F7; --surface-3: #EDF0EE;
  --glass: rgba(255, 255, 255, .78);
  --border: rgba(10, 30, 25, .08); --border-strong: rgba(10, 30, 25, .15);
  --text: #0F1A17; --text-2: #4A5753; --text-3: #7E8A86;
  --accent: #0E9F7C; --accent-strong: #0B8A6B; --accent-hover: #0B8A6B; --accent-soft: rgba(14, 159, 124, .1); --accent-glow: rgba(14, 159, 124, .25); --on-accent: #FFFFFF;
  --good: #11804B; --good-soft: rgba(17, 128, 75, .1); --warn: #A46400; --warn-soft: rgba(164, 100, 0, .1);
  --bad: #C53030; --bad-soft: rgba(197, 48, 48, .09); --info: #2459C6; --info-soft: rgba(36, 89, 198, .09);
  --series-1: #2a78d6; --series-2: #eb6834;
  --shadow: 0 1px 2px rgba(10, 30, 25, .05), 0 8px 24px -12px rgba(10, 30, 25, .12);
  --shadow-pop: 0 24px 64px -16px rgba(10, 30, 25, .25), 0 0 0 1px var(--border-strong);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 13.5px/1.5 "Inter", "Segoe UI", system-ui, sans-serif; font-feature-settings: "cv11", "ss01";
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; overflow: hidden;
}
::selection { background: var(--accent-soft); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.025em; font-weight: 650; }
h1 { font-size: 24px; }
h2 { font-size: 15px; letter-spacing: -.015em; }
h3 { font-size: 13.5px; }
.i { flex: none; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.neg { color: var(--bad); }
.pos { color: var(--good); }
.hidden { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--border-strong); }
::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   Coquille : barre de titre · navigation · contenu
   ========================================================================== */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: var(--titlebar-h) 1fr; height: 100vh; transition: grid-template-columns .3s var(--ease); }
.app.collapsed { --sidebar-w: 68px; }
.titlebar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 0 14px 0 0; min-width: 0;
  background: var(--bg); border-bottom: 1px solid var(--border); -webkit-app-region: drag; position: relative; z-index: 20;
}
body.desktop .titlebar { padding-right: 150px; }
.titlebar button, .titlebar select, .titlebar input, .titlebar a, .titlebar .presence, .titlebar .no-drag { -webkit-app-region: no-drag; }
.brand { width: var(--sidebar-w); display: flex; align-items: center; gap: 10px; padding-left: 18px; flex: none; transition: width .3s var(--ease); overflow: hidden; }
.logo-mark { width: 26px; height: 26px; flex: none; filter: drop-shadow(0 4px 12px var(--accent-glow)); }
.wordmark { font-size: 19px; font-weight: 750; letter-spacing: -.045em; white-space: nowrap; }
.wordmark b { color: var(--accent); }
.wordmark small { font-size: 11px; font-weight: 500; color: var(--text-3); letter-spacing: 0; margin-left: 6px; }
.app.collapsed .wordmark { opacity: 0; }

.dossier-pill {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 12px 0 6px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); cursor: pointer; color: var(--text); font: inherit; max-width: 340px; min-width: 0; transition: border-color .15s, background .15s;
}
.dossier-pill:hover { border-color: var(--accent); }
.dossier-pill .code { font-family: var(--mono); font-size: 11px; font-weight: 600; padding: 3px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.dossier-pill .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
.dossier-pill .fy { color: var(--text-3); white-space: nowrap; font-size: 12px; }
.search-trigger {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px 0 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-3); cursor: pointer; font: inherit; width: min(360px, 30vw); margin: 0 auto; transition: border-color .15s, color .15s;
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--text-2); }
.search-trigger .kbd { margin-left: auto; }
.sync { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); white-space: nowrap; padding: 0 6px; }
.sync .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.sync.off .dot { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.presence { display: flex; align-items: center; padding-left: 6px; }
.avatar {
  --c: #3987e5; width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10.5px; font-weight: 650;
  color: #fff; background: var(--c); border: 2px solid var(--bg); margin-left: -7px; flex: none; position: relative; letter-spacing: .02em;
}
.avatar.lg { width: 44px; height: 44px; font-size: 15px; margin: 0; }
.avatar.xl { width: 64px; height: 64px; font-size: 21px; margin: 0; border-width: 3px; }
.avatar.sm { width: 22px; height: 22px; font-size: 9px; margin-left: -5px; border-width: 1.5px; }
.avatar.online::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border-radius: 50%; background: var(--good); border: 2px solid var(--bg); }
.avatar.me { box-shadow: 0 0 0 2px var(--accent); }
.avatar sup { position: absolute; top: -6px; right: -6px; font-size: 9px; background: var(--surface-3); color: var(--text); border-radius: 8px; padding: 0 4px; line-height: 14px; }
.user-btn { display: flex; align-items: center; gap: 9px; height: 36px; padding: 0 8px 0 4px; border-radius: 10px; border: 0; background: transparent; color: var(--text); cursor: pointer; font: inherit; }
.user-btn:hover { background: var(--surface-2); }
.user-btn .avatar { margin: 0; width: 28px; height: 28px; }
.user-btn .who { text-align: left; line-height: 1.2; }
.user-btn .who small { display: block; color: var(--text-3); font-size: 11px; }

.sidebar {
  background: var(--bg); border-right: 1px solid var(--border); overflow-y: auto; overflow-x: hidden; padding: 10px 10px 16px;
  display: flex; flex-direction: column; gap: 1px;
}
.sidebar .group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-3); padding: 16px 10px 6px; font-weight: 600; white-space: nowrap; }
.sidebar a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--text-2); text-decoration: none;
  font-size: 13.5px; font-weight: 500; position: relative; white-space: nowrap; transition: background .15s, color .15s;
}
.sidebar a:hover { background: var(--surface); color: var(--text); }
.sidebar a.active { background: var(--accent-soft); color: var(--text); }
.sidebar a.active .i { color: var(--accent); }
.sidebar a.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
.sidebar a .count { margin-left: auto; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); }
.sidebar a .count.warn { background: var(--warn-soft); color: var(--warn); }
.sidebar .spacer { flex: 1; }
.sidebar .collapse-btn { margin-top: 8px; }
.app.collapsed .sidebar .group { visibility: hidden; height: 18px; padding: 0; }
.app.collapsed .sidebar a span, .app.collapsed .sidebar a .count { display: none; }
.app.collapsed .sidebar a { justify-content: center; }

.main {
  overflow: auto; padding: 26px 32px 64px; min-width: 0; position: relative; background: var(--bg-main);
  background-image: radial-gradient(ellipse 80% 40% at 50% -10%, var(--accent-soft), transparent 70%);
  background-attachment: local;
}
/* Animation d'entrée uniquement à l'ouverture d'une page (pas lors des mises à jour en direct). */
.main.animate > * { animation: rise .45s var(--ease) both; }
.main.animate > *:nth-child(2) { animation-delay: .04s; }
.main.animate > *:nth-child(3) { animation-delay: .08s; }
.main.animate > *:nth-child(4) { animation-delay: .12s; }
.main.animate > *:nth-child(n+5) { animation-delay: .16s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .muted.small, .page-head .sub { margin-top: 4px; color: var(--text-3); font-size: 12.5px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--accent); font-weight: 650; margin-bottom: 6px; }

/* ==========================================================================
   Contrôles
   ========================================================================== */
button, .btn {
  font: inherit; font-size: 13px; font-weight: 550; padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
button:hover, .btn:hover { background: var(--surface-3); text-decoration: none; }
button:active, .btn:active { transform: scale(.98); }
button.primary, .btn.primary {
  background: linear-gradient(180deg, var(--accent-hover), var(--accent-strong)); border-color: transparent; color: var(--on-accent);
  box-shadow: 0 6px 20px -8px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.25);
}
button.primary:hover, .btn.primary:hover { filter: brightness(1.07); background: linear-gradient(180deg, var(--accent-hover), var(--accent-strong)); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: transparent; }
button.danger:hover { background: var(--bad-soft); }
button.ghost, .btn.ghost { border-color: transparent; background: transparent; }
button.ghost:hover, .btn.ghost:hover { background: var(--surface-2); }
button.icon-btn { padding: 0; width: 34px; height: 34px; justify-content: center; border-color: transparent; background: transparent; color: var(--text-2); }
button.icon-btn:hover { background: var(--surface-2); color: var(--text); }
button.sm, .btn.sm { padding: 5px 10px; font-size: 12px; }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
input, select, textarea {
  font: inherit; font-size: 13.5px; padding: 8px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); min-width: 0; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:disabled, select:disabled, textarea:disabled { opacity: .7; background: var(--surface-2); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.6); cursor: pointer; }
:root[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator { filter: none; }
select option, select optgroup { background: var(--surface); color: var(--text); }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-2); font-weight: 550; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface); border: 1px solid var(--border); gap: 2px; }
.seg button { border: 0; border-radius: 8px; background: transparent; padding: 6px 12px; color: var(--text-2); }
.seg button:hover { background: var(--surface-2); color: var(--text); }
.seg button.on { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.05) inset, 0 2px 6px rgba(0,0,0,.2); }
.kbd { font-family: var(--mono); font-size: 10.5px; padding: 2px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2); color: var(--text-2); }

/* ==========================================================================
   Cartes, KPI, tableaux, badges
   ========================================================================== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card > .card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card > .card-head .actions { margin-left: auto; display: flex; gap: 6px; }
.card > .card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpis.six { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.kpi {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; overflow: hidden;
  box-shadow: var(--shadow); transition: transform .25s var(--ease), border-color .25s;
}
.kpi:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.kpi .label { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 8px; font-weight: 550; }
.kpi .label .chip { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.kpi .value { font-size: 25px; font-weight: 680; margin-top: 10px; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.kpi .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.kpi .spark { position: absolute; right: 0; bottom: 0; width: 52%; height: 40px; opacity: .6; pointer-events: none; }
.kpi .value, .kpi .label, .kpi .sub { position: relative; z-index: 1; }
.kpi.accent { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 16%, var(--surface)), var(--surface) 70%); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th {
  font-size: 11px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em;
  background: color-mix(in srgb, var(--surface-2) 92%, transparent); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.total td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--border-strong); }
tr.subtotal td { font-weight: 600; color: var(--text); background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
tr.group td { background: var(--surface-2); font-weight: 600; color: var(--text); }
tr.selected td { background: var(--accent-soft); }
tfoot td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
.empty { padding: 48px 20px; text-align: center; color: var(--text-3); }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.badge.blue { background: var(--info-soft); color: var(--info); }
.notice { padding: 11px 16px; border-radius: 12px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); color: var(--text); margin-bottom: 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.notice.good { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 30%, transparent); }

/* ==========================================================================
   Saisie
   ========================================================================== */
.entry-lines td { padding: 5px 6px; }
.entry-lines input, .entry-lines select { width: 100%; }
.entry-lines .acc { width: 140px; }
.entry-lines .amt { width: 140px; }
.acc-lbl { margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.totals-bar { display: flex; gap: 28px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.totals-bar .t { text-align: right; }
.totals-bar .t .l { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.totals-bar .t .v { font-size: 18px; font-weight: 680; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.totals-bar .t:last-child .v { color: var(--accent); }
.preview td { font-size: 12.5px; padding: 6px 12px; }
.doc-type-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.doc-tab { display: flex; align-items: center; gap: 9px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; font-weight: 550; }
.doc-tab:hover { border-color: var(--border-strong); color: var(--text); }
.doc-tab.on { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.doc-tab.on .i { color: var(--accent); }

/* ==========================================================================
   États / bilan / graphique
   ========================================================================== */
.statement { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.statement td.code { width: 74px; color: var(--text-3); font-family: var(--mono); font-size: 11.5px; }
details.acc-detail summary { cursor: pointer; list-style: none; }
details.acc-detail summary::-webkit-details-marker { display: none; }
details.acc-detail[open] summary { color: var(--accent); }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { fill: var(--text-3); font-size: 11px; font-family: inherit; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .bar-income { fill: var(--series-1); }
.chart .bar-expense { fill: var(--series-2); }
.chart .bar-accent { fill: var(--accent); }
.chart .bars path { transform-origin: bottom; transform-box: fill-box; animation: grow .7s var(--ease) both; }
@keyframes grow { from { transform: scaleY(0); } }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover { fill: var(--text); fill-opacity: .04; }
.legend { display: flex; gap: 18px; font-size: 12px; color: var(--text-2); margin-bottom: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--glass); backdrop-filter: blur(14px); border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop);
  border-radius: 10px; padding: 9px 12px; font-size: 12px; z-index: 5; min-width: 170px;
}
.tooltip .row { display: flex; justify-content: space-between; gap: 14px; }

/* ==========================================================================
   Modales, toasts, palette de commandes
   ========================================================================== */
.modal-back { position: fixed; inset: 0; background: rgba(4, 8, 12, .55); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-pop); width: min(640px, 100%); max-height: 90vh; display: flex; flex-direction: column; animation: pop .28s var(--ease) both; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal.wide { width: min(980px, 100%); }
.modal-head { padding: 18px 22px 14px; display: flex; align-items: center; }
.modal-head h2 { flex: 1; font-size: 17px; }
.modal-body { padding: 4px 22px 20px; overflow: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 18px 18px; }
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(400px, calc(100vw - 36px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; background: var(--glass); backdrop-filter: blur(16px); color: var(--text); padding: 12px 14px; border-radius: 12px;
  box-shadow: var(--shadow-pop); font-size: 13px; animation: slidein .3s var(--ease); border-left: 3px solid var(--accent);
}
.toast.error { border-left-color: var(--bad); }
.toast.sync { border-left-color: var(--info); }
.toast .avatar { margin: 0; width: 24px; height: 24px; font-size: 9px; border: 0; }
.toast.out { animation: slideout .25s ease forwards; }
@keyframes slidein { from { transform: translateX(16px); opacity: 0; } }
@keyframes slideout { to { transform: translateX(16px); opacity: 0; } }

.palette-back { position: fixed; inset: 0; background: rgba(4, 8, 12, .5); backdrop-filter: blur(6px); z-index: 150; display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; animation: fade .15s ease both; }
.palette { width: min(640px, calc(100vw - 32px)); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(24px) saturate(1.4); border-radius: 18px; box-shadow: var(--shadow-pop); overflow: hidden; animation: pop .22s var(--ease) both; }
.palette .p-input { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.palette input { flex: 1; border: 0; background: transparent; font-size: 16px; padding: 0; box-shadow: none; color: var(--text); }
.palette input:focus { box-shadow: none; }
.palette .p-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette .p-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-3); padding: 10px 12px 4px; font-weight: 650; }
.palette .p-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; cursor: pointer; color: var(--text-2); }
.palette .p-item .i { color: var(--text-3); }
.palette .p-item .hint { margin-left: auto; font-size: 11.5px; color: var(--text-3); }
.palette .p-item.on { background: var(--accent-soft); color: var(--text); }
.palette .p-item.on .i { color: var(--accent); }
.palette .p-foot { display: flex; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); }

.menu {
  position: absolute; right: 0; top: 44px; background: var(--glass); backdrop-filter: blur(20px); border-radius: 14px;
  box-shadow: var(--shadow-pop); min-width: 250px; padding: 6px; z-index: 60; animation: pop .18s var(--ease) both;
}
.menu button { width: 100%; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
.menu button:hover { background: var(--surface-3); }
.menu .sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu .head { display: flex; gap: 12px; align-items: center; padding: 10px; }
.dropdown { position: fixed; z-index: 70; background: var(--glass); backdrop-filter: blur(20px); border-radius: 14px; box-shadow: var(--shadow-pop); padding: 6px; width: 380px; max-height: 70vh; display: flex; flex-direction: column; animation: pop .18s var(--ease) both; }
.dropdown input { margin: 4px 4px 8px; }
.dropdown .list { overflow-y: auto; }
.dropdown .opt { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.dropdown .opt:hover, .dropdown .opt.on { background: var(--surface-3); }
.dropdown .opt .code { font-family: var(--mono); font-size: 11px; color: var(--accent); width: 64px; flex: none; }

/* ==========================================================================
   Détecteur TVA & Peppol
   ========================================================================== */
.vat-wrap { position: relative; display: flex; gap: 6px; align-items: stretch; }
.vat-wrap > input { flex: 1; min-width: 0; }
.vat-btn { padding: 0 10px; gap: 6px; font-size: 12px; color: var(--text-2); flex: none; }
.vat-btn:hover { color: var(--accent); border-color: var(--accent); }
.vat-btn.ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 50%, transparent); background: var(--good-soft); }
.vat-btn.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); background: var(--bad-soft); }
.vat-btn.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); background: var(--warn-soft); }
.vat-btn.busy svg { animation: vatspin .9s linear infinite; }
@keyframes vatspin { to { transform: rotate(360deg); } }
.vat-pop {
  position: absolute; top: calc(100% + 6px); left: 0; width: max(100%, 400px); max-width: min(520px, 90vw); z-index: 40; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 14px; box-shadow: var(--shadow-pop); padding: 6px; animation: pop .2s var(--ease) both; color: var(--text); font-size: 13px; font-weight: 400; text-transform: none; letter-spacing: 0;
}
.vat-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; font-weight: 600; }
.vat-row { display: flex; gap: 10px; padding: 9px 10px; border-radius: 10px; margin: 2px 0; }
.vat-row .small { color: var(--text-2); }
.vat-row.good { background: var(--good-soft); }
.vat-row.bad { background: var(--bad-soft); }
.vat-row.warn { background: var(--warn-soft); }
.vat-ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface); }
.vat-row.good .vat-ic { color: var(--good); }
.vat-row.bad .vat-ic { color: var(--bad); }
.vat-row.warn .vat-ic { color: var(--warn); }
.vat-id { margin-top: 6px; font-size: 12px; color: var(--text); line-height: 1.45; }
.vat-foot { display: flex; align-items: center; gap: 8px; padding: 8px 10px 4px; flex-wrap: wrap; }
.vat-actions { margin-left: auto; display: flex; gap: 6px; }
input.vat-filled { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.vat-chip { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
.vat-chip span { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 6px; letter-spacing: .02em; }
.vat-chip .on { background: var(--good-soft); color: var(--good); }
.vat-chip .off { background: var(--bad-soft); color: var(--bad); }
.vat-chip .unk { background: var(--surface-3); color: var(--text-3); }

/* ==========================================================================
   Écran de connexion · verrouillage
   ========================================================================== */
.auth { position: fixed; inset: 0; display: grid; grid-template-columns: 1.1fr 1fr; background: #05080B; color: #EEF2F4; overflow: hidden; color-scheme: dark; }
.auth .dragbar { position: absolute; top: 0; left: 0; right: 0; height: 40px; -webkit-app-region: drag; z-index: 3; }
.auth-art { position: relative; padding: 56px; display: flex; flex-direction: column; overflow: hidden; }
.aurora { position: absolute; inset: -25%; filter: blur(70px); opacity: .95; pointer-events: none; }
.aurora i { position: absolute; border-radius: 50%; mix-blend-mode: screen; animation: drift 18s ease-in-out infinite; }
.aurora i:nth-child(1) { width: 55%; height: 50%; left: 0; top: 8%; background: radial-gradient(circle, #19D3A2 0%, transparent 65%); }
.aurora i:nth-child(2) { width: 65%; height: 60%; right: -10%; top: 32%; background: radial-gradient(circle, #0A6E8A 0%, transparent 65%); animation-delay: -6s; animation-duration: 22s; }
.aurora i:nth-child(3) { width: 50%; height: 45%; left: 25%; bottom: -8%; background: radial-gradient(circle, #1B4BD1 0%, transparent 65%); opacity: .5; animation-delay: -11s; animation-duration: 26s; }
@keyframes drift { 0%,100% { transform: translate(0,0) scale(1); } 33% { transform: translate(6%,-5%) scale(1.1); } 66% { transform: translate(-6%,5%) scale(.94); } }
.gridlines { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 40px 40px; mask-image: radial-gradient(ellipse at 35% 45%, #000 15%, transparent 70%); pointer-events: none; }
.auth-art > *:not(.aurora):not(.gridlines) { position: relative; }
.auth-art .wordmark { font-size: 26px; display: flex; align-items: center; gap: 12px; }
.auth-art .logo-mark { width: 40px; height: 40px; }
.auth-art .clock { margin-top: auto; font-size: 76px; font-weight: 250; letter-spacing: -.05em; line-height: 1; font-variant-numeric: tabular-nums; }
.auth-art .date { font-size: 17px; color: #A3AEB9; margin-top: 8px; text-transform: capitalize; }
.auth-art .claim { margin-top: 40px; font-size: 30px; font-weight: 640; letter-spacing: -.035em; line-height: 1.15; max-width: 460px; }
.auth-art .claim em { font-style: normal; background: linear-gradient(90deg, #2AF0BE, #6FD3FF); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-art .foot { margin-top: 32px; font-size: 12px; color: #6C7783; display: flex; gap: 18px; }
.auth-panel { position: relative; display: flex; align-items: center; justify-content: center; padding: 40px; background: rgba(10,14,19,.86); border-left: 1px solid rgba(255,255,255,.06); }
.auth-card { width: min(420px, 100%); animation: rise .6s var(--ease) both; }
.auth-card h1 { font-size: 26px; margin-bottom: 6px; color: #EEF2F4; }
.auth-card .lead { color: #A3AEB9; margin: 0 0 26px; }
.auth-card .cabinet { font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: #19D3A2; font-weight: 650; margin-bottom: 10px; }
.auth input { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.14); color: #EEF2F4; padding: 12px 14px; font-size: 14.5px; border-radius: 11px; }
.auth input:focus { border-color: #19D3A2; box-shadow: 0 0 0 4px rgba(25,211,162,.16); }
.auth label.field { color: #A3AEB9; }
.auth button.primary { padding: 12px 18px; font-size: 14.5px; justify-content: center; border-radius: 11px; --accent-hover: #2AE6B4; --accent-strong: #12B894; --on-accent: #032119; --accent-glow: rgba(25,211,162,.45); }
.auth .ghost, .auth .link { color: #A3AEB9; background: none; border: 0; cursor: pointer; font: inherit; padding: 0; }
.auth .ghost:hover, .auth .link:hover { color: #EEF2F4; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; margin-bottom: 18px; max-height: 330px; overflow-y: auto; padding: 2px; }
.person {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 8px 14px; border-radius: 14px; border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.025); cursor: pointer; color: #EEF2F4; font: inherit; text-align: center; transition: border-color .2s, background .2s, transform .2s var(--ease);
}
.person:hover { border-color: rgba(25,211,162,.55); background: rgba(25,211,162,.06); transform: translateY(-2px); }
.person .avatar { border-color: #05080B; }
.person strong { font-size: 13px; font-weight: 600; line-height: 1.25; }
.person small { font-size: 11px; color: #6C7783; line-height: 1.2; }
.who-chosen { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; padding: 12px; border-radius: 14px; background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.08); }
.who-chosen strong { display: block; font-size: 15px; }
.who-chosen small { color: #6C7783; }
.auth-error { color: #FF9C9C; font-size: 13px; min-height: 20px; margin-top: 4px; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.lockscreen { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; background: rgba(4,8,12,.72); backdrop-filter: blur(22px) saturate(1.2); animation: fade .3s ease both; color-scheme: dark; color: #EEF2F4; }
.lockscreen .box { text-align: center; width: min(340px, 90vw); animation: rise .45s var(--ease) both; }
.lockscreen .clock { font-size: 64px; font-weight: 250; letter-spacing: -.05em; line-height: 1; margin-bottom: 30px; font-variant-numeric: tabular-nums; }
.lockscreen .avatar { margin: 0 auto 12px; }
.lockscreen input { width: 100%; text-align: center; margin-top: 16px; background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.16); color: #EEF2F4; padding: 12px; border-radius: 11px; }

/* ==========================================================================
   Panel de gestion · tâches · dossiers
   ========================================================================== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs a { padding: 10px 14px; color: var(--text-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; display: flex; gap: 8px; align-items: center; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.member { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); transition: transform .25s var(--ease), border-color .25s; }
.member:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.member .top { display: flex; gap: 12px; align-items: center; }
.member .top strong { display: block; font-size: 14px; }
.member .top small { color: var(--text-3); }
.member .status { margin-top: 12px; font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 7px; min-height: 18px; }
.member .status .live { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); animation: pulse 2s infinite; }
.member .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.member .stats div { text-align: center; }
.member .stats b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.member .stats span { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.matrix th.rot { height: 130px; white-space: nowrap; vertical-align: bottom; padding: 0 0 10px; text-transform: none; letter-spacing: 0; font-size: 12px; }
.matrix th.rot > div { transform: rotate(-45deg); transform-origin: 14px 0; width: 28px; translate: 12px 0; }
.matrix td.cell { text-align: center; padding: 6px; }
.toggle { width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--border-strong); background: transparent; display: inline-grid; place-items: center; cursor: pointer; padding: 0; color: transparent; }
.toggle:hover { border-color: var(--accent); }
.toggle.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.toggle.mgr { background: linear-gradient(180deg, #F2C14E, #D99A1E); border-color: transparent; color: #2A1A00; }
.board { display: grid; grid-template-columns: repeat(3, minmax(260px, 1fr)); gap: 14px; align-items: start; }
.col { background: color-mix(in srgb, var(--surface) 55%, transparent); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-height: 200px; transition: border-color .2s, background .2s; }
.col.drop { border-color: var(--accent); background: var(--accent-soft); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-weight: 600; }
.col-head .badge { margin-left: auto; }
.task {
  background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 11px 12px; margin-bottom: 8px; cursor: grab;
  box-shadow: var(--shadow); transition: transform .2s var(--ease), border-color .2s, opacity .2s;
}
.task:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.task.dragging { opacity: .4; }
.task .t-title { font-weight: 550; line-height: 1.35; }
.task.done .t-title { color: var(--text-3); text-decoration: line-through; }
.task .t-meta { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-3); }
.task .t-meta .avatar { margin: 0 0 0 auto; }
.task.high { box-shadow: inset 3px 0 0 var(--bad), var(--shadow); }
.dossier-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.dcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; cursor: pointer; box-shadow: var(--shadow);
  transition: transform .25s var(--ease), border-color .25s; position: relative; overflow: hidden;
}
.dcard:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.dcard::after { content: ""; position: absolute; inset: auto -40% -60% auto; width: 70%; height: 90%; background: radial-gradient(circle, var(--accent-soft), transparent 70%); opacity: 0; transition: opacity .3s; }
.dcard:hover::after { opacity: 1; }
.dcard .head { display: flex; align-items: center; gap: 12px; }
.dcard .mono-badge { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--surface-3); color: var(--text); flex: none; letter-spacing: -.02em; }
.dcard .head strong { display: block; font-size: 14.5px; }
.dcard .head small { color: var(--text-3); }
.dcard .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.dcard .foot { display: flex; align-items: center; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }
.dcard .foot .presence { margin-left: auto; }
.hero { display: flex; align-items: flex-end; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.hero h1 { font-size: 30px; letter-spacing: -.04em; }
.hero .sub { color: var(--text-2); margin-top: 6px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.quick a {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-weight: 600; transition: transform .25s var(--ease), border-color .25s, background .25s; box-shadow: var(--shadow);
}
.quick a:hover { text-decoration: none; transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: linear-gradient(160deg, var(--accent-soft), var(--surface) 70%); }
.quick a .chip { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.quick a small { display: block; font-weight: 450; color: var(--text-3); font-size: 11.5px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.feed li:last-child { border-bottom: 0; }
.feed li .avatar { margin: 0; width: 26px; height: 26px; font-size: 9.5px; border: 0; }
.feed li time { color: var(--text-3); font-size: 11px; display: block; }
.deadline { display: flex; align-items: center; gap: 14px; }
.deadline .days { font-size: 34px; font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) {
  .quick { grid-template-columns: repeat(2, 1fr); }
  .board { grid-template-columns: 1fr; }
  .search-trigger { width: 40px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger .kbd { display: none; }
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; height: auto; min-height: 100vh; }
  .titlebar { flex-wrap: wrap; padding: 8px 12px; height: auto; gap: 8px; }
  .brand { width: auto; padding-left: 0; }
  .sidebar { flex-direction: row; overflow-x: auto; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar .group, .sidebar .spacer, .sidebar .collapse-btn { display: none; }
  .sidebar a.active::before { display: none; }
  .main { padding: 18px 16px 48px; overflow: visible; }
  .statement { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; overflow: auto; position: absolute; }
  .auth-art { display: none; }
  .user-btn .who { display: none; }
}
@media print {
  body { overflow: visible; background: #fff; color: #000; }
  .sidebar, .titlebar, .page-head .actions, .toolbar, .toasts, .quick { display: none !important; }
  .app { display: block; height: auto; }
  .main { overflow: visible; padding: 0; background: none; }
  .card { border: 0; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
