/* =========================================================================
   Lumen — Studio Freelance · Design System
   Thème violet · Glassmorphism · Inspiration macOS
   ========================================================================= */

:root {
  /* Palette violette */
  --violet-50:  #f4f1ff;
  --violet-100: #e9ff;
  --violet-200: #d6c8ff;
  --violet-300: #b69cff;
  --violet-400: #9a78ff;
  --violet-500: #7c5cff;
  --violet-600: #6a3df5;
  --violet-700: #5a2fd6;
  --accent:     #a78bfa;
  --accent-2:   #f0abfc;

  /* Statuts */
  --green:  #34d399;
  --amber:  #fbbf24;
  --red:    #fb7185;
  --blue:   #60a5fa;
  --grey:   #94a3b8;

  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --transition: 320ms cubic-bezier(.22,.61,.36,1);
  --font: -apple-system, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}

/* ---- Thème sombre (défaut) ---- */
[data-theme="dark"] {
  --bg-grad-a: #1a1140;
  --bg-grad-b: #0c0a1f;
  --text:        #f1edff;
  --text-soft:   #b9b2da;
  --text-faint:  #847caa;
  --glass:       rgba(36, 28, 70, 0.55);
  --glass-2:     rgba(28, 22, 56, 0.4);
  --glass-hi:    rgba(255, 255, 255, 0.08);
  --stroke:      rgba(255, 255, 255, 0.10);
  --stroke-soft: rgba(255, 255, 255, 0.06);
  --shadow:      0 18px 50px rgba(8, 5, 30, 0.55);
  --nav-active:  rgba(124, 92, 255, 0.28);
}

/* ---- Thème clair ---- */
[data-theme="light"] {
  --bg-grad-a: #e9e3ff;
  --bg-grad-b: #f6f3ff;
  --text:        #1f1640;
  --text-soft:   #5a5280;
  --text-faint:  #8b84ad;
  --glass:       rgba(255, 255, 255, 0.62);
  --glass-2:     rgba(255, 255, 255, 0.45);
  --glass-hi:    rgba(255, 255, 255, 0.7);
  --stroke:      rgba(124, 92, 255, 0.16);
  --stroke-soft: rgba(31, 22, 64, 0.06);
  --shadow:      0 18px 50px rgba(108, 80, 220, 0.18);
  --nav-active:  rgba(124, 92, 255, 0.18);
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;   /* iOS : empêche l'agrandissement auto du texte (débordements) */
  text-size-adjust: 100%;
  overflow: hidden;
}

body {
  display: grid;
  place-items: center;
  padding: 18px;
  background: linear-gradient(135deg, var(--bg-grad-a), var(--bg-grad-b));
  transition: background var(--transition);
}

/* ---- Halos d'arrière-plan ---- */
.backdrop { position: fixed; inset: 0; overflow: hidden; z-index: 0; }
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .5;
  /* halos figés (l'animation continue rendait le défilement saccadé) */
}
.blob-1 { width: 460px; height: 460px; background: #7c5cff; top: -120px; left: -80px; }
.blob-2 { width: 520px; height: 520px; background: #c026d3; bottom: -160px; right: -100px; animation-delay: -6s; }
.blob-3 { width: 380px; height: 380px; background: #4f46e5; top: 40%; left: 45%; animation-delay: -11s; }
@keyframes float {
  0%,100% { transform: translate(0,0) scale(1); }
  50%     { transform: translate(40px,-30px) scale(1.08); }
}

/* =========================================================================
   Fenêtre
   ========================================================================= */
.window {
  position: relative;
  z-index: 1;
  width: min(1560px, 100%);
  height: calc(100vh - 36px);
  display: grid;
  grid-template-columns: 256px 1fr;
  grid-template-rows: minmax(0, 1fr);   /* contraint la hauteur → active le défilement interne */
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  background: var(--glass-2);
  backdrop-filter: blur(40px) saturate(160%);
  -webkit-backdrop-filter: blur(40px) saturate(160%);
}

/* =========================================================================
   Barre latérale
   ========================================================================= */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 14px 18px;
  background: var(--glass);
  border-right: 1px solid var(--stroke-soft);
  gap: 6px;
}

.traffic { display: flex; gap: 8px; padding: 4px 6px 14px; }
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.red { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green { background: #28c840; }

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 16px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 19px; color: #fff;
  background: linear-gradient(135deg, var(--violet-400), var(--violet-600));
  box-shadow: 0 6px 18px rgba(124,92,255,.45);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 16px; letter-spacing: .2px; }
.brand-text span { font-size: 11.5px; color: var(--text-faint); }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; padding-right: 2px; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: var(--stroke); border-radius: 3px; }

.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-faint); padding: 14px 12px 6px; font-weight: 700; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-soft); cursor: pointer;
  font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent;
  transition: background var(--transition), color var(--transition), transform 120ms ease;
  position: relative;
}
.nav-item .ic { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--glass-hi); color: var(--text); }
.nav-item:active { transform: scale(.98); }
.nav-item.active {
  background: var(--nav-active); color: var(--text);
  border-color: var(--stroke);
  box-shadow: inset 0 1px 0 var(--glass-hi);
}
.nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 4px 4px 0;
  background: linear-gradient(var(--violet-300), var(--violet-600));
}
.nav-item .count {
  margin-left: auto; font-size: 11px; font-weight: 700;
  background: var(--glass-hi); color: var(--text-soft);
  padding: 1px 7px; border-radius: 9px;
}

.sidebar-footer { padding-top: 12px; border-top: 1px solid var(--stroke-soft); }
.profile { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); cursor: pointer; }
.profile:hover { background: var(--glass-hi); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(135deg, #f0abfc, #7c5cff);
}
.profile-text { display: flex; flex-direction: column; line-height: 1.25; }
.profile-text strong { font-size: 13px; }
.profile-text span { font-size: 11px; color: var(--text-faint); }

/* =========================================================================
   Zone principale
   ========================================================================= */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--glass-2); }

