/* ============================================================
   Brewteam · Design System · v1 · 2026-08-24
   ------------------------------------------------------------
   Tokens + composants réutilisables. Toutes les pages du
   dashboard tenant doivent utiliser ces classes plutôt que
   de redéfinir leurs propres cards / chips / boutons.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --bt-bg:            #f7f3ec;
  --bt-bg-alt:        #ecefe7;
  --bt-surface:       #ffffff;
  --bt-surface-alt:   #f4f6f3;
  --bt-surface-hover: #eff5f1;
  --bt-border:        #e5ece5;
  --bt-border-strong: #d7e1da;
  --bt-text:          #21382d;
  --bt-text-soft:     #4f5b53;
  --bt-muted:         #607367;
  --bt-muted-soft:    #9aa79e;
  --bt-primary:       #3d604c;
  --bt-primary-dark:  #2f4a3a;
  --bt-primary-soft:  #dcebe1;
  --bt-primary-tint:  #eff5f1;
  --bt-accent:        #4a7862;
  --bt-warn:          #a5680a;
  --bt-warn-soft:     #fbedd2;
  --bt-danger:        #b8402f;
  --bt-danger-soft:   #fce5e1;
  --bt-success:       #2f6b50;
  --bt-success-soft:  #dcebe1;
  --bt-info:          #2a4e70;
  --bt-info-soft:     #e4eef7;

  --bt-radius-xs: 6px;
  --bt-radius-sm: 8px;
  --bt-radius:    12px;
  --bt-radius-lg: 16px;
  --bt-radius-xl: 22px;

  --bt-shadow-sm: 0 1px 2px rgba(33,56,45,0.06);
  --bt-shadow:    0 1px 2px rgba(33,56,45,0.05), 0 8px 24px -12px rgba(33,56,45,0.14);
  --bt-shadow-lg: 0 4px 12px rgba(33,56,45,0.08), 0 30px 60px -20px rgba(33,56,45,0.18);

  --bt-space-1: 4px;
  --bt-space-2: 8px;
  --bt-space-3: 12px;
  --bt-space-4: 16px;
  --bt-space-5: 20px;
  --bt-space-6: 24px;
  --bt-space-8: 32px;

  --bt-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bt-font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
}

/* ---------- Page head (unifié sur toutes les pages) ---------- */

.bt-page {
  padding: 28px 28px 56px;
  max-width: 1240px;
  margin: 0 auto;
}
.bt-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--bt-border);
}
.bt-page-head__title h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--bt-text);
}
.bt-page-head__sub {
  margin: 4px 0 0;
  color: var(--bt-muted);
  font-size: 13.5px;
  font-weight: 500;
}
.bt-page-head__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- Boutons ---------- */

