@font-face { font-family: 'Archivo'; font-weight: 500 900; font-display: swap; src: url('fonts/archivo-normal-latin.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 100 900; font-display: swap; src: url('fonts/inter-normal-latin.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 100 800; font-display: swap; src: url('fonts/jetbrains-mono-normal-latin-ext.woff2') format('woff2'); }

:root {
  --ink: #0E0E12; --ink-2: #2a2a35; --ink-3: #6b6b78;
  --cream: #FAF6EE; --sand: #F2EEE5; --sand-2: #ECE6D8; --line: #E0DBCE; --paper: #fff;
  --blue: #1849A9; --blue-deep: #0E2960; --blue-pale: #C5D2EA;
  --green: #1F6B3A; --green-soft: #DCEBDF; --red: #A3352B; --red-soft: #F2DCD9; --amber: #8F6210; --amber-soft: #F3E7C9;
  --cost: #8A8478;
  --radius: 14px; --radius-sm: 10px; --pad: clamp(18px, 3.5vw, 44px); --side: 236px;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-head: 'Archivo', 'Inter', system-ui, sans-serif;
  --font-num: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 15px/1.5 var(--font-body); -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: var(--blue); }
h1, h2, h3 { font-family: var(--font-head); font-weight: 700; letter-spacing: -0.01em; margin: 0; line-height: 1.15; }
h1 { font-size: clamp(26px, 3vw, 34px); }
h2 { font-size: 19px; }
h3 { font-size: 15px; margin: 22px 0 8px; }
p { margin: 0 0 10px; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 0.93em; white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.sub { color: var(--ink-3); margin: 6px 0 0; }
.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.back { margin: 0 0 14px; font-size: 13.5px; }
.back a { color: var(--ink-3); text-decoration: none; }
.back a:hover { color: var(--ink); text-decoration: underline; }
.js .js-hide { display: none; }

/* --- coquille --- */
.side { position: fixed; top: 0; bottom: 0; left: 0; width: var(--side); background: var(--ink); color: var(--cream); display: flex; flex-direction: column; padding: 28px 20px 24px; }
.mark { display: inline-flex; align-items: center; gap: 9px; font-family: var(--font-head); font-weight: 700; font-size: 24px; letter-spacing: 0.06em; color: inherit; text-decoration: none; line-height: 1; }
.mark i { display: block; width: 1.5px; height: 20px; background: currentColor; opacity: 0.55; }
.mark-sub { font-family: var(--font-head); font-size: 10.5px; letter-spacing: 0.24em; text-transform: uppercase; opacity: 0.55; margin: 7px 0 0 2px; }
.side .mark-sub { margin-bottom: 36px; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: rgba(250, 246, 238, 0.72); text-decoration: none; font-weight: 500; }
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav a:hover { background: rgba(250, 246, 238, 0.08); color: var(--cream); }
.nav a.on { background: var(--cream); color: var(--ink); }
.side-foot { margin-top: auto; font-size: 13px; }
.side-user { font-weight: 600; margin-bottom: 4px; }
.linkbtn { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; opacity: 0.7; }
.linkbtn:hover { opacity: 1; }
.topbar, .tabbar { display: none; }
.main { margin-left: var(--side); padding: 34px var(--pad) 64px; max-width: calc(1240px + var(--side)); }

/* --- en-tête de page --- */
.phead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 26px; }
.phead-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search input[type="search"] { width: 220px; }

/* --- KPI : chiffres séparés par des filets, écho du B|M|P --- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 2px solid var(--ink); padding-top: 18px; margin-bottom: 26px; }
.kpi { padding: 0 22px; min-width: 0; }
.kpi:first-child { padding-left: 0; }
.kpi + .kpi { border-left: 1px solid var(--line); }
.kpi-v { font-family: var(--font-head); font-weight: 700; font-size: clamp(22px, 2.4vw, 30px); letter-spacing: -0.02em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-l { color: var(--ink-3); font-size: 13px; margin-top: 6px; }

/* --- puces de statut --- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 26px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink-2); font-size: 13px; background: var(--paper); }
.chip b { font-family: var(--font-num); font-weight: 500; color: var(--ink-3); }
.chip:hover { border-color: var(--ink); }
.chip.on { background: var(--ink); color: var(--cream); border-color: var(--ink); }
.chip.on b { color: rgba(250, 246, 238, 0.7); }
.chip .st { font-size: inherit; }

/* --- panneaux réglés comme un registre --- */
.panel { border-top: 2px solid var(--ink); padding-top: 14px; margin-bottom: 34px; }
.panel-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-h a { font-size: 13.5px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 36px; }
.cols > * { min-width: 0; }
.cols-wide { grid-template-columns: 1.4fr 1fr; }

.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12.5px; padding: 4px 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl td:first-child, .tbl th:first-child { padding-left: 0; }
.tbl td:last-child, .tbl th:last-child { padding-right: 0; }
.tbl .r { text-align: right; }
.tbl tbody tr:hover td { background: var(--sand); }
.tbl a.row { color: inherit; text-decoration: none; font-weight: 600; }
.tbl a.row:hover { color: var(--blue); }
.tbl tfoot td { border-bottom: 0; font-weight: 600; }
.tbl-tight td { padding: 7px 8px; }
.tbl .row-new td { background: var(--sand); }
.mbar-cell { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.mbar-cell .mbar { flex: 1; }
.empty { padding: 22px 0; color: var(--ink-3); }
.empty a { font-weight: 600; }

.st { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; white-space: nowrap; }
.st i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.st-soumission i { background: transparent; border: 1.5px solid var(--ink-3); }
.st-accepte i { background: var(--blue); }
.st-en_cours i { background: var(--amber); }
.st-termine i { background: var(--green); }
.st-paye i { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.st-annule i { background: var(--red); }

/* --- barre de marge --- */
.mbar { display: flex; height: 8px; background: var(--sand-2); border-radius: 4px; overflow: hidden; min-width: 80px; }
.mbar-c { background: var(--cost); }
.mbar-p { background: var(--blue); }
.mbar-over .mbar-c { background: var(--red); }
.mbar-lg { height: 26px; border-radius: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 7px; vertical-align: -1px; }
.sw-c { background: var(--cost); }
.sw-p { background: var(--blue); }

.ledger { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 34px; }
.ledger-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.num-big { font-family: var(--font-head); font-weight: 700; font-size: clamp(30px, 4vw, 46px); letter-spacing: -0.02em; line-height: 1; }
.num-mid { font-family: var(--font-head); font-weight: 600; font-size: clamp(20px, 2.4vw, 26px); letter-spacing: -0.01em; line-height: 1; }
.ledger-price { text-align: right; }
.lbl { color: var(--ink-3); font-size: 13px; margin-top: 6px; }
.ledger-legend { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 12px; font-size: 13.5px; color: var(--ink-2); }
.ledger-legend b { font-weight: 600; color: var(--ink); margin-left: 4px; }
.ledger-legend .push { margin-left: auto; }
.warn-text { color: var(--red); font-weight: 500; margin: 10px 0 0; }

.facts { margin: 0; }
.facts div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; font-weight: 600; }

.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 24px; margin: 0 0 24px; }
.meta div { min-width: 0; }
.meta dt { color: var(--ink-3); font-size: 12.5px; }
.meta dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }

