/* Pico agrandit la police avec la largeur d'écran (jusqu'à ~21 px) : on la fixe et on resserre tout. */
:root {
  --pico-font-size: 15px;
  --pico-line-height: 1.45;
  --pico-spacing: .75rem;
  --pico-typography-spacing-vertical: .75rem;
  --pico-block-spacing-vertical: .9rem;
  --pico-block-spacing-horizontal: .9rem;
  --pico-form-element-spacing-vertical: .4rem;
  --pico-form-element-spacing-horizontal: .65rem;
  --pico-nav-element-spacing-vertical: .5rem;
  --pico-nav-element-spacing-horizontal: .6rem;
  --pico-border-radius: .4rem;

  --st-gray: #8a94a6;
  --st-blue: #2f74d0;
  --st-purple: #8250c4;
  --st-orange: #e07b00;
  --st-amber: #c99300;
  --st-green: #2e9d5b;
  --st-red: #d0453b;
}
h1, h2, h3 { --pico-font-weight: 650; }
h3 { font-size: 1.3rem; margin-bottom: .6rem; }
h4 { font-size: 1.05rem; margin-bottom: .5rem; }
body > main { padding-block: .5rem 1rem; }
.container { max-width: 1100px; }
input:not([type=checkbox], [type=radio]), select, textarea { margin-bottom: .6rem; }
label { font-size: .9rem; }
button, [role=button] { font-size: .9rem; }
.small, small { font-size: .82rem; }
.muted { color: var(--pico-muted-color); }

/* En-tête */
header nav { padding-block: .1rem; border-bottom: 1px solid var(--pico-muted-border-color); }
.brand { font-weight: 700; text-decoration: none; }
nav a, .brand { white-space: nowrap; }

/* Ajout rapide */
.quick-add { display: flex; gap: .5rem; align-items: center; margin: .6rem 0 .8rem; flex-wrap: wrap; }
.quick-add input, .quick-add textarea { flex: 1 1 16rem; margin: 0 !important; font-family: var(--pico-font-family-monospace); }
.quick-add textarea { resize: none; overflow-y: hidden; min-height: 0; line-height: 1.4; }
.quick-add button { width: auto; margin: 0; }
.quick-add a { white-space: nowrap; }

/* Onglets Tous / Réceptions / Envois */
.tabs { display: flex; justify-content: flex-start; gap: .2rem; border-bottom: 1px solid var(--pico-muted-border-color); margin-bottom: .6rem; }
.tabs a { padding: .35rem .8rem; text-decoration: none; color: var(--pico-muted-color); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: .9rem; }
.tabs a[aria-current] { color: var(--pico-primary); border-bottom-color: var(--pico-primary); font-weight: 600; }

/* Filtres */
.filters { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .8rem; }
.filters > * { margin: 0 !important; width: auto; flex: 1 1 9rem; font-size: .85rem; }
.filters input[type=search] { flex-basis: 14rem; }
.filters .archived { flex: 0 0 auto; white-space: nowrap; }