.bt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--bt-radius-sm);
  border: 1px solid transparent;
  font-family: var(--bt-font);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, border-color .12s, transform .05s, box-shadow .12s;
  white-space: nowrap;
  line-height: 1;
}
.bt-btn:active:not(:disabled) { transform: translateY(1px); }
.bt-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.bt-btn--primary { background: linear-gradient(135deg, var(--bt-primary), var(--bt-primary-dark)); color: #fff; box-shadow: 0 3px 10px rgba(61,96,76,0.24); }
.bt-btn--primary:hover:not(:disabled) { box-shadow: 0 6px 16px rgba(61,96,76,0.32); transform: translateY(-1px); }
.bt-btn--secondary { background: var(--bt-surface); color: var(--bt-text); border-color: var(--bt-border-strong); }
.bt-btn--secondary:hover:not(:disabled) { background: var(--bt-surface-hover); border-color: var(--bt-primary); }
.bt-btn--ghost { background: transparent; color: var(--bt-muted); }
.bt-btn--ghost:hover:not(:disabled) { background: var(--bt-surface-alt); color: var(--bt-text); }
.bt-btn--danger { background: var(--bt-danger-soft); color: var(--bt-danger); border-color: rgba(184,64,47,0.18); }
.bt-btn--danger:hover:not(:disabled) { background: var(--bt-danger); color: #fff; }
.bt-btn--sm { padding: 6px 10px; font-size: 12px; }
.bt-btn--lg { padding: 12px 20px; font-size: 14.5px; }

/* ---------- Card ---------- */

.bt-card {
  background: var(--bt-surface);
  border: 1px solid var(--bt-border);
  border-radius: var(--bt-radius);
  box-shadow: var(--bt-shadow-sm);
  overflow: hidden;
}
.bt-card__head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--bt-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.bt-card__title { margin: 0; font-size: 14px; font-weight: 800; color: var(--bt-text); }
.bt-card__body { padding: 20px; }
.bt-card--flush .bt-card__body { padding: 0; }

/* ---------- Chip / Badge ---------- */

.bt-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--bt-surface);
  border: 1px solid var(--bt-border-strong);
  color: var(--bt-text-soft);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  white-space: nowrap;
  line-height: 1.2;
  user-select: none;
  font-family: var(--bt-font);
}
.bt-chip:hover { background: var(--bt-surface-hover); border-color: var(--bt-primary); }
.bt-chip.is-active {
  background: linear-gradient(135deg, var(--bt-primary), var(--bt-primary-dark));
  color: #fff;
  border-color: transparent;
}
.bt-chip__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--bt-muted-soft);
  flex-shrink: 0;
}
.bt-chip.is-active .bt-chip__dot { background: rgba(255,255,255,0.8); }

.bt-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.3;
  white-space: nowrap;
}
.bt-badge--neutral { background: var(--bt-surface-alt); color: var(--bt-text-soft); }
.bt-badge--primary { background: var(--bt-primary-soft); color: var(--bt-primary-dark); }
.bt-badge--success { background: var(--bt-success-soft); color: var(--bt-success); }
.bt-badge--warn    { background: var(--bt-warn-soft);    color: var(--bt-warn); }
.bt-badge--danger  { background: var(--bt-danger-soft);  color: var(--bt-danger); }
.bt-badge--info    { background: var(--bt-info-soft);    color: var(--bt-info); }

/* ---------- Tabs (sous-navigation intra-page) ---------- */

.bt-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--bt-border);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.bt-tabs::-webkit-scrollbar { display: none; }
.bt-tab {
  padding: 10px 16px;
  color: var(--bt-muted);
  font-size: 13.5px;
  font-weight: 700;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color .12s, border-color .12s;
  text-decoration: none;
  white-space: nowrap;
  background: transparent;
  border-top: 0; border-left: 0; border-right: 0;
  font-family: var(--bt-font);
}
.bt-tab:hover { color: var(--bt-text); text-decoration: none; }
.bt-tab.is-active { color: var(--bt-primary-dark); border-bottom-color: var(--bt-primary); }

/* ---------- Stats row (KPI cards horizontal) ---------- */

.bt-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.bt-kpi {
  background: var(--bt-surface);
  border: 1px solid var(--bt-border);
  border-radius: var(--bt-radius);
  padding: 16px 18px;
  box-shadow: var(--bt-shadow-sm);
}
.bt-kpi__label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--bt-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.bt-kpi__value {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 800;
  color: var(--bt-text);
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.bt-kpi__sub {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--bt-muted);
  font-weight: 600;
}
.bt-kpi--accent { border-color: var(--bt-primary-soft); background: linear-gradient(135deg, var(--bt-surface) 0%, var(--bt-primary-tint) 100%); }
.bt-kpi--accent .bt-kpi__value { color: var(--bt-primary-dark); }

/* ---------- Empty state ---------- */

.bt-empty {
  text-align: center;
  padding: 48px 24px;
  border: 1px dashed var(--bt-border-strong);
  border-radius: var(--bt-radius-lg);
  background: var(--bt-surface-alt);
}
.bt-empty__icon {
  width: 56px; height: 56px; border-radius: 16px;
  margin: 0 auto 14px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bt-primary-soft); color: var(--bt-primary-dark);
  font-size: 26px;
}
.bt-empty__title { font-size: 17px; font-weight: 800; color: var(--bt-text); margin: 0 0 6px; }
.bt-empty__sub { color: var(--bt-muted); font-size: 14px; margin: 0 auto 16px; max-width: 400px; line-height: 1.5; }

