/* ════════════════════════════════════════════════════════════
   MYKOLLECTOR® WORKFLOW OS CSS GLOBAL
   workflow.mykollector.com v1.1
   Mode CLAIR Tokens design officiels
════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── TOKENS DESIGN ── */
:root {
  --gold: #c8a84b;
  --gold2: #e8c870;
  --blue: #0e3e5f;
  --blue2: #1a5580;
  --ok: #157a50;
  --live: #c0392b;
  --warn: #8a6a00;

  --bg: #f0f4f8;
  --bg2: #ffffff;
  --bg3: #e4eaf1;
  --bord: rgba(201,168,76,.25);
  --bord2: rgba(14,31,46,.1);
  --text: #0e1f2e;
  --dim: rgba(14,31,46,.48);
  --card: #ffffff;
  --sidebar: #0e1f2e;
  --violet: #7c5cbf;
  --violet2: #6b3fb5;
  --green: #16a368;
  --green2: #1db97a;

  --sidebar-w: 260px;
  --header-h: 60px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Montserrat', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ══ LAYOUT PRINCIPAL ══ */
#app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--sidebar);
  border-bottom: 1px solid rgba(201,168,76,.2);
  display: flex;
  align-items: center;
  padding: 0 20px 0 0;
  z-index: 1000;
  gap: 0;
}

#app-header .header-logo {
  width: var(--sidebar-w);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,.06);
}

#app-header .header-logo img {
  width: 32px; height: 32px; object-fit: contain;
}

#app-header .header-logo .brand-name {
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .1em;
  color: #fff;
}

#app-header .header-logo .brand-sub {
  font-size: .42rem;
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 1px;
}

#app-header .header-center {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
}

#app-header .header-title {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
}

#app-header .header-module-name {
  font-size: .8rem;
  font-weight: 700;
  color: rgba(255,255,255,.85);
}

#app-header .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.notif-btn {
  position: relative;
  width: 36px; height: 36px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .2s;
  color: rgba(255,255,255,.7);
}
.notif-btn:hover { background: rgba(255,255,255,.14); }
.notif-btn svg { width: 16px; height: 16px; }

/* Icônes d'accès rapide du header (mail, todo, calendrier, IA, config).
   Même gabarit que .notif-btn pour une barre homogène. */
.hdr-ico {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .2s;
  color: rgba(255,255,255,.7);
  padding: 0;
}
.hdr-ico:hover { background: rgba(255,255,255,.14); color: #fff; }
.hdr-ico svg { width: 16px; height: 16px; }
/* Sur très petit écran, on masque les raccouris (la sidebar reste l'accès). */
@media (max-width: 640px) {
  .hdr-ico { display: none !important; }
}
.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--live);
  color: #fff;
  font-size: .42rem;
  font-weight: 800;
  min-width: 16px; height: 16px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--sidebar);
  padding: 0 3px;
}

.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  padding: 6px 14px 6px 8px;
  cursor: pointer;
  transition: all .2s;
  position: relative;
}
.user-chip:hover { background: rgba(255,255,255,.14); }
.user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  display: flex; align-items: center; justify-content: center;
  font-size: .6rem; font-weight: 800; color: #07111c;
}
.user-name {
  font-size: .72rem; font-weight: 700;
  color: rgba(255,255,255,.85);
}
.user-role {
  font-size: .52rem; font-weight: 600;
  color: var(--gold);
}

.logout-btn {
  width: 36px; height: 36px;
  background: rgba(192,57,43,.15);
  border: 1px solid rgba(192,57,43,.3);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .2s;
  color: #e57373;
}
.logout-btn:hover { background: rgba(192,57,43,.25); }
.logout-btn svg { width: 16px; height: 16px; }

/* ══ SIDEBAR ══ */
#app-sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid rgba(255,255,255,.06);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 900;
  padding-bottom: 20px;
}

