:root {
  --navy: #0e284b;
  --navy-dark: #081729;
  --navy-light: #1f3f68;
  --red: #e20a21;
  --red-dark: #a80916;

  --bg: #f2f4f7;
  --bg-panel: #ffffff;
  --bg-panel-raised: #eef1f6;
  --border: #dde3ec;
  --text: #16203a;
  --text-dim: #5b6b82;
  --text-faint: #94a1b3;
  --accent: #e20a21;
  --accent-dim: #a80916;
  --ok: #1a8a4c;
  --ok-bg: rgba(26, 138, 76, 0.10);
  --warn: #c97a00;
  --warn-bg: rgba(201, 122, 0, 0.10);
  --danger: #e20a21;
  --danger-bg: rgba(226, 10, 33, 0.08);
  --radius: 8px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'Roboto Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--navy);
  border-right: 1px solid var(--navy-dark);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 0 8px 20px 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.brand-logo-wrap {
  background: #ffffff;
  border-radius: 8px;
  padding: 8px 12px;
  display: inline-flex;
}

.brand-logo {
  height: 26px;
  width: auto;
  display: block;
}

.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-family: var(--font-display); font-size: 15px; color: #ffffff; }
.brand-text span { font-size: 11px; color: rgba(255,255,255,0.55); }

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 16px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,0.68);
  font-size: 14px;
  font-weight: 500;
}

.nav a:hover { background: rgba(255,255,255,0.06); color: #ffffff; }
.nav a.active { background: var(--red); color: #ffffff; }
.nav-ico { width: 16px; text-align: center; font-size: 13px; opacity: 0.9; }

.sidebar-footer {
  margin-top: auto;
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  padding: 0 8px;
}

/* Entrées de menu visibles uniquement sur mobile (Compte, Déconnexion) */
.nav-mobile-only { display: none !important; }
.nav-logout-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.68);
  font-size: 13.5px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.nav-agence-mobile {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.95);
  font-size: 13.5px;
  font-family: var(--font-body);
  flex-shrink: 0;
  max-width: 180px;
}

/* ---------- Content ---------- */

.content {
  flex: 1;
  padding: 32px 40px 60px 40px;
  max-width: 1180px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0 0 4px 0;
  color: var(--navy);
}

.page-header p { color: var(--text-dim); margin: 0; font-size: 14px; }

.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--red);
  font-weight: 700;
  margin-bottom: 6px;
  display: block;
}

/* ---------- Flash messages ---------- */