/* ---------- Master-detail layout ---------- */

.bt-master {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}
.bt-master__side {
  background: var(--bt-surface);
  border: 1px solid var(--bt-border);
  border-radius: var(--bt-radius);
  box-shadow: var(--bt-shadow-sm);
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bt-master__side-head { padding: 14px 16px; border-bottom: 1px solid var(--bt-border); display: flex; flex-direction: column; gap: 10px; }
.bt-master__side-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.bt-master__side-foot { padding: 12px 16px; border-top: 1px solid var(--bt-border); }
.bt-master__main {
  background: var(--bt-surface);
  border: 1px solid var(--bt-border);
  border-radius: var(--bt-radius);
  box-shadow: var(--bt-shadow-sm);
  min-height: 400px;
  overflow: hidden;
}
.bt-master__main-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--bt-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.bt-master__main-body { padding: 22px; }
@media (max-width: 900px) {
  .bt-master { grid-template-columns: 1fr; }
  .bt-master__side { position: static; max-height: none; }
}

/* Élément de liste dans le master */
.bt-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--bt-radius-sm);
  color: var(--bt-text);
  text-decoration: none;
  transition: background .12s;
  cursor: pointer;
  font-family: var(--bt-font);
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
}
.bt-item:hover { background: var(--bt-surface-alt); text-decoration: none; }
.bt-item.is-active { background: var(--bt-primary-soft); color: var(--bt-primary-dark); }
.bt-item__avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--bt-primary-soft), var(--bt-primary-tint));
  color: var(--bt-primary-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
  flex-shrink: 0; overflow: hidden;
}
.bt-item__avatar img { width: 100%; height: 100%; object-fit: cover; }
.bt-item__body { flex: 1; min-width: 0; }
.bt-item__name { font-size: 14px; font-weight: 700; color: var(--bt-text); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-item.is-active .bt-item__name { color: var(--bt-primary-dark); }
.bt-item__meta { font-size: 12px; color: var(--bt-muted); margin-top: 2px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-item__side { margin-left: auto; }

/* ---------- Search input ---------- */

.bt-search {
  position: relative;
  width: 100%;
}
.bt-search__input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--bt-border-strong);
  border-radius: var(--bt-radius-sm);
  font-size: 14px;
  font-family: var(--bt-font);
  color: var(--bt-text);
  background: var(--bt-surface-alt);
  transition: background .12s, border-color .12s, box-shadow .12s;
  -webkit-appearance: none;
}
.bt-search__input:focus {
  outline: 0;
  background: var(--bt-surface);
  border-color: var(--bt-primary);
  box-shadow: 0 0 0 3px var(--bt-primary-tint);
}
.bt-search__icon {
  position: absolute;
  left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--bt-muted);
  pointer-events: none;
  width: 16px; height: 16px;
}

/* ---------- Filtres (barre de chips) ---------- */

.bt-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------- Form ---------- */

.bt-field { display: block; margin-bottom: 14px; }
.bt-field__label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--bt-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.bt-input, .bt-select, .bt-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--bt-border-strong);
  border-radius: var(--bt-radius-sm);
  font-size: 15px;
  font-family: var(--bt-font);
  color: var(--bt-text);
  background: var(--bt-surface);
  transition: border-color .12s, box-shadow .12s;
  -webkit-appearance: none;
  appearance: none;
}
.bt-input:focus, .bt-select:focus, .bt-textarea:focus {
  outline: 0;
  border-color: var(--bt-primary);
  box-shadow: 0 0 0 3px var(--bt-primary-tint);
}
.bt-textarea { min-height: 88px; resize: vertical; }
.bt-field__hint { margin-top: 6px; font-size: 12.5px; color: var(--bt-muted); line-height: 1.4; }
.bt-field__hint code { padding: 1px 6px; border-radius: 4px; background: var(--bt-surface-alt); font-family: var(--bt-font-mono); font-size: 12px; color: var(--bt-text-soft); }
.bt-field__row { display: flex; gap: 10px; align-items: flex-end; }
.bt-field__row .bt-field { flex: 1; margin: 0; }

