:root {
  --blue: #1f3a5f;
  --blue-light: #e8eef6;
  --text: #1d2430;
  --muted: #5d6878;
  --line: #d9dee6;
  --bg: #f4f6f9;
  --ok: #1e7d43;
  --ok-bg: #e3f4ea;
  --warn: #9a5b00;
  --warn-bg: #fff1d6;
  --bad: #b3261e;
  --bad-bg: #fde7e5;
  --radius: 10px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--blue); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--blue);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 0;
}
.topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 6px;
}
.brand { color: #fff; text-decoration: none; font-size: 17px; }
.who {
  color: #dbe5f1;
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45%;
}
.who::before { content: "\25CF  "; font-size: 9px; vertical-align: middle; color: #9fd3a8; }
.who.on { color: #fff; text-decoration: underline; }
.menu { display: flex; gap: 0; border-top: 1px solid rgba(255, 255, 255, 0.15); }
.menu a {
  flex: 1;
  text-align: center;
  color: #dbe5f1;
  text-decoration: none;
  padding: 10px 6px;
  font-size: 15px;
  font-weight: 600;
  border-bottom: 3px solid transparent;
}
.menu a.on { color: #fff; border-bottom-color: #e39b1b; }
@media (min-width: 700px) {
  .topbar { padding-left: 20px; padding-right: 20px; }
  .menu a { flex: 0 0 auto; padding: 10px 18px; }
}

.page { max-width: 960px; margin: 0 auto; padding: 12px 12px 40px; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }

h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 18px 0 8px; }
h3 { font-size: 16px; }

.summary { margin-bottom: 10px; }
.summary p { margin: 0 0 10px; color: var(--muted); }

.search, input, select {
  width: 100%;
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.search { margin-bottom: 10px; }

.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 15px; }
.form label.radio, label.radio { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 400; }
label.radio input { width: auto; margin-top: 3px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
legend { font-weight: 600; padding: 0 4px; }
.inline { display: flex; gap: 10px; }
.inline > * { flex: 1; }
.hint { color: var(--muted); font-size: 14px; margin: 0; font-weight: 400; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--blue);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { color: var(--bad); border-color: #efc2be; }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: 14px; }
.btn.wide { width: 100%; }

.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 10px; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-info { background: var(--blue-light); color: var(--blue); }
.flash-error { background: var(--bad-bg); color: var(--bad); }

.block { margin-bottom: 18px; }
.block h2 { margin-top: 6px; }

.city-group { margin-bottom: 8px; }
.city {
  margin: 0;
  padding: 8px 2px 6px;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.city .count { color: var(--muted); font-weight: 400; }

.site-card {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.site-card.zone-ideal { border-left-color: #2e8b57; background: #f1faf4; }
.site-card.zone-retard { border-left-color: var(--bad); background: #fff6f5; }
.site-card.zone-bientot { border-left-color: #e39b1b; background: #fffaf0; }
.site-card.zone-tot { border-left-color: #b8bec8; background: #f7f8fa; }
.site-card.zone-tot .site-name, .site-card.zone-tot .site-addr { color: #7a8391; }
.site-card.zone-jamais { border-left-color: var(--bad); border-left-style: dashed; }
.site-name { font-weight: 700; }
.site-addr { color: var(--muted); font-size: 15px; }
.site-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); margin-top: 2px; }
.site-actions { display: flex; gap: 8px; }
.site-actions .btn { flex: 1; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.badge-ideal { background: #dcf2e4; color: #1e6b41; }
.badge-retard { background: var(--bad-bg); color: var(--bad); }
.badge-bientot { background: var(--warn-bg); color: var(--warn); }
.badge-tot { background: #eceff3; color: #5d6878; }
.badge-jamais { background: var(--bad-bg); color: var(--bad); }

.legend { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; color: var(--muted); }
.legend-big { font-size: 15px; color: var(--text); gap: 8px 22px; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot-ideal { background: #2e8b57; }
.dot-retard { background: var(--bad); }
.dot-bientot { background: #e39b1b; }
.dot-tot { background: #b8bec8; }
.dot-jamais { background: #fff; border: 2px dashed var(--bad); width: 9px; height: 9px; }
.block-ideal h2 { color: #1e6b41; }

.empty { color: var(--muted); }
.hidden { display: none !important; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tabs a { padding: 6px 10px; border-radius: 8px; text-decoration: none; background: #fff; border: 1px solid var(--line); font-size: 15px; }
.tabs a.on { background: var(--blue); color: #fff; border-color: var(--blue); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.filters select { width: auto; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.table .hint { font-size: 13px; }

.stats { display: flex; gap: 18px; flex-wrap: wrap; margin: 6px 0 10px; }
.stats .big { font-size: 28px; font-weight: 700; display: block; }
progress.progress { width: 100%; height: 12px; }

.list { padding-left: 18px; margin: 6px 0; }
.list li { margin-bottom: 4px; }
.checks { list-style: none; padding: 0; }
.checks .ok { color: var(--ok); }
.checks .ko { color: var(--bad); }

details { margin: 6px 0; }
summary { cursor: pointer; font-weight: 600; }
code { background: var(--blue-light); padding: 1px 4px; border-radius: 4px; }

@media (min-width: 700px) {
  .site-card { flex-direction: row; align-items: center; justify-content: space-between; }
  .site-actions { flex: 0 0 auto; }
  .site-actions .btn { flex: 0 0 auto; }
}

/* Fenêtre de confirmation d'une visite */
.confirm-dialog { border: none; border-radius: 12px; padding: 18px; width: calc(100% - 32px); max-width: 420px; color: var(--text); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.confirm-dialog::backdrop { background: rgba(20, 30, 45, .55); }
.confirm-dialog h2 { margin: 0 0 8px; font-size: 20px; }
.confirm-question { font-size: 17px; font-weight: 600; margin: 0 0 10px; }
.confirm-actions { display: flex; gap: 10px; margin-top: 16px; }
.confirm-actions .btn { flex: 1; }
.btn:disabled { opacity: .5; cursor: default; }

/* Visite « Ne pas faire » (problème technique) : carte barrée */
.site-card { position: relative; overflow: hidden; }
.site-card.zone-stop { border-left-color: #7a8391; background: #f3f4f6; }
.site-card.zone-stop .site-name, .site-card.zone-stop .site-addr { color: #6b7280; text-decoration: line-through; }
.stamp {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-12deg);
  border: 3px solid #b3261e; border-radius: 6px; padding: 2px 14px;
  color: #b3261e; background: rgba(255, 255, 255, .75);
  font-size: 24px; font-weight: 800; letter-spacing: 2px; white-space: nowrap;
  pointer-events: none; z-index: 1;
}
.stamp-inline { display: inline-block; transform: rotate(-6deg); border: 3px solid #b3261e; border-radius: 6px; padding: 2px 12px; color: #b3261e; font-size: 20px; font-weight: 800; letter-spacing: 2px; }
.badge-stop { background: #e5e7eb; color: #374151; }
.dot-stop { background: #7a8391; }
.site-actions .inline-form { display: flex; position: relative; z-index: 2; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.mail-preview { white-space: pre-wrap; background: #f7f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 14px; max-height: 520px; overflow: auto; }