.topbar {
  position: relative; z-index: 20;   /* passe au-dessus du contenu (menu recherche) */
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 26px; gap: 18px;
  border-bottom: 1px solid var(--stroke-soft);
  background: var(--glass);
  backdrop-filter: blur(20px);
}
.topbar-left h1 { font-size: 21px; font-weight: 700; letter-spacing: -.3px; }
.topbar-left p { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.search {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 13px; width: 320px;
  background: var(--glass-hi); border: 1px solid var(--stroke);
  border-radius: 12px; color: var(--text-faint);
  transition: border var(--transition), box-shadow var(--transition);
}
.search:focus-within { border-color: var(--violet-400); box-shadow: 0 0 0 4px rgba(124,92,255,.18); }
.search .ic { width: 16px; height: 16px; }
.search input { flex: 1; border: 0; background: transparent; outline: none; color: var(--text); font-size: 13px; font-family: var(--font); }
.search input::placeholder { color: var(--text-faint); }
.search kbd {
  font-size: 11px; padding: 2px 6px; border-radius: 6px;
  background: var(--glass-2); border: 1px solid var(--stroke); color: var(--text-faint);
}

.icon-btn {
  position: relative; width: 40px; height: 40px;
  display: grid; place-items: center; cursor: pointer;
  border-radius: 11px; border: 1px solid var(--stroke);
  background: var(--glass-hi); color: var(--text-soft);
  transition: all var(--transition);
}
.icon-btn:hover { color: var(--text); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,.18); }
.icon-btn .ic { width: 18px; height: 18px; }
.badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #fb7185, #c026d3); border-radius: 9px;
  border: 2px solid var(--bg-grad-b);
}

/* Icônes génériques (stroke) */
.ic { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* =========================================================================
   Vue & scroll
   ========================================================================= */
.view {
  flex: 1; min-height: 0; overflow-y: auto; padding: 24px 26px 36px;
  animation: fade-up 420ms var(--transition);
  contain: paint;                 /* isole le rendu → défilement plus fluide */
  -webkit-overflow-scrolling: touch;
}
.view::-webkit-scrollbar { width: 9px; }
.view::-webkit-scrollbar-thumb { background: var(--stroke); border-radius: 5px; }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---- Carte verre ---- */
.card {
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 28px rgba(10,6,35,.18);
  backdrop-filter: blur(18px);
  padding: 18px;
  transition: transform var(--transition), box-shadow var(--transition), border var(--transition);
}
.card:hover { box-shadow: 0 14px 40px rgba(10,6,35,.28); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h3 { font-size: 14.5px; font-weight: 700; }
.card-head .link { font-size: 12px; color: var(--accent); cursor: pointer; }

.grid { display: grid; gap: 18px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2,1fr); } }

/* ---- KPI ---- */
.kpi { display: flex; flex-direction: column; gap: 12px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-ic {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--nav-active); color: var(--accent);
}
.kpi-ic .ic { width: 20px; height: 20px; }
.kpi-val { font-size: 27px; font-weight: 800; letter-spacing: -.6px; }
.kpi-label { font-size: 12.5px; color: var(--text-faint); }
.trend { font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.trend.up { color: var(--green); }
.trend.down { color: var(--red); }

/* ---- Mini graphes (SVG) ---- */
.chart { width: 100%; height: 190px; }
.bar-track { display: flex; align-items: stretch; gap: 12px; height: 170px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; height: 100%; }
.bar {
  width: 100%; max-width: 34px; border-radius: 8px 8px 4px 4px;
  background: linear-gradient(var(--violet-400), var(--violet-600));
  transition: height 600ms var(--transition); position: relative;
}
.bar:hover { filter: brightness(1.15); }
.bar-lbl { font-size: 11px; color: var(--text-faint); }

/* ---- Pipeline ---- */
.pipeline { display: flex; flex-direction: column; gap: 12px; }
.pipe-row { display: flex; align-items: center; gap: 12px; }
.pipe-name { width: 110px; font-size: 12.5px; color: var(--text-soft); }
.pipe-bar { flex: 1; height: 10px; border-radius: 6px; background: var(--glass-hi); overflow: hidden; }
.pipe-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--violet-400), var(--accent-2)); }
.pipe-val { width: 64px; text-align: right; font-size: 12.5px; font-weight: 700; }

/* ---- Listes / lignes ---- */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 11px 6px;
  border-bottom: 1px solid var(--stroke-soft); cursor: pointer; border-radius: 8px;
  transition: background var(--transition);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--glass-hi); }
.row .av {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--violet-400), var(--violet-700));
}
.row .meta { flex: 1; min-width: 0; }
.row .meta strong { font-size: 13px; display: block; }
.row .meta span { font-size: 11.5px; color: var(--text-faint); }
.row .right { text-align: right; font-size: 12px; }

/* ---- Tags / statuts ---- */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px;
  border: 1px solid var(--stroke);
}
.tag .pt { width: 7px; height: 7px; border-radius: 50%; }
.tag.green  { color: var(--green); background: rgba(52,211,153,.12); }
.tag.amber  { color: var(--amber); background: rgba(251,191,36,.12); }
.tag.red    { color: var(--red);   background: rgba(251,113,133,.12); }
.tag.blue   { color: var(--blue);  background: rgba(96,165,250,.12); }
.tag.violet { color: var(--accent);background: rgba(124,92,255,.14); }
.tag.grey   { color: var(--grey);  background: rgba(148,163,184,.12); }
.pt.green{background:var(--green)} .pt.amber{background:var(--amber)} .pt.red{background:var(--red)}
.pt.blue{background:var(--blue)} .pt.violet{background:var(--accent)} .pt.grey{background:var(--grey)}

