:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-light: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #2563eb;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --border-radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }

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

.sidebar {
  width: 250px;
  background: var(--bg);
  color: var(--text);
  padding: 0 0 1.25rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 1.1rem 1rem; border-bottom: 1px solid var(--surface); margin-bottom: .6rem;
}
.sidebar-brand { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.sidebar-avatar {
  width: 38px; height: 38px; border-radius: 10px; background: var(--primary);
  color: white; display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.sidebar-company { font-weight: 700; font-size: .95rem; line-height: 1.2; overflow-wrap: anywhere; }
.sidebar-role { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .02em; }
.sidebar-close { display: none; background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; }

.sidebar-section {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: #64748b; padding: 1rem 1.25rem .35rem;
}

.sidebar nav { padding: 0 1rem; }

.sidebar nav a {
  display: block;
  color: var(--text-muted);
  padding: .6rem .75rem;
  border-radius: 8px;
  margin-bottom: .15rem;
  font-size: .92rem;
}

.sidebar nav a:hover, .sidebar nav a.active {
  background: var(--surface);
  color: var(--text);
}

.main { flex: 1; min-width: 0; }

.topbar {
  background: white;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.content { padding: 1.25rem; max-width: 1200px; }

.card {
  background: white;
  border-radius: var(--border-radius);
  padding: 1.1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  margin-bottom: 1rem;
}

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

.stat { text-align: left; }
.stat .value { font-size: 1.6rem; font-weight: 700; }
.stat .label { color: #64748b; font-size: .85rem; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid #e2e8f0; }
th { color: #64748b; font-weight: 600; font-size: .8rem; text-transform: uppercase; }

.badge {
  display: inline-block; padding: .2rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-muted { background: #e2e8f0; color: #475569; }

.btn {
  display: inline-block; padding: .55rem 1rem; border-radius: 8px; border: none;
  background: var(--primary); color: white; font-size: .9rem; cursor: pointer;
}
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }

.form-group { margin-bottom: .9rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; }
.form-control {
  width: 100%; padding: .55rem .7rem; border: 1px solid #cbd5e1; border-radius: 8px; font-size: .95rem;
}

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg);
}
.login-card { background: white; padding: 2rem; border-radius: 12px; width: 100%; max-width: 360px; }

.hamburger-btn {
  display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer;
  padding: .2rem .5rem; margin-right: .5rem; color: #1e293b;
}

.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 40;
}
.sidebar-overlay.open { display: block; }

@media (max-width: 780px) {
  .app-shell { flex-direction: column; }
  .hamburger-btn { display: inline-block; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 50;
    transform: translateX(-100%); transition: transform .25s ease;
    overflow-y: auto; box-shadow: 4px 0 16px rgba(0,0,0,.15);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .sidebar nav a { white-space: normal; margin-bottom: .15rem; }
  .content { padding: 1rem; }
}

/* Portail livreur : cartes larges, boutons tactiles */
.livreur-card { padding: 1.25rem; }
.livreur-card-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem;
}
.livreur-line { margin: .4rem 0; font-size: .95rem; }
.livreur-address { color: #475569; background: #f1f5f9; padding: .5rem .7rem; border-radius: 8px; }
.livreur-actions { margin-top: .7rem; }
.livreur-actions .btn, .livreur-actions .form-control { font-size: 1rem; padding: .75rem; }
.livreur-actions .form-control { margin-bottom: .5rem; }

.commune-checklist {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .3rem .8rem; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: .7rem;
}
.commune-check { font-size: .88rem; font-weight: 400; display: flex; align-items: center; gap: .35rem; }
.commune-check input { margin: 0; }
.commune-check-all { border-bottom: 1px solid #e2e8f0; padding-bottom: .5rem; margin-bottom: .5rem; }

/* Toolbar + liste de cartes livreurs */
.deliverers-toolbar { margin-bottom: 1rem; }
.deliverer-list { display: flex; flex-direction: column; gap: .8rem; }
.deliverer-card { padding: 1rem; }
.deliverer-card-main { display: flex; gap: .8rem; align-items: flex-start; }
.deliverer-avatar {
  width: 52px; height: 52px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.deliverer-avatar-fallback {
  display: flex; align-items: center; justify-content: center;
  background: #dbeafe; color: #1e40af; font-weight: 700; font-size: 1.2rem;
}
.deliverer-info { flex: 1; min-width: 0; }
.deliverer-name-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .3rem; }
.deliverer-contact-row { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .4rem; }
.deliverer-meta { font-size: .85rem; color: #64748b; margin-bottom: .4rem; }
.deliverer-communes { display: flex; flex-wrap: wrap; gap: .25rem; }
.deliverer-card-actions {
  display: flex; gap: .5rem; flex-wrap: wrap; align-items: center;
  margin-top: .8rem; padding-top: .8rem; border-top: 1px solid #e2e8f0;
}

/* Modales (élément <dialog> natif) */
.deliverer-modal {
  border: none; border-radius: 12px; padding: 0; width: min(600px, 92vw);
  max-height: 88vh; overflow-y: auto;
}
.deliverer-modal::backdrop { background: rgba(15, 23, 42, .55); }
.deliverer-modal .modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.2rem; border-bottom: 1px solid #e2e8f0; position: sticky; top: 0; background: white;
}
.deliverer-modal .modal-header h3 { margin: 0; font-size: 1.05rem; }
.deliverer-modal .modal-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: #64748b; }
.deliverer-modal form { padding: 0 1.2rem 1.2rem; }
.deliverer-modal .modal-footer {
  display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem;
  padding-top: 1rem; border-top: 1px solid #e2e8f0; position: sticky; bottom: 0; background: white;
}

@media (max-width: 780px) {
  .deliverer-modal { width: 96vw; max-height: 92vh; }
}

.plan-card { text-align: center; }
.plan-card-current { border: 2px solid var(--primary); }
.plan-price { font-size: 1.8rem; font-weight: 800; margin: .5rem 0 0; }
.plan-price span { font-size: .9rem; font-weight: 400; color: #64748b; }
.plan-price-yearly { font-size: .8rem; color: #64748b; margin-bottom: 1rem; }
.plan-features { list-style: none; padding: 0; margin: 0 0 1.2rem; text-align: left; font-size: .88rem; }
.plan-features li { padding: .3rem 0; border-bottom: 1px solid #f1f5f9; }

.subscription-banner {
  background: #fef3c7; color: #92400e; padding: .7rem 1.25rem; font-size: .9rem;
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  border-bottom: 1px solid #fde68a;
}
.subscription-banner a { color: #92400e; font-weight: 700; text-decoration: underline; }

.password-field { position: relative; }
.password-field input { padding-right: 2.6rem; }
.password-toggle {
  position: absolute; right: .4rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 1.05rem;
  padding: .2rem .4rem; line-height: 1;
}

.locality-type-choice { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .9rem; font-weight: 400; }
.locality-type-choice label { display: flex; align-items: center; gap: .3rem; }

.photo-picker-buttons { display: flex; gap: .5rem; flex-wrap: wrap; }
