:root {
  --bg: #f5f7fa;
  --bg-strong: #edf1f5;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --ink: #17202c;
  --muted: #6c7787;
  --line: #dfe5ec;
  --line-strong: #cfd8e3;
  --nav: #111827;
  --nav-soft: #1f2937;
  --blue: #2764d8;
  --blue-soft: #e8f0ff;
  --teal: #127c71;
  --teal-soft: #e6f5f2;
  --amber: #a45a00;
  --amber-soft: #fff3d8;
  --red: #b42318;
  --red-soft: #fee8e5;
  --green: #1b7f4c;
  --green-soft: #e6f4ec;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --sidebar-width: 282px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.boot-screen,
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(245, 247, 250, 0.96)),
    linear-gradient(110deg, #ecf2fa 0%, #f7faf9 45%, #f1f5f9 100%);
}

.boot-card,
.login-panel {
  width: min(960px, 100%);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.boot-card {
  width: 320px;
  padding: 32px;
  text-align: center;
}

.brand-mark {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border-radius: 7px;
  background: #111827;
  color: white;
  font-weight: 800;
}

.login-panel {
  display: grid;
  grid-template-columns: 1fr 420px;
  min-height: 620px;
  overflow: hidden;
}

.login-hero {
  position: relative;
  padding: 44px;
  color: white;
  background:
    linear-gradient(135deg, rgba(17, 24, 39, 0.96), rgba(29, 78, 126, 0.9)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 80px);
}

.login-hero h1 {
  margin: 26px 0 14px;
  font-size: 40px;
  line-height: 1.04;
}

.login-hero p {
  max-width: 520px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.65;
}

.login-metrics {
  position: absolute;
  right: 32px;
  bottom: 32px;
  left: 44px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.login-metric {
  min-height: 94px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
}

.login-metric strong {
  display: block;
  font-size: 25px;
  margin-bottom: 6px;
}

.login-form {
  padding: 42px;
  align-self: center;
}

.login-form h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.login-form > p {
  margin: 0 0 28px;
  color: var(--muted);
}

.demo-box {
  margin-top: 22px;
  padding: 14px;
  border-radius: 7px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
  color: #e5e7eb;
  background: var(--nav);
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 4px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: white;
  color: var(--nav);
  font-weight: 800;
}

.sidebar-brand strong {
  display: block;
  font-size: 16px;
}

.sidebar-brand span,
.sidebar-foot {
  color: #9ca3af;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
  margin: 22px 0;
}

.nav-item {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  border: 0;
  border-radius: 7px;
  color: #cbd5e1;
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: var(--nav-soft);
}

.nav-icon,
.button-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  line-height: 1.55;
}

.main-area {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: 14px 28px;
  background: rgba(245, 247, 250, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  font-size: 21px;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.content {
  width: min(1520px, 100%);
  margin: 0 auto;
  padding: 24px 28px 46px;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.page-head h2 {
  margin: 0 0 4px;
  font-size: 25px;
}

.page-head p {
  margin: 0;
  color: var(--muted);
}

.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  border-color: #b6c2d1;
  background: var(--surface-muted);
}

.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.btn.danger {
  color: var(--red);
  border-color: #f2b7b0;
}

.btn.ghost {
  background: transparent;
}

.btn.icon-only {
  width: 36px;
  padding: 8px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card,
.panel,
.table-shell,
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat-card {
  padding: 18px;
  min-height: 126px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 750;
}

.stat-card strong {
  display: block;
  margin-top: 12px;
  font-size: 32px;
}

.stat-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.panel {
  padding: 18px;
}

.mileage-panel {
  margin-bottom: 16px;
}

.mileage-head {
  align-items: start;
}

.mileage-controls {
  display: flex;
  justify-content: flex-end;
  width: min(360px, 100%);
}

.mileage-filter {
  width: 100%;
}

.mileage-selection {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin: 12px 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.mileage-selection strong,
.mileage-selection span {
  display: block;
}

.mileage-selection span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.vehicle-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.vehicle-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.vehicle-chip small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.vehicle-chip.active {
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
}

.vehicle-chip.active small {
  color: rgba(255, 255, 255, 0.78);
}

.mileage-chart-wrap {
  width: 100%;
  overflow-x: hidden;
  padding-bottom: 4px;
}

.mileage-chart {
  display: block;
  width: 100%;
  height: auto;
}

.chart-bg {
  fill: #ffffff;
  stroke: transparent;
}

.chart-grid {
  stroke: #cfd8e3;
  stroke-width: 1;
  stroke-dasharray: 5 5;
}

.chart-grid.vertical {
  stroke-dasharray: 4 6;
  opacity: 0.72;
}

.chart-axis {
  fill: #111827;
  font-size: 13px;
  font-weight: 700;
}

.chart-axis.month {
  font-size: 14px;
  font-weight: 600;
}

.chart-y-label {
  fill: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.chart-area {
  opacity: 0.14;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 12px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #475569;
  font-size: 12px;
  font-weight: 750;
}

.chart-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-head h3 {
  margin: 0;
  font-size: 16px;
}

.dashboard-maintenance-summary {
  margin-top: 16px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.section-head h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.dashboard-health-grid {
  margin-bottom: 0;
}

.maintenance-selector {
  display: grid;
  grid-template-columns: minmax(240px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}

.maintenance-selector-meta {
  min-height: 38px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 0 2px;
}

.maintenance-selector-meta strong {
  font-size: 16px;
}

.maintenance-selector-meta span {
  color: var(--muted);
}

.vehicle-health-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin: 0 0 18px;
}

.health-card {
  --accent: #64748b;
  --tint: var(--surface);
  position: relative;
  min-height: 138px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--tint);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.07);
}

.health-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--accent);
}

.health-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.health-card-label {
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1.25;
}

.health-card-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.health-card-body {
  margin-top: 18px;
}

.health-card-body strong {
  display: block;
  font-size: 18px;
  line-height: 1.2;
}

.health-card-body small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.35;
}

.health-card.success {
  --accent: var(--green);
  --tint: #f0faf4;
  border-color: #b8e1c9;
}

.health-card.warning {
  --accent: #b76a00;
  --tint: #fff8e8;
  border-color: #f2d49b;
}

.health-card.danger {
  --accent: var(--red);
  --tint: #fff1ef;
  border-color: #f2b7b0;
}

.health-card.missing {
  --accent: #b76a00;
  --tint: #fff8e8;
  border-color: #f2d49b;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  padding: 14px;
  margin-bottom: 16px;
}

.driver-filter-bar {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
}

.textarea {
  min-height: 84px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(39, 100, 216, 0.14);
}

.table-shell {
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-muted);
  color: #4b5563;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
}

tbody tr:hover {
  background: #fbfcfe;
}

.table-actions {
  display: flex;
  gap: 7px;
  justify-content: flex-end;
}

.due-cell {
  display: grid;
  gap: 5px;
  min-width: 104px;
}

.due-cell small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.badge.ok,
.badge.actif,
.badge.terminé,
.badge.traitée {
  color: var(--green);
  background: var(--green-soft);
}

.badge.maintenance,
.badge.planifié,
.badge.moyenne,
.badge.surveillance,
.badge.manquant {
  color: var(--amber);
  background: var(--amber-soft);
}

.badge.immobilisé,
.badge.en-cours,
.badge.haute,
.badge.critique,
.badge.depasse,
.badge.ouverte {
  color: var(--red);
  background: var(--red-soft);
}

.badge.vendu,
.badge.annulé,
.badge.basse,
.badge.inactif,
.badge.non-requis {
  color: #475569;
  background: #eef2f7;
}

.muted {
  color: var(--muted);
}

.mono {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 4fr 38px;
  gap: 10px;
  align-items: center;
}

.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.bar-track {
  height: 10px;
  background: #edf2f7;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: var(--value);
  background: linear-gradient(90deg, var(--blue), var(--teal));
  border-radius: inherit;
}

.alert-list,
.timeline-list {
  display: grid;
  gap: 10px;
}

.alert-item,
.timeline-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-muted);
}

