/* ============================================================
   AO GroupeBurnel — couche applicative au-dessus de PERRIN UI.

   perrin-ui.css est le design system (kit fourni, ne pas modifier).
   Ce fichier ajoute uniquement ce que le kit ne couvre pas :
     1. alias de tokens hérités (styles inline des templates)
     2. coquille applicative (sidebar, topbar, page)
     3. composants applicatifs (formulaires, toasts, kanban,
        calendrier, contacts, bibliothèque, paramètres…)
     4. extensions dans l'esprit du kit (pastilles de statut AO,
        sparklines KPI, état vide, overlay de chargement)
   ============================================================ */

:root {
  /* —— Alias hérités : les templates référencent encore ces noms
        en styles inline ; ils pointent sur les tokens du kit. —— */
  --surface: var(--card);
  --surface-2: #f6f8fa;
  --surface-3: #eef0f3;
  --ink-2: var(--gray);
  --ink-3: var(--muted);
  --ink-4: #9aa1a8;
  --line-2: #f0f2f5;
  --brand: var(--blue-d);
  --brand-2: var(--blue);
  --brand-ink: #0f7ba1;
  --brand-wash: #e2f4fc;
  --accent: var(--orange);
  --accent-2: #c2480c;
  --accent-wash: #fde7da;
  --st-veille: #727a82;
  --st-analyse: #1187b8;
  --st-redaction: #b07a12;
  --st-soumis: #5e35b1;
  --st-gagne: #1f9d57;
  --st-perdu: #a51f17;
  --st-abandonne: #75786d;
  --radius-sm: 7px;
  --radius-lg: var(--radius);
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-2: var(--shadow);
  --font-sans: var(--font-body);
  --font-mono: var(--font-body);
  --focus-ring: rgba(55, 190, 236, 0.18);
}

html, body { height: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* Les templates posent la police display en inline avec l'ancien
   poids serif (500) ; Archivo demande du gras pour le rendu du kit. */
[style*="var(--font-display)"][style*="font-weight:500"],
[style*="var(--font-display)"][style*="font-weight: 500"] { font-weight: 700 !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(26, 26, 23, 0.15); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(26, 26, 23, 0.3); }

/* ===== Coquille applicative ===== */
.app {
  display: grid;
  grid-template-columns: 256px 1fr;
  height: 100vh;
  min-height: 100vh;
}

.sidebar {
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.brand {
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  align-items: center;
}
.brand-mark {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  display: flex; gap: 4px; align-items: baseline;
}
.brand-name .b-cyan { color: var(--blue-d); }
.brand-name .b-orange { color: var(--orange); }
.brand-sub {
  font-family: var(--font-display);
  font-size: 10px;
  color: var(--orange);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
}

.ent-switcher-wrap { margin: 14px 14px 0; }
.ent-switcher {
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  background: var(--card);
  transition: background 0.15s, border-color 0.15s;
}
.ent-switcher:hover { background: var(--surface-2); border-color: #cfd6dd; }
.ent-chev { transition: transform 0.15s; }
.ent-switcher-wrap.open .ent-chev { transform: rotate(180deg); }
.ent-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--blue-d);
  flex-shrink: 0;
}
.ent-dot.go { background: var(--orange); }
.ent-dot.all { background: linear-gradient(90deg, var(--blue-d) 0 50%, var(--orange) 50% 100%); }
.ent-label { font-size: 12.5px; font-weight: 600; flex: 1; }
.ent-count { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }

.ent-menu {
  padding: 6px 10px 10px;
  border-bottom: 1px solid var(--line);
  display: none;
}
.ent-menu .nav-section { padding: 10px 4px 6px; }
.ent-menu .nav-item { font-size: 12.5px; padding: 7px 10px; gap: 10px; }

.nav {
  padding: 14px 10px;
  flex: 1;
  overflow-y: auto;
}
.nav-section {
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 800;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 12px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--gray);
  cursor: pointer;
  position: relative;
  font-weight: 600;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active {
  background: var(--dark);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--orange);
}
.nav-item.active:hover { background: var(--dark); }
.nav-item svg { width: 16px; height: 16px; stroke-width: 1.75; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: var(--orange);
  padding: 1px 8px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}

