* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #1f2d3d; --muted: #7a899c;
  --primary: #2563eb; --primary-dark: #1d4ed8; --border: #e3e8ef;
  --green: #16a34a; --amber: #d97706; --red: #dc2626; --slate: #64748b;
}
body { font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--ink); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
a { cursor: pointer; }

/* LOGIN */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#1e3a8a,#2563eb); }
.login-card { background: #fff; padding: 36px 32px; border-radius: 14px; width: 340px; box-shadow: 0 20px 50px rgba(0,0,0,.25); display: flex; flex-direction: column; }
.login-logo { font-size: 40px; text-align: center; }
.login-card h1 { font-size: 22px; text-align: center; margin-top: 8px; }
.login-card p { text-align: center; margin-bottom: 18px; }
.login-card label { font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
.login-card input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.btn-block { width: 100%; margin-top: 18px; }
.error-msg { color: var(--red); font-size: 13px; text-align: center; margin-top: 10px; min-height: 18px; }

/* LAYOUT */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: var(--ink); color: #cbd5e1; display: flex; flex-direction: column; padding: 18px 0; }
.brand { font-size: 17px; font-weight: 700; color: #fff; padding: 0 20px 18px; border-bottom: 1px solid #33415540; }
.brand span { font-size: 15px; }
nav { flex: 1; padding-top: 10px; }
.nav-item { display: block; padding: 11px 20px; color: #cbd5e1; font-size: 14px; border-left: 3px solid transparent; }
.nav-item:hover { background: #ffffff10; color: #fff; }
.nav-item.active { background: #ffffff14; color: #fff; border-left-color: var(--primary); }
.sidebar-footer { padding: 16px 20px 0; border-top: 1px solid #33415540; display: flex; flex-direction: column; gap: 8px; }
.link-small { font-size: 12px; color: #94a3b8; }
.link-small:hover { color: #fff; }
.content { flex: 1; padding: 28px 34px; overflow-y: auto; }

/* TYPO */
.view h2 { font-size: 22px; margin-bottom: 4px; }
.view .subtitle { color: var(--muted); margin-bottom: 22px; font-size: 14px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }

/* BOUTONS */
.btn { border: none; border-radius: 8px; padding: 9px 16px; font-size: 14px; cursor: pointer; font-weight: 500; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: #cbd5e1; border: 1px solid #475569; }
.btn-ghost:hover { background: #ffffff10; }
.btn-light { background: #eef2f7; color: var(--ink); }
.btn-light:hover { background: #e2e8f0; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-danger { background: #fee2e2; color: var(--red); }
.btn-danger:hover { background: #fecaca; }
.btn-success { background: var(--green); color: #fff; }

/* CARTES STATS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.stat-card .num { font-size: 30px; font-weight: 700; }
.stat-card .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* TABLEAUX */
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
tr.clickable:hover { background: #f8fafc; cursor: pointer; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* BADGES */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.a_faire, .badge.en_attente { background: #f1f5f9; color: var(--slate); }
.badge.en_cours { background: #fef3c7; color: var(--amber); }
.badge.termine, .badge.livre { background: #dcfce7; color: var(--green); }

/* FORMULAIRES */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea { padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; }
.field textarea { resize: vertical; min-height: 70px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* MODALE */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-close { background: none; border: none; font-size: 26px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 22px; }

/* DETAIL VEHICULE */
.back-link { color: var(--primary); font-size: 14px; margin-bottom: 14px; display: inline-block; }
.detail-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 22px; margin-bottom: 22px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); gap: 14px; }
.detail-grid .k { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.detail-grid .v { font-size: 15px; font-weight: 500; margin-top: 2px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 14px; }
.section-head h3 { font-size: 17px; }
.actions-cell { display: flex; gap: 6px; }
@media (max-width: 640px){ .form-grid{grid-template-columns:1fr;} .sidebar{width:64px;} .brand span,.nav-item{font-size:0;} }

/* Lecture seule : masquer les actions de modification */
body.role-viewer .js-write { display: none !important; }