/* ---- Boutons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: 11px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--stroke); background: var(--glass-hi); color: var(--text);
  transition: all var(--transition);
}
.btn:hover { transform: translateY(-1px); }
.btn .ic { width: 16px; height: 16px; }
.btn.primary {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, var(--violet-400), var(--violet-600));
  box-shadow: 0 8px 22px rgba(124,92,255,.4);
}
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.chip {
  font-size: 12.5px; padding: 7px 13px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--stroke); background: var(--glass-hi); color: var(--text-soft);
  transition: all var(--transition);
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--nav-active); color: var(--text); border-color: var(--violet-400); }

/* ---- Kanban ---- */
.kanban { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; align-items: start; }
.kcol { display: flex; flex-direction: column; gap: 12px; }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.kcol-head strong { font-size: 13px; }
.kcol-head .count { font-size: 11px; color: var(--text-faint); background: var(--glass-hi); padding: 1px 8px; border-radius: 9px; }
.kcard {
  background: var(--glass); border: 1px solid var(--stroke); border-radius: var(--radius-md);
  padding: 14px; cursor: grab; box-shadow: 0 4px 16px rgba(10,6,35,.16);
  transition: transform var(--transition), box-shadow var(--transition);
}
.kcard:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(10,6,35,.3); }
.kcard h4 { font-size: 13.5px; margin-bottom: 6px; }
.kcard .client { font-size: 11.5px; color: var(--text-faint); margin-bottom: 10px; }
.kcard .foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.progress { height: 6px; border-radius: 4px; background: var(--glass-hi); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg,var(--violet-400),var(--accent-2)); }
.dl { font-size: 11px; color: var(--text-faint); display: inline-flex; align-items: center; gap: 4px; }

/* ---- Calendrier contenu ---- */
.cal { display: grid; grid-template-columns: repeat(7,1fr); gap: 8px; }
.cal-h { font-size: 10.5px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .5px; text-align: center; padding-bottom: 2px; }
.cal-cell { min-height: 82px; border-radius: 12px; border: 1px solid var(--stroke);
  background: var(--glass-2); padding: 7px 8px; display: flex; flex-direction: column; gap: 4px;
  transition: background var(--transition), border var(--transition); }