.user-card {
  margin: 0 12px 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex; flex-direction: column; gap: 10px;
}
.user-card-row { display: flex; align-items: center; gap: 10px; }
.user-card .logout {
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 12px;
  font-weight: 600;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.user-card .logout:hover { color: var(--orange); background: var(--surface-2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--blue-d);
  color: white;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.user-name { font-size: 12.5px; font-weight: 700; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Topbar ===== */
.main {
  display: flex; flex-direction: column;
  min-width: 0;
  background: var(--bg);
}
.topbar {
  height: 60px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 18px;
}
.breadcrumbs {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.breadcrumbs strong { color: var(--ink); font-weight: 700; }
.breadcrumbs span.sep { opacity: 0.4; }
.topbar .search { flex: 1; margin-left: auto; }
.topbar .search input { padding-top: 9px; padding-bottom: 9px; box-shadow: none; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 9px; border: 1px solid transparent;
  color: var(--gray); cursor: pointer; background: transparent;
  position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn .dot {
  position: absolute; top: 7px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--orange); border: 2px solid var(--card);
}

.content { flex: 1; overflow: auto; }
.page { padding: 26px 28px 60px; max-width: 1500px; margin: 0 auto; }

/* ===== En-tête de page (header du kit) ===== */
.page-head {
  margin-bottom: 24px;
  display: flex; align-items: flex-end; gap: 24px;
  border-bottom: 3px solid var(--dark);
  padding-bottom: 18px;
}
.page-head .title-group { flex: 1; min-width: 0; }
.eyebrow {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 10.5px;
  color: var(--orange);
}
.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin: 2px 0 0;
  color: var(--dark);
}
.page-title em { font-style: normal; font-weight: 800; color: var(--orange); }
.page-sub { font-size: 12.5px; font-weight: 500; color: var(--muted); margin-top: 5px; }

/* ===== Cartes (recette .panel du kit, avec en-tête structuré) ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head {
  padding: 15px 20px;
  border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 12px;
}
.card-title {
  font-family: var(--font-display);
  font-size: 12.5px; font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--dark);
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0;
}
.card-title::before {
  content: "";
  width: 8px; height: 8px; border-radius: 2px;
  background: var(--orange);
  flex: none;
}
.card-title + .card-sub { font-size: 11.5px; color: var(--muted); margin-left: 8px; font-weight: 600; }
.card-actions { margin-left: auto; display: flex; gap: 6px; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }

/* ===== Pastilles de statut AO (extension .st-pill du kit) ===== */
.st-pill.st-veille { background: #eef0f3; color: var(--gray); }
.st-pill.st-analyse { background: #e2f4fc; color: #1187b8; }
.st-pill.st-redaction { background: #fdf0d9; color: #b07a12; }
.st-pill.st-soumis { background: #ede7f6; color: #5e35b1; }
.st-pill.st-gagne { background: #e8f8ee; color: #1f9d57; }
.st-pill.st-perdu { background: #fbe0de; color: #a51f17; }
.st-pill.st-abandonne { background: #f3f5f7; color: var(--muted); }
.st-pill.st-urgent { background: #fde7da; color: #c2480c; }

/* Héritage : anciens noms .pill-* rendus sur la même recette,
   pour les templates pas encore réécrits sur .st-pill. */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 6px;
  line-height: 1.5;
  white-space: nowrap;
}
.pill .d { display: none; }
.pill-veille { color: var(--gray); background: #eef0f3; }
.pill-analyse { color: #1187b8; background: #e2f4fc; }
.pill-redaction { color: #b07a12; background: #fdf0d9; }
.pill-soumis { color: #5e35b1; background: #ede7f6; }
.pill-gagne { color: #1f9d57; background: #e8f8ee; }
.pill-perdu { color: #a51f17; background: #fbe0de; }
.pill-abandonne { color: var(--muted); background: #f3f5f7; }
.pill-urgent { color: #c2480c; background: #fde7da; }
.pill-outline { border: 1px solid var(--line); color: var(--gray); background: transparent; }

/* ===== KPI : extensions du kit ===== */
.kpi .note .up { color: var(--st-gagne); font-weight: 800; }
.kpi .note .down { color: var(--st-perdu); font-weight: 800; }
.kpi-spark {
  position: absolute;
  right: 16px; bottom: 16px;
  width: 70px; height: 28px;
  opacity: 0.9;
}

/* Héritage : ancienne structure .kpi-label/.kpi-value/.kpi-trend
   rendue sur la recette .lab/.val/.note du kit. */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.kpi-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; color: var(--muted);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.kpi-label svg { width: 13px; height: 13px; }
.kpi-value {
  font-family: var(--font-display);
  font-size: 27px; font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-top: 6px;
  color: var(--dark);
  font-variant-numeric: tabular-nums;
}
.kpi-value .unit { font-family: var(--font-body); font-size: 14px; font-weight: 700; color: var(--muted); margin-left: 4px; }
.kpi-trend { font-size: 11.5px; color: var(--muted); margin-top: 4px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi-trend .up { color: var(--st-gagne); font-weight: 800; }
.kpi-trend .down { color: var(--st-perdu); font-weight: 800; }

/* ===== Tableaux : héritage table.data == recette table.ds du kit ===== */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data thead th {
  position: sticky; top: 0; z-index: 4;
  background: #fafbfc;
  box-shadow: inset 0 -1.5px 0 var(--line);
  text-align: left;
  padding: 11px 14px;
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gray);
  white-space: nowrap;
}
table.data tbody td { padding: 10px 14px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
table.data tbody tr { cursor: pointer; transition: background 0.1s; }
table.data tbody tr:hover { background: #f9fbfd; }
table.data tbody tr:last-child td { border-bottom: none; }
table.ds tbody td { vertical-align: middle; }
.mono { font-weight: 600; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ===== Chips : héritage .chip.active == .chip.on du kit ===== */
.chip { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.chip.active { background: var(--dark); border-color: var(--dark); color: #fff; }
.chip .n { opacity: 0.6; font-size: 11px; font-variant-numeric: tabular-nums; }
.chip.on .n, .chip.active .n { opacity: 0.85; }
.chip-row { display: flex; align-items: center; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }

/* ===== Boutons : extensions du kit ===== */
.btn.accent { background: var(--orange); color: #fff; }
.btn.accent:hover { background: #c2480c; }
.btn.sm { padding: 6px 11px; font-size: 11px; border-radius: 7px; }

/* ===== Formulaires ===== */
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field > label {
  font-size: 11px; font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-field > input,
.form-field > select,
.form-field > textarea {
  height: 38px; padding: 0 12px;
  border-radius: 9px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-field > textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
.form-field > input::placeholder,
.form-field > textarea::placeholder { color: #9aa1a8; font-weight: 500; }
.form-field > input:focus,
.form-field > select:focus,
.form-field > textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px var(--focus-ring); }
.form-grid { display: grid; gap: 16px 20px; grid-template-columns: 1fr 1fr; }
.form-grid.full > .form-field { grid-column: 1 / -1; }

/* ===== Utilitaires ===== */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.stack-2 > * + * { margin-top: 8px; }
.stack-4 > * + * { margin-top: 16px; }
.stack-6 > * + * { margin-top: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-12 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
hr.rule { border: 0; border-top: 1px solid var(--line-2); margin: 16px 0; }
.empty { padding: 50px; text-align: center; color: var(--muted); font-weight: 600; }

/* ===== Toasts ===== */
.toasts {
  position: fixed; top: 16px; right: 16px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
  max-width: 380px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 600;
  animation: tween-in 0.25s ease-out;
}
.toast.success { border-color: #b7e2c6; background: #e8f8ee; color: #1f9d57; }
.toast.error   { border-color: #f5c6bf; background: #fdecea; color: #a51f17; }
.toast .close { margin-left: auto; cursor: pointer; color: var(--muted); }
@keyframes tween-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

/* ===== Entrée de page ===== */
.page > * { animation: fade-up 0.4s ease-out both; }
.page > *:nth-child(1) { animation-delay: 0.02s; }
.page > *:nth-child(2) { animation-delay: 0.06s; }
.page > *:nth-child(3) { animation-delay: 0.1s; }
.page > *:nth-child(4) { animation-delay: 0.14s; }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; }}

/* ===== Overlay de chargement (esprit kit : loader orange) ===== */
.loader {
  width: 42px; height: 42px;
  border: 4px solid #dfe4ea;
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Onglets soulignés (sous-navigation de page) ===== */
.param-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
.param-tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  background: transparent;
  border-left: none; border-right: none; border-top: none;
  font-family: inherit;
}
.param-tab:hover { color: var(--ink); }
.param-tab.active { color: var(--ink); border-bottom-color: var(--orange); }

/* ===== Calendrier ===== */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
}
.cal-dow {
  padding: 10px 12px;
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted);
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
}
.cal-cell {
  min-height: 118px;
  padding: 8px 9px;
  border-right: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-2);
  position: relative;
  display: flex; flex-direction: column; gap: 4px;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.out { background: var(--surface-2); color: var(--ink-4); }
.cal-cell.today .cal-day {
  color: white; background: var(--blue-d);
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
}
.cal-day { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--gray); }
.cal-evt {
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-left: 2px solid;
  cursor: pointer;
  background: var(--surface-2);
  text-decoration: none;
}
.cal-evt.limite    { border-color: var(--orange); color: var(--orange); background: #fde7da; font-weight: 700; }
.cal-evt.visite    { border-color: var(--blue-d); color: var(--blue-d); background: #e2f4fc; }
.cal-evt.commission{ border-color: #5e35b1; color: #5e35b1; background: #ede7f6; }
.cal-evt.question  { border-color: #b07a12; color: #b07a12; background: #fdf0d9; }
.cal-evt.rdv       { border-color: var(--muted); color: var(--gray); }

/* ===== Contacts ===== */
.contacts-layout { display: grid; grid-template-columns: 1fr 420px; gap: 20px; align-items: flex-start; }
.contact-row {
  display: grid;
  grid-template-columns: 36px 1.4fr 1fr 1fr 70px 80px;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-2);
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
  color: inherit;
}
.contact-row:hover { background: #f9fbfd; }
.contact-row.active { background: #e2f4fc; }
.contact-row .cnom { font-size: 13px; font-weight: 700; color: var(--ink); }
.contact-row .crole { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.contact-row .corg { font-size: 12.5px; color: var(--gray); }
.contact-row .cville { font-size: 12px; color: var(--muted); }
.contact-row .cnum { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; color: var(--gray); }
.ctag {
  display: inline-block;
  font-size: 10px; font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ctag-acheteur     { color: #5e35b1; background: #ede7f6; }
.ctag-architecte   { color: var(--blue-d); background: #e2f4fc; }
.ctag-soustraitant { color: #b07a12; background: #fdf0d9; }
.ctag-autre        { color: var(--muted); background: var(--surface-2); }

.contact-panel {
  position: sticky; top: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.contact-panel .ch {
  padding: 24px 22px 20px;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
}
.contact-panel .cbig {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--ink);
}
.contact-panel .ckv {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 10px;
  padding: 12px 22px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--line-2);
}
.contact-panel .ckv .k { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.contact-panel .ckv .v { color: var(--ink); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.contact-panel .ckv .v.sans { font-weight: 500; }

/* ===== Bibliothèque ===== */
.biblio-cat {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: inherit;
}
.biblio-cat:hover { border-color: #cfd6dd; transform: translateY(-1px); box-shadow: var(--shadow); }
.biblio-cat.active { border-color: #f7d6c6; }
.biblio-cat .ic {
  width: 36px; height: 36px; border-radius: 9px;
  display: grid; place-items: center;
  background: #f0f2f5; color: var(--gray);
  flex-shrink: 0;
  transition: 0.15s;
}
.biblio-cat.active .ic { background: var(--orange); color: white; }
.biblio-cat .lbl { font-size: 13px; font-weight: 700; color: var(--ink); }
.biblio-cat .n { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); margin-left: auto; }

.doc-row {
  display: grid;
  grid-template-columns: 44px 1.6fr 110px 90px 90px 90px 70px 40px;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
  color: inherit;
}
.doc-row:hover { background: #f9fbfd; }
.doc-type {
  width: 40px; height: 48px;
  border-radius: 4px;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 800;
  color: white;
  position: relative;
}
.doc-type.PDF  { background: #b3261e; }
.doc-type.DOCX { background: var(--blue-d); }
.doc-type.DOC  { background: var(--blue-d); }
.doc-type.XLSX { background: #1f9d57; }
.doc-type.XLS  { background: #1f9d57; }
.doc-type.TXT,
.doc-type.AUTRE { background: var(--muted); }
.doc-type::after {
  content: ""; position: absolute; top: 0; right: 0;
  border-left: 10px solid transparent;
  border-top: 10px solid rgba(0, 0, 0, 0.15);
}
.doc-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.doc-tags { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.doc-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line-2);
}

/* ===== Paramètres ===== */
.weight-row {
  display: grid;
  grid-template-columns: 1.5fr 3fr 80px;
  gap: 20px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--line-2);
}
.weight-row .lbl { font-size: 13px; font-weight: 700; color: var(--ink); }
.weight-row .desc { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.weight-bar {
  height: 8px;
  background: #f0f2f5;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.weight-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--blue-d));
  transition: width 0.2s;
}
.weight-val {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-align: right;
}

.integration-row {
  display: grid;
  grid-template-columns: 48px 1.5fr 1fr 100px;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-2);
}
.integration-logo {
  width: 44px; height: 44px;
  border-radius: 11px;
  background: #f0f2f5;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--gray);
  border: 1px solid var(--line);
}
.switch {
  width: 38px; height: 22px;
  background: var(--line);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
  border: none;
  padding: 0;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: white; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: left 0.15s;
}
.switch.on { background: var(--blue-d); }
.switch.on::after { left: 18px; }

/* ===== Kanban ===== */
.kanban-col {
  background: #eef2f6;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}
.kanban-col-head {
  padding: 6px 8px 12px;
  display: flex; align-items: center; gap: 8px;
}
.kanban-col-head .t { font-family: var(--font-display); font-size: 13px; font-weight: 800; color: var(--dark); }
.kanban-col-head .n {
  font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums;
  color: var(--gray); background: var(--card);
  padding: 1px 8px; border-radius: 20px; border: 1px solid var(--line);
}
.kanban-col-head .tot { margin-left: auto; font-family: var(--font-display); font-size: 11.5px; font-weight: 800; color: var(--muted); }
.kanban-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  cursor: grab;
  box-shadow: var(--shadow-1);
  transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
}
.kanban-card:hover { border-color: #cfd6dd; transform: translateY(-1px); box-shadow: var(--shadow); }
.kanban-add {
  padding: 10px;
  border: 1.5px dashed #cfd6dd;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: flex; align-items: center; gap: 6px; justify-content: center;
  width: 100%;
  margin-top: 8px;
}
.kanban-add:hover { border-color: var(--orange); color: var(--orange); }

/* ===== Responsive ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 40;
}
.sidebar-toggle {
  display: none;
  width: 36px; height: 36px;
  border-radius: 9px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--gray);
  cursor: pointer;
  place-items: center;
  margin-right: 4px;
}

html, body { overflow-x: hidden; max-width: 100vw; }
.app { max-width: 100vw; overflow-x: hidden; }
.main { min-width: 0; max-width: 100%; overflow-x: hidden; }
.content { min-width: 0; max-width: 100%; }
.page { box-sizing: border-box; min-width: 0; max-width: 100%; }
img, svg, video { max-width: 100%; }

.card .card-body.flush { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card .table-scroll,
.tbl-wrap .table-scroll { -webkit-overflow-scrolling: touch; }

@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 280px; max-width: 86vw; z-index: 50;
    transform: translateX(-100%); transition: transform 0.25s;
    box-shadow: 2px 0 24px rgba(0, 0, 0, 0.08);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .sidebar-toggle { display: grid; }
  .page { padding: 22px 18px 60px; }
  .contacts-layout { grid-template-columns: 1fr 360px; gap: 16px; }
  .cal-layout { grid-template-columns: 1fr 320px !important; }
}

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-12 { grid-template-columns: 1fr; }
  .biblio-layout { grid-template-columns: 1fr !important; }
  .cal-layout { grid-template-columns: 1fr !important; }
  .cal-layout > [style*="grid-column:2"] {
    grid-column: 1 !important;
    grid-row: auto !important;
    position: static !important;
  }
  .contacts-layout { grid-template-columns: 1fr; }
  .contact-panel { position: static; }
}

@media (max-width: 768px) {
  .topbar { padding: 0 14px; gap: 10px; height: 56px; }
  .breadcrumbs { font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .search { max-width: 100%; }
  .top-actions { gap: 4px; }
  .page { padding: 18px 14px 56px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 22px; }
  .page-head .row { flex-wrap: wrap; }
  .page-title { font-size: 22px; line-height: 1.15; }
  .kpi .val { font-size: 23px; }
  .kpi-value { font-size: 23px; }
  .kpi-spark { width: 56px; right: 12px; bottom: 12px; }
  .form-grid { grid-template-columns: 1fr; gap: 14px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 12px; }
  .card-head { padding: 14px 16px; gap: 10px; flex-wrap: wrap; }
  .card-body { padding: 16px; }
  table.data, table.ds { font-size: 12.5px; min-width: 540px; }
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .tbl-wrap { overflow-x: auto; }
  .cal-cell { min-height: 78px; padding: 6px 6px; }
  .cal-dow { padding: 7px 6px; font-size: 10px; }
  .cal-day { font-size: 11px; }
  .cal-evt { font-size: 10px; padding: 2px 4px; }
  .contact-row,
  .contact-row-head {
    grid-template-columns: 32px 1.4fr 1fr 80px;
    gap: 10px;
    padding: 12px 12px;
  }
  .contact-row > :nth-child(5),
  .contact-row > :nth-child(6),
  .contact-row-head > :nth-child(5),
  .contact-row-head > :nth-child(6) { display: none; }
  .param-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .param-tab { white-space: nowrap; padding: 10px 12px; }
  .weight-row { grid-template-columns: 1fr 70px; gap: 10px 14px; row-gap: 6px; }
  .weight-row .desc { grid-column: 1 / -1; }
  .weight-bar { grid-column: 1 / -1; }
  .integration-row { grid-template-columns: 44px 1fr auto; gap: 8px 12px; padding: 14px; }
  .integration-row > :nth-child(3) { grid-column: 1 / -1; padding-left: 56px; }
  .contact-panel .ckv { grid-template-columns: 70px 1fr; padding: 10px 16px; }
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns:repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  [style*="grid-template-columns:repeat(6,1fr)"],
  [style*="grid-template-columns: repeat(6, 1fr)"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  [style*="grid-template-columns:repeat(5,1fr)"],
  [style*="grid-template-columns: repeat(5, 1fr)"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  [style*="grid-template-columns:repeat(3,1fr)"],
  [style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 640px) {
  .topbar { gap: 8px; }
  .breadcrumbs { display: none; }
  .page { padding: 14px 12px 48px; }
  .page-title { font-size: 20px; }
  .page-head .row .btn { flex: 1 1 auto; justify-content: center; }
  .toasts { top: 8px; right: 8px; left: 8px; max-width: none; }
  .kpi-grid { grid-template-columns: 1fr; }
  .chip-row { gap: 5px; margin-bottom: 12px; }
  .cal-grid { font-size: 11px; }
  .cal-cell { min-height: 62px; padding: 4px 4px; }
  .cal-dow { font-size: 9.5px; padding: 5px 3px; letter-spacing: 0.04em; }
  .contact-row,
  .contact-row-head {
    grid-template-columns: 28px 1fr 70px;
    gap: 8px;
    padding: 10px 10px;
  }
  .contact-row > :nth-child(3),
  .contact-row-head > :nth-child(3) { display: none; }
  .kpi-value, .kpi .val,
  .page-title,
  .card-title,
  .doc-title,
  .cnom { overflow-wrap: break-word; }
  table.data, table.ds { word-break: normal; overflow-wrap: normal; }
  table.data thead th, table.ds thead th { white-space: nowrap; }
  [style*="grid-template-columns:1fr auto"],
  [style*="grid-template-columns: 1fr auto"],
  [style*="grid-template-columns:2fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns:1fr 2fr"],
  [style*="grid-template-columns: 1fr 2fr"],
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:repeat(2,1fr)"],
  [style*="grid-template-columns: repeat(2, 1fr)"],
  [style*="grid-template-columns:repeat(3,1fr)"],
  [style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: 1fr !important;
  }
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns:repeat(4, 1fr)"],
  [style*="grid-template-columns:repeat(6,1fr)"],
  [style*="grid-template-columns: repeat(6, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 480px) {
  .topbar { padding: 0 10px; }
  .topbar .search { display: none; }
  .page { padding: 12px 10px 40px; }
  .page-title { font-size: 19px; }
}

@supports (padding: max(0px)) {
  .topbar {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .page {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
}
