:root {
  --blue: #0a3fa8; --blue-dark: #072d7a; --blue-soft: #e8efff;
  --orange: #ff4f0f; --orange-soft: #fff0e8;
  --red: #d92d20; --red-soft: #fff1f0; --green: #12843a; --green-soft: #def7e5;
  --ink: #12234d; --muted: #5d6b8a; --line: #e3e8f2; --bg: #f3f6fb; --card: #fff;
  --radius: 12px; --shadow: 0 2px 10px rgba(16, 38, 90, .07);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
h1, h2, h3 { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }

/* ---------- Connexion ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, var(--blue-dark), var(--blue)); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-card img { width: 220px; display: block; margin: 0 auto 18px; }
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.login-card p { text-align: center; margin: 0 0 18px; }

/* ---------- Structure ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; grid-template-rows: 68px 1fr; height: 100vh; }
.topbar { grid-column: 1 / -1; background: var(--blue); color: #fff; display: flex; align-items: center; gap: 18px; padding: 0 18px 0 12px; }
.topbar .logo { height: 46px; border-radius: 3px; display: block; }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; border: 0; border-radius: 9px; padding: 10px 14px; background: rgba(255,255,255,.92); color: var(--ink); }
.search-results { position: absolute; top: 44px; left: 0; right: 0; background: #fff; color: var(--ink); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-height: 70vh; overflow: auto; z-index: 40; }
.search-results h4 { margin: 0; padding: 8px 14px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.search-results button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 14px; }
.search-results button:hover { background: var(--blue-soft); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.datetime { display: flex; align-items: center; gap: 14px; padding-right: 16px; border-right: 1px solid rgba(255,255,255,.25); }
.date { font-size: 14px; }
.d-short { display: none; }
.clock { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.online { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; display: inline-block; }
.dot.off { background: #b7c0d6; }
.bell { position: relative; background: none; border: 0; color: #fff; font-size: 20px; padding: 6px; }
.bell .badge { position: absolute; top: -2px; right: -4px; background: var(--orange); color: #fff; border-radius: 10px; font-size: 11px; min-width: 18px; padding: 1px 5px; text-align: center; }
.userbtn { background: rgba(255,255,255,.12); border: 0; color: #fff; border-radius: 10px; padding: 6px 12px; text-align: left; line-height: 1.2; }
.userbtn small { opacity: .8; display: block; font-size: 11.5px; }
.menu { position: absolute; right: 18px; top: 62px; background: #fff; color: var(--ink); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 50; width: 340px; max-height: 70vh; overflow: auto; }
.menu.small-menu { width: 240px; }
.menu button.item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 11px 16px; }
.menu button.item:hover { background: var(--blue-soft); }
.notif { padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 14px; cursor: pointer; }
.notif.unread { background: var(--orange-soft); }
.notif:hover { background: var(--blue-soft); }

.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; overflow: auto; }
.nav { display: flex; align-items: center; gap: 12px; width: 100%; background: none; border: 0; padding: 11px 14px; border-radius: 9px; color: var(--blue-dark); font-weight: 500; text-align: left; }
.nav:hover { background: var(--blue-soft); }
.nav.active { background: var(--orange); color: #fff; }
.nav .ico { width: 20px; text-align: center; }
.nav .count { margin-left: auto; background: var(--orange); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
.nav.active .count { background: #fff; color: var(--orange); }
.sep { height: 1px; background: var(--line); margin: 10px 8px; }

.main { overflow: auto; padding: 22px 26px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; }
.hello h1 { font-size: 36px; }
.hello h1 span { color: var(--orange); }
.hello p { margin: 4px 0 0; font-size: 17px; color: var(--muted); }
.banner { position: relative; border-radius: var(--radius); padding: 26px 28px; margin-bottom: 18px; color: #fff; overflow: hidden;
  background: linear-gradient(110deg, var(--blue-dark) 0%, var(--blue) 55%, #2f66d6 100%); }
.banner::after { content: ""; position: absolute; right: -30px; top: 0; bottom: 0; width: 38%; background: repeating-linear-gradient(115deg, transparent 0 22px, rgba(255,255,255,.07) 22px 34px); }
.banner h1 { font-size: 32px; }
.banner h1 span { color: #ffb08f; }
.banner p { margin: 6px 0 0; opacity: .9; font-size: 16px; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 0; text-align: left; width: 100%; }
.stat:hover { box-shadow: 0 4px 16px rgba(16,38,90,.14); }
.stat .circle { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; flex: none; }
.stat b { display: block; font-size: 15px; }
.stat .num { font-size: 34px; font-weight: 800; line-height: 1.05; }
.stat.blue .circle { background: var(--blue-soft); } .stat.blue .num { color: var(--blue); }
.stat.orange .circle { background: var(--orange-soft); } .stat.orange .num { color: var(--orange); }
.stat.red { background: var(--red-soft); } .stat.red .circle { background: #ffe0dd; } .stat.red .num { color: var(--red); }

.grid-main { display: grid; grid-template-columns: 1fr 300px; gap: 14px; margin-bottom: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1.05fr; gap: 14px; }
.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card h2 a, .linkbtn { font-size: 13.5px; font-weight: 500; background: none; border: 0; color: var(--blue); text-decoration: none; padding: 0; }
.linkbtn:hover { text-decoration: underline; }

.quick { display: flex; flex-direction: column; gap: 10px; }
.qbtn { border: 0; color: #fff; border-radius: 10px; padding: 14px 16px; text-align: left; font-weight: 700; font-size: 15px; }
.qbtn small { display: block; font-weight: 400; opacity: .9; font-size: 12.5px; }
.qbtn.b { background: var(--blue); } .qbtn.o { background: var(--orange); }
.reminder-card { background: var(--orange-soft); border-radius: var(--radius); padding: 14px 16px; margin-top: 12px; }
.reminder-card b { color: var(--blue); }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 9px 10px; background: #f3f6fb; white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.row { cursor: pointer; }
tr.row:hover td { background: #f7f9fe; }
tr.done td { opacity: .6; }
tr.done .t-title { text-decoration: line-through; }
.t-title { font-weight: 600; }
.overdue-text { color: var(--red); font-weight: 600; }
.pri { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.pri i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.pri.low i { background: var(--green); } .pri.normal i { background: #f59e0b; } .pri.high i { background: var(--red); }
.pri.urgent i { background: #7a0f0f; box-shadow: 0 0 0 3px #f4c3bf; } .pri.urgent { font-weight: 700; color: #7a0f0f; }
.chip { display: inline-block; padding: 4px 11px; border-radius: 14px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: #eef1f7; color: var(--muted); }
.chip.todo, .chip.to_process { background: var(--blue-soft); color: var(--blue); }
.chip.in_progress, .chip.supplier_search { background: #e0ecff; color: #1d4fbf; }
.chip.waiting, .chip.waiting_reply, .chip.to_order, .chip.to_finalize { background: #ffe9d6; color: #c2410c; }
.chip.ordered, .chip.delivery_expected, .chip.sent { background: #fff5c2; color: #8a6a00; }
.chip.done, .chip.received, .chip.accepted { background: var(--green-soft); color: var(--green); }
.chip.cancelled, .chip.refused { background: #eceff4; color: #6b7280; }
.chip.team { background: #efe9ff; color: #5b3fc4; }
.empty { text-align: center; padding: 28px 10px; color: var(--muted); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { border: 1px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 20px; font-size: 14px; }
.tab.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.tab .n { opacity: .7; margin-left: 4px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: #fff; min-width: 140px; }

/* ---------- Formulaires ---------- */
.btn { border: 0; border-radius: 9px; padding: 10px 18px; font-weight: 700; background: var(--blue); color: #fff; }
.btn:hover { background: var(--blue-dark); }
.btn.orange { background: var(--orange); } .btn.orange:hover { background: #d93c00; }
.btn.ghost { background: #fff; color: var(--blue); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--blue-soft); }
.btn.danger { background: var(--red); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: wait; }
label.f { display: block; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
label.f > span.req { color: var(--orange); }
.f input, .f select, .f textarea, .input { display: block; width: 100%; margin-top: 5px; border: 1px solid #cdd5e6; border-radius: 9px; padding: 9px 11px; background: #fff; font-weight: 400; }
.f input:focus, .f select:focus, .f textarea:focus, .input:focus { outline: 2px solid #9db8f5; border-color: var(--blue); }
.f textarea { min-height: 76px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.error { background: var(--red-soft); color: var(--red); border-radius: 9px; padding: 9px 12px; margin-bottom: 12px; font-size: 14px; }
.notice { background: #fff8e1; color: #7a5b00; border-radius: 9px; padding: 9px 12px; margin-bottom: 12px; font-size: 14px; }

/* Liste déroulante avec recherche */
.combo { position: relative; margin-top: 5px; }
.combo .box { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid #cdd5e6; border-radius: 9px; padding: 5px 8px; background: #fff; min-height: 40px; cursor: text; }
.combo .box:focus-within { outline: 2px solid #9db8f5; border-color: var(--blue); }
.combo .box input { border: 0; outline: 0; flex: 1; min-width: 90px; margin: 0; padding: 4px 2px; font-weight: 400; }
.combo .pill { background: var(--blue-soft); color: var(--blue-dark); border-radius: 14px; padding: 3px 4px 3px 10px; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.combo .pill button { border: 0; background: none; color: var(--blue-dark); font-size: 15px; padding: 0 5px; line-height: 1; }
.combo .list { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid #cdd5e6; border-radius: 9px; box-shadow: 0 10px 24px rgba(16,38,90,.18); max-height: 230px; overflow: auto; z-index: 70; margin-top: 3px; }
.combo .list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; font-weight: 400; }
.combo .list button:hover, .combo .list button.hl { background: var(--blue-soft); }
.combo .list .add { color: var(--orange); font-weight: 700; border-top: 1px solid var(--line); }

/* ---------- Fenêtres ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 25, 60, .5); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 14px; overflow: auto; z-index: 100; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 640px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 20px; }
.x { border: 0; background: none; font-size: 26px; line-height: 1; color: var(--muted); padding: 0 4px; }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal.reminder .modal-head { background: var(--orange); color: #fff; border-radius: 16px 16px 0 0; border: 0; }
.modal.reminder .x { color: #fff; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; margin-bottom: 14px; }
.detail-grid div span { display: block; font-size: 12px; color: var(--muted); }
.thread h3 { font-size: 15px; margin: 18px 0 8px; }
.comment { background: #f5f7fc; border-radius: 10px; padding: 9px 12px; margin-bottom: 8px; }
.comment .who { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.comment .body { white-space: pre-wrap; word-break: break-word; }
.hist { font-size: 13px; color: var(--muted); padding: 3px 0; }
.status-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 14px; }
.status-row button { border: 1px solid var(--line); background: #fff; border-radius: 18px; padding: 6px 12px; font-size: 13px; }
.status-row button.on { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---------- Notifications éphémères ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 300; max-width: 360px; }
.toast { background: var(--blue-dark); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.3); cursor: pointer; font-size: 14px; border-left: 5px solid var(--orange); }

.user-row td .you { font-size: 12px; color: var(--muted); }
.pwbox { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 20px; background: #f3f6fb; border-radius: 10px; padding: 12px; text-align: center; letter-spacing: .06em; user-select: all; margin: 10px 0; }

@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .grid-main { grid-template-columns: 1fr; }
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 4px; }
details.more { margin: 4px 0 10px; }
details.more summary { cursor: pointer; font-weight: 600; color: var(--blue); margin-bottom: 12px; }
.banner-order { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 15px; }
.inline-form { background: #f5f7fc; border-radius: 12px; padding: 12px 14px; margin: 10px 0; }
.inline-form h3 { font-size: 14px; margin: 0 0 8px; }
a.nav, a.stat { text-decoration: none; color: inherit; }
a.nav { color: var(--blue-dark); }
a.nav.active { color: #fff; }
.card .card { box-shadow: none; border: 1px solid var(--line); padding: 10px 12px; }
.card .card .num { font-size: 26px; color: var(--blue); }
.conn-bad { color: #ffd2c2; }
.btn.full { width: 100%; }

/* --- Ajustements de mise en page --- */
.stat .num, .stat .muted { display: block; }
.grid-3 { grid-template-columns: 1fr 1fr; }
.grid-3 > :nth-child(3) { grid-column: 1 / -1; }
@media (min-width: 1650px) {
  .grid-3 { grid-template-columns: 1fr 1fr 1.05fr; }
  .grid-3 > :nth-child(3) { grid-column: auto; }
}
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.filters input[type=search] { min-width: 300px; }
.filters input[type=checkbox] { min-width: 0; width: auto; margin-right: 6px; }
.filters label { display: inline-flex; align-items: center; }
td, th { padding-left: 8px; padding-right: 8px; }

/* =====================================================================
   TÉLÉPHONE (écrans de 780 px ou moins)
   ===================================================================== */
@media (max-width: 780px) {
  html, body { overflow-x: hidden; }
  body { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }

  /* Zone du haut */
  .shell { display: block; height: auto; min-height: 100vh; }
  .topbar { position: sticky; top: 0; z-index: 30; flex-wrap: wrap; gap: 8px 10px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; }
  .topbar .logo { height: 34px; }
  .topbar-right { margin-left: auto; gap: 10px; }
  .datetime { flex-direction: column; align-items: flex-end; gap: 0; border: 0; padding: 0; line-height: 1.1; }
  .clock { font-size: 20px; }
  .date { font-size: 11px; opacity: .9; }
  .d-long { display: none; }
  .d-short { display: inline; }
  .search { order: 10; flex: 1 1 100%; max-width: none; }
  .search input { font-size: 16px; padding: 10px 12px; }
  .search-results { position: fixed; left: 8px; right: 8px; top: 108px; max-height: 60vh; }
  .online:not(.bad) { display: none; }
  .online.bad { flex: 1 1 100%; order: 11; font-size: 11.5px; }
  .userbtn { padding: 5px 10px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .userbtn small { display: none; }
  .bell { font-size: 22px; padding: 6px 8px; }
  .menu, .menu.small-menu { position: fixed; left: 8px; right: 8px; top: 108px; width: auto; max-height: 65vh; }

  /* Barre de navigation en bas */
  .sidebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; flex-direction: row; gap: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    background: #fff; border: 0; border-top: 1px solid var(--line); box-shadow: 0 -4px 14px rgba(16,38,90,.1); overflow-x: auto; scroll-snap-type: x proximity; }
  .sidebar .sep { display: none; }
  .nav { flex: 0 0 auto; flex-direction: column; justify-content: center; gap: 2px; min-width: 76px; width: auto; padding: 6px 8px; font-size: 11px; text-align: center; line-height: 1.15; scroll-snap-align: start; border-radius: 10px; white-space: normal; }
  .nav .ico { font-size: 20px; width: auto; }
  .nav.active { background: var(--orange-soft); color: var(--orange); font-weight: 700; }
  a.nav.active { color: var(--orange); }

  /* Contenu */
  .main { overflow: visible; padding: 14px 12px calc(96px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 12px; align-items: center; }
  .page-head h1 { font-size: 22px; }
  .page-head .btn { width: 100%; padding: 12px; font-size: 16px; }
  .banner { padding: 16px; margin-bottom: 12px; }
  .banner h1 { font-size: 24px; }
  .banner p { font-size: 14px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
  .stat { padding: 12px; gap: 10px; flex-direction: column; align-items: flex-start; }
  .stat .circle { width: 40px; height: 40px; font-size: 19px; }
  .stat b { font-size: 13.5px; }
  .stat .num { font-size: 28px; }
  .grid-main, .grid-3 { grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
  .grid-3 > :nth-child(3) { grid-column: auto; }
  .card { padding: 14px; }
  .card h2 { font-size: 16px; flex-wrap: wrap; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .qbtn { padding: 14px; font-size: 16px; }

  /* Onglets défilants et filtres */
  .tabs { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px 12px; padding: 0 12px 4px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; padding: 9px 14px; }
  .filters { gap: 8px; }
  .filters input, .filters select { flex: 1 1 100%; min-width: 0; width: 100%; }
  .filters input[type=search] { min-width: 0; }
  .filters input[type=checkbox] { flex: 0 0 auto; width: auto; }

  /* Tableaux -> cartes */
  .table-wrap { overflow: visible; }
  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; box-shadow: var(--shadow); }
  tr.row:active { background: #f1f5ff; }
  td { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 5px 0; border: 0; text-align: right; }
  td::before { content: attr(data-label); flex: 0 0 auto; font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; }
  tbody tr { display: flex; flex-direction: column; }
  td.t-title { display: block; order: -1; text-align: left; font-size: 16px; padding: 2px 40px 6px 0; }
  td.t-title::before { display: none; }
  td.chk { position: absolute; top: 10px; right: 12px; width: auto; padding: 0; }
  td.chk::before { display: none; }
  td[data-label=""]:not(.chk) { order: 99; justify-content: flex-end; padding-top: 8px; }
  td[data-label=""]::before { display: none; }
  td input[type=checkbox] { width: 26px; height: 26px; }
  td.right { justify-content: flex-end; flex-wrap: wrap; }
  td.right::before { display: none; }
  tr.done td { opacity: .65; }
  .tabs + .filters + .card, .card:has(> .table-wrap) { background: transparent; box-shadow: none; padding: 0; }
  td .chip { white-space: normal; text-align: right; }

  /* Formulaires et fenêtres plein écran */
  .overlay { padding: 0; align-items: stretch; background: #fff; }
  .modal, .modal.wide { max-width: none; width: 100%; min-height: 100%; border-radius: 0; box-shadow: none; display: flex; flex-direction: column; }
  .modal-head { position: sticky; top: 0; z-index: 5; background: #fff; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; }
  .modal.reminder .modal-head { border-radius: 0; }
  .modal-head h2 { font-size: 17px; }
  .x { font-size: 32px; padding: 0 8px; }
  .modal-body { flex: 1; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
  .modal-foot { position: sticky; bottom: 0; background: #fff; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
  .row2, .row3, .detail-grid { grid-template-columns: 1fr; gap: 0 12px; }
  .detail-grid { gap: 8px; }
  .f input, .f select, .f textarea, .input, .combo .box input { font-size: 16px; }
  .f input, .f select, .input { min-height: 44px; }
  .btn { min-height: 44px; font-size: 15px; }
  .btn.sm { min-height: 40px; }
  .actions .btn { flex: 1 1 auto; }
  .status-row { gap: 6px; }
  .status-row button { padding: 9px 12px; font-size: 14px; }
  .combo .list { max-height: 40vh; }
  .combo .list button { padding: 12px; }
  .pwbox { font-size: 17px; }

  /* Messages */
  #toasts { left: 8px; right: 8px; max-width: none; bottom: calc(76px + env(safe-area-inset-bottom)); }

  /* Connexion */
  .login-wrap { padding: 16px; align-items: start; padding-top: 12vh; }
}
@media (max-width: 380px) {
  .cards { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* --- Logistique, synthèse, import, impression --- */
.chip.to_issue { background: var(--blue-soft); color: var(--blue); }
.chip.issued { background: #fff5c2; color: #8a6a00; }
.chip.picked_up { background: var(--green-soft); color: var(--green); }
.chip.alert { background: #ffe1d6; color: #b42318; }
.chip.billing { background: #7a0f0f; color: #fff; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0 12px; font-weight: 600; font-size: 14px; }
.check input { width: auto; margin: 0; min-height: 0; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.cgv-input { max-width: 130px; display: inline-block; }
.load { display: flex; align-items: center; gap: 8px; }
.load progress { width: 160px; height: 10px; accent-color: var(--blue); }
#print-area { display: none; }
.print-logo { width: 220px; display: block; margin-bottom: 14px; }
.print-table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 14px; }
.print-table th, .print-table td { border: 1px solid #999; padding: 8px 10px; text-align: left; vertical-align: top; background: #fff; }
.print-table th { width: 28%; background: #f0f0f0; }
.print-cgv { font-size: 12.5px; margin: 18px 0; }
.print-sign { display: flex; justify-content: space-between; gap: 30px; margin-top: 50px; }
.print-sign > div { flex: 1; border-top: 1px solid #333; padding-top: 6px; min-height: 70px; font-size: 13px; }
@media print {
  body * { visibility: hidden !important; }
  #print-area, #print-area * { visibility: visible !important; }
  #print-area { display: block !important; position: absolute; left: 0; top: 0; width: 100%; padding: 15mm; color: #000; }
}
@media (max-width: 780px) {
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1 1 100%; text-align: center; }
  .load progress { width: 100px; }
  .cgv-input { max-width: none; width: 100%; }
}

/* --- Planning atelier, tableau CRM, automatisations --- */
.chip.booked { background: var(--blue-soft); color: var(--blue); }
.chip.pending { background: #ffe9d6; color: #c2410c; }
.week-nav { align-items: center; }
.week-nav b { margin-left: 8px; }
.plan-week { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.plan-day { background: var(--card); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); min-width: 0; }
.plan-day.today { outline: 2px solid var(--orange); }
.plan-day h3 { font-size: 14px; text-transform: capitalize; margin-bottom: 8px; color: var(--blue-dark); }
.slot { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 7px 9px; margin-bottom: 6px; font-size: 13px; }
.slot b { margin-right: 4px; }
.slot small { display: block; color: var(--muted); margin: 2px 0 4px; }
.slot.free { color: var(--muted); background: #f8fafe; border-style: dashed; }
.slot.free:not([disabled]):hover { border-color: var(--orange); color: var(--orange); }
.slot[disabled] { opacity: .45; cursor: default; }
.slot.booked { background: var(--blue-soft); border-color: #bcd0ff; }
.slot.booked.pending { background: var(--orange-soft); border-color: #ffcdb2; }
.slot.booked:hover { box-shadow: 0 2px 8px rgba(16,38,90,.18); }
.kanban { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.kcol { flex: 1 0 170px; background: #e9eef8; border-radius: var(--radius); padding: 10px; min-height: 120px; }
.kcol h3 { font-size: 14px; margin-bottom: 4px; display: flex; justify-content: space-between; }
.ktotal { font-weight: 700; color: var(--blue); font-size: 13px; margin-bottom: 8px; }
.kcard { background: #fff; border-radius: 10px; padding: 9px 10px; margin-top: 8px; box-shadow: var(--shadow); cursor: grab; font-size: 13px; }
.kcard select { width: 100%; margin-top: 7px; border: 1px solid var(--line); border-radius: 7px; padding: 5px; font-size: 12.5px; background: #fff; }
.auto-rule h2 { align-items: center; }
.auto-rule .check { font-weight: 600; margin: 0; }
@media (max-width: 1100px) { .plan-week { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 780px) {
  .plan-week { grid-template-columns: 1fr; }
  .kcol { flex-basis: 78vw; }
  .slot { padding: 11px 12px; font-size: 14px; }
}