.flash-stack { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  border: 1px solid transparent;
}
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: rgba(26,138,76,0.25); }
.flash-error { background: var(--danger-bg); color: var(--danger); border-color: rgba(226,10,33,0.25); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--navy);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.btn:hover { border-color: var(--navy-light); background: var(--bg-panel-raised); }
.btn-primary { background: var(--red); color: #ffffff; border-color: var(--red); }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-danger-outline { color: var(--danger); border-color: rgba(226,10,33,0.35); background: transparent; }
.btn-danger-outline:hover { background: var(--danger-bg); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Cards / panels ---------- */

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 16px;
  margin: 0 0 16px 0;
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--navy);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-card .num { font-family: var(--font-display); font-size: 30px; display: block; margin-bottom: 4px; color: var(--navy); }
.stat-card .label { color: var(--text-dim); font-size: 12.5px; }
.stat-card.accent-danger { border-top-color: var(--danger); }
.stat-card.accent-danger .num { color: var(--danger); }
.stat-card.accent-warn { border-top-color: var(--warn); }
.stat-card.accent-warn .num { color: var(--warn); }
.stat-card.accent-ok { border-top-color: var(--ok); }
.stat-card.accent-ok .num { color: var(--ok); }

/* ---------- Table ---------- */

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 700;
  padding: 0 12px 10px 12px;
  border-bottom: 1px solid var(--border);
}
td { padding: 13px 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.row-link:hover { background: var(--bg-panel-raised); cursor: pointer; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-faint);
  font-size: 14px;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-bientot { background: var(--warn-bg); color: var(--warn); }
.badge-expire { background: var(--danger-bg); color: var(--danger); }
.badge-neutre { background: var(--bg-panel-raised); color: var(--text-dim); }
.badge-affecte { background: rgba(14,40,75,0.08); color: var(--navy); }
.badge-parking { background: var(--ok-bg); color: var(--ok); }
.badge-panne { background: var(--danger-bg); color: var(--danger); }
.badge::before { content: "●"; font-size: 8px; }

/* ---------- French plate signature element ---------- */

.plaque {
  display: inline-flex;
  align-items: stretch;
  font-family: var(--font-mono);
  border-radius: 5px;
  overflow: hidden;
  height: 44px;
  box-shadow: 0 2px 8px rgba(14,40,75,0.18);
  border: 1px solid #cfd4da;
}
.plaque-fr {
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 22px;
  font-size: 8px;
  line-height: 1.1;
  padding: 2px 0;
}
.plaque-body {
  background: #fdfdfd;
  color: #14161a;
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

/* ---------- Forms ---------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.field input, .field select, .field textarea {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--red);
  outline-offset: 1px;
  border-color: var(--red);
}
.field textarea { resize: vertical; min-height: 70px; }
.field-hint { font-size: 12px; color: var(--text-faint); }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 10px 0 16px 0; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--red); }
.checkbox-row label { font-size: 13.5px; color: var(--text); }

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tab.active { color: var(--red); border-color: var(--red); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Photo grid ---------- */

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.photo-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.photo-card img { width: 100%; height: 160px; object-fit: cover; display: block; }
.photo-card-body { padding: 12px 14px; }
.photo-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.photo-cat { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--navy); font-weight: 700; }
.photo-analyse {
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: pre-line;
  max-height: 140px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
}
.photo-actions { display: flex; gap: 8px; }

/* ---------- Calendrier ---------- */

.calendrier { display: flex; flex-direction: column; gap: 4px; }
.cal-entete, .cal-semaine { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-entete div {
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 700;
  padding-bottom: 6px;
}
.cal-jour {
  min-height: 96px;
  background: var(--bg-panel-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
}
.cal-vide { background: transparent; border-color: transparent; }
.cal-aujourdhui { border-color: var(--red); border-width: 2px; }
.cal-num { font-size: 12px; font-weight: 700; color: var(--text-dim); margin-bottom: 2px; }
.cal-aujourdhui .cal-num { color: var(--red); }
.cal-rdv {
  display: block;
  font-size: 11px;
  line-height: 1.25;
  padding: 4px 5px;
  border-radius: 4px;
  background: var(--navy);
  color: #fff;
  text-decoration: none;
  border-left: 3px solid var(--red);
}
.cal-rdv:hover { filter: brightness(1.2); }
.cal-rdv-type { display: block; font-size: 10px; opacity: 0.75; }
.cal-rdv-realise { background: var(--ok); border-left-color: var(--ok); }
.cal-rdv-annule { background: var(--text-faint); border-left-color: var(--text-faint); text-decoration: line-through; }

/* ---------- Timeline (historique) ---------- */

.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.timeline-date { font-size: 12px; color: var(--text-faint); min-width: 78px; flex-shrink: 0; padding-top: 2px; font-family: var(--font-mono); }
.timeline-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--navy); margin-top: 6px; flex-shrink: 0; }
.timeline-dot.type-mouvement { background: var(--red); }
.timeline-dot.type-document { background: var(--warn); }
.timeline-dot.type-reparation { background: var(--danger); }
.timeline-dot.type-revision { background: var(--ok); }
.timeline-dot.type-entretien { background: var(--navy-light); }
.timeline-dot.type-rdv { background: #7c5cbf; }
.timeline-content { flex: 1; }
.timeline-content .titre { font-weight: 600; font-size: 14px; color: var(--text); }
.timeline-content .detail { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

/* ---------- Misc ---------- */

.text-dim { color: var(--text-dim); }
.mono { font-family: var(--font-mono); }
.section-title { font-family: var(--font-display); font-size: 18px; margin: 0 0 4px 0; color: var(--navy); }
.divider { height: 1px; background: var(--border); margin: 24px 0; border: none; }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }

  /* Barre supérieure compacte et collante */
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 50;
    flex-direction: column;
    align-items: stretch;
    padding: 10px 0 0 0;
    gap: 8px;
  }
  .brand {
    border-bottom: none;
    padding: 0 16px;
    margin-bottom: 0;
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }
  .brand-logo-wrap { padding: 5px 9px; }
  .brand-logo { height: 20px; }
  .brand-text span { display: none; }
  .brand-text strong { font-size: 14px; }

  /* Menu horizontal glissable au doigt */
  .nav {
    flex-direction: row;
    flex-wrap: nowrap;
    margin: 0;
    padding: 0 12px 10px 12px;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;         /* Firefox */
  }
  .nav::-webkit-scrollbar { display: none; }  /* Chrome/Safari */
  .nav a {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 8px 14px;
    font-size: 13.5px;
  }

  .sidebar-footer { display: none; }
  .nav-mobile-only { display: flex !important; }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }

  /* Tableaux : défilement horizontal plutôt qu'écrasement des colonnes */
  .panel { padding: 16px; overflow-x: auto; }
  table { min-width: 560px; }

  /* Onglets de la fiche véhicule : glissables aussi */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex-shrink: 0; white-space: nowrap; }

  /* Cibles tactiles plus confortables */
  .btn { padding: 10px 16px; }
  .field input, .field select, .field textarea { font-size: 16px; } /* évite le zoom auto iOS */

  .page-header { flex-direction: column; align-items: stretch; }
  .page-header > div[style] { flex-wrap: wrap; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

  /* Calendrier : grille compacte, défilement horizontal si besoin */
  .calendrier { min-width: 620px; }
  .cal-jour { min-height: 72px; padding: 4px; }
  .cal-rdv { font-size: 10px; padding: 3px 4px; }
  .cal-rdv-type { display: none; }
}
