/* ------------------------------------------------------------------ */
/*  Thème                                                              */
/* ------------------------------------------------------------------ */
:root {
  --bg: #f3f5fb;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e6eaf2;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-soft: #eef0ff;
  --good: #10b981;
  --bad: #ef4444;
  --warn: #f59e0b;
  --side: #0b1020;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --bs-body-font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-primary: #6366f1;
  --bs-primary-rgb: 99, 102, 241;
  --bs-link-color: #4f46e5;
  --bs-link-color-rgb: 79, 70, 229;
  --bs-link-hover-color: #3730a3;
  --bs-border-radius: 10px;
}

body { background: var(--bg); color: var(--ink); font-feature-settings: "tnum" 1; }
a { text-decoration: none; }

/* ------------------------------------------------------------------ */
/*  Layout : sidebar + contenu                                         */
/* ------------------------------------------------------------------ */
.app { display: flex; min-height: 100vh; }
.sidebar { background: var(--side) !important; color: #cbd5e1; --bs-offcanvas-width: 270px; }
.sidebar-inner { display: flex; flex-direction: column; height: 100%; padding: 22px 16px; }
@media (min-width: 992px) {
  .sidebar { width: 260px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 700; font-size: 1.05rem; padding: 0 8px 22px; }
.brand:hover { color: #fff; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 1.1rem;
  box-shadow: 0 6px 18px -6px rgba(99, 102, 241, .8);
}
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #64748b; padding: 16px 12px 6px; font-weight: 600; }
.side-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  color: #cbd5e1; font-weight: 500; font-size: .93rem; transition: background .15s, color .15s;
}
.side-link i { font-size: 1.05rem; opacity: .85; }
.side-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-link.active { background: rgba(99, 102, 241, .18); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.side-link.active i { color: #a5b4fc; opacity: 1; }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 18px; }
.btn-side { border-radius: 12px; font-weight: 600; padding: 10px; }
.btn-side-ghost { background: rgba(255, 255, 255, .06); color: #e2e8f0; border: 1px solid rgba(255, 255, 255, .08); }
.btn-side-ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.main { flex: 1; min-width: 0; }
.topbar { background: var(--side); color: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 1020; }
.topbar .brand { padding: 0; }
.content { padding: 28px 32px 48px; max-width: 1400px; }
@media (max-width: 991.98px) { .content { padding: 20px 16px 40px; } }

/* ------------------------------------------------------------------ */
/*  En-têtes de page                                                   */
/* ------------------------------------------------------------------ */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.page-head h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.page-head .sub { color: var(--ink-2); margin: 4px 0 0; font-size: .93rem; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 30px 0 14px; }
.section-title h2 { font-size: 1.1rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.section-title .sub { color: var(--ink-3); font-size: .85rem; }

/* ------------------------------------------------------------------ */
/*  Cartes                                                             */
/* ------------------------------------------------------------------ */
.card, .panel {
  background: var(--surface); border: 1px solid var(--line) !important; border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 20px 22px; }
.panel-title { font-weight: 700; font-size: .98rem; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-title .muted { font-weight: 500; color: var(--ink-3); font-size: .82rem; }
.card.shadow-sm { box-shadow: var(--shadow) !important; }

.kpi { padding: 18px 20px; height: 100%; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--ink-2); font-size: .85rem; font-weight: 500; }
.kpi-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 1.05rem; background: var(--tint, var(--accent-soft)); color: var(--c, var(--accent)); }
.kpi-value { white-space: nowrap; font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; margin-top: 10px; line-height: 1.15; }
.kpi-sub { font-size: .8rem; color: var(--ink-3); margin-top: 4px; }
.text-good { color: var(--good) !important; }
.text-bad { color: var(--bad) !important; }

/* Carte héro (trésorerie) */
.hero {
  border-radius: 22px; padding: 24px 26px; color: #fff; height: 100%; position: relative; overflow: hidden;
  background: radial-gradient(120% 140% at 100% 0%, #8b5cf6 0%, #6366f1 45%, #312e81 100%);
  box-shadow: 0 18px 40px -18px rgba(79, 70, 229, .7);
}
.hero::after { content: ""; position: absolute; right: -60px; bottom: -80px; width: 240px; height: 240px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.hero-label { font-size: .85rem; opacity: .85; font-weight: 500; }
.hero-amount { font-size: 2.3rem; font-weight: 800; letter-spacing: -.03em; margin: 6px 0 2px; }
.hero-sub { opacity: .85; font-size: .88rem; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; position: relative; z-index: 1; }
.hero-chip { background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .18); border-radius: 999px; padding: 6px 12px; font-size: .8rem; }
.hero-chip b { font-weight: 700; }

/* ------------------------------------------------------------------ */
/*  Enveloppes (comptes)                                               */
/* ------------------------------------------------------------------ */
.env {
  --c: #6366f1; position: relative; padding: 18px 18px 16px; height: 100%; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s; color: var(--ink);
}
.env:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -16px rgba(15, 23, 42, .25); color: var(--ink); }
.env::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; border-radius: var(--radius) var(--radius) 0 0; background: var(--c); }
.env-head { display: flex; align-items: center; gap: 12px; }
.env-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.15rem; color: var(--c); background: color-mix(in srgb, var(--c) 14%, white); flex-shrink: 0; }
.env-name { font-weight: 700; font-size: .95rem; line-height: 1.2; }
.env-pct { font-size: .78rem; color: var(--ink-3); }
.env-label { margin-top: 16px; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; }
.env-amount { white-space: nowrap; font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.env-amount.neg { color: var(--bad); }
.env-bar { height: 7px; border-radius: 99px; background: color-mix(in srgb, var(--c) 12%, #eef1f6); margin: 12px 0 10px; overflow: hidden; }
.env-bar > span { display: block; height: 100%; border-radius: 99px; background: var(--c); }
.env-bar.over > span { background: var(--bad); }
.env-foot { display: flex; justify-content: space-between; gap: 8px; font-size: .78rem; color: var(--ink-2); margin-top: auto; }
.env-foot .in { color: var(--good); font-weight: 600; }
.env-foot .out { color: var(--ink-2); font-weight: 600; }
.env-avenir { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: .76rem; color: var(--ink-3); }
.env-lock { position: absolute; top: 16px; right: 16px; font-size: .7rem; padding: 3px 8px; border-radius: 99px; background: color-mix(in srgb, var(--c) 12%, white); color: var(--c); font-weight: 600; }

/* Barre de répartition empilée */
.split-bar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: #eef1f6; }
.split-bar > span { height: 100%; transition: width .25s; }
.split-legend { display: grid; gap: 8px; margin-top: 14px; }
.split-row { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.split-row .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.split-row .val { margin-left: auto; font-weight: 700; }
.split-row .pct { color: var(--ink-3); font-size: .8rem; width: 48px; text-align: right; }

/* ------------------------------------------------------------------ */
/*  Tableaux, formulaires, boutons                                     */
/* ------------------------------------------------------------------ */
.table { --bs-table-bg: transparent; margin: 0; }
.table > thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 600; border-bottom-color: var(--line); background: #f8fafc !important; padding-top: 12px; padding-bottom: 12px; }
.table td { border-color: #f0f2f7; padding-top: 12px; padding-bottom: 12px; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f8f9ff; }
.card > .table-responsive { border-radius: var(--radius); }
.card > .table-responsive thead th:first-child { padding-left: 20px; }
.card > .table-responsive td:first-child { padding-left: 20px; }
.card > .table-responsive td:last-child, .card > .table-responsive th:last-child { padding-right: 20px; }

.form-control, .form-select { border-color: #dfe4ee; padding-top: .55rem; padding-bottom: .55rem; }
.form-control:focus, .form-select:focus { border-color: #a5b4fc; box-shadow: 0 0 0 .22rem rgba(99, 102, 241, .15); }
.form-label { font-weight: 600; font-size: .85rem; color: var(--ink-2); }
.form-control-sm, .form-select-sm { padding-top: .35rem; padding-bottom: .35rem; }

.btn { font-weight: 600; border-radius: 10px; }
.btn-primary { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: #4f46e5; --bs-btn-hover-border-color: #4f46e5; --bs-btn-active-bg: #4338ca; }
.btn-outline-primary { --bs-btn-color: var(--accent); --bs-btn-border-color: #c7d2fe; --bs-btn-hover-bg: var(--accent); --bs-btn-hover-border-color: var(--accent); }
.btn-success { --bs-btn-bg: #10b981; --bs-btn-border-color: #10b981; --bs-btn-hover-bg: #059669; --bs-btn-hover-border-color: #059669; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; }

.badge { font-weight: 600; border-radius: 7px; padding: .38em .6em; }
.badge-soft { background: color-mix(in srgb, var(--c, #6366f1) 13%, white); color: var(--c, #6366f1); }

.alert { border: 0; border-radius: 14px; box-shadow: var(--shadow); }

.segmented { display: inline-flex; flex-wrap: wrap; background: #e9ecf5; border-radius: 12px; padding: 4px; gap: 2px; }
.segmented a { padding: 6px 12px; border-radius: 9px; font-size: .83rem; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.segmented a:hover { color: var(--ink); }
.segmented a.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }

.chart-box { position: relative; height: 290px; }
.list-clean { list-style: none; margin: 0; padding: 0; }
.list-clean li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid #f0f2f7; }
.list-clean li:last-child { border-bottom: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }

.quick-prices { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.quick-prices button { border: 1px solid #dfe4ee; background: #fff; border-radius: 99px; padding: 3px 12px; font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.quick-prices button:hover { border-color: var(--accent); color: var(--accent); }

.empty { text-align: center; color: var(--ink-3); padding: 34px 10px; }
.empty i { font-size: 2rem; display: block; margin-bottom: 8px; color: #cbd5e1; }

.stock-ring { --p: 50; width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c, var(--accent)) calc(var(--p) * 1%), #eef1f6 0); }
.stock-ring > div { width: 92px; height: 92px; border-radius: 50%; background: #fff; display: grid; place-items: center; text-align: center; }

@media (max-width: 576px) {
  .kpi-value { font-size: 1.25rem; }
  .hero-amount { font-size: 1.8rem; }
  .chart-box { height: 240px; }
  .page-head h1 { font-size: 1.35rem; }
}

/* Google Contacts */
.btn-google { background: #fff; border: 1px solid #dadce0; color: #3c4043; }
.btn-google:hover { background: #f8faff; border-color: #c6d4f5; color: #1a73e8; }
.btn-google .bi-google { color: #1a73e8; }
.google-case { border: 1px dashed #c6d4f5; background: #f7f9ff; border-radius: 12px; padding: 10px 14px; }
.google-case .bi-google { color: #1a73e8; }
.etape { display: flex; gap: 12px; margin-bottom: 12px; }
.etape-num { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .8rem; display: grid; place-items: center; flex-shrink: 0; }
.copie { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; background: #f1f5f9; border-radius: 8px; padding: 6px 10px; word-break: break-all; }
