/* IKSD Gestion — feuille de style (aucune police ni ressource externe) */
:root {
  --blue: #1f9fd6; --blue-600: #1683b3; --blue-50: #e8f5fc;
  --green: #8cbf2e; --green-600: #5f8a14; --green-50: #f0f7e2;
  --red: #d64545; --red-50: #fdecec; --amber: #d98a0b; --amber-50: #fdf3e1;
  --navy: #0f2a3d; --navy-2: #163a52;
  --bg: #f4f7fa; --card: #ffffff; --text: #182533; --muted: #66768a; --line: #e3e9ef; --soft: #f7f9fb;
  --shadow: 0 1px 2px rgba(16,40,60,.05), 0 6px 18px rgba(16,40,60,.06);
  --radius: 14px;
  --c-in: #8cbf2e; --c-out: #1f9fd6; --c-fct: #e08a2c; --c-net: #0f2a3d;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0c1620; --card: #132231; --text: #e5edf4; --muted: #92a3b5; --line: #22374a; --soft: #182b3c;
  --blue-50: #13344a; --green-50: #22331a; --red-50: #3a1d22; --amber-50: #3a2b14;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  --c-net: #e5edf4; --green-600: #a9d65a; --blue-600: #5cc1ea;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); margin: 2px 0 0; }
.ico { flex: none; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.small { font-size: 13px; }
.pos { color: var(--green-600); }
.neg { color: var(--red); }
.hide { display: none !important; }

/* ---------- Menu latéral ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; background: var(--navy); color: #c9d8e4; display: flex; flex-direction: column; padding: 18px 14px; z-index: 40; }
.brand { display: block; }
.brand-plate { display: block; background: #fff; border-radius: 12px; padding: 8px 10px; }
.brand-plate img { display: block; width: 100%; height: auto; }
.brand-sub { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: #8fb3c9; margin: 10px 4px 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; color: #c9d8e4; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(31,159,214,.28), rgba(140,191,46,.12)); color: #fff; box-shadow: inset 3px 0 0 var(--green); }
.side-foot { border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; }
.me { display: flex; gap: 10px; align-items: center; }
.me-txt { min-width: 0; }
.me-txt b { display: block; color: #fff; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-txt small { color: #8fb3c9; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--blue), var(--green)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.side-actions { display: flex; gap: 6px; margin-top: 10px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0; background: rgba(255,255,255,.07); color: inherit; cursor: pointer; }
.icon-btn:hover { background: rgba(255,255,255,.14); text-decoration: none; }

.main { margin-left: 250px; padding: 28px 32px 48px; max-width: 1400px; }
.main-guest { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.topbar, .bottom-nav, .backdrop { display: none; }

/* ---------- En-têtes, cartes ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 18px; }
.grid > .card + .card { margin-top: 0; }
.grid { align-items: start; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-wide { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
.mt { margin-top: 18px; }

/* Indicateurs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--k, var(--blue)); }
.kpi .lbl { color: var(--muted); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .val small.cur { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.kpi .val { font-size: clamp(17px, 1.55vw, 23px); white-space: nowrap; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; }
.kpi .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.in { --k: var(--c-in); } .kpi.out { --k: var(--c-out); } .kpi.fct { --k: var(--c-fct); } .kpi.net { --k: var(--navy); }
[data-theme="dark"] .kpi.net { --k: #6c8aa3; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--blue); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-600); }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { filter: brightness(.95); border-color: var(--green); }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); background: var(--red-50); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--soft); border-color: var(--line); }
.link-btn { background: none; border: 0; padding: 0; color: var(--blue-600); font: inherit; cursor: pointer; }

/* ---------- Formulaires ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
label.f { display: block; }
label.f > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=date], input[type=email], input[type=number], input[type=month], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31,159,214,.18); }
textarea { min-height: 80px; resize: vertical; }
input.amount { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters label.f { min-width: 150px; }
.filters .grow { flex: 1; min-width: 180px; }
.seg { display: inline-flex; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg input:checked + span { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.seg input[value=entree]:checked + span { color: var(--green-600); }
.seg input[value=sortie]:checked + span { color: var(--blue-600); }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: var(--soft); }
.t tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
.t .actions { white-space: nowrap; text-align: right; }
.t .actions form { display: inline; }
.t a.row-link { color: var(--text); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.empty .ico { opacity: .5; margin-bottom: 6px; }

/* ---------- Badges, barres ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.in, .st-en_cours { background: var(--green-50); color: var(--green-600); }
.badge.out { background: var(--blue-50); color: var(--blue-600); }
.st-prospect { background: var(--amber-50); color: var(--amber); }
.st-suspendu { background: var(--red-50); color: var(--red); }
.st-termine { background: var(--blue-50); color: var(--blue-600); }
.badge.fct { background: var(--amber-50); color: var(--amber); }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; color: var(--muted); }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--green)); border-radius: 99px; }
.bar.over > i { background: var(--red); }

/* ---------- Classements ---------- */
.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: grid; grid-template-columns: 28px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rank li:last-child { border-bottom: 0; }
.rank .pos-n { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--soft); color: var(--muted); }
.rank li:first-child .pos-n { background: linear-gradient(135deg, var(--blue), var(--green)); color: #fff; }
.rank .nm { min-width: 0; }
.rank .nm b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank .nm small { color: var(--muted); }
.rank .mini { height: 5px; background: var(--soft); border-radius: 9px; margin-top: 5px; overflow: hidden; }
.rank .mini i { display: block; height: 100%; border-radius: 9px; }

/* ---------- Messages ---------- */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 500; border: 1px solid transparent; }
.flash-success { background: var(--green-50); color: var(--green-600); border-color: rgba(140,191,46,.35); }
.flash-error { background: var(--red-50); color: var(--red); border-color: rgba(214,69,69,.3); }
.flash-info { background: var(--blue-50); color: var(--blue-600); border-color: rgba(31,159,214,.3); }
.note { background: var(--soft); border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; font-size: 13.5px; color: var(--muted); }

/* ---------- Connexion ---------- */
.login-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 32px 30px; }
.login-logo { background: #fff; border-radius: 14px; padding: 10px 14px; margin: -6px -4px 18px; text-align: center; }
.login-logo img { width: 100%; max-width: 280px; height: auto; }
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.login-card .muted { text-align: center; margin-bottom: 22px; }
.login-card .btn { width: 100%; justify-content: center; padding: 12px; margin-top: 8px; }
.login-card label.f { margin-bottom: 14px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ---------- Graphiques ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-zero { stroke: var(--muted); stroke-width: 1; opacity: .5; }
.chart .hit:hover { opacity: .85; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-tip { position: fixed; pointer-events: none; z-index: 100; background: var(--navy); color: #fff; padding: 8px 11px; border-radius: 9px; font-size: 12.5px; box-shadow: 0 6px 20px rgba(0,0,0,.2); opacity: 0; transition: opacity .12s; max-width: 260px; }
.chart-tip b { display: block; margin-bottom: 2px; }
.chart-tip.on { opacity: 1; }
.donut-wrap { display: grid; grid-template-columns: 180px minmax(0,1fr); gap: 18px; align-items: center; }
.card { container-type: inline-size; }
@container (max-width: 440px) {
  .donut-wrap { grid-template-columns: minmax(0,1fr); }
  .donut-wrap .chart { max-width: 190px; margin: 0 auto; }
}
.donut-legend { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.donut-legend li { display: grid; grid-template-columns: 12px minmax(0,1fr) auto; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.donut-legend li:last-child { border-bottom: 0; }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; }
.donut-legend span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Divers ---------- */
.pill-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.pill-tabs a { padding: 7px 13px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-weight: 600; font-size: 13.5px; }
.pill-tabs a.on { background: var(--navy); color: #fff; border-color: var(--navy); }
[data-theme="dark"] .pill-tabs a.on { background: var(--blue); border-color: var(--blue); }
.pill-tabs a:hover { text-decoration: none; }
.dl { display: grid; grid-template-columns: 140px minmax(0,1fr); gap: 8px 14px; font-size: 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; }
.split { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
details.box summary { cursor: pointer; font-weight: 600; }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 14px; }

/* ---------- Mobile ---------- */
@media (max-width: 1100px) {
  .g-wide, .g3 { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-105%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(8,20,30,.45); z-index: 35; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 30; justify-content: space-between; align-items: center; background: var(--card); border-bottom: 1px solid var(--line); padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top)); }
  .top-logo { background: #fff; border-radius: 8px; padding: 3px 6px; display: block; }
  .top-logo img { height: 34px; width: auto; display: block; }
  .top-actions { display: flex; gap: 6px; color: var(--text); }
  .top-actions .icon-btn { background: var(--soft); }
  .main { margin-left: 0; padding: 18px 14px 96px; }
  .g2 { grid-template-columns: minmax(0,1fr); }
  .form-grid { grid-template-columns: minmax(0,1fr); }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; background: var(--card); border-top: 1px solid var(--line); z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 9px; font-size: 11px; color: var(--muted); background: none; border: 0; font-family: inherit; cursor: pointer; }
  .bottom-nav a.active { color: var(--blue); }
  .bottom-nav a:hover { text-decoration: none; }
  h1 { font-size: 21px; }
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .val { font-size: 18px; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .donut-wrap { grid-template-columns: minmax(0,1fr); }
  .donut-wrap .chart { max-width: 220px; margin: 0 auto; }
  .t .hide-sm { display: none; }
  .dl { grid-template-columns: 110px minmax(0,1fr); }
}
@media print {
  .sidebar, .topbar, .bottom-nav, .head-actions, .btn { display: none !important; }
  .main { margin: 0; padding: 0; }
}