#app-sidebar::-webkit-scrollbar { width: 4px; }
#app-sidebar::-webkit-scrollbar-track { background: transparent; }
#app-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.nav-group-label {
  font-size: .44rem;
  font-weight: 700;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: rgba(255,255,255,.22);
  padding: 20px 20px 8px;
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  cursor: pointer;
  transition: all .18s;
  color: rgba(255,255,255,.55);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .03em;
  border-left: 3px solid transparent;
  text-decoration: none;
  position: relative;
}
.nav-item:hover {
  color: rgba(255,255,255,.85);
  background: rgba(255,255,255,.05);
}
.nav-item.active {
  color: var(--gold);
  background: rgba(201,168,76,.1);
  border-left-color: var(--gold);
}
.nav-item .nav-icon {
  width: 16px; height: 16px;
  opacity: .6;
  flex-shrink: 0;
}
.nav-item.active .nav-icon { opacity: 1; }

/* ── Recherche de module ── */
.nav-search {
  position: relative;
  margin: 14px 16px 6px;
}
.nav-search svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: rgba(255,255,255,.3); pointer-events: none;
}
.nav-search input {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  color: rgba(255,255,255,.9);
  font-size: .72rem;
  padding: 8px 26px 8px 30px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.nav-search input::placeholder { color: rgba(255,255,255,.3); }
.nav-search input:focus { border-color: var(--gold); background: rgba(255,255,255,.09); }
.nav-search #nav-search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: rgba(255,255,255,.4);
  font-size: 1rem; cursor: pointer; line-height: 1; padding: 2px 4px;
}
.nav-search #nav-search-clear:hover { color: rgba(255,255,255,.8); }

.nav-pinned { margin-top: 4px; }

/* ── Groupes repliables (accordéon) ── */
.nav-group { display: block; }
.nav-group-label.is-toggle {
  width: 100%;
  background: none;
  border: none;
  display: flex; align-items: center;
  cursor: pointer;
  /* hérite du look .nav-group-label mais cliquable */
}
.nav-group-label.is-toggle .ngl-text { flex: 1; text-align: left; }
.nav-group-label .ngl-chevron {
  width: 12px; height: 12px; flex: 0 0 auto;
  color: rgba(255,255,255,.3);
  transition: transform .2s ease;
}
.nav-group.collapsed .nav-group-label .ngl-chevron { transform: rotate(-90deg); }
.nav-group-items {
  overflow: hidden;
  max-height: 800px;
  opacity: 1;
  transition: max-height .26s ease, opacity .18s ease;
}
.nav-group.collapsed .nav-group-items {
  max-height: 0; opacity: 0; pointer-events: none;
}
/* Un groupe dont tous les items sont masqués (rôle) se cache entièrement.
   Piloté en JS via la classe .is-empty. */
.nav-group.is-empty { display: none; }

/* Mode recherche : on aplatit l'accordéon, on montre tout ce qui matche. */
#app-sidebar.searching .nav-group-label { display: none; }
#app-sidebar.searching .nav-group-items { max-height: none !important; opacity: 1 !important; pointer-events: auto !important; }
#app-sidebar.searching .nav-item.search-hidden { display: none; }
#app-sidebar.searching .nav-group.no-match { display: none; }
.nav-item .nav-badge {
  margin-left: auto;
  background: rgba(192,57,43,.2);
  border: 1px solid rgba(192,57,43,.3);
  color: #e57373;
  font-size: .44rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
}

/* ══ CONTENU PRINCIPAL ══ */
#app-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
  padding: 28px;
}

/* ══ MODULES ══ */
.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.module-title {
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: .05em;
  color: var(--text);
}
.module-title em { color: var(--gold); font-style: normal; }
.module-subtitle {
  font-size: .64rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--dim);
  margin-top: 3px;
}

/* ══ COMPOSANTS ══ */
/* Boutons */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 24px; border-radius: 50px; border: none; cursor: pointer;
  background: linear-gradient(135deg, #c8a84b, #e8c76a, #c8a84b);
  background-size: 200%;
  font-family: inherit; font-size: .72rem; font-weight: 800;
  letter-spacing: .1em; text-transform: uppercase; color: #07111c;
  box-shadow: 0 4px 20px rgba(150,110,0,.3);
  transition: all .3s; text-decoration: none;
}
.btn-primary:hover { background-position: right; transform: translateY(-1px); box-shadow: 0 6px 28px rgba(150,110,0,.4); }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 50px; cursor: pointer;
  background: var(--bg3); border: 1px solid var(--bord2);
  font-family: inherit; font-size: .7rem; font-weight: 700;
  letter-spacing: .06em; color: var(--dim); transition: all .2s;
}
.btn-secondary:hover { color: var(--text); background: var(--bg2); }

