/* Espace client — thème clair, simple et épuré */
:root {
  --bg: #f5f7fb; --card: #ffffff; --ink: #172033; --muted: #66708a; --line: #e6eaf2; --soft: #f0f4fa;
  --brand: #0d5fb3; --brand-2: #0a4d93; --brand-soft: #e8f1fc;
  --green: #18a058; --green-soft: #e7f6ee; --orange: #e07b12; --orange-soft: #fdf1e3; --red: #d64545; --red-soft: #fdecec;
  --radius: 16px; --shadow: 0 1px 2px rgba(23,32,51,.04), 0 6px 24px rgba(23,32,51,.06);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
button { font: inherit; }
h1 { font-size: 26px; line-height: 1.2; margin: 0; letter-spacing: -.02em; font-weight: 700; }
h2 { font-size: 17px; margin: 0 0 14px; font-weight: 650; letter-spacing: -.01em; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 10px; font-weight: 650; }
small, .muted { color: var(--muted); }
[hidden] { display: none !important; }
svg { flex: none; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- Connexion */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side { background: linear-gradient(150deg, var(--brand) 0%, #083b73 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 380px; height: 380px; border-radius: 50%; background: rgba(255,255,255,.07); }
.auth-side h2 { font-size: 32px; line-height: 1.2; margin: 0 0 14px; color: #fff; letter-spacing: -.02em; }
.auth-side p { color: #d4e5f9; max-width: 420px; margin: 0; }
.auth-side ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.auth-side li { display: flex; gap: 12px; align-items: center; color: #eaf3fd; }
.auth-side li span { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.14); display: grid; place-items: center; }
.auth-side small { color: #a9c8ec; position: relative; z-index: 1; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .logo { width: 110px; height: 110px; object-fit: contain; display: block; margin: 0 0 18px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card form { margin-top: 26px; display: grid; gap: 16px; }
.auth-help { margin-top: 22px; font-size: 13.5px; color: var(--muted); }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-card .logo { margin: 0 auto 14px; }
  .auth-card > .head { text-align: center; }
}

/* ---------------------------------------------------------------- Formulaires */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: #39435a; }
input { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #d5dbe6; border-radius: 12px; padding: 12px 14px; transition: border-color .15s, box-shadow .15s; }
input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(13,95,179,.12); }
.pw { position: relative; }
.pw input { padding-right: 48px; }
.pw button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); padding: 8px; cursor: pointer; border-radius: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 12px; padding: 10px 16px; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; }
.btn:hover { border-color: #cdd5e2; background: #fafbfd; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.block { width: 100%; padding: 13px 16px; }
.btn.sm { padding: 7px 12px; font-size: 13.5px; border-radius: 10px; }
.btn:disabled { opacity: .6; cursor: default; }
.alert { padding: 12px 14px; border-radius: 12px; font-size: 14px; }
.alert.err { background: var(--red-soft); color: #9d2b2b; }
.alert.ok { background: var(--green-soft); color: #136b3e; }
.alert.info { background: var(--brand-soft); color: #0b4a8b; }
.rules { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.rules li::before { content: "○"; margin-right: 8px; }
.rules li.ok { color: var(--green); }
.rules li.ok::before { content: "✓"; }

/* ------------------------------------------------------------------ Layout */
.top { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1180px; margin: 0 auto; padding: 0 24px; height: 68px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; }
.brand img { width: 44px; height: 44px; object-fit: contain; }
.brand span { display: grid; line-height: 1.15; font-size: 14px; }
.brand small { font-weight: 500; font-size: 12px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: 14.5px; }
.nav a:hover { color: var(--ink); background: var(--soft); }
.nav a.active { color: var(--brand); background: var(--brand-soft); }
.nav em { font-style: normal; font-size: 10.5px; font-weight: 700; color: var(--orange); background: var(--orange-soft); border-radius: 999px; padding: 1px 7px; }
.me { position: relative; }
.me-btn { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px 4px 4px; cursor: pointer; color: var(--ink); max-width: 260px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.me-btn b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; min-width: 220px; display: grid; }
.menu a, .menu button { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 0; background: none; border-radius: 10px; color: var(--ink); text-align: left; cursor: pointer; font-size: 14px; }
.menu a:hover, .menu button:hover { background: var(--soft); }
.main { max-width: 1180px; margin: 0 auto; padding: 32px 24px 64px; }
.foot { max-width: 1180px; margin: 0 auto; padding: 8px 24px 40px; font-size: 12px; color: #98a1b5; text-align: center; }
.bottom { display: none; }
@media (max-width: 860px) {
  .nav, .me-btn b { display: none; }
  .top-in { height: 60px; padding: 0 16px; justify-content: space-between; }
  .me-btn { padding: 4px; }
  .main { padding: 22px 16px 100px; }
  .bottom { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom a { display: grid; justify-items: center; gap: 3px; padding: 6px 0; color: #8a93a8; font-size: 11px; font-weight: 600; }
  .bottom a.active { color: var(--brand); }
  .foot { padding-bottom: 100px; }
}

/* ------------------------------------------------------------- Composants */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; font-weight: 600; margin-bottom: 14px; }
.back:hover { color: var(--brand); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.g-half { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: grid; gap: 20px; align-content: start; }
@media (max-width: 1000px) { .g2, .g-half { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.empty { text-align: center; color: var(--muted); padding: 36px 20px; }
.empty .ico { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 16px; background: var(--soft); color: #9aa4b8; display: grid; place-items: center; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.badge i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-green { background: var(--green-soft); color: var(--green); } .b-orange { background: var(--orange-soft); color: var(--orange); }
.b-blue { background: var(--brand-soft); color: var(--brand); } .b-gray { background: var(--soft); color: var(--muted); }
.plate { display: inline-flex; align-items: stretch; border: 1.5px solid #1d2a44; border-radius: 6px; overflow: hidden; font: 700 14px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .06em; background: #fff; }
.plate::before { content: "F"; background: #1f4fbf; color: #fff; font-size: 9px; padding: 6px 4px 0; }
.plate span { padding: 5px 8px; }

/* Bienvenue */
.hello { display: flex; align-items: center; gap: 18px; background: linear-gradient(135deg, #ffffff 0%, var(--brand-soft) 100%); border: 1px solid #dce9f8; border-radius: 20px; padding: 26px 28px; margin-bottom: 24px; }
.hello .avatar { width: 56px; height: 56px; font-size: 19px; background: #fff; box-shadow: var(--shadow); }
.hello h1 { font-size: 24px; }
.hello p { margin: 4px 0 0; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); }
.kpi span { display: block; color: var(--muted); font-size: 13px; }
.kpi b { display: block; font-size: 22px; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
@media (max-width: 640px) { .kpis { grid-template-columns: 1fr 1fr; } .kpis .kpi:first-child { grid-column: 1 / -1; } .hello { padding: 20px; } }

/* Contrat (carte) */
.kgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.kgrid > :only-child { max-width: 720px; }
@media (max-width: 400px) { .kgrid { grid-template-columns: 1fr; } }
.kcard { display: grid; gap: 16px; color: var(--ink); transition: border-color .15s, transform .15s, box-shadow .15s; }
a.kcard:hover { border-color: #c9d8ec; transform: translateY(-2px); box-shadow: 0 10px 30px rgba(13,95,179,.10); }
.kcard-top { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 14px; align-items: center; }
.veh-img { position: relative; height: 78px; overflow: hidden; border-radius: 12px; background: linear-gradient(180deg, #f7f9fc, #eef2f8); }
.veh-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transform: scale(1.4); }
.kref { font: 700 12px ui-monospace, Menlo, monospace; color: var(--brand); letter-spacing: .04em; }
.kcard-main { display: grid; gap: 5px; min-width: 0; }
.kcard-main small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
.kcard-foot b { color: var(--ink); }
.kcard-foot .go { color: var(--brand); font-weight: 650; display: inline-flex; align-items: center; gap: 4px; }

/* Barres de progression */
.prog { display: grid; gap: 16px; }
.p-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 7px; }
.p-head span { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: #4a5470; }
.p-head b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.p-head b small { font-weight: 500; }
.bar { height: 10px; border-radius: 999px; background: #edf1f7; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #2aa9e0, var(--brand)); transition: width .8s cubic-bezier(.2,.8,.2,1); }
.bar.km i { background: linear-gradient(90deg, #35c17a, var(--green)); }
.bar.warn i { background: linear-gradient(90deg, #f4a340, var(--orange)); }
.bar.over i { background: linear-gradient(90deg, #ec6b6b, var(--red)); }
.p-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 6px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.p-foot .over { color: var(--red); font-weight: 600; }

/* Listes : documents, factures */
.list { display: grid; }
.item { display: flex; align-items: center; gap: 14px; padding: 13px 4px; border-top: 1px solid var(--line); color: var(--ink); min-width: 0; }
.item:first-child { border-top: 0; }
.card.flush .item { padding: 14px 20px; }
a.item:hover { background: #fafcff; }
.f-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; color: var(--c, var(--brand)); background: color-mix(in srgb, var(--c, var(--brand)) 11%, #fff); }
.item .grow { flex: 1; min-width: 0; }
.item .grow b { display: block; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .grow small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item .acts { display: flex; gap: 6px; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); background: #fff; border-radius: 10px; color: #4a5470; cursor: pointer; }
.icon-btn:hover { color: var(--brand); border-color: #c9d8ec; }
@media (max-width: 560px) { .item .amount small { display: none; } .hide-sm { display: none !important; } }

/* Onglets */
.tabs { display: inline-flex; background: #eaeef5; border-radius: 12px; padding: 4px; gap: 2px; margin-bottom: 20px; }
.tabs button { border: 0; background: none; padding: 8px 16px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(23,32,51,.1); }
.tabs button em { font-style: normal; color: var(--muted); font-weight: 500; margin-left: 4px; }

/* Détail contrat */
.k-hero { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; align-items: center; }
.k-hero .veh-img { height: 140px; }
.k-hero .veh-img img { transform: scale(1.3); }
.k-hero h1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.facts { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 12px; color: var(--muted); font-size: 14px; }
.facts span { display: inline-flex; align-items: center; gap: 7px; }
@media (max-width: 700px) { .k-hero { grid-template-columns: 1fr; } .k-hero .veh-img { height: 120px; } }
.dl { display: grid; grid-template-columns: minmax(130px, auto) minmax(0, 1fr); gap: 11px 18px; margin: 0; }
.dl dt { color: var(--muted); font-size: 14px; }
.dl dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.dl dd small { font-weight: 500; }
.next { display: flex; align-items: center; gap: 14px; background: var(--brand-soft); border-radius: 14px; padding: 14px 16px; margin-top: 18px; color: #0b4a8b; }
.next b { display: block; color: var(--ink); }

/* SAV / bientôt */
.soon { text-align: center; padding: 48px 24px; }
.soon .ico { width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 22px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.soon p { max-width: 520px; margin: 8px auto 0; color: var(--muted); }
.soon ul { list-style: none; padding: 0; margin: 24px auto 0; max-width: 460px; display: grid; gap: 10px; text-align: left; }
.soon li { display: flex; gap: 10px; align-items: center; background: var(--soft); border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.contact { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }

/* Visionneuse */
.viewer { position: fixed; inset: 0; z-index: 50; background: rgba(15,22,36,.72); display: flex; flex-direction: column; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #fff; }
.viewer-bar b { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-body { flex: 1; min-height: 0; display: grid; place-items: center; padding: 18px; }
.viewer-body iframe { width: min(960px, 100%); height: 100%; border: 0; border-radius: 10px; background: #fff; }
.viewer-body img { max-width: 100%; max-height: 100%; border-radius: 10px; background: #fff; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 60; box-shadow: var(--shadow); animation: fade .2s; }
.toast.err { background: var(--red); }
@media (max-width: 860px) { .toast { bottom: 90px; } }
