/* ==========================================================================
   Mise en page : barre latérale, barre supérieure, contenu, mobile
   ========================================================================== */
.app { display: flex; min-height: 100vh; }

/* ---------- Barre latérale ---------- */
.sidebar { width: var(--sidebar-w); flex: none; background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px 14px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; color: var(--brand-900); text-decoration: none; }
.company-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r-md); background: #fff; text-align: left; }
.company-btn:hover { background: #F7F9FB; }
.company-av { width: 32px; height: 32px; border-radius: 7px; background: #E3EBF7; color: var(--brand-900); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.company-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.company-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.company-role { font-size: 12px; color: var(--text-muted); }
.nav-label { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); padding: 18px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 0 10px; height: 38px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); font-weight: 500; text-align: left; text-decoration: none; }
.nav-item:hover { background: #F1F4F8; color: var(--text); }
.nav-item[aria-current="page"] { background: var(--action-50); color: #1450C8; font-weight: 600; }
.nav-count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-full); background: var(--warning-bg); color: var(--warning-fg); font-size: var(--fs-xs); font-weight: 650; display: grid; place-items: center; }
.sidebar-foot { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 2px; }
.trial-box { margin-top: 10px; border: 1px solid var(--border); border-radius: 9px; padding: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.trial-box.ended { background: #FEF3F2; border-color: var(--danger-border); color: #912018; }

/* ---------- Zone principale ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 12px 28px; min-height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--border); }
.topbar-l { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.crumb { color: var(--text-muted); font-size: var(--fs-sm); font-weight: 550; display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; text-decoration: none; }
.crumb:hover { color: var(--link); }
.page-title { font-size: var(--fs-xl); font-weight: 650; letter-spacing: -.015em; color: #14202E; }
.topbar-r { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.avatar-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid #DCE1E8; background: #E3EBF7; color: var(--brand-900); font-weight: 650; font-size: 13px; }
.menu-toggle { display: none; }
.content { padding: 24px 28px 56px; display: flex; flex-direction: column; gap: 20px; width: 100%; max-width: var(--content-max); }
.page-banner { padding: 16px 28px 0; }
.bottom-nav { display: none; }

/* ---------- Tablette et mobile ---------- */
@media (max-width: 1024px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--shadow-modal); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 55; }
  .menu-toggle { display: inline-flex; }
}
@media (max-width: 760px) {
  .topbar { padding: 10px 14px; gap: 8px; flex-wrap: nowrap; }
  .topbar-l { flex: 1 1 auto; }
  .topbar-r { flex-wrap: nowrap; gap: 8px; }
  .topbar .search { display: none; }
  .page-title { font-size: 18px; }
  .content { padding: 16px 14px 96px; gap: 14px; }
  .page-banner { padding: 12px 14px 0; }
  .btn-new-label { display: none; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: #fff; border-top: 1px solid var(--border); padding: 0 6px env(safe-area-inset-bottom, 6px); }
  .bottom-nav a, .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px; font-size: 11px; font-weight: 560; color: var(--text-muted); text-decoration: none; border: 0; background: none; }
  .bottom-nav [aria-current="page"] { color: #1450C8; }
  .toasts { left: 14px; right: 14px; bottom: 76px; align-items: stretch; }
  .modal-f .btn { flex: 1 1 auto; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
  /* Les tableaux deviennent des listes-cartes */
  .table, .table.sm { min-width: 0 !important; }
  .table .thr { display: none; }
  .table .tr { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 12px 14px; align-items: center; }
  .table .tr > * { min-width: 0; }
  .table .tr .m-hide { display: none; }
  .table .tr .m-full { flex: 1 1 100%; }
  .table .tr .right { margin-left: auto; }
  .kpi { border-right: 0; border-bottom: 1px solid var(--border-soft); }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi-v { font-size: 21px; }
  .kpi:nth-child(odd) { border-right: 1px solid var(--border-soft); }
  .tabs { padding: 0 8px; }
}