/* --- graphique mensuel --- */
.chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 190px; border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: end; gap: 2px; height: 100%; }
.bar span { flex: 1; display: block; border-radius: 3px 3px 0 0; height: var(--h); min-height: 0; }
.bar .v { background: var(--blue); }
.bar .c { background: var(--cost); }
.chart-x { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; font-size: 11px; color: var(--ink-3); text-align: center; margin-top: 6px; font-family: var(--font-num); }
.legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--ink-3); margin-top: 10px; }

/* --- boutons et formulaires --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: var(--radius); border: 1.5px solid var(--ink); background: var(--ink); color: var(--cream); font: 600 14px var(--font-body); cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap; }
.btn:hover { background: var(--blue); border-color: var(--blue); color: var(--cream); }
.btn-primary { background: var(--blue); border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-deep); border-color: var(--blue-deep); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--sand-2); border-color: var(--ink); color: var(--ink); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; padding: 12px; }
.btn-danger { background: transparent; color: var(--red); border-color: transparent; padding: 5px 8px; font-weight: 500; }
.btn-danger:hover { background: var(--red-soft); border-color: transparent; color: var(--red); }
.btn:focus-visible, a:focus-visible, .linkbtn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12.5px; color: var(--ink-3); font-weight: 500; }
input, select, textarea { font: inherit; color: inherit; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; min-width: 0; width: 100%; }
input[type="checkbox"] { width: auto; }
select { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6b78' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; background-size: 16px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
textarea { resize: vertical; }
.inline select { width: auto; }
.frow { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.frow .field { flex: 1 1 150px; }
.frow .field.wide { flex: 2 1 220px; }
.frow .btn { height: 41px; flex: 0 0 auto; }
.f-2, .f-pass { display: grid; align-items: end; }
.f-pass { grid-template-columns: 1fr 1fr auto; max-width: 620px; }
.f-2 { grid-template-columns: 1fr 1fr; max-width: 720px; }
.f-2 .span2 { grid-column: span 2; }
.form-add { background: var(--sand); border-radius: var(--radius); padding: 14px 16px; margin-top: 14px; }
.form-page .actions { margin-top: 20px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.pct-in { display: inline-flex; align-items: center; gap: 6px; }
.pct-in input { width: 84px; font-family: var(--font-num); text-align: right; }
.check { display: inline-flex; align-items: center; gap: 8px; }
.shares tfoot b { font-family: var(--font-num); }
.notes { white-space: pre-line; max-width: 70ch; }
.danger-zone { margin-top: 12px; padding-top: 18px; border-top: 1px solid var(--line); }

.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 22px; background: var(--green-soft); color: var(--green); font-weight: 500; }
.flash-err { background: var(--red-soft); color: var(--red); }
.flash-warn { background: var(--amber-soft); color: var(--amber); }

/* --- connexion --- */
.auth-body { background: var(--cream); }
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-brand { background: var(--ink); color: var(--cream); padding: 44px; display: flex; flex-direction: column; }
.auth-brand .mark { font-size: 40px; gap: 14px; }
.auth-brand .mark i { height: 32px; }
.auth-brand h1 { margin-top: auto; font-size: clamp(28px, 3.6vw, 44px); max-width: 15ch; letter-spacing: -0.02em; }
.auth-brand p { margin: 16px 0 0; opacity: 0.7; max-width: 42ch; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 44px 24px; }
.auth-form form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.auth-form h2 { font-size: 24px; }
.auth-form .flash { margin: 0; }

