/* Espace documents Pechavy - charte Groupe Péchavy */

@font-face { font-family: "Roboto"; font-weight: 400; font-display: swap; src: url("../fonts/roboto-400.woff2") format("woff2"); }
@font-face { font-family: "Roboto"; font-weight: 500; font-display: swap; src: url("../fonts/roboto-500.woff2") format("woff2"); }
@font-face { font-family: "Roboto"; font-weight: 700; font-display: swap; src: url("../fonts/roboto-700.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-weight: 600; font-display: swap; src: url("../fonts/fira-sans-600.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-weight: 700; font-display: swap; src: url("../fonts/fira-sans-700.woff2") format("woff2"); }

:root {
  --red: #d83030;
  --red-dark: #b42424;
  --red-soft: #fdecec;
  --navy: #032e42;
  --navy-2: #0a4460;
  --navy-soft: #e8f0f4;
  --ink: #1f2a33;
  --grey: #676767;
  --grey-2: #8a9299;
  --line: #e3e7ea;
  --bg: #f4f6f8;
  --white: #fff;
  --green: #1e8a4c;
  --green-soft: #e6f5ec;
  --amber: #b7791f;
  --amber-soft: #fdf4e3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(3, 46, 66, .06), 0 4px 16px rgba(3, 46, 66, .06);
  --font: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-title: "Fira Sans", var(--font);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--navy-2); }
