* { box-sizing: border-box; }
body { 
  font-family: 'Segoe UI', Tahoma, sans-serif; 
  margin: 0; 
  padding: 20px; 
  background: #ffffff;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 10px 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(10, 22, 40, 0.1);
}

.collapsible-title {
  cursor: pointer;
  user-select: none;
}
.collapsible-title:hover {
  color: #5DB4E8;
}

h1 {
  color: #0A1628;
  text-align: center;
  --margin: 10px 0 30px 0;
  font-size: 2em;
  margin: 0;
  width:100%;
}

.section {
  background: white;
  padding: 15px;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(10, 22, 40, 0.1);
  border: 1px solid #e5e7eb;
}

.img-200 {
  width:150px;
}

.section h3 {
  padding: 0;
}

#vehicleContent {
  border-top: 3px solid #5DB4E8;
  padding-top: 15px;
  margin-top: 10px;
}


.editing-mode {
  border: 3px solid #5DB4E8;
  box-shadow: 0 0 20px rgba(93, 180, 232, 0.3);
}

.editing-banner {
  background: #e0f2fe;
  border: 2px solid #5DB4E8;
  color: #0A1628;
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.editing-banner button {
  background: #0A1628;
  padding: 6px 12px;
  margin: 0;
}

/* Bandeau de statut sauvegarde */
.save-status {
  position: fixed;
  top: 15px;
  right: 15px;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9em;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  transition: opacity 0.5s ease;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
}

.save-status.show { opacity: 1; }
.save-status.success { background: #d1fae5; color: #065f46; border: 1px solid #10b981; }
.save-status.error   { background: #fee2e2; color: #991b1b; border: 1px solid #ef4444; }
.save-status.saving  { background: #e0f2fe; color: #0A1628; border: 1px solid #5DB4E8; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
  margin-bottom: 15px;
}

.form-field { display: flex; flex-direction: column; }
.form-field-wide { grid-column: 1 / -1; }

label {
  font-weight: 600;
  margin-bottom: 5px;
  color: #0A1628;
  font-size: 0.9em;
}

input, select, textarea {
  padding: 10px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 1em;
  transition: border-color 0.3s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #5DB4E8;
}

textarea { resize: vertical; font-family: inherit; }

button {
  background: #5DB4E8;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  transition: background 0.3s, transform 0.1s;
  margin-top: 10px;
}

button:hover { background: #4a9fd4; transform: translateY(-2px); }
button:active { transform: translateY(0); }

button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
}

.table-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.btn-export {
  background: #10b981;
  margin: 0;
}
.btn-export:hover { background: #059669; }

.btn-print {
  background: #0A1628;
  margin: 0;
}
.btn-print:hover { background: #1a2f4a; }

.btn-json {
  background: #f59e0b;
  width: calc(33.33% - 7px);
  margin-top: 20px;
  display: inline-block;
  margin-left: 10px;
}
.btn-json:hover { background: #d97706; }

.btn-import {
  background: #8b5cf6;
  width: calc(50% - 5px);
  margin-top: 10px;
  display: inline-block;
}
.btn-import:hover { background: #7c3aed; }

.btn-edit {
  background: #5DB4E8;
  padding: 5px 10px;
  font-size: 0.85em;
  margin: 0 5px 0 0;
}
.btn-edit:hover { background: #4a9fd4; }

.btn-delete {
  background: #ef4444;
  padding: 5px 10px;
  font-size: 0.85em;
  margin: 0;
}
.btn-delete:hover { background: #dc2626; }

.btn-update { background: #5DB4E8; }
.btn-update:hover { background: #4a9fd4; }

.period-selector {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
  background: #f0f9ff;
  padding: 15px;
  border-radius: 8px;
  border-left: 4px solid #5DB4E8;
}

.period-selector label { margin: 0; }
.period-selector select { flex: 1; max-width: 200px; }

.period-info {
  background: #e0f2fe;
  border-left: 4px solid #5DB4E8;
  padding: 15px;
  margin-bottom: 15px;
  border-radius: 4px;
}
.period-info strong { color: #0A1628; }

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

thead { background: #0A1628; color: white; }

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
}

th {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85em;
  letter-spacing: 0.5px;
}

tbody tr:hover { background: #f0f9ff; }
tbody tr:last-child td { border-bottom: none; }

.total-row {
  background: #e0f2fe !important;
  font-weight: 700;
  font-size: 1.1em;
}
.total-row td {
  border-top: 3px solid #5DB4E8;
  padding-top: 15px;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: #9ca3af;
  font-style: italic;
}

.action-buttons { display: flex; gap: 5px; }

.data-management {
  background: #fef3c7;
  border-left: 4px solid #f59e0b;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
}
.data-management h4 {
  margin-top: 0;
  color: #92400e;
  display: flex;
  align-items: center;
  gap: 8px;
}
.data-management p {
  color: #78350f;
  margin: 10px 0;
  font-size: 0.9em;
}

.file-input-wrapper {
  position: relative;
  display: inline-block;
  width: calc(50% - 5px);
}
.file-input-wrapper input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* ---- Section période + calendrier côte à côte ---- */
.period-calendar-layout {
  display: flex;
  gap: 48px;
  align-items: flex-start;
}
.period-left {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.period-left .period-selector {
  margin-bottom: 0;
}
.period-left .period-info {
  margin-bottom: 0;
}
.period-right {
  flex: 1;
  max-width: 500px;
}

/* Calendrier + stats côte à côte */
.calendar-and-stats {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}
.calendar-block {
  flex: 1;
  min-width: 0;
}
.cal-stats-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
}
.cal-stat-card {
  background: #0A1628;
  color: white;
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
  box-shadow: 0 2px 6px rgba(10,22,40,0.18);
}
.cal-stat-card.cal-stat-money {
  background: #5DB4E8;
}
.cal-stat-value {
  font-size: 1.25em;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}
.cal-stat-label {
  font-size: 0.68em;
  font-weight: 500;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ---- Calendrier ---- */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 10px;
}
#calMonthLabel {
  font-weight: 700;
  font-size: 1em;
  color: #0A1628;
  min-width: 140px;
  text-align: center;
}
.cal-nav-btn {
  background: #0A1628;
  padding: 4px 12px;
  font-size: 1em;
  margin: 0;
  border-radius: 6px;
  line-height: 1.4;
}
.cal-nav-btn:hover { background: #1a2f4a; transform: none; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.cal-day-header {
  text-align: center;
  font-weight: 700;
  font-size: 0.72em;
  color: #0A1628;
  padding: 3px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cal-cell {
  background: #f0f9ff;
  border-radius: 6px;
  min-height: 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid #e0f2fe;
}
.cal-cell.cal-empty {
  background: transparent;
  border: none;
}
.cal-cell.cal-today {
  background: #e0f2fe;
  border: 2px solid #5DB4E8;
}
.cal-day-num {
  font-size: 0.82em;
  color: #0A1628;
  font-weight: 500;
}
.cal-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5DB4E8;
  display: block;
}
.calendar-legend {
  margin-top: 8px;
  font-size: 0.8em;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.cal-dot-legend {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5DB4E8;
  display: inline-block;
}

@media (max-width: 600px) {
  .period-calendar-layout { flex-direction: column; }
  .period-left { flex: none; width: 100%; }
}

@media print {
  @page { size: A4 landscape; margin: 12mm 14mm; }
  body { background: white; padding: 0; font-size: 0.78em; }
  .container { max-width: 100%; }
  .header { box-shadow: none; border-bottom: 2px solid #5DB4E8; border-radius: 0; }
  h1 { font-size: 1.4em; border-bottom: 3px solid #5DB4E8; padding-bottom: 6px; }
  .section { box-shadow: none; border-radius: 0; border: none; margin-bottom: 6px; }
  /* La section période ne doit pas pousser le tableau à la page suivante */
  .section:has(#periodInfo) { page-break-after: avoid; }
  /* Le tableau démarre juste après, pas de saut */
  .section:has(#tableau) { page-break-before: avoid; }
  .section h3 { page-break-after: avoid; }
  .print-header { page-break-after: avoid; }
  .no-print { display: none !important; }
  button { display: none; }
  .action-buttons { display: none; }
  table { page-break-inside: auto; border-radius: 0; }
  tr { page-break-inside: avoid; page-break-after: auto; }
  thead { display: table-header-group; }
  th, td { padding: 7px 9px; font-size: 0.95em; }
  .period-selector { border: 1px solid #e0e0e0; background: white; border-radius: 0; }
  .period-info { border-radius: 0; }
  /* Période + véhicule/date sur la même ligne */
  .period-calendar-layout {
    flex-direction: row;
    align-items: center;
  }
  .period-left {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    gap: 20px;
  }
  .print-header {
    display: flex !important;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    color: #444;
    font-size: 0.88em;
    white-space: nowrap;
  }
  #vehicleInfoPrint { font-weight: 700; color: #0A1628; }
  .save-status { display: none; }
}