.alert-item strong,
.timeline-item strong {
  display: block;
  margin-bottom: 4px;
}

.empty-state {
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.46);
}

.modal {
  width: min(820px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal-head,
.modal-foot {
  position: sticky;
  background: var(--surface);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
}

.modal-head {
  top: 0;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 20px;
}

.modal-foot {
  bottom: 0;
  border-top: 1px solid var(--line);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  color: var(--muted);
}

#toast-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 260px;
  max-width: 420px;
  padding: 13px 15px;
  color: white;
  background: #111827;
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--red);
}

.toast.success {
  background: var(--green);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    padding: 14px;
  }

  .sidebar-brand,
  .sidebar-foot {
    display: none;
  }

  .nav-list {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    margin: 0;
  }

  .nav-item {
    width: auto;
  }

  .grid.cols-4,
  .grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vehicle-health-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body {
    font-size: 13px;
    overflow-x: hidden;
  }

  .login-panel {
    grid-template-columns: 1fr;
  }

  .login-hero {
    display: none;
  }

  .login-form {
    padding: 28px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 35;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    overflow: hidden;
    padding: 10px 12px;
  }

  .nav-list {
    display: flex;
    gap: 8px;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    min-height: 42px;
    padding: 9px 11px;
    white-space: nowrap;
  }

  .nav-icon,
  .button-icon {
    width: 17px;
    height: 17px;
  }

  .topbar {
    padding: 14px 12px;
  }

  .app-shell,
  .main-area,
  .topbar,
  .content,
  .page-head,
  .filter-bar,
  .panel,
  .table-shell {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
  }

  .topbar,
  .page-head,
  .section-head,
  .mileage-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .topbar-meta > span {
    grid-column: 1 / -1;
    min-width: 0;
    font-size: 12px;
  }

  .topbar-meta .btn,
  .button-row .btn {
    width: 100%;
  }

  .button-row {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .btn,
  .input,
  .select {
    min-height: 44px;
    min-width: 0;
  }

  .topbar {
    min-height: 0;
  }

  .content {
    padding: 14px 12px 34px;
  }

  .grid.cols-4,
  .grid.cols-3,
  .grid.cols-2,
  .maintenance-selector,
  .vehicle-health-grid,
  .filter-bar,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 0;
  }

  .modal {
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

  .table-shell {
    margin-left: -2px;
    margin-right: -2px;
  }

  .table-scroll {
    scrollbar-width: thin;
  }

  table {
    min-width: 760px;
  }

  th,
  td {
    padding: 11px 10px;
  }

  .mileage-chart {
    min-width: 100%;
  }

  .mileage-controls,
  .mileage-filter {
    width: 100%;
  }

  .mileage-selection {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .vehicle-chip-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vehicle-chip {
    justify-content: center;
    width: 100%;
  }

  .chart-legend {
    gap: 8px 12px;
  }

  .stat-card,
  .panel {
    padding: 14px;
  }

  #toast-root {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }

  .toast {
    min-width: 0;
    max-width: none;
  }
}