a:hover { color: var(--red); }
h1, h2, h3 { font-family: var(--font-title); color: var(--navy); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 1em; }
img { max-width: 100%; }
.muted { color: var(--grey); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .9em; }
.sr-only, input.sr-only[type] { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; margin: -1px; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.right { text-align: right; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.hidden { display: none !important; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 40px; padding: .5rem 1.1rem; border: 1px solid transparent; border-radius: 8px; font: 500 .95rem/1 var(--font); cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, color .15s; white-space: nowrap; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); color: #fff; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-2); color: #fff; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--navy); }
.btn-ghost:hover { border-color: var(--navy); color: var(--navy); }
.btn-danger { background: #fff; border-color: #f1c4c4; color: var(--red-dark); }
.btn-danger:hover { background: var(--red-soft); color: var(--red-dark); }
.btn-sm { min-height: 32px; padding: .35rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--navy-2); text-decoration: underline; cursor: pointer; }
.link-btn:hover { color: var(--red); }

/* Formulaires */
label { display: block; font-weight: 500; font-size: .9rem; color: var(--navy); margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.field .hint { font-size: .8rem; color: var(--grey); margin-top: .25rem; }
/* Mot de passe : bouton « œil » dans le champ pour afficher la saisie en clair. */
.pw-field { position: relative; }
.pw-field > input[type] { padding-right: 3rem; }
.pw-field input::-ms-reveal { display: none; }
.pw-toggle { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); width: 2.4rem; height: 2.4rem; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--grey); cursor: pointer; }
.pw-toggle:hover { color: var(--navy); background: var(--bg); }
.pw-toggle:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; }
.pw-toggle .eye-off, .pw-toggle[aria-pressed="true"] .eye { display: none; }
.pw-toggle[aria-pressed="true"] .eye-off { display: block; }
/* Info-bulle : pastille « i », texte au survol ou au focus clavier. */
.tip { position: relative; display: inline-grid; place-items: center; width: 1.05rem; height: 1.05rem; margin-left: .25rem; border-radius: 50%; background: var(--navy-soft); color: var(--navy); font: 700 .7rem/1 var(--font); font-style: normal; cursor: help; vertical-align: 1px; }
.tip::after { content: attr(data-tip); position: absolute; left: calc(100% + .6rem); top: 50%; transform: translateY(-50%); width: max-content; max-width: 18rem; padding: .55rem .7rem; border-radius: 8px; background: var(--navy); color: #fff; font: 400 .8rem/1.4 var(--font); text-transform: none; letter-spacing: 0; white-space: normal; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 20; }
.tip::after { display: none; }
.tip:hover::after, .tip:focus::after { display: block; opacity: 1; }
@media (max-width: 640px) { .tip::after { left: auto; right: -1rem; top: calc(100% + .5rem); transform: none; max-width: calc(100vw - 3rem); } }
.tip:focus { outline: 2px solid var(--red); outline-offset: 2px; }
input[type=text], input[type=password], input[type=email], input[type=search], input[type=date], input[type=number], select, textarea {
  width: 100%; min-height: 42px; padding: .55rem .75rem; border: 1px solid #cfd6db; border-radius: 8px; background: #fff; font: inherit; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid rgba(216, 48, 48, .25); outline-offset: 1px; border-color: var(--red); }
.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 400; color: var(--ink); }
.checkbox input { width: 18px; height: 18px; accent-color: var(--red); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.code-input { letter-spacing: .4em; font-size: 1.4rem !important; text-align: center; font-family: ui-monospace, Menlo, monospace; }

/* Alertes */
.alert { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; border-left: 4px solid; font-size: .95rem; }
.alert-error { background: var(--red-soft); border-color: var(--red); color: #7d1a1a; }
.alert-success { background: var(--green-soft); border-color: var(--green); color: #14532d; }
.alert-info { background: var(--navy-soft); border-color: var(--navy-2); color: var(--navy); }
.alert-warning { background: var(--amber-soft); border-color: var(--amber); color: #6b4511; }

/* Cartes et tableaux */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.4rem; }
.card + .card { margin-top: 1.25rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.table-wrap { overflow-x: auto; margin: 0 -1.4rem; }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .7rem 1.4rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--grey); font-weight: 500; background: #fafbfc; }
.table th a.sort { color: inherit; text-decoration: none; }
.table th a.sort.is-active { color: var(--navy); }
.table tbody tr:hover { background: #fafbfc; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions form { display: inline; }
/* Tableaux à nombreuses colonnes : marges réduites, boutons d'action sur deux lignes au besoin (jamais de défilement horizontal). */
.table-compact th, .table-compact td { padding: .7rem .75rem; }
.table-compact th:first-child, .table-compact td:first-child { padding-left: 1.4rem; }
.table-compact th:last-child, .table-compact td:last-child { padding-right: 1.4rem; }
.table-compact td.actions { white-space: normal; }
.table-compact td.actions > .btn, .table-compact td.actions > form { margin: .15rem 0 .15rem .3rem; }
.table-compact .badge { white-space: normal; line-height: 1.3; }
.table td.actions .row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .35rem; min-width: 11rem; white-space: nowrap; }
.empty { text-align: center; color: var(--grey); padding: 2.5rem 1rem; }

.badge { display: inline-block; padding: .2rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 500; background: var(--navy-soft); color: var(--navy); white-space: nowrap; }
.badge-facture { background: var(--red-soft); color: var(--red-dark); }
.badge-livraison { background: #e6f0fb; color: #1d4f91; }
.badge-avoir { background: var(--green-soft); color: var(--green); }
.badge-ok { background: var(--green-soft); color: var(--green); }
.badge-ko { background: var(--red-soft); color: var(--red-dark); }
.badge-warn { background: var(--amber-soft); color: var(--amber); }

.pagination { display: flex; gap: .3rem; justify-content: center; align-items: center; margin-top: 1.25rem; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; text-decoration: none; padding: 0 .5rem; font-size: .9rem; }
.pagination a { color: var(--navy); border: 1px solid var(--line); background: #fff; }
.pagination a:hover { border-color: var(--navy); }
.pagination .current { background: var(--navy); color: #fff; }
.pagination .gap { color: var(--grey); }
.results-info { color: var(--grey); font-size: .85rem; }

/* ---------- Espace client ---------- */
.front-header { background: #fff; border-bottom: 3px solid var(--red); }
.front-header .inner { max-width: 1140px; margin: 0 auto; padding: .8rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.front-header .logo img { height: 46px; width: auto; display: block; }
.front-nav { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.front-nav a, .front-nav button { color: var(--navy); text-decoration: none; padding: .45rem .8rem; border-radius: 8px; font-weight: 500; font-size: .92rem; background: none; border: 0; cursor: pointer; font-family: inherit; }
.front-nav a:hover, .front-nav button:hover { background: var(--navy-soft); color: var(--navy); }
.front-nav a.is-active { background: var(--navy); color: #fff; }
.front-nav .who { color: var(--grey); font-size: .85rem; margin-right: .5rem; }
/* Pied de page toujours en bas : le contenu occupe la hauteur restante. */
body.front { min-height: 100vh; display: flex; flex-direction: column; }
.front-main { max-width: 1140px; width: 100%; margin: 0 auto; padding: 2rem 1.25rem 3rem; flex: 1 0 auto; }
.front-footer { border-top: 1px solid var(--line); background: #fff; color: var(--grey); font-size: .82rem; }
.front-footer .inner { max-width: 1140px; margin: 0 auto; padding: 1.25rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-title h1 { margin: 0; }
.page-title .sub { color: var(--grey); margin: .25rem 0 0; }

/* Connexion */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: #fff; }
.auth-brand { background: var(--navy); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-brand > div { position: relative; z-index: 1; }
.auth-brand h1 { color: #fff; font-size: 2.2rem; max-width: 420px; }
.auth-brand p { color: #c9d7df; max-width: 420px; font-size: 1.05rem; }
.auth-brand .tagline { text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; color: #ff8b8b; font-weight: 500; margin-bottom: 1rem; }
.auth-brand ul { list-style: none; padding: 0; margin: 2rem 0 0; color: #dfe8ee; max-width: 420px; position: relative; z-index: 1; }
.auth-brand li { padding: .45rem 0 .45rem 1.6rem; position: relative; }
.auth-brand li::before { content: ""; position: absolute; left: 0; top: .95rem; width: 10px; height: 2px; background: var(--red); }
.auth-brand .foot { color: #8fa9b8; font-size: .8rem; position: relative; z-index: 1; }
.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: 3rem 1.5rem; }
.auth-box { width: 100%; max-width: 400px; margin: 0 auto; }
.auth-box .logo { height: 56px; width: auto; margin-bottom: 2rem; }
.auth-box h2 { font-size: 1.5rem; }
.auth-links { margin-top: 1.25rem; font-size: .9rem; display: flex; flex-direction: column; gap: .4rem; }
.auth-help { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--line); color: var(--grey); font-size: .85rem; }

/* Liste des documents */
.chips { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .85rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--navy); text-decoration: none; font-size: .88rem; font-weight: 500; }
.chip .count { color: var(--grey); font-weight: 400; }
.chip:hover { border-color: var(--navy); color: var(--navy); }
.chip.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip.is-active .count { color: #c9d7df; }
.filters { display: grid; grid-template-columns: minmax(200px, 2fr) repeat(3, minmax(130px, 1fr)) auto; gap: .75rem; align-items: end; margin-bottom: 1rem; }
.filters .field { margin: 0; }
.filters label { font-size: .78rem; color: var(--grey); font-weight: 500; }
.doc-label { font-weight: 500; color: var(--navy); }
.doc-actions { display: inline-flex; gap: .4rem; }

/* ---------- Back-office ---------- */
.admin { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.admin > div { min-width: 0; }
.sidebar { background: var(--navy); color: #c9d7df; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { background: #fff; padding: 1rem 1.25rem; border-bottom: 3px solid var(--red); }
.sidebar .brand img { height: 40px; width: auto; display: block; }
.sidebar .brand span { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--grey); margin-top: .35rem; }
.sidebar nav { padding: 1rem .75rem; flex: 1; overflow-y: auto; }
.sidebar nav a { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: 8px; color: #c9d7df; text-decoration: none; font-weight: 500; font-size: .93rem; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar nav a.is-active { background: var(--red); color: #fff; }
.sidebar nav .sep { margin: 1rem .8rem .4rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: #6f8d9e; }
.sidebar svg { width: 18px; height: 18px; flex: none; }
.sidebar .me { padding: .9rem 1rem; border-top: 1px solid rgba(255, 255, 255, .1); font-size: .85rem; }
.sidebar .me strong { color: #fff; display: block; padding: 0 .3rem; }
.sidebar .me-entity { padding: .1rem .3rem 0; font-size: .78rem; color: #9fb4c1; }
.sidebar .me-links { display: flex; gap: .25rem 1rem; flex-wrap: wrap; margin-top: .4rem; }
.sidebar .me-links a, .sidebar .me-links button { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem; color: #c9d7df; font-size: .82rem; text-decoration: none; border-radius: 6px; }
.sidebar .me-links a:hover, .sidebar .me-links button:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.sidebar .me-links svg { width: 16px; height: 16px; }
.sidebar-collapse { display: flex; align-items: center; gap: .6rem; width: 100%; margin-top: .6rem; padding: .5rem .55rem; border: 1px solid rgba(255, 255, 255, .14); border-radius: 8px; background: none; color: #c9d7df; font: 500 .82rem/1 inherit; cursor: pointer; }
.sidebar-collapse:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.sidebar-collapse svg { transition: transform .2s; }

/* Menu replié : icônes seules (écrans larges). */
@media (min-width: 961px) {
  .admin { transition: grid-template-columns .2s; }
  .admin.is-collapsed { grid-template-columns: 68px minmax(0, 1fr); }
  .admin.is-collapsed .sidebar .label, .admin.is-collapsed .sidebar .brand span { display: none; }
  .admin.is-collapsed .sidebar .brand { padding: .9rem 0; display: flex; justify-content: center; }
  .admin.is-collapsed .sidebar .brand img { width: 27px; height: 34px; object-fit: cover; object-position: left center; }
  .admin.is-collapsed .sidebar nav { padding: 1rem .6rem; }
  .admin.is-collapsed .sidebar nav a { justify-content: center; padding: .65rem 0; }
  .admin.is-collapsed .sidebar nav .sep { margin: .9rem .3rem .5rem; height: 1px; background: rgba(255, 255, 255, .15); }
  .admin.is-collapsed .sidebar .me { padding: .8rem .6rem; }
  .admin.is-collapsed .sidebar .me-links { flex-direction: column; align-items: center; gap: .2rem; margin-top: 0; }
  .admin.is-collapsed .sidebar .me-links a, .admin.is-collapsed .sidebar .me-links button { padding: .5rem; }
  .admin.is-collapsed .sidebar-collapse { justify-content: center; }
  .admin.is-collapsed .sidebar-collapse svg { transform: rotate(180deg); }
}
@media (max-width: 960px) { .sidebar-collapse { display: none; } }
.admin-main { padding: 1.75rem 2rem 3rem; min-width: 0; }
.admin-topbar { display: none; }
.breadcrumb { font-size: .85rem; color: var(--grey); margin-bottom: .4rem; }
.breadcrumb a { color: var(--grey); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; text-decoration: none; color: inherit; border-top: 3px solid var(--navy); display: block; }
.stat:hover { color: inherit; box-shadow: 0 2px 4px rgba(3, 46, 66, .08), 0 8px 24px rgba(3, 46, 66, .1); }
.stat.red { border-top-color: var(--red); }
.stat.green { border-top-color: var(--green); }
.stat.amber { border-top-color: var(--amber); }
.stat .value { font: 700 1.9rem/1.1 var(--font-title); color: var(--navy); }
.stat .label { color: var(--grey); font-size: .85rem; margin-top: .3rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.grid-2 > .card + .card { margin-top: 0; }
.chart { width: 100%; height: 160px; }
.chart rect.bar { fill: var(--navy); }
.chart rect.bar.today { fill: var(--red); }
.chart text { font-size: 10px; fill: var(--grey); font-family: var(--font); }

dl.props { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 0; font-size: .92rem; }
dl.props dt { color: var(--grey); }
dl.props dd { margin: 0; }

/* Dépôt multiple */
.dropzone { border: 2px dashed #b7c4cc; border-radius: var(--radius); padding: 2rem 1rem; text-align: center; background: #fafcfd; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.is-over { border-color: var(--red); background: var(--red-soft); }
.dropzone strong { color: var(--navy); display: block; font-size: 1.05rem; }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.dropzone strong { margin-bottom: 0; }
.queue { margin-top: 1rem; }
.queue-item { display: grid; grid-template-columns: minmax(180px, 2fr) 130px 160px 150px 110px 36px; gap: .6rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.queue-item .name { font-size: .78rem; color: var(--grey); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: .2rem; }
.queue-item .status.ok { color: var(--green); font-weight: 500; }
.queue-item .status.ko { color: var(--red-dark); }
.queue-item input, .queue-item select { min-height: 36px; padding: .35rem .55rem; font-size: .88rem; }
.queue-item .status { font-size: .8rem; }
.queue-item progress { width: 100%; height: 8px; accent-color: var(--red); }
.queue-item .remove { background: none; border: 0; color: var(--grey); cursor: pointer; font-size: 1.2rem; }
.queue-actions { margin-top: 1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }


.error-page { min-height: 70vh; display: flex; align-items: center; justify-content: center; text-align: center; padding: 2rem; }
.error-page .code { font: 700 4rem/1 var(--font-title); color: var(--red); }
.error-page pre { text-align: left; max-width: 900px; overflow: auto; font-size: .75rem; background: #fff; padding: 1rem; border-radius: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .field:first-child { grid-column: 1 / -1; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-brand { padding: 2rem 1.5rem; }
  .auth-brand ul, .auth-brand .foot { display: none; }
  .admin { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.is-open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .4); }
  .admin-topbar { display: flex; align-items: center; justify-content: space-between; background: #fff; padding: .6rem 1rem; border-bottom: 3px solid var(--red); position: sticky; top: 0; z-index: 40; }
  .admin-topbar img { height: 34px; width: auto; }
  .admin-main { padding: 1.25rem 1rem 2.5rem; }
  .queue-item { grid-template-columns: 1fr 1fr; }
  .queue-item > div:first-child { grid-column: 1 / -1; }
}

/* Tablette et mobile : chaque ligne de tableau devient une carte, l'intitulé de colonne précède chaque valeur
   (intitulés ajoutés par app.js d'après l'en-tête). Plus aucun défilement horizontal, menu ouvert compris. */
@media (max-width: 1260px) {
  .filters { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .filters .field:first-child { grid-column: 1 / -1; }
  .table.responsive thead, .table.table-cards thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td,
  .table.table-cards, .table.table-cards tbody, .table.table-cards tr, .table.table-cards td { display: block; width: 100%; }
  .table.responsive tr, .table.table-cards tr { padding: .8rem 1.4rem; border-bottom: 1px solid var(--line); }
  .table.responsive td, .table.table-cards td { border: 0; padding: .15rem 0; white-space: normal; }
  .table.responsive td.actions, .table.table-cards td.actions { text-align: left; padding-top: .5rem; }
  .table.table-cards td.actions .row-actions { justify-content: flex-start; min-width: 0; }
  .table-compact td.actions > .btn, .table-compact td.actions > form { margin: .15rem .3rem .15rem 0; }
  .table.responsive td[data-label]::before, .table.table-cards td[data-label]::before { content: attr(data-label) " : "; color: var(--grey); font-size: .8rem; }
  .table.table-cards td.right { text-align: left; }
  .table.responsive td[data-label]::before, .table.table-cards td[data-label]::before { font-family: var(--font); letter-spacing: 0; }
  .table td:first-child { overflow-wrap: anywhere; }
  /* Petits tableaux sans en-tête (dernières connexions, emails en échec) : une ligne par élément, détails à la suite. */
  .table:not(.table-cards):not(.responsive) tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .6rem; padding: .6rem 1.4rem; border-bottom: 1px solid var(--line); }
  .table:not(.table-cards):not(.responsive) tbody td { display: block; border: 0; padding: 0; }
  .table:not(.table-cards):not(.responsive) tbody td:first-child { flex-basis: 100%; }
  .table:not(.table-cards):not(.responsive) tbody td.nowrap { white-space: normal; }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .front-main { padding: 1.25rem 1rem 2rem; }
  .front-header .logo img { height: 38px; }
  .front-nav .who { display: none; }
  .filters { grid-template-columns: 1fr; }
  .card { padding: 1rem; }
  .table-wrap { margin: 0 -1rem; }
  /* Tableau des documents en cartes sur mobile */
  .table.responsive tr, .table.table-cards tr { padding: .8rem 1rem; }
  dl.props, .contact-list { grid-template-columns: minmax(0, 1fr); gap: 0; }
  dl.props dt, .contact-list dt { margin-top: .45rem; }
  dl.props dd, .contact-list dd { overflow-wrap: anywhere; }
  h1 { font-size: 1.45rem; }
}
.mt { margin-top: 1rem; }
.mb0 { margin-bottom: 0; }

/* Bandeau Antium Digital (recette) : le menu admin se cale sous le bandeau. */
body:has(> .antium-bar:not(.is-collapsed)) .sidebar { top: 44px; height: calc(100vh - 44px); }
@media (max-width: 960px) {
  body:has(> .antium-bar:not(.is-collapsed)) .admin-topbar { top: 44px; }
  body:has(> .antium-bar:not(.is-collapsed)) .sidebar { top: 44px; height: calc(100vh - 44px); }
}
body:has(> .antium-bar:not(.is-collapsed)) .auth { min-height: calc(100vh - 44px); }

.contact-list { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .9rem; margin: .5rem 0 0; }
.contact-list dt { color: var(--grey); }
.contact-list dd { margin: 0; color: var(--ink); }

/* Entités Pechavy (couleurs des en-têtes de factures) */
.badge-ent-alternatives { background: #e8f5e9; color: #2e7d32; }
.badge-ent-energie { background: #e3eefb; color: #1d4f91; }
.badge-ent-lubrifiants { background: #fff1e6; color: #c2570c; }
.badge-ent-none { background: #f1f3f5; color: var(--grey); }
.badges { display: inline-flex; gap: .3rem; flex-wrap: wrap; }
.stat.ent-alternatives { border-top-color: #2e7d32; }
.stat.ent-energie { border-top-color: #1d4f91; }
.stat.ent-lubrifiants { border-top-color: #c2570c; }
.stat.ent-none { border-top-color: var(--grey-2); }
.chip.chip-ent-alternatives.is-active { background: #2e7d32; border-color: #2e7d32; }
.chip.chip-ent-energie.is-active { background: #1d4f91; border-color: #1d4f91; }
.chip.chip-ent-lubrifiants.is-active { background: #c2570c; border-color: #c2570c; }
.act-stats a.num { font-weight: 600; color: var(--navy); text-decoration: none; font-variant-numeric: tabular-nums; }
.act-stats a.num:hover { text-decoration: underline; }
.act-stats a.num.warn { color: var(--amber); }
.act-stats tr.total td { border-top: 2px solid var(--line); font-weight: 700; }
.act-stats th.right, .act-stats td.right { text-align: right; }

/* Dépôt */
.btn-lg { padding: .75rem 1.3rem; font-size: 1rem; }
.sidebar nav a.nav-depot { background: rgba(255, 255, 255, .1); color: #fff; font-weight: 600; margin-bottom: .75rem; border: 1px solid rgba(255, 255, 255, .2); }
.sidebar nav a.nav-depot:hover { background: rgba(255, 255, 255, .16); }
.sidebar nav a.nav-depot.is-active { background: var(--red); border-color: var(--red); }
.depot-step + .depot-step { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.depot-step h2 { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.step-num { display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--navy); color: #fff; font-size: .9rem; }
.client-pick { position: relative; max-width: 560px; }
.client-pick input { width: 100%; font-size: 1rem; }
.suggestions { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: .25rem 0 0; padding: .3rem; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 320px; overflow: auto; }
.suggestions li { display: grid; grid-template-columns: 110px 1fr auto; gap: .6rem; align-items: center; padding: .5rem .6rem; border-radius: 8px; cursor: pointer; }
.suggestions li.is-active { background: var(--navy-soft); }
.suggestions li.empty { display: block; color: var(--grey); cursor: default; }
.client-chosen { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .9rem 1rem; border-radius: 10px; background: var(--navy-soft); }
.client-chosen strong { font-size: 1.05rem; color: var(--navy); }
.entity-locked { font-weight: 600; color: var(--navy); margin: 0; }
.dropzone.is-disabled { cursor: pointer; opacity: .6; }
.dropzone.is-disabled:hover { border-color: #b7c4cc; background: #fafcfd; }
.depot [data-default-entity] { max-width: 420px; }

/* Fenêtre de dépôt */
dialog.modal { width: min(1080px, calc(100vw - 2rem)); max-height: calc(100vh - 3rem); padding: 1.5rem 1.75rem; border: 0; border-radius: var(--radius); box-shadow: 0 24px 64px rgba(3, 46, 66, .35); overflow: auto; color: inherit; }
dialog.modal::backdrop { background: rgba(3, 30, 45, .55); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.modal-head h1 { margin: 0; font-size: 1.5rem; }
dialog.modal > .sub { color: var(--grey); margin: .25rem 0 1.25rem; }
.modal-close { background: none; border: 0; font-size: 1.8rem; line-height: 1; color: var(--grey); cursor: pointer; padding: .2rem .5rem; border-radius: 8px; }
.modal-close:hover { color: var(--navy); background: var(--navy-soft); }
@media (max-width: 960px) { dialog.modal { padding: 1.1rem; } }
.step-note { font: 400 .9rem/1.4 inherit; color: var(--grey); }
.blocked { margin-top: .4rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.blocked form { display: inline; }
.entity-choice, .access-choice { border: 0; padding: 0; margin: 0 0 1rem; }
.entity-choice legend, .access-choice legend { font-weight: 600; font-size: .9rem; color: var(--navy); margin-bottom: .4rem; }
.entity-choice .checkbox, .access-choice .checkbox { display: flex; align-items: center; gap: .5rem; margin: .25rem 0; }

/* File de dépôt : colonnes titrées et alignées */
.depot .dropzone { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: .6rem 1rem; padding: 1rem; }
.depot .dropzone-text strong { display: inline; font-size: 1rem; }
.depot .dropzone-hint { flex-basis: 100%; text-align: center; }
.depot .queue-head, .depot .queue-item { display: grid; grid-template-columns: minmax(200px, 2fr) 230px 150px 150px 100px 32px; gap: .6rem; }
.depot .queue-head { margin-top: 1rem; padding: 0 0 .35rem; border-bottom: 1px solid var(--line); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--grey); }
.depot .queue { margin-top: 0; }
.depot .queue-item { align-items: start; padding: .55rem 0; }
.depot .queue-item input, .depot .queue-item select { height: 38px; min-height: 38px; box-sizing: border-box; }
.depot .queue-item .name { margin: .25rem 0 0; }
.depot .queue-item .status, .depot .queue-item .remove { height: 38px; display: flex; align-items: center; }
@media (max-width: 960px) {
  .depot .queue-head { display: none; }
  .depot .queue-item { grid-template-columns: 1fr 1fr; }
  .depot .queue-item > .cell-label { grid-column: 1 / -1; }
}
dialog.modal-narrow { width: min(720px, calc(100vw - 2rem)); }
.modal-actions { justify-content: flex-end; margin-top: 1rem; }

/* Carte repliable (tableau de bord) */
details.fold > summary { cursor: pointer; list-style: none; margin-bottom: 0; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { display: flex; align-items: center; gap: .5rem; margin: 0; }
details.fold > summary h2::before { content: ""; width: .5rem; height: .5rem; border-right: 2px solid var(--navy); border-bottom: 2px solid var(--navy); transform: rotate(-45deg); transition: transform .15s; margin-right: .2rem; }
details.fold[open] > summary h2::before { transform: rotate(45deg); }
details.fold[open] > summary { margin-bottom: 1rem; }
details.fold .when-open, details.fold[open] .when-closed { display: none; }
details.fold[open] .when-open { display: inline; }
.card-head form.row { flex-wrap: wrap; justify-content: flex-end; }
.card-head form.row input, .card-head form.row select { width: auto; min-width: 180px; }

/* Notifications en bas de page */
.toasts { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; align-items: center; gap: .5rem; width: max-content; max-width: calc(100vw - 2rem); pointer-events: none; }
.toast { padding: .75rem 1.15rem; border-radius: 10px; background: var(--navy); color: #fff; font-size: .92rem; font-weight: 500; box-shadow: 0 10px 30px rgba(3, 30, 45, .28); opacity: 0; transform: translateY(18px); transition: opacity .35s ease, transform .45s cubic-bezier(.2, .8, .2, 1); }
.toast.is-in { opacity: 1; transform: translateY(0); }
.toast-success { background: #0f6b4f; }
.toast-warning { background: #9a5b07; }
.toast-error { background: var(--red); }
@media (prefers-reduced-motion: reduce) { .toast { transition: opacity .2s; transform: none; } }

/* Listes mises à jour en direct */
[data-live-results] { transition: opacity .15s; }
[data-live-results].is-loading { opacity: .5; }
.pw-reset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem 1rem; margin: 0 0 1rem; }
.pw-reset legend { font-weight: 600; font-size: .9rem; color: var(--navy); padding: 0 .3rem; }

/* Bouton « Faire un retour » (personnel uniquement) */
.fb-open { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 60; padding: .6rem 1rem; border: 0; border-radius: 999px; background: var(--navy); color: #fff; font: 600 .85rem/1 var(--font); box-shadow: 0 6px 18px rgba(3, 30, 45, .28); cursor: pointer; }
.fb-open:hover { background: var(--navy-2); }
@media print { .fb-open { display: none; } }