/* ---------- Table ---------- */

.bt-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bt-surface);
}
.bt-table th, .bt-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--bt-border);
  font-size: 13.5px;
  color: var(--bt-text);
}
.bt-table th {
  background: var(--bt-surface-alt);
  color: var(--bt-muted);
  font-weight: 800;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.bt-table tbody tr:last-child td { border-bottom: none; }
.bt-table tbody tr:hover { background: var(--bt-surface-alt); }

/* ---------- Section (bloc titre + contenu dans une page config) ---------- */

.bt-section {
  margin-bottom: 24px;
}
.bt-section__title {
  font-size: 15px;
  font-weight: 800;
  color: var(--bt-text);
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bt-section__sub {
  color: var(--bt-muted);
  font-size: 13px;
  margin: 0 0 14px;
  line-height: 1.5;
}

/* ---------- Alerts ---------- */

.bt-alert {
  padding: 12px 16px;
  border-radius: var(--bt-radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  line-height: 1.5;
  margin-bottom: 14px;
}
.bt-alert--success { background: var(--bt-success-soft); color: var(--bt-success); border-color: rgba(47,107,80,0.18); }
.bt-alert--warn    { background: var(--bt-warn-soft);    color: var(--bt-warn);    border-color: rgba(165,104,10,0.18); }
.bt-alert--danger  { background: var(--bt-danger-soft);  color: var(--bt-danger);  border-color: rgba(184,64,47,0.18); }
.bt-alert--info    { background: var(--bt-info-soft);    color: var(--bt-info);    border-color: rgba(42,78,112,0.18); }

/* ---------- Toast flottant (flash messages · auto-dismiss 4.5s) ---------- */

@keyframes btToastIn  { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes btToastOut { from { transform: translateY(0); opacity: 1; }  to { transform: translateY(20px); opacity: 0; } }

.bt-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: min(440px, calc(100vw - 48px));
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: #fff;
  box-shadow: 0 14px 36px rgba(21,40,30,0.18), 0 2px 6px rgba(21,40,30,0.06);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--bt-text, #21382D);
  animation: btToastIn .28s cubic-bezier(.16,1,.3,1);
}
.bt-toast.is-leaving { animation: btToastOut .3s cubic-bezier(.4,0,1,1) forwards; }
.bt-toast__icon {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 900; color: #fff;
}
.bt-toast__msg { flex: 1; min-width: 0; }
.bt-toast__close {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 0;
  background: rgba(21,40,30,0.06);
  color: #607367;
  font-size: 16px; line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background .12s;
}
.bt-toast__close:hover { background: rgba(21,40,30,0.12); }

.bt-toast--success { border-color: rgba(47,107,80,0.18); }
.bt-toast--success .bt-toast__icon { background: var(--bt-success, #2F6B50); }
.bt-toast--danger  { border-color: rgba(184,64,47,0.18); }
.bt-toast--danger  .bt-toast__icon { background: var(--bt-danger, #B54040); }
.bt-toast--warn, .bt-toast--warning { border-color: rgba(165,104,10,0.18); }
.bt-toast--warn .bt-toast__icon, .bt-toast--warning .bt-toast__icon { background: var(--bt-warn, #A5680A); }
.bt-toast--info    { border-color: rgba(42,78,112,0.18); }
.bt-toast--info    .bt-toast__icon { background: var(--bt-info, #2A4E70); }

@media (max-width: 640px) {
  .bt-toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* ---------- Divider ---------- */

.bt-divider { border: 0; border-top: 1px solid var(--bt-border); margin: 20px 0; }

/* ---------- Modal ---------- */

.bt-modal {
  border: 0;
  border-radius: var(--bt-radius-lg);
  padding: 0;
  width: 520px;
  max-width: 94vw;
  box-shadow: var(--bt-shadow-lg);
  background: var(--bt-surface);
  color: var(--bt-text);
}
.bt-modal::backdrop { background: rgba(21,40,30,0.45); backdrop-filter: blur(3px); }
.bt-modal__head {
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--bt-border);
}
.bt-modal__title { margin: 0; font-size: 17px; font-weight: 800; color: var(--bt-text); letter-spacing: -0.01em; }
.bt-modal__sub { margin: 4px 0 0; color: var(--bt-muted); font-size: 13px; font-weight: 500; }
.bt-modal__body { padding: 20px 24px; }
.bt-modal__foot { padding: 14px 24px; border-top: 1px solid var(--bt-border); display: flex; gap: 10px; justify-content: flex-end; background: var(--bt-surface-alt); }

/* ---------- Sidebar app-shell (refonte) ---------- */

.app-shell { display: flex; min-height: 100vh; align-items: stretch; }
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bt-surface);
  border-right: 1px solid var(--bt-border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 10px;
  border-bottom: 1px solid var(--bt-border);
  margin-bottom: 12px;
}
.sidebar-brand img { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; }
.sidebar-brand__name { font-weight: 800; font-size: 16px; letter-spacing: -0.01em; color: var(--bt-text); }
.sidebar-tenant {
  padding: 4px 10px 12px;
  color: var(--bt-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.sidebar-tenant__name {
  color: var(--bt-text);
  text-transform: none;
  letter-spacing: -0.005em;
  font-size: 13.5px;
  font-weight: 800;
  margin-top: 2px;
  display: block;
  line-height: 1.3;
}
.sidebar-tenant select {
  width: 100%;
  margin-top: 6px;
  padding: 6px 8px;
  border: 1px solid var(--bt-border-strong);
  border-radius: var(--bt-radius-sm);
  background: var(--bt-surface-alt);
  color: var(--bt-text);
  font-family: var(--bt-font);
  font-size: 13px;
  font-weight: 700;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23607367' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 26px;
}
.sidebar-section {
  padding: 12px 10px 4px;
  color: var(--bt-muted-soft);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--bt-radius-sm);
  color: var(--bt-text-soft);
  font-weight: 600;
  font-size: 13.5px;
  text-decoration: none;
  transition: background .12s, color .12s;
}
.sidebar-nav a:hover { background: var(--bt-surface-alt); color: var(--bt-text); text-decoration: none; }
.sidebar-nav a.active { background: var(--bt-primary-soft); color: var(--bt-primary-dark); font-weight: 800; }
.sidebar-nav__icon { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer {
  margin-top: auto;
  padding: 10px 8px 4px;
  border-top: 1px solid var(--bt-border);
}
.sidebar-account { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.sidebar-account__avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bt-primary-soft); color: var(--bt-primary-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 11.5px;
  flex-shrink: 0;
}
.sidebar-account__name { font-size: 13px; font-weight: 700; color: var(--bt-text); line-height: 1.2; }
.sidebar-account__logout { color: var(--bt-muted); font-size: 11.5px; font-weight: 600; margin-top: 1px; text-decoration: none; }
.sidebar-account__logout:hover { color: var(--bt-danger); }

.app-main {
  flex: 1;
  min-width: 0;
  background: var(--bt-bg);
  background-image: radial-gradient(circle at top left, rgba(61,96,76,0.05), transparent 40%);
}

/* ---------- Responsive ---------- */
/* ---------- Mobile topbar + sidebar drawer · cachés en desktop ---------- */
.mobile-topbar { display: none; }
.sidebar-close { display: none; }
.sidebar-overlay { display: none; }

@media (max-width: 900px) {
  /* Topbar mobile fixe · toujours accessible pour rouvrir le menu. */
  .mobile-topbar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    background: var(--bt-surface);
    border-bottom: 1px solid var(--bt-border);
    position: sticky; top: 0; z-index: 40;
  }
  .mobile-topbar__logo { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; }
  .mobile-topbar__name { font-weight: 800; font-size: 15px; color: var(--bt-text); letter-spacing: -0.01em; }
  .mobile-topbar__burger {
    margin-left: auto; background: transparent; border: 0;
    color: var(--bt-text); padding: 6px; cursor: pointer;
    display: flex; align-items: center;
  }
  .app-shell { flex-direction: column; }
  /* Sidebar devient un drawer coulissant depuis la gauche · caché par défaut. */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 82%; max-width: 320px;
    height: 100vh;
    z-index: 60;
    padding: 18px 12px;
    flex-direction: column;
    gap: 0;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    border-right: 1px solid var(--bt-border);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar.is-open { transform: translateX(0); }
  /* Overlay noir semi-transparent · absorbe les taps hors drawer pour fermer. */
  .sidebar-overlay {
    display: block;
    position: fixed; inset: 0;
    background: rgba(15, 30, 22, 0.5);
    z-index: 50;
    opacity: 0; pointer-events: none;
    transition: opacity .22s ease;
  }
  .sidebar-overlay.is-visible { opacity: 1; pointer-events: auto; }
  .sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 0 4px 12px;
    border-bottom: 1px solid var(--bt-border);
    margin-bottom: 12px;
  }
  .sidebar-close {
    display: inline-flex; align-items: center; justify-content: center;
    margin-left: auto;
    width: 32px; height: 32px;
    background: transparent; border: 0; color: var(--bt-muted);
    font-size: 18px; cursor: pointer; border-radius: 6px;
  }
  .sidebar-close:hover { background: var(--bt-surface-alt); color: var(--bt-text); }
  .sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
  .sidebar-nav a { white-space: normal; padding: 10px 12px; font-size: 14px; }
  .sidebar-footer { margin-top: auto; }
  .bt-page { padding: 18px 14px 40px; }
  .bt-page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .bt-page-head__actions { width: 100%; }
  .bt-page-head__actions .bt-btn { width: 100%; justify-content: center; }
  .bt-page-head__title h1 { font-size: 20px; }
  .bt-page-head__sub { font-size: 13px; }
  /* KPIs · 2 par ligne au lieu de "auto-fit 180px" qui peut pousser à 3+
     et créer un scroll horizontal sur petits écrans (~350-400px). */
  .bt-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
  .bt-kpi { padding: 12px 14px; }
  .bt-kpi__label { font-size: 10.5px; }
  .bt-kpi__value { font-size: 20px; }
  .bt-kpi__sub { font-size: 11.5px; }
  /* Tables · scroll horizontal contenu au lieu de casser le layout page. */
  .bt-card__body { padding: 14px; }
  .bt-card { border-radius: 12px; }
  .bt-table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .bt-table thead th { font-size: 11px; }
  .bt-table td { font-size: 13px; }
}

/* ---------- Mobile étroit (téléphone en portrait) ---------- */
@media (max-width: 480px) {
  /* Sous 480px, 1 KPI par ligne · les valeurs restent lisibles à pleine largeur. */
  .bt-kpis { grid-template-columns: 1fr; }
  .bt-page-head__title h1 { font-size: 18px; }
  .bt-card__head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .bt-card__head .bt-btn { width: 100%; justify-content: center; }
}

/* ---------- Utilitaires ---------- */
.bt-hidden { display: none !important; }
.bt-flex { display: flex; }
.bt-gap-2 { gap: 8px; }
.bt-gap-3 { gap: 12px; }
.bt-mt-2 { margin-top: 8px; }
.bt-mt-4 { margin-top: 16px; }
.bt-mt-6 { margin-top: 24px; }
.bt-align-center { align-items: center; }
.bt-justify-between { justify-content: space-between; }
.bt-text-muted { color: var(--bt-muted); }
