:root {
  --bg: #f4efe8;
  --panel: rgba(255, 251, 247, 0.88);
  --line: #d9cabb;
  --text: #2a211b;
  --muted: #715f52;
  --brand: #a24b2a;
  --brand-strong: #7d3316;
  --warn: #cc7a00;
  --danger: #b2362f;
  --ok: #2e6a4f;
  --shadow: 0 24px 70px rgba(73, 40, 20, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  background:
    radial-gradient(circle at top left, rgba(162, 75, 42, 0.12), transparent 30%),
    linear-gradient(180deg, #f7f1ea, #efe5d9 55%, #eadccf);
}

button,
input,
select {
  font: inherit;
}

.page {
  max-width: 1380px;
  margin: 0 auto;
  padding: 32px 20px 56px;
}

.topnav {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--brand-strong);
  text-decoration: none;
  background: rgba(162, 75, 42, 0.1);
  border: 1px solid rgba(162, 75, 42, 0.14);
}

.nav-link.active {
  background: var(--brand);
  color: #fff8f2;
}

.hero,
.panel,
.metric,
.dialog-card {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(121, 75, 51, 0.12);
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  border-radius: 28px;
  padding: 28px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--brand);
  font-size: 0.75rem;
  margin: 0 0 12px;
}

h1,
h2,
h3,
th {
  font-family: Georgia, "Times New Roman", serif;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 4.1rem);
}

.lead {
  max-width: 720px;
  line-height: 1.5;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  background: var(--brand);
  color: #fff8f2;
  transition: transform 180ms ease, background 180ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--brand-strong);
}

button.ghost {
  background: rgba(162, 75, 42, 0.12);
  color: var(--brand-strong);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 20px 0;
}

.metric {
  border-radius: 22px;
  padding: 18px;
}

.metric .label {
  color: var(--muted);
  font-size: 0.9rem;
}

.metric .value {
  font-size: 2rem;
  margin-top: 6px;
}

.panel {
  border-radius: 28px;
  padding: 22px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

tbody tr:hover {
  background: rgba(162, 75, 42, 0.05);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.85rem;
  background: rgba(42, 33, 27, 0.08);
}

.pill.attribue { background: rgba(162, 75, 42, 0.15); }
.pill.en_cours { background: rgba(204, 122, 0, 0.15); }
.pill.cloture { background: rgba(46, 106, 79, 0.15); }
.pill.retour_fiche_2 { background: rgba(178, 54, 47, 0.18); }

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

/* Apres .muted: une alerte posee sur un texte discret doit rester visible.
   Dans l'ordre inverse, ".muted danger" s'affichait en gris. */
.danger { color: var(--danger); }
.warning { color: var(--warn); }
.success { color: var(--ok); }

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Lien wa.me presente comme un bouton: c'est une action, pas de la navigation. */
.bouton-whatsapp {
  display: inline-block;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  background: #1f7a4d;
  color: #fff8f2;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 180ms ease, background 180ms ease;
}

.bouton-whatsapp:hover {
  transform: translateY(-1px);
  background: #18613d;
}

.bouton-whatsapp.urgent {
  background: var(--danger);
}

dialog {
  border: none;
  background: transparent;
  padding: 0;
  width: min(860px, calc(100vw - 32px));
}

dialog::backdrop {
  background: rgba(42, 33, 27, 0.35);
}

.dialog-card {
  border-radius: 26px;
  padding: 22px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dialog-content {
  display: grid;
  gap: 14px;
}

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

.form-actions {
  display: flex;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf9;
  padding: 10px 12px;
}

.timeline {
  display: grid;
  gap: 8px;
}

.technician-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.nearby-groups {
  display: grid;
  gap: 10px;
}

.nearby-card {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(121, 75, 51, 0.1);
}

.technician-card {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(121, 75, 51, 0.1);
}

.technician-name {
  font-weight: 700;
}

.timeline-item {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.65);
}

@media (max-width: 780px) {
  .hero {
    align-items: start;
    flex-direction: column;
  }
}

/* --- Connexion --- */
.page-connexion {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}

.panel-connexion {
  width: min(420px, 100%);
}

.form-connexion {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

.form-connexion label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-connexion button {
  margin-top: 4px;
}

#erreur-connexion:empty {
  display: none;
}

.nav-compte {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

/* Le panel-header est une ligne dans le dashboard; sur la connexion il doit
   s'empiler, sinon titre et texte se disputent 400 px de large. */
.panel-connexion .panel-header {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.panel-connexion h1 {
  font-size: 2rem;
}

.panel-connexion .panel-header p:last-child {
  color: var(--muted);
  margin: 4px 0 0;
}

/* Suggestions d'attribution */
.suggestions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(46, 106, 79, 0.08);
  border: 1px solid rgba(46, 106, 79, 0.18);
}

.puce-suggestion {
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.9rem;
  background: var(--ok);
  color: #fff8f2;
}

.puce-suggestion:hover {
  background: #245640;
}

/* Tri et filtres du tableau */
th button.tri {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

th button.tri:hover {
  transform: none;
  color: var(--brand);
}

th button.tri.actif {
  color: var(--brand);
}

.ligne-filtres th {
  padding: 6px 10px 12px;
  border-bottom: 2px solid var(--line);
}

.ligne-filtres input,
.ligne-filtres select {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 0.85rem;
  /* Le tableau defile horizontalement: mieux vaut l'elargir qu'afficher
     "Toute..." dans une liste deroulante. */
  min-width: 110px;
}

.ligne-filtres button {
  padding: 6px 12px;
  font-size: 0.85rem;
  white-space: nowrap;
}