.btn-gold-outline {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 50px; cursor: pointer;
  background: rgba(201,168,76,.08); border: 1px solid rgba(201,168,76,.3);
  font-family: inherit; font-size: .68rem; font-weight: 700;
  letter-spacing: .06em; color: var(--gold); transition: all .2s;
}
.btn-gold-outline:hover { background: rgba(201,168,76,.15); }

.btn-danger {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 50px; cursor: pointer;
  background: rgba(192,57,43,.1); border: 1px solid rgba(192,57,43,.3);
  font-family: inherit; font-size: .68rem; font-weight: 700;
  letter-spacing: .06em; color: var(--live); transition: all .2s;
}
.btn-danger:hover { background: rgba(192,57,43,.18); }

.btn-sm {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 50px; cursor: pointer;
  font-family: inherit; font-size: .62rem; font-weight: 700;
  letter-spacing: .06em; border: none; transition: all .2s;
  background: linear-gradient(135deg, #c8a84b, #e8c76a);
  color: #07111c;
}

.btn-icon {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--bg3); border: 1px solid var(--bord2);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all .2s;
}
.btn-icon:hover { background: var(--bg2); border-color: rgba(201,168,76,.3); }
.btn-icon svg { width: 15px; height: 15px; stroke: var(--dim); fill: none; stroke-width: 2; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--bord2);
  border-radius: 14px;
  padding: 20px;
}
.card-gold {
  background: var(--card);
  border: 1px solid rgba(201,168,76,.2);
  border-left: 3px solid var(--gold);
  border-radius: 14px;
  padding: 20px;
}
.card-live {
  background: var(--card);
  border: 1px solid rgba(192,57,43,.2);
  border-left: 3px solid var(--live);
  border-radius: 14px;
  padding: 20px;
}
.card-warn {
  background: var(--card);
  border: 1px solid rgba(240,180,41,.2);
  border-left: 3px solid #d4a017;
  border-radius: 14px;
  padding: 20px;
}
.card-ok {
  background: var(--card);
  border: 1px solid rgba(22,163,104,.2);
  border-left: 3px solid var(--ok);
  border-radius: 14px;
  padding: 20px;
}

/* KPI stat cards */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi-card {
  background: var(--card);
  border: 1px solid var(--bord2);
  border-radius: 14px;
  padding: 18px 16px;
  transition: box-shadow .2s;
}
.kpi-card:hover { box-shadow: 0 4px 20px rgba(14,31,46,.08); }
.kpi-value {
  font-size: 1.9rem; font-weight: 900;
  letter-spacing: .03em; color: var(--gold);
  line-height: 1;
}
.kpi-label {
  font-size: .52rem; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--dim); margin-top: 6px;
}
.kpi-trend {
  font-size: .62rem; font-weight: 600;
  color: var(--ok); margin-top: 6px;
}

/* Tableau */
.wf-table { width: 100%; border-collapse: collapse; }
.wf-table th {
  padding: 9px 14px; text-align: left;
  font-size: .52rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--dim); border-bottom: 1px solid var(--bord2);
  background: var(--bg);
}
.wf-table td {
  padding: 11px 14px; font-size: .78rem;
  border-bottom: 1px solid var(--bord2);
  color: var(--text);
}
.wf-table tbody tr:hover td { background: rgba(201,168,76,.04) !important; }
.wf-table .td-ref { font-family: 'Courier New', monospace; color: var(--gold); font-weight: 700; font-size: .72rem; }
.wf-table .td-bold { font-weight: 700; }
.wf-table .td-dim { color: var(--dim); font-size: .72rem; }

