/* Boxify Move — charte Boxify (Graphic Guidelines) :
   rouge #cc003d, noir #2d2a2e, gris #a7a5a6 / #d3d2d2, bleus #007299 / #33647f, jaune #f4c400.
   Klavika et Museo sont des polices sous licence : Barlow (libre, proche de Klavika) en attendant. */
@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("/fonts/barlow-400.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("/fonts/barlow-500.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("/fonts/barlow-600.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 700; font-display: swap; src: url("/fonts/barlow-700.woff2") format("woff2"); }

:root {
  --brand: #cc003d;          /* surchargé par tenant (marque blanche) */
  --brand-dark: #a30031;
  --brand-soft: #fbe8ee;
  --ink: #2d2a2e;
  --muted: #6f6c70;
  --grey: #a7a5a6;
  --line: #e4e2e1;
  --bg: #f4f3f2;
  --card: #ffffff;
  --blue: #007299;
  --blue-dark: #33647f;
  --blue-soft: #e5f1f5;
  --yellow: #f4c400;
  --yellow-soft: #fdf6d6;
  --warn: #8a6d00;
  --ok: #1d7a4f;
  --ok-soft: #e6f3ec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(45, 42, 46, .06), 0 2px 8px rgba(45, 42, 46, .04);
  font-family: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--blue); }

/* En-tête blanc : la charte interdit le logo sur fond foncé */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: #fff; color: var(--ink);
  border-bottom: 3px solid var(--brand);
}
.topbar .logo { width: 30px; height: 34px; flex: none; }
.topbar h1 { font-size: 18px; font-weight: 600; margin: 0; flex: 1; white-space: nowrap; overflow: hidden;
             text-overflow: ellipsis; letter-spacing: .01em; }
.topbar .product { display: block; font-size: 11px; font-weight: 600; color: var(--brand); text-transform: uppercase;
                   letter-spacing: .08em; line-height: 1; margin-bottom: 2px; }
.icon-btn { background: none; border: 0; color: inherit; font-size: 22px; padding: 4px 8px; border-radius: 8px;
            cursor: pointer; font-family: inherit; }
.topbar .icon-btn { margin-left: -8px; color: var(--brand); }
.sync { font-size: 13px; font-weight: 600; background: var(--blue-soft); color: var(--blue-dark); border-radius: 99px;
        padding: 4px 10px; }
.sync:empty { display: none; }
.sync.offline { background: var(--yellow); color: var(--ink); }

main { padding: 16px; max-width: 640px; margin: 0 auto; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
        border: 1px solid var(--line); box-shadow: var(--shadow); }
.card h2 { font-size: 19px; font-weight: 600; margin: 0 0 4px; }
.card h3 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); font-weight: 600; text-transform: uppercase;
           letter-spacing: .05em; }