.cal-cell:hover { background: var(--glass-hi); border-color: var(--violet-400); }
.cal-cell.empty { background: transparent; border-color: transparent; pointer-events: none; }
.cal-cell.weekend { background: var(--glass); }
.cal-cell .d { font-size: 12px; color: var(--text-soft); font-weight: 700; }
.cal-cell.today { border-color: var(--violet-400); box-shadow: inset 0 0 0 1px var(--violet-400); background: var(--nav-active); }
.cal-cell.today .d { color: var(--accent); font-weight: 800; }
.post {
  font-size: 10.5px; padding: 4px 7px; border-radius: 7px; color: #fff; font-weight: 600;
  display: flex; align-items: center; gap: 5px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.post.ig  { background: linear-gradient(135deg,#f9737d,#c026d3); }
.post.li  { background: #2563eb; }
.post.tk  { background: #111; }
.post.yt  { background: #dc2626; }
.post.nl  { background: linear-gradient(135deg,#7c5cff,#6a3df5); }

/* ---- Tables (factures) ---- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-faint); padding: 10px 12px; border-bottom: 1px solid var(--stroke); font-weight: 700; }
.table td { padding: 13px 12px; border-bottom: 1px solid var(--stroke-soft); }
.table tr:hover td { background: var(--glass-hi); }
.table .amount { font-weight: 700; }

/* ---- Timeline ---- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content:""; position:absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--stroke); }
.tl-item { position: relative; padding: 0 0 18px 4px; }
.tl-item::before { content:""; position:absolute; left: -20px; top: 3px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--violet-500); border: 2px solid var(--bg-grad-b); box-shadow: 0 0 0 3px rgba(124,92,255,.25); }
.tl-item .when { font-size: 11px; color: var(--text-faint); }
.tl-item .what { font-size: 13px; margin-top: 2px; }

/* ---- Alertes bandeau ---- */
.alerts { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.alert {
  display: flex; align-items: center; gap: 10px; padding: 11px 15px; border-radius: var(--radius-md);
  border: 1px solid var(--stroke); background: var(--glass); font-size: 13px; flex: 1; min-width: 200px;
  cursor: pointer; font-family: var(--font); color: var(--text); text-align: left;
  transition: transform var(--transition), box-shadow var(--transition), border var(--transition);
}
.alert:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(0,0,0,.14); }
.alert.active { border-color: var(--violet-400); box-shadow: 0 0 0 3px var(--nav-active); }
.alert .ic { width: 18px; height: 18px; flex-shrink: 0; }
.alert.hot  { border-color: rgba(251,113,133,.4); }
.alert.warn { border-color: rgba(251,191,36,.4); }
.alert b { font-weight: 800; }

/* ---- Détail / split ---- */
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }

/* ---- Toggle (paramètres) ---- */
.set-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px; border-bottom: 1px solid var(--stroke-soft); }
.set-row:last-child { border: 0; }
.set-row .lbl strong { font-size: 13.5px; display: block; }
.set-row .lbl span { font-size: 12px; color: var(--text-faint); }
.switch { width: 46px; height: 27px; border-radius: 20px; background: var(--glass-hi); border: 1px solid var(--stroke);
  position: relative; cursor: pointer; transition: background var(--transition); }
.switch::after { content:""; position: absolute; top: 2px; left: 2px; width: 21px; height: 21px; border-radius: 50%;
  background: #fff; transition: transform var(--transition); box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.switch.on { background: linear-gradient(135deg, var(--violet-400), var(--violet-600)); }
.switch.on::after { transform: translateX(19px); }

.swatch { width: 30px; height: 30px; border-radius: 9px; cursor: pointer; border: 2px solid transparent; }
.swatch.sel { border-color: #fff; box-shadow: 0 0 0 2px var(--violet-500); }

.muted { color: var(--text-faint); }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-soft); margin: 6px 0 12px; }

/* Bouton menu (mobile uniquement) */
.menu-btn {
  display: none; width: 40px; height: 40px; place-items: center; cursor: pointer;
  border-radius: 11px; border: 1px solid var(--stroke); background: var(--glass-hi);
  color: var(--text-soft); flex-shrink: 0;
}
.menu-btn .ic { width: 20px; height: 20px; }
.sidebar-backdrop { display: none; }

/* ---- Boutons icône en ligne (éditer / supprimer) ---- */
.row-btn {
  width: 30px; height: 30px; display: grid; place-items: center; cursor: pointer;
  border-radius: 9px; border: 1px solid var(--stroke); background: var(--glass-hi);
  color: var(--text-soft); transition: all var(--transition);
}
.row-btn:hover { color: var(--text); transform: translateY(-1px); }
.row-btn.danger:hover { color: var(--red); border-color: rgba(251,113,133,.5); }
.row-btn .ic { width: 15px; height: 15px; }

/* =========================================================================
   Modale / formulaires
   ========================================================================= */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 24px;
  background: rgba(8, 5, 25, 0.5);
  backdrop-filter: blur(8px);
  animation: fade-in 200ms ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

.modal {
  width: min(560px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--glass); border: 1px solid var(--stroke);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  backdrop-filter: blur(40px) saturate(160%);
  padding: 24px; animation: pop-in 260ms var(--transition);
}
.modal::-webkit-scrollbar { width: 8px; }
.modal::-webkit-scrollbar-thumb { background: var(--stroke); border-radius: 4px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-head h2 { font-size: 18px; font-weight: 700; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: span 2; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-soft); }
.field input, .field select, .field textarea {
  font-family: var(--font); font-size: 13.5px; color: var(--text);
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--stroke); background: var(--glass-hi);
  outline: none; transition: border var(--transition), box-shadow var(--transition);
}
.field textarea { resize: vertical; min-height: 76px; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--violet-400); box-shadow: 0 0 0 4px rgba(124,92,255,.18);
}
.field select option { color: #1f1640; }

.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 22px; }
.form-actions .spacer { flex: 1; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: rgba(251,113,133,.4); }
.btn.danger:hover { background: rgba(251,113,133,.12); }

/* Confirmation */
.confirm { width: min(420px, 100%); text-align: left; }
.confirm p { font-size: 13.5px; color: var(--text-soft); margin: 8px 0 4px; line-height: 1.5; }

/* =========================================================================
   Écran de connexion (mode serveur)
   ========================================================================= */
.auth-overlay {
  position: fixed; inset: 0; z-index: 60; overflow: hidden;
  display: grid; place-items: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  font-family: var(--font);
  background: linear-gradient(180deg, #FFF1E0 0%, #FFD9B8 52%, #F49B73 100%);
}
/* Fond animé interactif (canvas plein écran) */
.auth-canvas { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; display: block; }
/* Scène 3D : la carte s'incline vers le curseur */
.auth-stage { position: relative; z-index: 1; perspective: 1100px; width: min(400px, 100%); }
.auth-card {
  position: relative; width: 100%;
  max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 40px); overflow-y: auto;
  background: rgba(255,251,245,0.72);
  border: 1px solid rgba(255,255,255,0.75);
  border-radius: 28px;
  box-shadow: 0 40px 90px rgba(150,72,42,.32), inset 0 1px 0 rgba(255,255,255,.85);
  backdrop-filter: blur(20px) saturate(150%); -webkit-backdrop-filter: blur(20px) saturate(150%);
  padding: 34px 30px 30px; color: #2A211A; text-align: center;
  transform-style: preserve-3d; transition: transform .25s cubic-bezier(.23,1,.32,1);
  will-change: transform; animation: pop-in 460ms var(--transition);
}

/* Mascotte (regard suiveur) */
.auth-cat-badge {
  width: 96px; height: 96px; margin: 0 auto 6px; padding: 9px; border-radius: 26px; overflow: hidden;
  display: grid; place-items: center; transform: translateZ(45px);
  background: linear-gradient(135deg, #FFCB8E, #FF7E5F);
  box-shadow: 0 18px 38px rgba(226,97,58,.42), 0 0 0 7px rgba(255,255,255,.5);
}
.auth-cat-badge svg { width: 100%; height: auto; display: block; }
.neko-cat { animation: nekoFloat 5.5s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes nekoFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.neko-eyes { transform-box: fill-box; transform-origin: center; animation: nekoBlink 5.5s infinite; }
@keyframes nekoBlink { 0%,93%,100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
.neko-pupils { transition: transform .12s ease-out; }
.neko-tail { transform-box: fill-box; transform-origin: 14% 62%; animation: nekoTail 4.2s ease-in-out infinite; }
@keyframes nekoTail { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(4deg); } }

.auth-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .26em; text-transform: uppercase; color: #B5683E; margin-top: 8px; transform: translateZ(28px); }
.auth-brand { font-family: var(--serif); font-size: 40px; font-weight: 700; letter-spacing: -.02em; line-height: 1; color: #2A211A; margin-top: 4px; transform: translateZ(28px); }
.auth-card .auth-logo { width: 52px; height: 52px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 16px; font-size: 24px; color: #fff; background: linear-gradient(135deg, #FFB26B, #E2613A); box-shadow: 0 12px 26px rgba(226,97,58,.38); }
.auth-card .auth-title { font-family: var(--serif); font-size: 23px; font-weight: 700; color: #2A211A; }
.auth-card .auth-sub { font-size: 13.5px; color: #7A5A48; margin: 10px 0 22px; line-height: 1.55; }
.auth-card form { text-align: left; }
.auth-card label { font-size: 12.5px; font-weight: 600; color: #6B4A38; }
.auth-card .field { margin-bottom: 15px; }
.auth-card .field input {
  width: 100%; background: rgba(255,255,255,.85); border: 1px solid #ECD7C5; color: #2A211A;
  padding: 13px 14px; border-radius: 13px; font-family: var(--font); font-size: 14px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.auth-card .field input::placeholder { color: #BBA08D; }
.auth-card .field input:focus { outline: none; border-color: #E2613A; box-shadow: 0 0 0 4px rgba(226,97,58,.16); }
.auth-card .auth-forgot { display: inline-block; font-size: 12px; color: #C44E2C; margin: -2px 0 18px; cursor: pointer; transition: color var(--transition); }
.auth-card .auth-forgot:hover { color: #A33C1E; }
.auth-card #au-err { color: #C0264D !important; }
.auth-card .pw-eye { color: #BBA08D; }
.auth-card .btn.primary {
  width: 100%; justify-content: center; padding: 14px; font-size: 14.5px; font-weight: 700; border-radius: 14px;
  color: #fff; background: linear-gradient(135deg, #FFB26B, #E2613A); box-shadow: 0 12px 26px rgba(226,97,58,.40);
  transition: transform .14s cubic-bezier(.23,1,.32,1), box-shadow .2s ease;
}
.auth-card .btn.primary:hover { transform: translateY(-1px); box-shadow: 0 16px 34px rgba(226,97,58,.52); }
.auth-card .btn.primary:active { transform: scale(.98); }
.auth-card code { font-size: 12px; background: rgba(226,97,58,.10); color: #A33C1E; padding: 2px 6px; border-radius: 6px; }

@media (max-width: 560px) {
  .auth-brand { font-size: 34px; }
  .auth-card { padding: 28px 22px 26px; }
  .auth-cat-badge { width: 84px; height: 84px; }
}
@media (prefers-reduced-motion: reduce) {
  .neko-cat, .neko-eyes, .neko-tail { animation: none; }
  .auth-card { transition: none; }
}

/* =========================================================================
   Notifications (toast)
   ========================================================================= */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: 70; padding: 11px 18px; border-radius: 12px;
  font-size: 13px; font-weight: 600; color: var(--text);
  background: var(--glass); border: 1px solid var(--stroke);
  box-shadow: var(--shadow); backdrop-filter: blur(20px);
  opacity: 0; pointer-events: none; transition: all var(--transition);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[data-kind="warn"] { border-color: rgba(251,191,36,.5); }
.toast[data-kind="ok"]   { border-color: rgba(52,211,153,.4); }

/* =========================================================================
   Panneau de notifications
   ========================================================================= */
.notif-panel {
  position: fixed; top: 74px; right: 24px; width: 348px; max-height: 70vh; overflow-y: auto;
  z-index: 55; padding: 14px;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); backdrop-filter: blur(30px) saturate(160%);
  animation: pop-in 220ms var(--transition);
}
.notif-panel::-webkit-scrollbar { width: 7px; }
.notif-panel::-webkit-scrollbar-thumb { background: var(--stroke); border-radius: 4px; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 10px; }
.notif-head h3 { font-size: 14px; font-weight: 700; }
.notif-item { display: flex; gap: 11px; align-items: flex-start; padding: 10px 8px; border-radius: 10px; cursor: pointer; transition: background var(--transition); }
.notif-item:hover { background: var(--glass-hi); }
.notif-ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.notif-ic .ic { width: 16px; height: 16px; }
.notif-item .nt { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.notif-item .ns { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.notif-empty { font-size: 12.5px; color: var(--text-faint); padding: 18px 8px; text-align: center; }

/* Carte cliquable générique */
.clickable { cursor: pointer; }
.clickable:hover { border-color: var(--violet-400) !important; transform: translateY(-2px); }

/* =========================================================================
   Effet verre désactivé (panneaux opaques)
   ========================================================================= */
html.no-glass *, html.no-glass *::before, html.no-glass *::after {
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
}
html.no-glass[data-theme="dark"]  { --glass: rgba(28,21,52,.97); --glass-2: rgba(20,15,40,.98); --glass-hi: rgba(255,255,255,.05); }
html.no-glass[data-theme="light"] { --glass: rgba(255,255,255,.98); --glass-2: rgba(247,245,255,.99); --glass-hi: rgba(124,92,255,.06); }

/* =========================================================================
   Recherche globale
   ========================================================================= */
.search { position: relative; }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 56;
  max-height: 60vh; overflow-y: auto; padding: 6px; display: none;
  border: 1px solid var(--stroke); border-radius: var(--radius-md);
  box-shadow: 0 24px 60px rgba(8,4,30,.5);
}
/* Fond OPAQUE pour une lisibilité parfaite (corrige le chevauchement) */
[data-theme="dark"]  .search-results { background: #221a44; }
[data-theme="light"] .search-results { background: #ffffff; }
.search-results.show { display: block; animation: pop-in 180ms var(--transition); }
.search-item { padding: 9px 11px; border-radius: 9px; cursor: pointer; transition: background var(--transition); }
.search-item:hover { background: var(--glass-hi); }
.search-item .nt { font-size: 13px; font-weight: 600; }
.search-item .ns { font-size: 11px; color: var(--text-faint); margin-top: 1px; }

/* =========================================================================
   Dashboard personnalisable (widgets)
   ========================================================================= */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; align-items: start; }
.dash-widget { position: relative; }
.dash-widget.full { grid-column: 1 / -1; }
.dash-grid.editing .dash-widget {
  outline: 2px dashed var(--violet-400); outline-offset: 4px; border-radius: var(--radius-lg); cursor: grab;
}
.dash-grid.editing .dash-widget:active { cursor: grabbing; }
.dash-widget.dragging { opacity: .45; }
.widget-controls { position: absolute; top: 10px; right: 12px; z-index: 6; display: flex; gap: 5px; }
.widget-controls .row-btn { background: var(--glass); font-size: 11px; font-weight: 800; }

/* Pastille de contenu par défaut (plateformes sans couleur dédiée) */
.post { background: linear-gradient(135deg, var(--violet-400), var(--violet-600)); }
.post.relance { background: linear-gradient(135deg, #fbbf24, #f97316); }

/* Tâches en 3 colonnes (par priorité) */
.task-board { grid-template-columns: repeat(3, 1fr); }

/* Administration : grille de modules */
.mods-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 10px; }
.mod-check { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 9px 11px;
  border: 1px solid var(--stroke); border-radius: 10px; background: var(--glass-hi); cursor: pointer; }
.mod-check input { accent-color: var(--violet-500); width: 16px; height: 16px; }
@media (max-width: 900px) { .mods-grid { grid-template-columns: 1fr; } }

/* Galerie de logos */
.logo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.logo-tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 10px;
  border-radius: 14px; border: 1px solid var(--stroke); background: var(--glass-hi); cursor: pointer;
  transition: transform var(--transition), border var(--transition);
}
.logo-tile:hover { border-color: var(--violet-400); transform: translateY(-2px); }
.logo-tile svg { width: 54px; height: 54px; }
.logo-tile span { font-size: 11.5px; color: var(--text-soft); }
@media (max-width: 900px) { .logo-grid { grid-template-columns: repeat(2, 1fr); } }

/* =========================================================================
   Éditeur de facture (formulaire + aperçu)
   ========================================================================= */
.modal.wide { width: min(960px, 100%); }
.invoice-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.ie-preview {
  background: #fff; color: #1f1640; border-radius: var(--radius-md); padding: 22px;
  overflow: auto; max-height: 72vh; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.ie-item { display: grid; grid-template-columns: 1fr 70px 104px 32px; gap: 8px; margin-bottom: 8px; align-items: center; }
.ie-item input {
  padding: 8px 10px; border-radius: 9px; border: 1px solid var(--stroke);
  background: var(--glass-hi); color: var(--text); font-size: 12.5px; font-family: var(--font); outline: none;
}
.ie-item input:focus { border-color: var(--violet-400); }

/* Document facture (aperçu + impression) */
.inv-doc { font-size: 12.5px; }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.inv-brand { display: flex; gap: 12px; align-items: center; }
.inv-logo { width: 50px; height: 50px; border-radius: 12px; object-fit: cover; }
.inv-logo-txt { width: 50px; height: 50px; border-radius: 12px; color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 22px;
  background: linear-gradient(135deg, var(--violet-400), var(--violet-600)); }
.inv-name { font-size: 18px; font-weight: 800; color: var(--violet-600); }
.inv-sub { font-size: 11px; color: #8b84ad; line-height: 1.5; }
.inv-meta { text-align: right; }
.inv-type { font-size: 18px; font-weight: 800; letter-spacing: 1px; }
.inv-num { font-size: 11px; color: #8b84ad; }
.inv-client { margin-bottom: 14px; }
.inv-client .muted { color: #8b84ad; font-size: 11px; }
.inv-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.inv-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; color: #8b84ad; border-bottom: 1px solid #ececf5; padding: 6px 8px; }
.inv-table th:not(:first-child), .inv-table td:not(:first-child) { text-align: right; }
.inv-table td { padding: 8px; border-bottom: 1px solid #f3f1fa; }
.inv-totals { margin-left: auto; width: 210px; }
.inv-totals > div { display: flex; justify-content: space-between; padding: 3px 0; }
.inv-totals .inv-ttc { border-top: 2px solid var(--violet-600); margin-top: 5px; padding-top: 8px; font-size: 15px; font-weight: 800; }

/* =========================================================================
   Page de connexion — variante COUCHER DE SOLEIL
   ========================================================================= */
/* Thème app COUCHER DE SOLEIL (orange / blanc) */
html.sunset {
  --bg-grad-a: #FDF7EE; --bg-grad-b: #FAEEDF;
  --text: #2A211A; --text-soft: #5C5046; --text-faint: #9C8E7F;
  --glass: rgba(255,253,250,0.74); --glass-2: rgba(255,250,243,0.55); --glass-hi: rgba(255,255,255,0.72);
  --stroke: rgba(226,97,58,0.16); --stroke-soft: rgba(70,40,20,0.07);
  --accent-2: #ff9e7a;
  --shadow: 0 16px 44px rgba(190,110,60,0.16);
  --nav-active: rgba(226,97,58,0.16);
}
html.sunset .blob-1 { background:#ffb26b; }
html.sunset .blob-2 { background:#ff7e5f; }
html.sunset .blob-3 { background:#ffc89a; }
/* Grain subtil sur le fond (casse le flat, fini éditorial) */
html.sunset .backdrop::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .4; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}

/* Titres éditoriaux en serif (direction crème / coucher de soleil) */
.brand-text strong, #view-title, .card-head h3, .auth-title, .m-title { font-family: var(--serif); letter-spacing: -.01em; }
.m-title { font-weight: 700; }

/* (Le login utilise désormais la scène « coucher de soleil » de base — voir plus haut.) */

/* Logo chat noir animé (page de connexion) — badge crème/sunset */
.auth-logo.cat-badge {
  width: 92px; height: 92px; padding: 9px; overflow: hidden; border-radius: 26px;
  margin: 0 auto 6px; display: grid; place-items: center;
  background: linear-gradient(135deg, #FFCB8E, #FF8E5E);
  box-shadow: 0 18px 40px rgba(226,97,58,.42), 0 0 0 7px rgba(255,255,255,.55);
}
.auth-logo.cat-badge .cat { width: 100%; height: 100%; display: block; }
.cat-tail { transform-box: fill-box; transform-origin: 0% 100%; animation: catTail 1.7s ease-in-out infinite; }
@keyframes catTail { 0%,100% { transform: rotate(-11deg); } 50% { transform: rotate(11deg); } }
.cat-eyes { transform-box: fill-box; transform-origin: center; animation: catBlink 4.5s infinite; }
@keyframes catBlink { 0%,90%,100% { transform: scaleY(1); } 94% { transform: scaleY(.08); } }
@media (prefers-reduced-motion: reduce) { .cat-tail, .cat-eyes { animation: none; } }

/* Afficher / masquer le mot de passe */
.pw-wrap { position: relative; }
.pw-wrap input { width: 100%; padding-right: 42px; }
.pw-eye {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; cursor: pointer; color: var(--text-faint);
  padding: 6px; display: grid; place-items: center;
}
.pw-eye:hover { color: var(--text); }
.pw-eye .ic { width: 18px; height: 18px; }
.auth-overlay.light .pw-eye, .auth-overlay.sunset .pw-eye { color: #9a8a7e; }

/* =========================================================================
   Responsive — tablette & mobile
   ========================================================================= */
@media (max-width: 900px) {
  html, body { height: auto; overflow: visible; }   /* la page défile naturellement */
  body { display: block; padding: 0; }
  .window {
    display: block; width: 100%; height: auto; min-height: 100dvh;
    border-radius: 0; border: 0; overflow: visible; backdrop-filter: none;
  }
  .main { display: block; }

  /* Barre latérale → tiroir coulissant */
  .menu-btn { display: grid; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 274px; z-index: 45;
    background: var(--bg-grad-a);
    padding: calc(14px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
    transform: translateX(-100%);
    transition: transform 300ms var(--transition);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 24px 0 70px rgba(0,0,0,.5); }
  .traffic { display: none; }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 44;
    background: rgba(5,3,20,.55); opacity: 0; pointer-events: none;
    transition: opacity 300ms ease;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

  /* Topbar (reste visible en haut ; marge pour l'encoche) */
  .topbar { position: sticky; top: 0; z-index: 30; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; gap: 12px; }
  .topbar { flex-wrap: wrap; }
  .topbar-left h1 { font-size: 18px; }
  .topbar-left p { display: none; }
  /* Recherche en pleine largeur sur sa propre ligne (mobile) */
  .topbar-right { display: contents; }
  .menu-btn { order: 0; }
  .topbar-left { order: 1; flex: 1 1 auto; }
  .topbar-right .icon-btn { order: 2; }
  .search { order: 3; flex: 0 0 100%; width: 100%; margin-top: 8px; }

  /* Contenu : défilement naturel de la page (fiable sur iOS) */
  .view { height: auto; overflow: visible; padding: 16px 14px calc(40px + env(safe-area-inset-bottom)); }
  .cols-4 { grid-template-columns: repeat(2, 1fr); }   /* KPI sur 2 colonnes */
  .cols-3, .cols-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .kanban { grid-template-columns: 1fr; }
  .split  { grid-template-columns: 1fr; }

  /* Éléments larges : défilement horizontal */
  .card:has(.table), .card:has(.cal) { overflow-x: auto; }
  .table { min-width: 520px; }
  .cal   { min-width: 600px; }

  /* Modales & formulaires en pleine largeur */
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .field { min-width: 0; }
  .field.full { grid-column: auto; }
  .modal { padding: 20px; }
  .notif-panel { left: 12px; right: 12px; width: auto; top: calc(62px + env(safe-area-inset-top)); }
  .modal.wide { width: 100%; }
  .invoice-editor { grid-template-columns: minmax(0, 1fr); }
  .invoice-editor > * { min-width: 0; }            /* empêche un enfant d'élargir la modale */
  .ie-preview { max-height: none; overflow-x: auto; }
  .ie-item { grid-template-columns: 1fr 52px 84px 30px; gap: 6px; }

  /* Lignes de réglages : la valeur peut passer à la ligne au lieu d'être coupée */
  .set-row { gap: 12px; }
  .set-row .lbl { flex-shrink: 0; }
  .set-row > span.muted { min-width: 0; text-align: right; overflow-wrap: anywhere; }

  /* Boutons d'actions des modales : pas de coupe, ils s'adaptent */
  .form-actions { flex-wrap: wrap; }
  .form-actions .spacer { display: none; }
  .form-actions .btn { flex: 1 1 auto; justify-content: center; }

  /* Sélecteur de modèle de facture : défile horizontalement si besoin (jamais coupé) */
  #ie-templates { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  #ie-templates .chip { flex: 0 0 auto; }
}

/* ============================================================
   Accueil mobile (PWA installée / petit écran)
   ============================================================ */
.mhome { display: flex; flex-direction: column; gap: 16px; padding-bottom: 24px; }
.m-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.m-greet { margin: 2px 0 0; font-family: var(--serif); font-size: 24px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; color: var(--text); }
.m-greet span { color: var(--text-faint); font-weight: 600; }

.m-hero { border-radius: 24px; padding: 20px; color: #fff;
          background: linear-gradient(135deg, var(--violet-400), var(--violet-600));
          box-shadow: 0 16px 40px rgba(226, 97, 58, .32); }
.m-hero-top { display: flex; justify-content: space-between; align-items: center; font-size: 14px; opacity: .96; }
.m-pill { background: rgba(255,255,255,.22); padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.m-hero-val { font-size: 40px; font-weight: 800; letter-spacing: -1.5px; margin: 8px 0 18px; }
.m-hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.m-mini { background: rgba(255,255,255,.16); border-radius: 14px; padding: 11px 12px; }
.m-mini-v { font-size: 18px; font-weight: 800; }
.m-mini-l { font-size: 11px; opacity: .9; margin-bottom: 9px; }
.m-mini-bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,.28); overflow: hidden; }
.m-mini-bar span { display: block; height: 100%; background: #fff; border-radius: 4px; }

.m-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.m-action { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 15px 6px; border: 0;
            border-radius: 18px; background: var(--glass-hi); color: var(--text); font-size: 11px; font-weight: 600;
            cursor: pointer; text-align: center; line-height: 1.2; }
.m-action svg { width: 22px; height: 22px; color: var(--violet-400); }

.m-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.m-card { background: var(--glass-hi); border-radius: 20px; padding: 16px; }
.m-card-ic { width: 38px; height: 38px; border-radius: 12px; background: var(--violet-500); color: #fff;
             display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.m-card-ic svg { width: 20px; height: 20px; }
.m-card-v { font-size: 26px; font-weight: 800; }
.m-card-l { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

.m-clients { background: var(--glass-hi); border-radius: 22px; padding: 16px; }
.m-clients-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.m-clients-head h3 { margin: 0; font-size: 16px; }
.m-client { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid rgba(127,127,127,.16); cursor: pointer; }
.m-client:first-of-type { border-top: 0; }
.m-ava { width: 42px; height: 42px; border-radius: 14px; background: var(--violet-500); color: #fff;
         display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.m-client-meta { flex: 1; min-width: 0; }
.m-client-meta strong { display: block; font-size: 14px; }
.m-client-meta span { font-size: 12px; color: var(--text-faint); }
.m-client-status { font-size: 12px; font-weight: 700; color: var(--violet-400); white-space: nowrap; }

/* ============================================================
   Copilote IA — bulle + panneau de chat
   ============================================================ */
.ai-fab {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 55;
  width: 56px; height: 56px; border: 0; border-radius: 50%; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--violet-400), var(--violet-600));
  box-shadow: 0 12px 30px rgba(226,97,58,.45); display: grid; place-items: center;
  transition: transform .16s var(--transition), box-shadow .2s var(--transition), opacity .2s;
}
.ai-fab svg { width: 26px; height: 26px; }
.ai-fab:hover { transform: translateY(-2px); box-shadow: 0 16px 38px rgba(226,97,58,.55); }
.ai-fab:active { transform: scale(.94); }
.ai-fab.hide { opacity: 0; pointer-events: none; transform: scale(.8); }

.ai-panel {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 56;
  width: min(380px, calc(100vw - 32px)); height: min(560px, calc(100dvh - 110px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 22px;
  box-shadow: var(--shadow); backdrop-filter: blur(26px) saturate(150%); -webkit-backdrop-filter: blur(26px) saturate(150%);
  opacity: 0; transform: translateY(16px) scale(.98); pointer-events: none;
  transition: opacity .22s var(--transition), transform .22s var(--transition);
}
.ai-panel.open { opacity: 1; transform: none; pointer-events: auto; }
.ai-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px 13px 16px; border-bottom: 1px solid var(--stroke-soft); }
.ai-head-t { display: flex; align-items: center; gap: 9px; font-size: 15px; font-family: var(--serif); }
.ai-dot { width: 8px; height: 8px; border-radius: 50%; background: #16855a; box-shadow: 0 0 0 3px rgba(22,133,90,.18); }
.ai-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 86%; padding: 10px 13px; border-radius: 15px; font-size: 14px; line-height: 1.5; word-wrap: break-word; }
.ai-msg.bot { align-self: flex-start; background: var(--glass-hi); color: var(--text); border-bottom-left-radius: 5px; }
.ai-msg.user { align-self: flex-end; color: #fff; background: linear-gradient(135deg, var(--violet-400), var(--violet-600)); border-bottom-right-radius: 5px; }
.ai-suggest { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 16px 6px; }
.ai-chip { font-size: 12px; padding: 7px 11px; border-radius: 999px; border: 1px solid var(--stroke); background: var(--glass-hi); color: var(--text-soft); cursor: pointer; transition: .15s; }
.ai-chip:hover { border-color: var(--violet-400); color: var(--violet-600); }
.ai-input { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--stroke-soft); }
.ai-input input { flex: 1; min-width: 0; background: var(--glass-hi); border: 1px solid var(--stroke); border-radius: 12px; padding: 11px 13px; color: var(--text); font: inherit; font-size: 14px; outline: none; transition: border-color .2s, box-shadow .2s; }
.ai-input input:focus { border-color: var(--violet-400); box-shadow: 0 0 0 4px var(--nav-active); }
.ai-send { width: 44px; flex-shrink: 0; border: 0; border-radius: 12px; color: #fff; cursor: pointer; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--violet-400), var(--violet-600)); transition: transform .14s var(--transition); }
.ai-send:active { transform: scale(.94); }
.ai-send svg { width: 18px; height: 18px; }
.ai-typing { display: inline-flex; gap: 5px; padding: 2px 0; }
.ai-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); animation: aiBlink 1.2s infinite; }
.ai-typing i:nth-child(2) { animation-delay: .2s; } .ai-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes aiBlink { 0%,60%,100% { opacity: .3; } 30% { opacity: 1; } }
@media (max-width: 560px) {
  .ai-panel { right: 10px; left: 10px; width: auto; bottom: 10px; height: min(72dvh, 560px); }
  .ai-fab { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .ai-typing i { animation: none; } }

/* ---- Barre du bas (mobile) : raccourcis rapides en verre ---- */
/* Dock flottant en verre (style iOS) */
.mbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 54;
  width: min(430px, calc(100% - 26px));
  display: none; justify-content: space-around; align-items: stretch; gap: 2px;
  padding: 8px 8px;
  background: var(--glass-hi);
  backdrop-filter: blur(26px) saturate(180%); -webkit-backdrop-filter: blur(26px) saturate(180%);
  border: 1px solid var(--stroke);
  border-radius: 26px;
  box-shadow: 0 18px 44px rgba(60,30,15,.22), inset 0 1px 0 rgba(255,255,255,.55);
}
.mbar-item {
  position: relative; flex: 1; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 2px 6px; border-radius: 18px; color: var(--text-faint);
  font: 600 10px/1.1 var(--font); transition: color .22s var(--ease, ease), transform .12s ease;
}
.mbar-item .ic { width: 23px; height: 23px; transition: transform .22s var(--ease, ease), filter .2s ease; }
.mbar-item.active { color: var(--violet-600); }
.mbar-item.active::before {
  content: ""; position: absolute; inset: 0; border-radius: 18px; z-index: -1;
  background: var(--glass); border: 1px solid var(--stroke);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5);
  animation: dock-pop .26s var(--ease, ease);
}
.mbar-item.active .ic { transform: translateY(-1px); filter: drop-shadow(0 4px 9px rgba(226,97,58,.32)); }
.mbar-item:active { transform: scale(.9); }
@keyframes dock-pop { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }
@media (max-width: 640px) {
  .mbar { display: flex; }
  .main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .ai-fab { bottom: calc(104px + env(safe-area-inset-bottom)); }
}
