:root {
  --bg: #f4f5f7;
  --card: #fff;
  --border: #d8dbe0;
  --text: #1a1d22;
  --muted: #6b7280;
  --accent: #2b6cb0;
  --accent-hover: #1e4f80;
  --error: #c0392b;
  --ok: #1f7a3a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.25rem 1rem 6rem;
}

h1 { margin: 0 0 1rem; font-size: 1.5rem; }
h2 { margin: 0 0 0.75rem; font-size: 1.1rem; }
.hint { color: var(--muted); margin: -0.25rem 0 0.75rem; font-size: 0.9rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.card.sticky {
  position: sticky;
  bottom: 0.5rem;
  z-index: 5;
  box-shadow: 0 4px 18px rgba(0,0,0,0.08);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--muted);
  gap: 0.25rem;
}

input[type=text], select {
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

input[type=text]:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

button {
  font: inherit;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
}
button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.ghost { background: transparent; color: var(--accent); }
button.ghost:hover { background: #eaf1f9; }
button.tiny { padding: 0.2rem 0.5rem; font-size: 0.85rem; }
button.danger { border-color: var(--error); color: var(--error); }
button.danger:hover { background: #fbe9e7; border-color: var(--error); color: var(--error); }
button.danger.ghost { background: transparent; }

.totals-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.note-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.2rem;
}
.note-row input {
  flex: 1 1 auto;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--muted);
}

.day {
  border-top: 1px solid var(--border);
  padding: 0.75rem 0;
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 0.75rem;
  align-items: start;
}
.day:first-child { border-top: 0; padding-top: 0.25rem; }

.day-label {
  font-weight: 600;
  color: var(--muted);
  padding-top: 0.4rem;
}

.day-locations {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.loc-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.loc-row input { flex: 1 1 auto; min-width: 0; }
.loc-row .arrow { color: var(--muted); font-size: 0.85rem; min-width: 1rem; text-align: center; }

.day-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-end;
}

.retour {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.retour input[type=checkbox] { margin: 0; }
.retour.disabled { opacity: 0.4; cursor: not-allowed; }

.day-km {
  font-weight: 600;
  white-space: nowrap;
}
.day-km.loading { color: var(--muted); }
.day-km.error { color: var(--error); }

.totals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.totals strong { font-size: 1.05rem; }
#total-km { font-size: 1.3rem; font-weight: 700; }

.tiny-error {
  font-size: 0.78rem;
  color: var(--error);
  margin-top: 0.15rem;
}
