/* Gestion Leasing — palette chantier : graphite, acier, béton, jaune grue */
:root {
  --graphite: #0F2E57;   /* bleu nuit, texte et fonds sombres */
  --steel: #4F6078;
  --steel-2: #8A99AD;
  --concrete: #EEF2F7;
  --paper: #FFFFFF;
  --line: #D8E0EA;
  --brand: #2263AF;      /* bleu SOMALEV */
  --brand-soft: #EAF1FA;
  --crane: #ED7C2F;      /* orange SOMALEV */
  --crane-soft: #FDEEE3;
  --go: #2E8B57;
  --stop: #C2412D;
  --info: #2263AF;
  --ink: #0F2E57;
  --r: 6px;
  --num: "Barlow Condensed", "Arial Narrow", sans-serif;
  --head: "Exo 2", "Barlow", sans-serif;
  --txt: "Barlow", "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--txt); color: var(--ink); background: var(--concrete); }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--crane); outline-offset: 2px; }
h1 { font: 700 28px/1.2 var(--head); margin: 0 0 4px; letter-spacing: .2px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
h2 { font: 600 18px/1.25 var(--head); color: var(--graphite); margin: 0 0 12px; }
.lead { margin: 0; color: var(--steel); max-width: 75ch; }
.muted { color: var(--steel); }
.small { font-size: 13px; }
code { background: var(--crane-soft); padding: 1px 5px; border-radius: 3px; }

/* ---------- Structure ---------- */
.side { position: fixed; inset: 0 auto 0 0; width: 228px; background: var(--paper); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; flex-direction: column; gap: 6px; padding: 22px 20px 18px; border-bottom: 1px solid var(--line); }
.brand img { width: 170px; height: auto; display: block; }
.brand span { font: 600 12.5px var(--txt); color: var(--steel); letter-spacing: .6px; padding-left: 2px; }
.brand:hover { text-decoration: none; }
.side nav { display: flex; flex-direction: column; padding: 12px 0; }
.side nav a { color: var(--steel); padding: 10px 20px 10px 17px; border-left: 3px solid transparent; font-weight: 500; }
.side nav a:hover { background: var(--concrete); text-decoration: none; color: var(--graphite); }
.side nav a.on { border-left-color: var(--crane); color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.me { margin-top: auto; padding: 16px 20px 20px; border-top: 1px solid var(--line); font-size: 13px; display: flex; flex-direction: column; gap: 2px; color: var(--steel); }
.me strong { color: var(--graphite); font-size: 14px; }
.me a { color: var(--brand); }
.menu-toggle { display: none; }
main.with-side { margin-left: 228px; padding: 0 32px 48px; min-width: 0; }
main.bare { padding: 0 20px 40px; }
.stripe { height: 5px; margin: 0 -32px 26px; background: linear-gradient(90deg, var(--crane) 0 160px, var(--brand) 160px); }
main.bare .stripe { margin: 0 -20px 40px; }

.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.head.small { align-items: center; margin-bottom: 8px; }
.head.small h2 { margin: 0; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crumb { margin: 0 0 4px; font-size: 13px; color: var(--steel); }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; margin-bottom: 20px; min-width: 0; }
.card.narrow, .narrow { max-width: 680px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.cols.wide-left { grid-template-columns: 2fr 1fr; }
.cols > .card { margin-bottom: 20px; }

/* ---------- Indicateurs chiffrés ---------- */
.kpis { display: flex; flex-wrap: wrap; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 20px; }
.kpi { background: var(--paper); padding: 16px 18px; display: flex; flex-direction: column; min-width: 0; flex: 1 1 150px; }
.kpi span { font-size: 13px; color: var(--steel); }
.kpi strong { font: 600 26px/1.15 var(--num); margin: 4px 0 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi small { color: var(--steel); font-size: 12.5px; }
.kpi.hero { background: var(--graphite); color: #fff; position: relative; flex: 1.8 1 250px; }
.kpi.hero::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--crane); }
.kpi.hero span, .kpi.hero small { color: #B8C8DE; }
.kpi.hero strong { font-size: 32px; color: #fff; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); }
.table-wrap.tall { max-height: 72vh; }
.card .table-wrap { border-radius: 4px; }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
.grid th, .grid td { padding: 7px 10px; border-bottom: 1px solid #E7EAE6; text-align: left; vertical-align: top; }
.grid thead th { position: sticky; top: 0; z-index: 2; background: #F3F6FA; font: 600 13.5px/1.2 var(--num); letter-spacing: .2px; color: var(--steel); border-bottom: 2px solid var(--line); white-space: nowrap; }
.grid tbody tr:hover td { background: #F7FAFD; }
.grid td.n, .grid th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid td.strong { font-weight: 600; }
.grid tfoot td { background: #F3F6FA; font-weight: 600; border-top: 2px solid var(--line); position: sticky; bottom: 0; }
.grid td.obj { max-width: 260px; min-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid .s1 { white-space: nowrap; }
.grid.compact td, .grid.compact th { padding: 5px 9px; }
.grid .stick { position: sticky; background: var(--paper); z-index: 1; }
.grid thead .stick { z-index: 3; background: #F3F6FA; }
.grid tfoot .stick { background: #F3F6FA; z-index: 3; }
.grid .s0 { left: 0; min-width: 56px; }
.grid .s1 { left: 56px; min-width: 132px; }
.grid .s2 { left: 188px; min-width: 104px; box-shadow: 2px 0 0 var(--line); }
tr.verify td.s2 { background: var(--crane-soft); }
tr.paid td { color: var(--steel-2); }
tr.cancel td { color: var(--steel-2); text-decoration: line-through; }
tr.next td { background: var(--crane-soft) !important; font-weight: 600; }
tr.vr td { background: #F5F6F4; font-style: italic; }
tr.tot td { font-weight: 600; border-top: 2px solid var(--line); }
.nowrap { white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--crane); vertical-align: middle; box-shadow: 0 0 0 2px var(--crane-soft); }

/* Indicateur : jauge de remboursement */
.ind { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 12.5px; font-weight: 500; }
.ind b { width: 46px; height: 7px; border-radius: 4px; background: #E3E6E2; overflow: hidden; display: none; }
.ind b i { display: block; height: 100%; background: var(--go); }
.ind.run b, .ind.warn b { display: inline-block; }
.ind.warn b i { background: var(--crane); }
.ind.warn { color: #B4561A; }
.ind.ok { color: var(--go); }
.ind.ok::before, .ind.info::before, .ind.off::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.ind.info { color: var(--info); }
.ind.off { color: var(--steel-2); }
h1 .ind { font: 500 14px var(--txt); background: var(--paper); border: 1px solid var(--line); padding: 3px 10px; border-radius: 20px; }
.share { display: inline-block; width: 60px; height: 6px; background: #E3E6E2; border-radius: 3px; margin-right: 8px; vertical-align: middle; overflow: hidden; }
.share i { display: block; height: 100%; background: var(--crane); }

/* ---------- Formulaires ---------- */
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; color: var(--steel); margin-bottom: 12px; }
.form label.radio, .form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.form label.check { align-self: end; margin-bottom: 20px; }
input, select, textarea { font: 15px var(--txt); color: var(--ink); padding: 8px 10px; border: 1px solid #C5D2E3; border-radius: 4px; background: #fff; min-width: 0; }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; accent-color: var(--graphite); }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 2px solid rgba(34,99,175,.25); outline-offset: 0; }
textarea { resize: vertical; }
fieldset { border: 0; border-top: 1px solid var(--line); padding: 14px 0 2px; margin: 0 0 8px; }
legend { font: 600 17px var(--num); padding-right: 10px; color: var(--ink); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 16px; }
.form.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form.row label { margin-bottom: 0; }
.form.row .grow { flex: 1 1 320px; }
.form.upload { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0 16px; }
.hint { background: var(--crane-soft); padding: 8px 12px; border-radius: 4px; font-size: 13.5px; margin: 0 0 12px; font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
form.inline { display: inline; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; background: var(--brand); color: #fff; border: 1px solid var(--brand); border-radius: 4px; font: 600 14.5px var(--txt); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #1B4F8F; border-color: #1B4F8F; text-decoration: none; }
.btn.ghost { background: #fff; color: var(--brand); border-color: #C5D2E3; }
.btn.ghost:hover { border-color: var(--brand); background: var(--brand-soft); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; justify-content: center; }
.link { background: none; border: 0; padding: 0 4px; color: var(--info); cursor: pointer; font: inherit; }
.link.danger { color: var(--stop); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { min-width: 260px; }
.seg { display: inline-flex; border: 1px solid #C3C9C2; border-radius: 4px; overflow: hidden; background: #fff; }
.seg a, .seg label { padding: 7px 12px; color: var(--ink); font-size: 14px; }
.seg a.on { background: var(--brand); color: #fff; }
.seg a:hover { text-decoration: none; }
.seg.big { margin-bottom: 14px; flex-wrap: wrap; }
.seg.big label { display: flex; flex-direction: row; align-items: center; gap: 6px; margin: 0; color: var(--ink); }
.refdate label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--steel); margin: 0; }
.refdate input { padding: 7px 8px; }

.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 16px; color: var(--steel); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--crane); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

.flash { padding: 10px 14px; border-radius: 4px; margin-bottom: 14px; border-left: 4px solid var(--go); background: #E6F2EB; }
.flash.err { border-color: var(--stop); background: #F8E6E2; }
.flash.warn { border-color: var(--crane); background: var(--crane-soft); }
.flash.info { border-color: var(--info); background: #E4EEF5; }

.dl { display: grid; grid-template-columns: minmax(150px, 40%) 1fr; gap: 6px 14px; margin: 0; }
.dl dt { color: var(--steel); font-size: 13.5px; }
.dl dd { margin: 0; font-variant-numeric: tabular-nums; }
.note { background: #F5F6F4; padding: 10px 12px; border-radius: 4px; font-size: 13.5px; }
.av { border-left: 3px solid var(--crane); padding: 4px 0 4px 12px; margin-bottom: 14px; }
.av p { margin: 4px 0; }
.docs { list-style: none; padding: 0; margin: 0 0 8px; }
.docs li { padding: 6px 0; border-bottom: 1px solid #EEF0ED; }
.list { list-style: none; padding: 0; margin: 0 0 16px; }
.list li { padding: 7px 0; border-bottom: 1px solid #EEF0ED; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.list li span { color: var(--steel); font-size: 13.5px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags a { background: var(--crane-soft); padding: 2px 8px; border-radius: 3px; font-size: 13px; color: var(--ink); }
.empty { padding: 40px; text-align: center; color: var(--steel); }
.chart { position: relative; height: 320px; }
.chart.sm { height: 300px; }
table.calc td:first-child { color: var(--steel); }

.login { max-width: 380px; margin: 8vh auto 0; background: var(--paper); padding: 32px; border-radius: var(--r); border: 1px solid var(--line); }
.login h1 { margin-top: 12px; }
.login-logo { width: 240px; max-width: 100%; display: block; margin: 0 auto 8px; }
.login h1, .login > p { text-align: center; }
.login { border-top: 4px solid var(--crane); }

@media (max-width: 1100px) {
  .grid4 { grid-template-columns: repeat(2, 1fr); }
  .cols, .cols.wide-left { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .side { position: sticky; top: 0; width: auto; inset: auto; flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 10px 16px; border-bottom: 0; }
  .brand img { width: 130px; }
  .brand span { display: none; }
  .menu-toggle { display: block; margin-left: auto; margin-right: 12px; background: none; border: 1px solid #C5D2E3; color: var(--brand); padding: 6px 12px; border-radius: 4px; font: inherit; }
  .side nav, .side .me { display: none; width: 100%; }
  body.nav-open .side nav, body.nav-open .side .me { display: flex; }
  main.with-side { margin-left: 0; padding: 0 14px 40px; }
  .stripe { margin: 0 -14px 18px; }
  .grid2, .grid4 { grid-template-columns: 1fr; }
  .kpi strong { font-size: 22px; }
  .kpi.hero strong { font-size: 26px; }
  .filters input[type=search] { min-width: 0; flex: 1 1 100%; }
  .grid .stick { position: static; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .side, .actions, .filters, .tabs, .stripe, form.inline, .menu-toggle { display: none !important; }
  main.with-side { margin: 0; padding: 0; }
  .table-wrap.tall { max-height: none; overflow: visible; }
  body { background: #fff; }
}

/* ---------- Notifications ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.form label.chip { flex-direction: row; align-items: center; gap: 7px; margin: 0; padding: 7px 12px; border: 1px solid #C5D2E3; border-radius: 20px; background: #fff; color: var(--graphite); font-size: 14px; cursor: pointer; }
.form label.chip:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.form label.chip small { color: var(--steel-2); font-weight: 400; }
.form label.chip.off { opacity: .55; cursor: not-allowed; }
.rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; margin-bottom: 12px; }
.rule { border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--r); padding: 14px 16px; }
.rule.paused { border-left-color: var(--steel-2); background: #FAFBFC; }
.rule header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 16px; }
.rule .dl { margin-bottom: 12px; grid-template-columns: 110px 1fr; }
.rule .actions { gap: 6px; }
.testform input { padding: 5px 8px; font-size: 13px; width: 200px; }
.pill { font-size: 12px; padding: 2px 10px; border-radius: 12px; background: #E6EAF0; color: var(--steel); }
.pill.on { background: #E3F2EA; color: var(--go); }
.warn-t { color: #B4561A; font-weight: 600; }
.err-t { color: var(--stop); font-size: 13px; }
pre.cmd { background: var(--graphite); color: #fff; padding: 12px 14px; border-radius: 4px; overflow-x: auto; font-size: 13px; white-space: pre-wrap; word-break: break-all; }
code.wrap { word-break: break-all; }
.steps { padding-left: 20px; margin: 6px 0; }
.testmail { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
@media (max-width: 820px) { .rules { grid-template-columns: 1fr; } }