.muted { color: var(--muted); font-size: 15px; }
.kind { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* Pastilles de statut */
.tag { display: inline-block; font-size: 13px; font-weight: 600; border-radius: 99px; padding: 3px 10px;
       margin: 2px 4px 2px 0; background: var(--bg); color: var(--ink); border: 0; }
.tag.warn { background: var(--yellow-soft); color: var(--warn); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.status { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 99px; padding: 3px 10px;
          text-transform: uppercase; letter-spacing: .05em; background: var(--bg); color: var(--muted); }
.status.offered { background: var(--yellow-soft); color: var(--warn); }
.status.accepted { background: var(--blue-soft); color: var(--blue-dark); }
.status.in_progress { background: var(--brand); color: #fff; }
.status.done, .status.closed { background: var(--ok-soft); color: var(--ok); }
.status.disputed { background: var(--brand-soft); color: var(--brand-dark); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }

ul.items { margin: 6px 0 0; padding-left: 18px; font-size: 15px; line-height: 1.5; }

/* Boutons : gros, pensés pour des mains gantées */
.btn { display: block; width: 100%; min-height: 56px; border-radius: 10px; border: 0; margin-top: 10px;
       font-family: inherit; font-size: 18px; font-weight: 600; letter-spacing: .01em; cursor: pointer;
       background: var(--brand); color: #fff; transition: background .15s, transform .05s; }
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: scale(.99); }
.btn.secondary { background: var(--card); color: var(--ink); border: 2px solid var(--line); }
.btn.secondary:hover { border-color: var(--grey); background: var(--card); }
.btn.accent { background: var(--ink); }
.btn.ok { background: var(--ok); }
.btn:disabled { opacity: .4; cursor: default; }
a.btn { text-align: center; line-height: 56px; text-decoration: none; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }
.done { color: var(--ok); font-weight: 600; }

input[type=email], input[type=text], input[type=datetime-local], select {
  width: 100%; min-height: 50px; font-family: inherit; font-size: 17px; color: var(--ink);
  border-radius: 10px; border: 1px solid var(--line); padding: 0 12px; margin-top: 8px; background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: transparent; }
dialog { border: 0; border-radius: var(--radius); width: min(92vw, 520px); padding: 20px; color: var(--ink);
         box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(45, 42, 46, .55); }
canvas.sign { width: 100%; height: 220px; border: 2px dashed var(--grey); border-radius: 10px; touch-action: none;
              background: #fff; }
.timeline { font-size: 15px; margin: 0; padding-left: 0; list-style: none; }
.timeline li { padding: 6px 0 6px 18px; border-left: 2px solid var(--line); position: relative; margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 12px; width: 10px; height: 10px;
                       border-radius: 50%; background: var(--brand); }

/* Écrans bureau et déménageur */
a.card.link { display: block; color: inherit; text-decoration: none; transition: border-color .15s; }
a.card.link:hover { border-color: var(--grey); }
.section { margin: 22px 2px 8px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
           color: var(--muted); }
table.lines { width: 100%; border-collapse: collapse; font-size: 16px; }
table.lines td { padding: 8px 0; border-bottom: 1px solid var(--line); }
table.lines td:last-child { text-align: right; white-space: nowrap; padding-left: 12px; font-variant-numeric: tabular-nums; }
table.lines tr.total td { font-weight: 700; font-size: 18px; border-bottom: 0; padding-top: 12px; }
table.lines tr.total td:last-child { color: var(--brand); }
.stop-edit { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.icon-btn.dark { color: var(--ink); background: var(--bg); }
label.pick { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
label.pick span { flex: 1; font-size: 17px; }
label.pick input { width: 22px; height: 22px; margin: 0; accent-color: var(--brand); }

/* Bureau : plus large, deux colonnes pour le détail d'une mission */
@media (min-width: 900px) {
  main { max-width: 1080px; padding: 24px; }
  main.narrow { max-width: 640px; }
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .grid-2 > .col > .card:last-child { margin-bottom: 0; }
  .list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
  .list-grid > .card { margin-bottom: 0; }
}
.toolbar { display: flex; justify-content: flex-end; margin-bottom: 14px; }
@media (min-width: 900px) { .toolbar .btn { width: auto; padding: 0 28px; } }
.hero { display: flex; align-items: center; gap: 16px; margin: 24px 4px 20px; }
.hero img { width: 64px; height: 72px; }
.hero-title { font-size: 28px; font-weight: 700; letter-spacing: .01em; }
/* Terrain : un seul arrêt déplié à la fois */
.card.current-stop { border: 2px solid var(--brand); }
.card.compact { padding: 12px 16px; }
.card.compact .card-head { margin-bottom: 2px; }
.stop-line { font-size: 17px; font-weight: 500; }
.done-stop { opacity: .7; }
.link-btn { background: none; border: 0; padding: 8px 0 0; color: var(--blue); font: inherit; font-weight: 600; cursor: pointer; }
.btn.ok:disabled { background: var(--line); color: var(--muted); opacity: 1; }

/* ---------- Navigation ---------- */
.tabs { display: flex; gap: 4px; margin: -4px 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap;
          border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs a.logout { margin-left: auto; font-weight: 500; font-size: 14px; }

/* ---------- Formulaires ---------- */
.field { display: block; margin-top: 12px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.field input, .field select { margin-top: 2px; }
.field-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.grid-3, .grid-2-form { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
.grid-3.tight .field { margin-top: 8px; }
.row.wrap { flex-wrap: wrap; align-items: center; margin-top: 8px; }
.row.wrap .btn { flex: 0 0 auto; width: auto; }
.spacer { flex: 1; }
.btn.small { min-height: 42px; font-size: 15px; padding: 0 16px; margin-top: 8px; line-height: 42px; width: auto; display: inline-block; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; margin: 10px 14px 0 0; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.card h2 .step { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff;
                 font-size: 14px; align-items: center; justify-content: center; margin-right: 6px; vertical-align: 2px; }
.small { font-size: 13px; }
.error { color: var(--brand-dark); font-weight: 600; min-height: 1em; }
.warn-text { color: var(--warn); font-weight: 600; }
.card.info { background: var(--blue-soft); border-color: transparent; box-shadow: none; }
.card.info p { margin: 0; line-height: 1.5; }
.card.empty { text-align: center; padding: 36px 16px; }
table.lines.compact td { padding: 5px 0; font-size: 15px; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0 4px; font-size: 15px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-weight: 500; text-align: right; }

/* Itinéraire en création */
ol.stops { list-style: none; margin: 8px 0 0; padding: 0; }
ol.stops .stop-edit { border: 1px solid var(--line); border-left: 4px solid var(--grey); border-radius: 10px;
                      padding: 10px 12px 12px; margin: 0; }
ol.stops .stop-edit.loading { border-left-color: var(--blue); }
ol.stops .stop-edit.unloading { border-left-color: var(--brand); }
.stop-head { display: flex; align-items: center; gap: 8px; }
.stop-head select { width: auto; min-height: 40px; margin: 0; font-weight: 600; }
.stop-num { width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 13px; font-weight: 700;
            display: inline-flex; align-items: center; justify-content: center; flex: none; }
.leg-edit { list-style: none; padding: 6px 0 6px 20px; margin-left: 12px; border-left: 2px dashed var(--grey); }
.leg-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; background: var(--blue-soft);
            color: var(--blue-dark); padding: 4px 10px; border-radius: 99px; }
.leg-chip.pending { background: var(--bg); color: var(--muted); }
.leg-chip input { width: 70px; min-height: 30px; margin: 0; font-size: 14px; }
.item-add { display: grid; grid-template-columns: 80px 1fr; gap: 0 10px; }
.items-table td:nth-child(2) { white-space: nowrap; }

/* Feuille de route (lecture) */
ol.route { list-style: none; padding: 0; margin: 8px 0 0; }
.route-stop { border-left: 4px solid var(--grey); padding: 4px 0 4px 12px; }
.route-stop.loading { border-left-color: var(--blue); }
.route-stop.unloading { border-left-color: var(--brand); }
.route-leg { font-size: 13px; color: var(--muted); padding: 4px 0 4px 16px; margin-left: 2px; border-left: 2px dashed var(--line); }

/* Notifications */
#toasts { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
          z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 440px); pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; font-weight: 500;
         box-shadow: 0 8px 24px rgba(0,0,0,.2); transition: opacity .4s, transform .4s; }
.toast.error { background: var(--brand-dark); }
.toast.warn { background: var(--yellow); color: var(--ink); }
.toast.out { opacity: 0; transform: translateY(8px); }

@media (min-width: 700px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-2-form { grid-template-columns: 1fr 1fr; }
  .item-add { grid-template-columns: 80px 2fr 1fr 1fr; }
}
@media (min-width: 1000px) {
  .grid-form { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
  .card.sticky { position: sticky; top: 84px; }
  .list-grid.wide { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
}
