:root {
  --bg: #F5F7F8;
  --card-bg: #FFFFFF;
  --text: #171A1F;
  --text-muted: #667085;
  --accent: #1B4F8C;
  --accent-dark: #123A66;
  --accent-light: #E7EDF6;
  --danger: #DC2626;
  --danger-light: #FDECEC;
  --success: #16A34A;
  --success-light: #EAF7EE;
  --warning: #C9781B;
  --warning-light: #FBF0E1;
  --border: #E3E7EA;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

/* Des classes comme .btn imposent display:inline-flex, ce qui ecrase la
   regle par defaut du navigateur pour [hidden] (display:none) a specificite
   egale : sans ceci, un bouton avec l'attribut hidden reste visible. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
p { margin: 0 0 12px; color: var(--text-muted); }

a { color: var(--accent-dark); }

.app-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header .brand-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.app-header .brand {
  font-weight: 700;
  font-size: 18px;
  white-space: nowrap;
}

.app-header .brand span { color: var(--accent); }

.header-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn-plain {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 6px;
  border-radius: 50%;
  color: var(--text-muted);
  line-height: 1;
}

.icon-btn-plain:hover { background: var(--accent-light); }

main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 100px;
}

.auth-shell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

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

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-row + .card-row { margin-top: 10px; }

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  margin-top: 14px;
}

label:first-child { margin-top: 0; }

input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

textarea { min-height: 72px; resize: vertical; }

button {
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
}

.btn {
  min-height: 52px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-dark); }

.btn-secondary { background: var(--accent-light); color: var(--accent-dark); }

.btn-ghost { background: transparent; color: var(--text-muted); }

.btn-danger { background: var(--danger-light); color: var(--danger); }

.btn-icon {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  flex-shrink: 0;
}

.item-name { font-weight: 600; font-size: 16px; }
.item-meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.badge-success { background: var(--success); color: #fff; }
.badge-danger { background: var(--danger); color: #fff; }
.badge-warning { background: var(--warning); color: #fff; }
.badge-neutral { background: var(--text-muted); color: #fff; }
.badge-accent { background: var(--accent); color: #fff; }

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

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 12px;
}

.section-title h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }

/* Modal (fiche de saisie) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

.modal-overlay[hidden] { display: none; }

.modal-sheet {
  background: var(--card-bg);
  width: 100%;
  max-width: 640px;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 88vh;
  overflow-y: auto;
}

.modal-sheet .close-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: -8px;
}

.form-error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-top: 14px;
}

.form-error[hidden] { display: none; }

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  gap: 4px;
  z-index: 20;
}

.bottom-nav a {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}

.bottom-nav a.active { color: var(--accent-dark); background: var(--accent-light); }

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.filters input, .filters select { min-height: 44px; }

.loading { text-align: center; padding: 30px; color: var(--text-muted); }

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 8px;
}

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.kpi-card .kpi-value { font-size: 24px; font-weight: 800; }
.kpi-card .kpi-label { font-size: 13px; color: var(--text-muted); }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  position: relative;
  padding: 4px 0 4px 20px;
  font-size: 14px;
}
.timeline li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline li .timeline-date { color: var(--text-muted); font-size: 12px; margin-left: 6px; }

.tracking-number {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* Suggestions d'adresse (autocomplete France) sous le champ concerne */
.suggestions-adresse {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 30;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 20px rgba(15, 20, 25, 0.12);
  max-height: 220px;
  overflow-y: auto;
  margin-top: 4px;
}
.suggestion-adresse {
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
}
.suggestion-adresse:hover { background: var(--accent-light); }
.suggestion-adresse:not(:last-child) { border-bottom: 1px solid var(--border); }

/* Carte colis : lignes d'infos avec icones (numero, expediteur, trajet, poids...) */
.colis-card-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.colis-card-meta span { display: flex; align-items: center; gap: 6px; }

/* Parcours du colis : etapes cochees / en cours / a venir */
.parcours { list-style: none; padding: 0; margin: 0; }
.parcours li {
  position: relative;
  padding: 6px 0 6px 28px;
  font-size: 14px;
}
.parcours li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 12px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
}
.parcours li:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 24px;
  width: 2px;
  height: calc(100% - 12px);
  background: var(--border);
}
.parcours li.fait { color: var(--text); }
.parcours li.fait::before { border-color: var(--success); background: var(--success); }
.parcours li.fait::after { background: var(--success); }
.parcours li.actuel { color: var(--accent-dark); font-weight: 700; }
.parcours li.actuel::before { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 4px var(--accent-light); }
.parcours li.avenir { color: var(--text-muted); }
.parcours li .timeline-date { color: var(--text-muted); font-size: 12px; font-weight: 400; margin-left: 6px; }

/* Bandeau auto-promo sur la page de suivi public (une fois le colis affiche) */
.promo-annonce {
  margin-top: 20px;
  padding: 16px;
  border-radius: 12px;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  text-align: center;
}
.promo-titre { font-weight: 700; color: var(--accent-dark); margin-bottom: 6px; }
.promo-detail { font-size: 13px; margin-bottom: 4px; }
.promo-tel {
  display: inline-block;
  margin-top: 6px;
  font-weight: 700;
  text-decoration: none;
  color: var(--accent-dark);
}
.promo-reseaux { margin-top: 10px; display: flex; justify-content: center; gap: 16px; }
.promo-reseaux a { font-size: 13px; text-decoration: underline; }