/* Badges / Pills */
.pill {
  display: inline-block;
  font-size: .5rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; padding: 3px 10px; border-radius: 999px;
}
.p-ok    { background: rgba(22,163,104,.1);  border: 1px solid rgba(22,163,104,.3);  color: #157a50; }
.p-warn  { background: rgba(240,180,41,.1);  border: 1px solid rgba(240,180,41,.3);  color: #8a6a00; }
.p-live  { background: rgba(192,57,43,.1);   border: 1px solid rgba(192,57,43,.3);   color: #c0392b; }
.p-gold  { background: rgba(201,168,76,.1);  border: 1px solid rgba(201,168,76,.25); color: #c8a84b; }
.p-dim   { background: rgba(14,31,46,.06);   border: 1px solid var(--bord2);          color: var(--dim); }
.p-blue  { background: rgba(14,62,95,.1);    border: 1px solid rgba(14,62,95,.25);   color: var(--blue2); }
.p-violet{ background: rgba(124,92,191,.12); border: 1px solid rgba(124,92,191,.3);  color: var(--violet2); }

/* Formulaires */
.flbl {
  display: block; font-size: .54rem; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--dim); margin-bottom: 7px;
}
.finput {
  width: 100%; padding: 11px 14px;
  background: #f7f9fb; border: 1px solid var(--bord2);
  border-radius: 10px; color: var(--text);
  font-family: inherit; font-size: .85rem; font-weight: 500;
  outline: none; transition: all .2s;
}
.finput:focus { border-color: rgba(201,168,76,.45); background: rgba(201,168,76,.04); box-shadow: 0 0 0 3px rgba(201,168,76,.08); }
.finput::placeholder { color: rgba(14,31,46,.28); }
.fselect {
  width: 100%; padding: 11px 14px;
  background: #f7f9fb; border: 1px solid var(--bord2);
  border-radius: 10px; color: var(--text);
  font-family: inherit; font-size: .85rem; outline: none; cursor: pointer; appearance: none;
}
.fselect option { background: #ffffff; color: #0e1f2e; }
.ftextarea {
  width: 100%; padding: 11px 14px;
  background: #f7f9fb; border: 1px solid var(--bord2);
  border-radius: 10px; color: var(--text);
  font-family: inherit; font-size: .85rem; font-weight: 500;
  outline: none; transition: all .2s; resize: vertical;
  min-height: 100px;
}
.ftextarea:focus { border-color: rgba(201,168,76,.45); background: rgba(201,168,76,.04); box-shadow: 0 0 0 3px rgba(201,168,76,.08); }

/* Filter tabs */
.ftab {
  padding: 7px 16px; border-radius: 50px; cursor: pointer;
  font-size: .66rem; font-weight: 700; letter-spacing: .05em;
  border: 1px solid var(--bord2);
  background: rgba(14,31,46,.04); color: var(--dim);
  transition: all .2s; display: inline-block;
}
.ftab:hover { color: var(--text); }
.ftab.on { background: rgba(201,168,76,.1); border-color: rgba(201,168,76,.3); color: var(--gold); }

/* Séparateurs */
.divider { width: 100%; height: 1px; background: var(--bord2); margin: 20px 0; }
.divider-gold { width: 100%; height: 1px; background: linear-gradient(90deg, transparent, rgba(201,168,76,.3), transparent); margin: 20px 0; }

/* Section header */
.section-header {
  font-size: .52rem; font-weight: 700; letter-spacing: .22em;
  text-transform: uppercase; color: var(--dim);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--bord2);
  margin-bottom: 16px;
}
.section-header.gold { color: var(--gold); border-bottom-color: rgba(201,168,76,.2); }

/* Alertes */
.alert-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: .78rem;
  font-weight: 600;
}
.alert-item a { color: var(--gold); text-decoration: none; margin-left: 4px; font-size: .68rem; }
.alert-live { background: rgba(192,57,43,.07); border: 1px solid rgba(192,57,43,.2); color: var(--text); }
.alert-warn { background: rgba(240,180,41,.07); border: 1px solid rgba(240,180,41,.2); color: var(--text); }
.alert-ok   { background: rgba(22,163,104,.07); border: 1px solid rgba(22,163,104,.2); color: var(--text); }
.alert-info { background: rgba(14,62,95,.06); border: 1px solid rgba(14,62,95,.15); color: var(--text); }

/* Loading / Empty states */
.loading-state {
  display: flex; align-items: center; justify-content: center;
  padding: 60px; color: var(--dim); gap: 10px;
  font-size: .78rem; font-weight: 600;
}
.empty-state {
  text-align: center; padding: 48px;
  color: var(--dim); font-size: .78rem;
}

/* IA Groq block */
.groq-block {
  background: linear-gradient(135deg, rgba(14,62,95,.06), rgba(201,168,76,.05));
  border: 1px solid rgba(201,168,76,.2);
  border-radius: 14px;
  padding: 18px 20px;
}
.groq-block .groq-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.groq-block .groq-label {
  font-size: .5rem; font-weight: 800; letter-spacing: .2em;
  text-transform: uppercase; color: var(--gold);
}
.groq-block .groq-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold); animation: blink 2s ease-in-out infinite;
}
.groq-block .groq-content {
  font-size: .82rem; font-weight: 500; line-height: 1.6; color: var(--text);
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.2} }