/* --- mobile --- */
@media (max-width: 960px) {
  .cols, .cols-wide { grid-template-columns: 1fr; }
  .f-pass { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .side { display: none; }
  .topbar { display: flex; align-items: center; gap: 14px; background: var(--ink); color: var(--cream); padding: 13px 18px; position: sticky; top: 0; z-index: 5; }
  .topbar .mark { font-size: 19px; }
  .topbar-title { font-weight: 600; opacity: 0.8; font-size: 14px; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .main { margin-left: 0; padding: 22px 16px 96px; }
  .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: var(--ink); padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); z-index: 5; }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; color: rgba(250, 246, 238, 0.6); font-size: 11px; text-decoration: none; }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a.on { color: var(--cream); }
  .hide-m { display: none; }
  .phead-actions { width: 100%; }
  .search { flex: 1; }
  .search input[type="search"] { width: 100%; }
}
@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 28px 24px; min-height: 220px; }
  .auth-brand .mark { font-size: 30px; }
  .auth-brand h1 { font-size: 24px; margin-top: 28px; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr 1fr; row-gap: 20px; }
  .kpi { padding: 0 14px; }
  .kpi:nth-child(odd) { border-left: 0; padding-left: 0; }
  .frow .field, .frow .field.wide { flex-basis: 100%; }
  .frow .btn { width: 100%; }
  .f-2 { grid-template-columns: 1fr; }
  .f-2 .span2 { grid-column: auto; }
  .ledger { padding: 18px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .chip, .nav a { transition: background-color 0.15s, border-color 0.15s, color 0.15s; }
}
