:root {
  --cob: #2E4BFF; --cob-soft: #EEF1FF; --ink: #15171C; --ink-2: #3A3E48; --mute: #6B6F7A; --line: #E6E4DE;
  --bg: #F6F5F1; --card: #FFFFFF; --grn: #12A150; --grn-soft: #E6F6EC; --red: #E5484D; --red-soft: #FDECEC;
  --amb: #D98A00; --amb-soft: #FFF4DE; --lil: #9AA8FF;
  --r: 14px; --head: 'Space Grotesk', system-ui, sans-serif; --body: 'Poppins', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 14px; }
a { color: var(--cob); text-decoration: none; }
h1, h2, h3, .num { font-family: var(--head); letter-spacing: -0.01em; }
h1 { font-size: 26px; margin: 0; } h2 { font-size: 17px; margin: 0 0 12px; } h3 { font-size: 15px; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

/* Mise en page */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #fff; padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: var(--cob); display: grid; place-items: center; font-family: var(--head); font-weight: 700; }
.brand b { font-family: var(--head); font-size: 15px; display: block; } .brand small { color: #9DA1AC; font-size: 11px; }
.side .group { color: #7E828D; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin: 14px 10px 6px; }
.side a { color: #D7D9DE; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; font-size: 13.5px; }
.side a:hover { background: #22252D; color: #fff; }
.side a.on { background: var(--cob); color: #fff; }
.side svg { width: 18px; height: 18px; flex: none; }
.side .foot { margin-top: auto; border-top: 1px solid #2A2D35; padding: 14px 8px 0; font-size: 12.5px; color: #9DA1AC; }
.side .foot b { color: #fff; display: block; font-size: 13.5px; }
.main { padding: 26px 32px 60px; min-width: 0; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.top p { margin: 4px 0 0; color: var(--mute); }
.btn.menu-btn { display: none; margin-bottom: 10px; }
.kpi .lbl svg { width: 16px; height: 16px; flex: none; }

/* Cartes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g2 { grid-template-columns: repeat(2, 1fr); }
.kpi .lbl { color: var(--mute); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.kpi .val { font-family: var(--head); font-size: 28px; font-weight: 600; margin: 6px 0 2px; }
.kpi .sub { color: var(--mute); font-size: 12px; }
.kpi .sub b { color: var(--grn); font-weight: 600; }
.mt { margin-top: 14px; } .mt2 { margin-top: 22px; }
.row { display: flex; align-items: center; gap: 10px; } .between { justify-content: space-between; } .wrap { flex-wrap: wrap; }
.muted { color: var(--mute); } .small { font-size: 12px; } .right { text-align: right; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--mute); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid #F0EEE9; vertical-align: middle; }
tr.click { cursor: pointer; } tr.click:hover td { background: #FAFAF7; }
td .who b { display: block; font-weight: 500; } td .who span { color: var(--mute); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.in { color: var(--grn); } .out { color: var(--red); }
.strike { text-decoration: line-through; opacity: .55; }
.empty { text-align: center; padding: 36px; color: var(--mute); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 500; background: #F0EEE9; color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--grn-soft); color: var(--grn); } .badge.no { background: var(--red-soft); color: var(--red); }
.badge.warn { background: var(--amb-soft); color: var(--amb); } .badge.blue { background: var(--cob-soft); color: var(--cob); }
.badge.dark { background: var(--ink); color: #fff; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* Formulaires */
.btn { border: 1px solid var(--line); background: #fff; padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.btn:hover { border-color: #CFCCC4; }
.btn.primary { background: var(--cob); border-color: var(--cob); color: #fff; } .btn.primary:hover { background: #2440E0; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost-danger { color: var(--red); }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 12px; outline: none; }
.input:focus { border-color: var(--cob); box-shadow: 0 0 0 3px var(--cob-soft); }
textarea.input { min-height: 90px; resize: vertical; }
label.f { display: block; margin-bottom: 12px; } label.f > span { display: block; font-size: 12.5px; color: var(--mute); margin-bottom: 5px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters .input { width: auto; min-width: 150px; } .filters .search { flex: 1; min-width: 220px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-bottom: 1px solid #F0EEE9; }
.switch:last-child { border-bottom: 0; }
.toggle { position: relative; width: 44px; height: 24px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: #D9D6CF; border-radius: 99px; cursor: pointer; transition: .2s; }
.toggle span::after { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.toggle input:checked + span { background: var(--cob); } .toggle input:checked + span::after { transform: translateX(20px); }

/* Pagination */
.pager { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; color: var(--mute); font-size: 12.5px; }

/* Graphiques */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 130px; padding-top: 8px; }
.bars div { flex: 1; background: var(--cob); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars div.zero { background: #E6E4DE; }
.bars div:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 4px 8px; border-radius: 6px; font-size: 11px; white-space: nowrap; margin-bottom: 4px; z-index: 2; }
.bars.green div:not(.zero) { background: var(--grn); }
.axis { display: flex; justify-content: space-between; color: var(--mute); font-size: 11px; margin-top: 6px; }
.meter { height: 8px; background: #F0EEE9; border-radius: 99px; overflow: hidden; } .meter i { display: block; height: 100%; background: var(--cob); }

/* Fiche */
.profile { display: flex; align-items: center; gap: 14px; }
.avatar { width: 52px; height: 52px; border-radius: 14px; background: var(--cob-soft); color: var(--cob); display: grid; place-items: center; font-family: var(--head); font-weight: 700; font-size: 20px; flex: none; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 13px; } .kv dt { color: var(--mute); } .kv dd { margin: 0; }
.fund { border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.fund .amt { font-family: var(--head); font-size: 20px; font-weight: 600; }

/* Modale & toasts */
.overlay { position: fixed; inset: 0; background: rgba(21, 23, 28, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 480px; padding: 22px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal h2 { margin-bottom: 6px; } .modal p { color: var(--mute); margin: 0 0 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.secret { font-family: var(--head); font-size: 20px; background: var(--cob-soft); color: var(--cob); padding: 12px; border-radius: 10px; text-align: center; user-select: all; }
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: up .2s ease; max-width: 360px; }
.toast.err { background: var(--red); }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }

/* Connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--ink); }
.login .card { width: 100%; max-width: 400px; padding: 30px; }
.login .logo { width: 46px; height: 46px; border-radius: 13px; background: var(--cob); color: #fff; display: grid; place-items: center; font-family: var(--head); font-weight: 700; font-size: 20px; margin-bottom: 18px; }
.login p { color: var(--mute); margin: 6px 0 22px; }
.err-box { background: var(--red-soft); color: var(--red); padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; }
.banner { background: var(--amb-soft); color: #8A5A00; padding: 10px 14px; border-radius: 12px; margin-bottom: 16px; font-size: 13px; }

.loading { padding: 50px; text-align: center; color: var(--mute); }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: .2s; }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .main { padding: 18px 16px 50px; }
  .g4, .g3, .g2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
}