/* Toggle */
.toggle { position: relative; width: 40px; height: 22px; flex-shrink: 0; cursor: pointer; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.tslider {
  position: absolute; inset: 0; border-radius: 22px;
  background: rgba(14,31,46,.15); transition: all .3s;
}
.tslider::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; border-radius: 50%;
  left: 3px; top: 3px;
  background: rgba(14,31,46,.4); transition: all .3s;
}
.toggle input:checked + .tslider { background: var(--gold); }
.toggle input:checked + .tslider::before { transform: translateX(18px); background: #07111c; }

/* Progress bar */
.progress-bar {
  height: 6px; border-radius: 999px; background: var(--bg3);
  overflow: hidden; margin-top: 6px;
}
.progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--gold2));
  transition: width .5s;
}
.progress-fill.ok { background: linear-gradient(90deg, var(--ok), var(--green2)); }
.progress-fill.warn { background: linear-gradient(90deg, #d4a017, #f0b429); }
.progress-fill.live { background: linear-gradient(90deg, var(--live), #e57373); }

/* Toast */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 9999;
}
.toast {
  background: var(--sidebar);
  border: 1px solid rgba(201,168,76,.3);
  border-radius: 12px; padding: 12px 20px;
  font-size: .78rem; font-weight: 600; color: #fff;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
  animation: slideIn .3s ease;
  max-width: 300px;
}
.toast.ok { border-color: rgba(22,163,104,.4); }
.toast.live { border-color: rgba(192,57,43,.4); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Grilles */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.g4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 14px; }
.flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flex-col { display: flex; flex-direction: column; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.mt8 { margin-top: 8px; } .mt14 { margin-top: 14px; } .mt20 { margin-top: 20px; } .mt28 { margin-top: 28px; }
.mb8 { margin-bottom: 8px; } .mb14 { margin-bottom: 14px; } .mb20 { margin-bottom: 20px; }
.w100 { width: 100%; }

/* Pagination */
.pagination {
  display: flex; align-items: center; gap: 6px; margin-top: 20px;
  justify-content: center;
}
.page-btn {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--bg3); border: 1px solid var(--bord2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: .72rem; font-weight: 700; color: var(--dim);
  transition: all .2s;
}
.page-btn:hover, .page-btn.active { background: rgba(201,168,76,.1); border-color: rgba(201,168,76,.3); color: var(--gold); }

/* Chat bubbles (M29) */
.chat-container {
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px 0;
}
.chat-msg {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: .82rem; line-height: 1.55; font-weight: 500;
}
.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--blue), var(--blue2));
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--bord2);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-input-bar {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--bord2);
  border-radius: 14px;
}
.chat-input-bar textarea {
  flex: 1; background: none; border: none; outline: none;
  font-family: inherit; font-size: .85rem; color: var(--text);
  resize: none; min-height: 36px; max-height: 120px; padding: 4px 0;
}
.chat-input-bar textarea::placeholder { color: rgba(14,31,46,.28); }

