/* Tournéo Pro — feuille de style */
:root {
  --ink: #1d2b4f;
  --ink-soft: #4a5675;
  --accent: #ff7a59;
  --accent-dark: #e85d3c;
  --ok: #1f9d74;
  --warn: #d97706;
  --bad: #d64545;
  --bg: #f6f4ef;
  --card: #ffffff;
  --line: #e4e0d8;
  --muted: #7b8297;
  --radius: 12px;
  --topbar-h: 56px;
  --tabs-h: 0px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }

/* --- En-tête ------------------------------------------------------------ */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: var(--ink); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-name { font-weight: 700; font-size: 1.25rem; letter-spacing: .3px; }
.tagline { opacity: .7; font-size: .9rem; }

/* --- Mise en page ------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: minmax(360px, 440px) 1fr;
  height: calc(100dvh - var(--topbar-h) - var(--tabs-h));
}
.panel { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.map-wrap { position: relative; }
#map { position: absolute; inset: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.count {
  background: var(--ink); color: #fff; border-radius: 999px;
  font-size: .75rem; padding: 2px 9px; font-weight: 600;
}

.field-label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-soft); margin: 10px 0 4px; }
.field-label:first-of-type { margin-top: 0; }
input[type=text], input[type=number], input[type=search], input[type=email], input[type=password], input[type=date], input[type=time], select, textarea {
  width: 100%;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: .78rem; color: var(--muted); margin: 6px 0 0; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; font-size: .9rem; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); }

/* --- Boutons ------------------------------------------------------------ */
.btn {
  border: 1px solid var(--ink); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 9px 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #eef0f6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; width: 100%; padding: 13px; font-size: 1rem; }
.btn.primary:hover { background: var(--accent-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary:disabled { opacity: 1; background: #c9ccd6; border-color: #c9ccd6; }
.link { background: none; border: 0; color: var(--ink-soft); text-decoration: underline; cursor: pointer; padding: 0 0 0 10px; font-size: .82rem; }
.link.danger { color: var(--bad); }

/* --- Champ adresse + suggestions --------------------------------------- */
.addr-field { position: relative; }
.addr-field input { padding-right: 34px; }
.addr-status { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: .95rem; }
.addr-status.ok { color: var(--ok); }
.addr-status.bad { color: var(--bad); }
.suggestions {
  position: absolute; z-index: 1000; left: 0; right: 0; top: calc(100% + 4px);
  list-style: none; margin: 0; padding: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(29, 43, 79, .15);
}
.suggestions li { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: .9rem; }
.suggestions li:hover, .suggestions li.active { background: #fff1ec; }

/* --- Ajout d'adresses --------------------------------------------------- */
.add-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.add-row .addr-field { grid-column: 1 / -1; }
body.multi .add-row { grid-template-columns: 1fr 1fr auto; }
.small { text-align: center; padding-left: 6px !important; padding-right: 6px !important; }
.persons-col { display: none !important; }
body.multi .persons-col { display: block !important; }
body.multi dl .persons-col { display: flex !important; }

.paste { margin-top: 10px; font-size: .9rem; }
.paste summary { cursor: pointer; color: var(--ink-soft); font-weight: 600; }
.paste textarea { margin: 8px 0; font-size: .85rem; }

.progress { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: .82rem; color: var(--ink-soft); }
.progress-bar { flex: 1; height: 8px; background: #eee9df; border-radius: 99px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.list-tools { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: .82rem; color: var(--ink-soft); }

/* --- Liste des arrêts --------------------------------------------------- */
.stops { list-style: none; margin: 8px 0 0; padding: 0; }
.stop {
  display: grid; grid-template-columns: 30px 1fr 72px auto; gap: 8px; align-items: center;
  padding: 8px 4px; border-top: 1px solid var(--line);
}
body.multi .stop { grid-template-columns: 30px 1fr 66px 50px auto; }
.actions { display: flex; }
.stop.selected { background: #fff6f2; }
.badge {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: .75rem; font-weight: 700;
  background: var(--ink); color: #fff;
}
.stop.pending .badge { background: #c9ccd6; }
.stop.notfound .badge { background: var(--bad); }
.stop-text { min-width: 0; cursor: pointer; }
.stop-label { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop-sub { font-size: .74rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop.notfound .stop-sub { color: var(--bad); white-space: normal; }
.stop input { padding: 6px; font-size: .85rem; }
.stop input.edit { width: 100%; }
.icon-btn { border: 0; background: none; cursor: pointer; font-size: 1.1rem; color: var(--muted); padding: 4px; border-radius: 6px; }
.icon-btn:hover { color: var(--bad); background: #fbeaea; }
.empty { color: var(--muted); font-size: .88rem; text-align: center; margin: 18px 0 4px; }

/* --- Récapitulatif ------------------------------------------------------ */
.totals dl { margin: 0; display: grid; gap: 6px; }
.totals dl > div { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }
.totals dt { color: var(--ink-soft); }
.totals dd { margin: 0; font-weight: 700; }
.totals dd.muted { font-weight: 400; color: var(--muted); font-style: italic; }

.panel-footer { position: sticky; bottom: 0; padding-top: 4px; background: linear-gradient(transparent, var(--bg) 30%); }

/* --- Carte -------------------------------------------------------------- */
.pin {
  width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--ink); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35);
  display: grid; place-items: center;
}
.pin span { transform: rotate(45deg); color: #fff; font-size: 11px; font-weight: 700; }
.pin.depot { background: var(--accent); }
.pin.bad { background: var(--bad); }
.pin.selected { background: var(--accent-dark); outline: 3px solid rgba(255, 122, 89, .4); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--tabs-h)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px;
  z-index: 2000; font-size: .9rem; max-width: calc(100% - 32px);
}

/* --- Téléphone ---------------------------------------------------------- */
.mobile-tabs { display: none; }
@media (max-width: 860px) {
  :root { --tabs-h: 58px; --topbar-h: 50px; }
  .tagline { display: none; }
  .layout { grid-template-columns: 1fr; }
  .layout[data-view="list"] .map-wrap { display: none; }
  .layout[data-view="map"] .panel { display: none; }
  .panel { padding: 12px; }
  .mobile-tabs {
    display: grid; grid-template-columns: 1fr 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; height: var(--tabs-h);
    background: #fff; border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-tabs button { border: 0; background: none; font-weight: 600; color: var(--muted); }
  .mobile-tabs button.active { color: var(--accent-dark); box-shadow: inset 0 3px 0 var(--accent); }
  input[type=text], select, textarea { font-size: 16px; } /* évite le zoom auto sur iPhone */
}
@media (max-width: 420px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* --- Étape 2 : onglets, résultats ------------------------------------- */
.panel-tabs { display: grid; grid-template-columns: 1fr 1fr; background: #e9e5dc; border-radius: 10px; padding: 4px; gap: 4px; }
.panel-tabs button { border: 0; background: none; padding: 8px; border-radius: 7px; font-weight: 600; color: var(--ink-soft); cursor: pointer; font-size: .88rem; }
.panel-tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.panel-tabs button:disabled { opacity: .45; cursor: default; }
.pane { display: flex; flex-direction: column; gap: 14px; }
.center { text-align: center; }
.panel-footer .progress { margin: 0 0 8px; background: var(--bg); }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tile { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.tile .k { font-size: .75rem; color: var(--ink-soft); }
.tile .v { font-size: 1.15rem; font-weight: 700; margin-top: 2px; }
.tile.wide { grid-column: 1 / -1; }

.stale { background: #fff7e6; border-color: #f3d39b; color: #8a5a00; font-size: .88rem; }
.warn-list:empty { display: none; }
.warn-list .card { background: #fff7e6; border-color: #f3d39b; color: #8a5a00; font-size: .88rem; padding: 10px 14px; }

.itinerary { list-style: none; margin: 0; padding: 0; }
.it-leg { display: flex; align-items: center; gap: 10px; padding: 4px 0 4px 12px; margin-left: 13px; border-left: 2px dashed #cfd3df; font-size: .78rem; color: var(--muted); }
.it-leg .delay { color: var(--warn); }
.it-stop { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 6px 0; cursor: pointer; }
.it-stop:hover .it-label { text-decoration: underline; }
.it-stop .badge { width: 28px; height: 28px; }
.it-stop.depot .badge { background: var(--accent); }
.it-label { font-size: .88rem; font-weight: 600; overflow-wrap: anywhere; }
.it-sub { font-size: .76rem; color: var(--muted); margin-top: 2px; }
.it-time { font-weight: 700; font-size: .95rem; text-align: right; white-space: nowrap; }
.it-time small { display: block; font-weight: 400; color: var(--muted); font-size: .72rem; }

/* --- Navigation, pages de gestion -------------------------------------- */
.topbar nav { display: flex; gap: 4px; margin-left: 12px; }
.topbar nav a { color: rgba(255,255,255,.75); text-decoration: none; padding: 6px 12px; border-radius: 8px; font-size: .9rem; font-weight: 600; white-space: nowrap; }
.topbar nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.topbar nav a.active { color: #fff; background: rgba(255,255,255,.14); }
.account { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .85rem; white-space: nowrap; }
.account .org { opacity: .85; }
.plan-badge { background: rgba(255,255,255,.15); padding: 2px 8px; border-radius: 99px; font-size: .72rem; font-weight: 700; }
.plan-badge.pro { background: var(--accent); }
.link.light { color: rgba(255,255,255,.8); }

.page { max-width: 1280px; margin: 0 auto; padding: 20px 16px 40px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.page-head h1 { font-size: 1.35rem; margin: 0 auto 0 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.toolbar input[type=search], .toolbar select { width: auto; min-width: 160px; }
.toolbar input[type=search] { flex: 1 1 220px; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { background: var(--accent-dark); }
.btn.small { padding: 5px 10px; font-size: .82rem; }
.btn.danger { border-color: var(--bad); color: var(--bad); }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.data th { text-align: left; background: #f3f1ec; color: var(--ink-soft); font-weight: 600; padding: 9px 10px; position: sticky; top: 0; white-space: nowrap; }
table.data td { padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
table.data tr:hover td { background: #fcfbf8; }
table.data .muted, .muted { color: var(--muted); }
table.data input[type=text], table.data input[type=email], table.data select { padding: 5px 7px; font-size: .84rem; min-width: 120px; }
.status { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.status.ok { background: #e3f5ee; color: var(--ok); }
.status.corrected { background: #e8eefc; color: #2f55b5; }
.status.check, .status.doubtful { background: #fff1d6; color: #9a6200; }
.status.notfound { background: #fbe4e4; color: var(--bad); }
.status.duplicate, .status.empty, .status.pending { background: #eceef3; color: var(--muted); }
.notes-list { margin: 4px 0 0; padding: 0; list-style: none; font-size: .76rem; }
.notes-list li.fix { color: #2f55b5; }
.notes-list li.warn { color: #9a6200; }
.sugg { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.sugg button { font-size: .74rem; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 3px 6px; cursor: pointer; text-align: left; }
.sugg button:hover { border-color: var(--accent); background: #fff6f2; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 12px; cursor: pointer; font-size: .85rem; font-weight: 600; }
.chip b { margin-left: 4px; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.steps-bar { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.steps-bar span { padding: 6px 12px; border-radius: 99px; background: #e9e5dc; font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.steps-bar span.active { background: var(--ink); color: #fff; }
.steps-bar span.done { background: #d9efe6; color: var(--ok); }
.dropzone { border: 2px dashed #cfc8ba; border-radius: var(--radius); background: #fff; padding: 36px 16px; text-align: center; cursor: pointer; }
.dropzone.over { border-color: var(--accent); background: #fff6f2; }
.dropzone strong { display: block; font-size: 1.05rem; margin-bottom: 6px; }

.modal { position: fixed; inset: 0; background: rgba(20, 26, 45, .45); z-index: 3000; display: grid; place-items: center; padding: 16px; }
.modal-box { background: #fff; border-radius: 14px; width: min(720px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: 20px; }
.modal-box h2 { margin: 0 0 14px; font-size: 1.1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px 12px; margin: 12px 0 0; }
legend { font-size: .82rem; font-weight: 700; color: var(--ink-soft); padding: 0 6px; }
.form .btn.primary { margin-top: 16px; }

.auth-page { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
.auth-box { width: min(420px, 100%); display: flex; flex-direction: column; gap: 12px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 1.8rem; font-weight: 800; }
.auth-tagline { text-align: center; color: var(--ink-soft); margin: 0 0 6px; }

@media (max-width: 860px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar nav { margin-left: 0; overflow-x: auto; }
  .topbar nav a { padding: 6px 8px; font-size: .82rem; }
  .account .org, .account .plan-badge { display: none; }
  .form-grid { grid-template-columns: 1fr; }
}

.from-sites { margin-top: 10px; width: 100%; border-style: dashed; }

/* --- Compte, formules ---------------------------------------------------- */
.account-page .card { margin-bottom: 16px; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.plan-card { border: 2px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.plan-card h3 { margin: 0; font-size: 1rem; }
.plan-card .price { font-size: 1.5rem; font-weight: 800; margin: 4px 0 8px; }
.plan-card .price small { font-size: .8rem; font-weight: 400; color: var(--muted); }
.plan-card ul { margin: 0; padding-left: 18px; font-size: .88rem; line-height: 1.6; }
.plan-card.pro { border-color: #ffd2c4; background: #fffaf7; }
.plan-card.current { border-color: var(--ok); box-shadow: 0 0 0 3px #d9efe6; }
.plan-card.current h3::after { content: " · votre formule"; color: var(--ok); font-size: .8rem; }
.locked { position: relative; }
.locked::after { content: "Formule Premium"; position: absolute; top: 14px; right: 14px; background: var(--accent); color: #fff; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.rec-card { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.rec-card .grow { flex: 1 1 260px; }
@media (max-width: 700px) { .plans { grid-template-columns: 1fr; } }
a.btn { text-decoration: none; display: inline-block; text-align: center; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: #eeebe4; border-radius: 9px; padding: 3px; margin-bottom: 8px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 7px 6px; border-radius: 7px; font-size: .84rem; font-weight: 600; color: var(--ink-soft); }
.seg input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.stop .actions { flex-wrap: nowrap; }

/* --- Pages légales ------------------------------------------------------ */
.legal { max-width: 900px; line-height: 1.6; }
.legal h1 { font-size: 1.5rem; }
.legal h2 { font-size: 1.1rem; margin-top: 26px; }
.legal mark { background: #fff1d6; color: #9a6200; padding: 0 4px; border-radius: 4px; }
.legal-links { margin-top: 24px; }
.legal-links a { color: var(--ink-soft); }

#inviteLink code { word-break: break-all; }