/* Cartes */
.grid-cards { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); }
.card {
  display: flex; gap: .7rem; padding: .6rem; border-radius: var(--pico-border-radius);
  background: var(--pico-card-background-color); border: 1px solid var(--pico-muted-border-color);
  color: inherit; text-decoration: none; transition: border-color .12s;
}
.card:hover { border-color: var(--pico-primary); }
.card .body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: .15rem; }
.card .title { font-weight: 600; font-size: .95rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta, .card .when { font-size: .78rem; color: var(--pico-muted-color); }
.card .last { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.row { display: flex; align-items: center; gap: .4rem; min-width: 0; }

.thumb {
  flex: 0 0 3.5rem; width: 3.5rem; height: 3.5rem; border-radius: .35rem; overflow: hidden;
  display: grid; place-items: center; background: var(--pico-secondary-background); font-size: 1.4rem;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.big { flex-basis: 7.5rem; width: 7.5rem; height: 7.5rem; position: relative; font-size: 2.5rem; margin: 0; }
.thumb.big .change {
  position: absolute; inset: auto 0 0 0; margin: 0; padding: .2rem; font-size: .7rem; text-align: center;
  background: rgb(0 0 0 / .55); color: #fff; cursor: pointer; opacity: 0; transition: opacity .15s;
}
.thumb.big:hover .change, .thumb.big.over .change { opacity: 1; }
.thumb.big .change input { display: none; }
.drop.over, fieldset.over { outline: 3px dashed var(--pico-primary); }

/* Sens */
.dir { font-weight: 600; }
.dir-inbound { color: var(--st-blue); }
.dir-outbound { color: var(--st-orange); }

/* Statuts */
.badge { display: inline-block; padding: .05rem .45rem; border-radius: 1rem; font-size: .7rem; font-weight: 600; color: #fff; background: var(--st-gray); white-space: nowrap; }
.badge.st-in_transit { background: var(--st-blue); }
.badge.st-customs { background: var(--st-purple); }
.badge.st-out_for_delivery { background: var(--st-orange); }
.badge.st-available_for_pickup { background: var(--st-amber); }
.badge.st-delivered { background: var(--st-green); }
.badge.st-exception, .badge.st-returned { background: var(--st-red); }

.pickup { font-size: .78rem; font-weight: 600; color: var(--st-amber); }
.pickup.urgent { color: var(--st-red); }
.warn { color: var(--st-red); cursor: help; }
.error { color: var(--st-red); }
.empty { text-align: center; padding: 2rem 0; color: var(--pico-muted-color); }
.flash { padding: .45rem .8rem; border-radius: var(--pico-border-radius); font-size: .88rem; margin-bottom: .6rem; }
.flash.ok { background: color-mix(in srgb, var(--st-green) 14%, transparent); color: var(--st-green); }
.flash.ko { background: color-mix(in srgb, var(--st-red) 14%, transparent); color: var(--st-red); }

/* Détail */
.detail-head { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; padding: .9rem; }
.detail-head > div { flex: 1 1 18rem; min-width: 0; }
.detail-head h3 { margin-bottom: .2rem; }
.detail-head p { margin-bottom: .35rem; }
.meta { font-size: .85rem; }
.tn { user-select: all; font-size: .8rem; }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.actions form { margin: 0; }
.actions button { padding: .25rem .7rem; font-size: .8rem; margin: 0; width: auto; }
details > summary { font-size: .92rem; }

.timeline { list-style: none; padding: 0; border-left: 2px solid var(--pico-muted-border-color); margin-left: .4rem; }
.timeline li { position: relative; padding: 0 0 .6rem 1rem; list-style: none; font-size: .88rem; }
.timeline li::before {
  content: ""; position: absolute; left: -.38rem; top: .3rem; width: .62rem; height: .62rem; border-radius: 50%;
  background: var(--st-gray);
}
.timeline li.st-in_transit::before { background: var(--st-blue); }
.timeline li.st-customs::before { background: var(--st-purple); }
.timeline li.st-out_for_delivery::before { background: var(--st-orange); }
.timeline li.st-available_for_pickup::before { background: var(--st-amber); }
.timeline li.st-delivered::before { background: var(--st-green); }
.timeline li.st-exception::before, .timeline li.st-returned::before { background: var(--st-red); }
.timeline time { font-size: .75rem; color: var(--pico-muted-color); }

/* Pied de page quotas */
.quota { display: flex; flex-wrap: wrap; gap: .3rem .9rem; align-items: center; font-size: .75rem; color: var(--pico-muted-color); padding-block: 1rem; border-top: 1px solid var(--pico-muted-border-color); }
.quota-link { display: contents; color: inherit; text-decoration: none; }
.quota .exhausted { color: var(--st-red); }
.quota .logout { margin: 0 0 0 auto; }
.quota .logout button { padding: .15rem .6rem; font-size: .75rem; margin: 0; }

.login { max-width: 22rem; margin: 3rem auto; }
label.has-file { color: var(--st-green); }

/* Page Identifiants */
section { margin-bottom: 1.6rem; }
section form > button, section .actions button { width: auto; }
section .actions { margin-top: .3rem; }
.budget { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; padding: .8rem 1rem; font-size: .88rem; }
.big-number { font-size: 2rem; font-weight: 700; line-height: 1; color: var(--pico-primary); }
.big-number small { font-size: 1rem; color: var(--pico-muted-color); font-weight: 500; }
.quota-grid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr)); }
.quota-card { margin: 0; padding: .7rem .8rem; display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; }
.quota-card header { display: flex; justify-content: space-between; align-items: center; margin: 0; padding: 0; background: none; border: 0; }
.quota-card progress { margin: 0; height: .4rem; }
.quota-card progress.mid { accent-color: var(--st-amber); --pico-progress-color: var(--st-amber); }
.quota-card progress.high { accent-color: var(--st-red); --pico-progress-color: var(--st-red); }
.quota-card.is-exhausted { opacity: .7; }
.quota-numbers { display: flex; justify-content: space-between; font-size: .8rem; }
details.account { border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius); padding: .45rem .8rem; margin-bottom: .45rem; }
details.account summary { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
details.account[open] summary { margin-bottom: .6rem; }
details.account .pos { display: inline-grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--pico-primary); color: #fff; font-size: .72rem; font-weight: 700; }
details.add-account { border-style: dashed; }
.actions button[disabled] { opacity: .35; }
pre { font-size: .78rem; }