/* Login page */
#login-page {
  min-height: 100vh;
  background: var(--sidebar);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 100%; max-width: 420px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(201,168,76,.2);
  /* Bandeau dore en haut de carte, comme les ecrans fab. Le theme
     sombre du Workflow est conserve : seule la barre est commune. */
  border-top: 3px solid var(--gold);
  border-radius: 20px;
  padding: 40px;
  /* Hauteur alignee sur les ecrans de connexion fab (612px). Minimum
     et non hauteur fixe : un message long doit pouvoir agrandir la
     carte plutot que d'etre coupe. */
  min-height: 612px;
  display: flex;
  flex-direction: column;
}
/* Emplacement reserve au message d'erreur : la carte ne bouge pas
   quand il s'affiche, et le message apparait juste sous le titre. */
.login-card .login-error-slot { min-height: 60px; flex-shrink: 0; }
.login-card .login-error-slot .login-error { margin-bottom: 0; }
/* Le bloc d'erreur est masque tant qu'il n'y a pas de message : sans
   cela sa bordure gauche reste visible dans la zone reservee. */
.login-card .login-error:empty { display: none !important; }
/* Mention de bas de carte poussee en bas, quelle que soit la
   hauteur du contenu. */
.login-card .login-footer {
  margin-top: auto;
  padding-top: 20px;
  text-align: center;
  font-size: .6rem;
  color: rgba(255,255,255,.2);
  letter-spacing: .08em;
}
/* Bloc logo aligne sur les ecrans fab : image centree en 96px, nom
   dessous, sous-titre dessous. Les couleurs restent celles du
   Workflow (fond sombre, nom en blanc, tag dore). */
.login-logo {
  text-align: center;
  margin-bottom: 34px;
}
.login-logo img {
  width: 96px; height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto 10px;
}
.login-brand { font-size: 1.4rem; font-weight: 900; letter-spacing: .1em; color: #fff; }
.login-tag {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 2px;
}
.login-title { font-size: 1.1rem; font-weight: 800; color: #fff; margin-bottom: 28px; text-align: center; letter-spacing: .04em; }
/* Espacements internes alignes sur les ecrans fab. Portee limitee a
   .login-card : le reste du Workflow garde ses propres reglages. */
.login-card .flbl {
  color: rgba(255,255,255,.5);
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: none;
  margin-bottom: 6px;
}
.login-card .finput { padding: 9px 12px; }
.login-card .btn-primary { padding: 11px 16px; font-size: .85rem; }
.login-card .finput { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.1); color: #fff; }
.login-card .finput:focus { border-color: rgba(201,168,76,.5); background: rgba(201,168,76,.05); }
.login-card .finput::placeholder { color: rgba(255,255,255,.25); }
.login-error {
  background: rgba(192,57,43,.15); border: 1px solid rgba(192,57,43,.3);
  border-radius: 10px; padding: 10px 14px;
  font-size: .74rem; color: #e57373; margin-bottom: 16px; display: none;
}

/* Responsive helpers */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 220px; }
  #app-content { padding: 16px; }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE MOBILE · ajouté V12
   Breakpoints : 768px (tablette) · 520px (mobile large) · 380px (compact)
   ══════════════════════════════════════════════════════════════ */

/* ─── Bouton hamburger (caché sur desktop) ─── */
#sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  color: rgba(255,255,255,.8);
}
#sidebar-toggle svg { display: block; }
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 899;
}

/* ─── Tablettes : sidebar réduite, grilles 2 colonnes ─── */
@media (max-width: 768px) {
  :root { --sidebar-w: 200px; }
  .g3 { grid-template-columns: 1fr 1fr; }
  .g4 { grid-template-columns: 1fr 1fr; }
  .module-header { flex-wrap: wrap; gap: 10px; }
  .module-header .flex { flex-wrap: wrap; }
}

/* ─── Mobile : sidebar en tiroir, tout se met en colonne ─── */
@media (max-width: 520px) {
  :root { --sidebar-w: 260px; }

  /* Sidebar cachée par défaut, glisse depuis la gauche */
  #app-sidebar {
    transform: translateX(-100%);
    transition: transform .22s cubic-bezier(.4,0,.2,1);
    z-index: 1000;
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  #app-sidebar.open {
    transform: translateX(0);
  }
  #sidebar-overlay.open {
    display: block;
  }
  #sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .header-center { display: none; }

  /* Contenu plein écran */
  #app-content {
    margin-left: 0 !important;
    padding: 12px !important;
  }

  /* Grilles : tout en colonne */
  .g2, .g3, .g4 { grid-template-columns: 1fr !important; }

  /* Tableaux : défilement horizontal + cellules compactes */
  /* TABLEAUX -> CARTES
     Le defilement horizontal obligeait a scroller de cote sans jamais
     voir une ligne entiere, avec un texte minuscule. Chaque ligne
     devient une carte, chaque valeur precedee de son intitule
     (injecte par mobile-tables.js). */
  .wf-table-wrap { overflow-x: visible; }

  .wf-table.mko-cards,
  .wf-table.mko-cards thead,
  .wf-table.mko-cards tbody,
  .wf-table.mko-cards tr,
  .wf-table.mko-cards td { display: block; width: 100%; min-width: 0; }

  .wf-table.mko-cards thead { display: none; }

  .wf-table.mko-cards tr {
    background: var(--card, #141a24);
    border: 1px solid var(--border, #223047);
    border-radius: 10px;
    margin-bottom: 9px;
    padding: 3px 2px;
  }

  .wf-table.mko-cards td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    padding: 7px 12px;
    border: none;
    border-bottom: 1px solid rgba(255,255,255,.06);
    font-size: .78rem;
    text-align: right;
    white-space: normal;
  }
  .wf-table.mko-cards td:last-child { border-bottom: none; }

  .wf-table.mko-cards td::before {
    content: attr(data-label);
    flex: 0 0 38%;
    text-align: left;
    font-size: .64rem;
    font-weight: 600;
    color: var(--dim, #8b97a8);
    text-transform: uppercase;
    letter-spacing: .03em;
  }
  .wf-table.mko-cards td[data-label=""]::before,
  .wf-table.mko-cards td:not([data-label])::before { display: none; }
  .wf-table.mko-cards td[data-label=""],
  .wf-table.mko-cards td:not([data-label]) { justify-content: flex-end; }

  .wf-table.mko-cards td[colspan] { text-align: center; justify-content: center; }
  .wf-table.mko-cards td[colspan]::before { display: none; }

  /* Tableaux non convertis : defilement en secours */
  .wf-table:not(.mko-cards) { min-width: 480px; font-size: .68rem; }
  .wf-table:not(.mko-cards) th,
  .wf-table:not(.mko-cards) td { padding: 6px 8px; }

  /* Modules 2 panneaux (ex: M05 Emails) → colonne */
  #m05-inbox {
    grid-template-columns: 1fr !important;
  }
  #m05-reader { min-height: 300px; }

  /* Cards : padding réduit */
  .card, .card-gold { padding: 14px; }

  /* Module header */
  .module-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .module-header .flex,
  .module-header > div:last-child {
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }
  .module-header button, .module-header select { flex: 1; min-width: 0; }

  /* Boutons en ligne → taille tactile */
  .btn-primary, .btn-secondary, .btn-gold-outline {
    padding: 9px 14px;
    font-size: .72rem;
    min-height: 38px;
  }

  /* KPI cards : 2 par ligne sur mobile */
  .kpi-card { padding: 12px 10px; }
  .kpi-value { font-size: 1.4rem !important; }

  /* Formulaires : inputs full width */
  .finput, .fselect, .ftextarea { width: 100% !important; box-sizing: border-box; }
  .g2.mb12, .g2.mb14, .g2.mb16 { grid-template-columns: 1fr; }

  /* Header compact */
  #app-header {
    padding: 0 10px;
    gap: 6px;
  }
  .header-logo .brand-sub { display: none; }
  .user-name, .user-role { display: none; }
  .groq-counter { display: none; }

  /* Modales plein écran sur mobile */
  [id$="-modal"] > .card {
    width: 96vw !important;
    max-height: 88vh;
    overflow-y: auto;
  }
}

/* ─── Très petits écrans (iPhone SE, etc.) ─── */
@media (max-width: 380px) {
  :root { --sidebar-w: 240px; }
  .g2 { grid-template-columns: 1fr !important; }
  .module-title { font-size: 1rem; }
}
