/* RénoGest — habillage (repris d'ElecGest « Courant » v2, emblème maison)
   Chargé après app.css : ne modifie que l'apparence (couleurs, reliefs, arrondis, animations).
   Pour revenir à l'ancien style, il suffit de retirer la ligne <link …design.css> de index.html. */

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #0e1630;
  --muted: #5d6886;
  --border: #e6e9f2;
  --border-strong: #d3d9e6;
  --navy: #0b1126;
  --navy-2: #151d3d;
  --primary: #3355ff;
  --primary-d: #2440e0;
  --primary-50: #edf0ff;
  --amber: #ffc21a;
  --amber-50: #fff6da;
  --violet: #7c4dff;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(14, 22, 48, .04), 0 4px 14px -6px rgba(14, 22, 48, .08);
  --shadow-hover: 0 2px 4px rgba(14, 22, 48, .05), 0 14px 32px -12px rgba(14, 22, 48, .22);
  --shadow-lg: 0 24px 60px -12px rgba(14, 22, 48, .28);
  --grad-primary: linear-gradient(135deg, #3d5cff 0%, #6a45ff 100%);
  --grad-volt: linear-gradient(135deg, #ffd84d 0%, #ffab00 100%);
  --grad-ink: linear-gradient(160deg, #0e1531 0%, #0a0f24 55%, #120f33 100%);
  --soft: #f5f7fc;
  --hover: #eef1f8;
  --row-hover: #f6f8ff;
  --focus: rgba(51, 85, 255, .22);
  --ease: cubic-bezier(.2, .7, .2, 1);
}
:root[data-theme="dark"] {
  --bg: #0a0d16;
  --card: #121827;
  --text: #e8ebf3;
  --muted: #9aa3ba;
  --border: #212a3d;
  --border-strong: #2e3850;
  --navy: #070a14;
  --navy-2: #131a30;
  --primary: #6f8bff;
  --primary-d: #5a78ff;
  --primary-50: rgba(111, 139, 255, .14);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 18px -8px rgba(0, 0, 0, .5);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, .4), 0 16px 36px -12px rgba(0, 0, 0, .7);
  --grad-ink: linear-gradient(160deg, #0b1020 0%, #070a14 60%, #0f0c26 100%);
  --soft: #161d2e;
  --hover: #1b2335;
  --row-hover: #172036;
  --focus: rgba(111, 139, 255, .3);
}

body {
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(106, 69, 255, .07), transparent 60%),
    radial-gradient(900px 400px at 10% -5%, rgba(51, 85, 255, .06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  letter-spacing: -.003em;
}
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.025em; }
h2 { font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; }
::selection { background: rgba(51, 85, 255, .2); }

/* ---------- Barre latérale ---------- */
.sidebar {
  background: var(--grad-ink);
  border-right: 1px solid rgba(255, 255, 255, .04);
}
.sidebar::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(420px 260px at 0% 0%, rgba(255, 194, 26, .10), transparent 70%),
              radial-gradient(380px 300px at 100% 100%, rgba(106, 69, 255, .16), transparent 70%);
}
.sidebar > * { position: relative; }
.brand { padding: 20px 20px 16px; font-size: 20px; letter-spacing: -.03em; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--grad-volt);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .15) inset, 0 6px 18px -4px rgba(255, 171, 0, .55);
}
.brand:hover .brand-mark { animation: volt 1.2s var(--ease); }
@keyframes volt { 0%, 100% { filter: none; } 20% { filter: brightness(1.35) drop-shadow(0 0 8px rgba(255, 200, 0, .9)); } 40% { filter: none; } 55% { filter: brightness(1.2); } }
.nav-group { color: #5f6c97; font-size: 10.5px; letter-spacing: .12em; padding: 18px 12px 6px; }
#nav a { color: #b9c3de; padding: 8px 12px; border-radius: 10px; transition: background .15s, color .15s, transform .15s; }
#nav a svg { opacity: .8; transition: opacity .15s, color .15s; }
#nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; transform: translateX(2px); }
#nav a:hover svg { opacity: 1; }
#nav a.active, :root[data-theme="dark"] #nav a.active {
  background: linear-gradient(90deg, rgba(61, 92, 255, .38), rgba(106, 69, 255, .16));
  color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07);
  position: relative;
}
#nav a.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--grad-volt); box-shadow: 0 0 10px rgba(255, 194, 26, .8);
}
#nav a.active svg { color: var(--amber); opacity: 1; }
.side-company { border-top: 1px solid rgba(255, 255, 255, .06); color: #7480a6; }
:root[data-theme="dark"] .side-company { border-top-color: rgba(255, 255, 255, .05); }

/* ---------- Barre du haut ---------- */
.topbar { background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: saturate(1.6) blur(14px); border-bottom-color: transparent; box-shadow: 0 1px 0 var(--border); }
.search input { border-radius: 12px; background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow); height: 40px; }
.search input:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 4px var(--focus); }
.search-results, .menu { border-radius: 14px; border-color: var(--border); animation: pop .16s var(--ease); }
.menu a, .menu button { border-radius: 9px; }
.avatar { background: var(--grad-primary); box-shadow: 0 4px 12px -4px rgba(61, 92, 255, .6); }
:root[data-theme="dark"] .avatar { background: var(--grad-primary); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Boutons ---------- */
.btn { border-radius: 10px; border-color: var(--border); box-shadow: 0 1px 2px rgba(14, 22, 48, .05); transition: background .15s, box-shadow .15s, transform .08s, border-color .15s; }
.btn:hover { border-color: var(--border-strong); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary { background: var(--grad-primary); border-color: transparent; box-shadow: 0 6px 16px -6px rgba(61, 92, 255, .65), inset 0 1px 0 rgba(255, 255, 255, .18); }
.btn.primary:hover { background: var(--grad-primary); filter: brightness(1.07); box-shadow: 0 10px 22px -8px rgba(61, 92, 255, .75), inset 0 1px 0 rgba(255, 255, 255, .2); }
.btn.amber { background: var(--grad-volt); border-color: transparent; box-shadow: 0 6px 16px -6px rgba(255, 171, 0, .6); }
.btn.ok { box-shadow: 0 6px 16px -6px rgba(15, 138, 95, .55); }
.btn.ghost { box-shadow: none; }

/* ---------- Champs ---------- */
input, select, textarea { border-radius: 10px; border-color: var(--border-strong); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 4px var(--focus); }
input[type=checkbox], input[type=radio] { box-shadow: none; }

/* ---------- Cartes ---------- */
.card { border-radius: var(--radius); border-color: var(--border); box-shadow: var(--shadow); }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head h2 svg { color: var(--primary); }
.list-item.click, .list-item[data-href] { margin: 0 -10px; padding: 10px; border-radius: 12px; border-bottom-color: transparent; transition: background .15s, transform .15s; cursor: pointer; }
.list-item.click:hover, .list-item[data-href]:hover { background: var(--row-hover); transform: translateX(2px); }
.list-item + .list-item { box-shadow: 0 -1px 0 var(--line-soft); }
.empty { color: var(--muted); }

/* ---------- Indicateurs (KPI) ---------- */
.kpis { gap: 16px; }
.kpi {
  position: relative; overflow: hidden; border-radius: var(--radius); padding: 16px 18px; border-color: var(--border);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.kpi .label { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 800; letter-spacing: -.03em; margin-top: 8px; }
.kpi-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); flex: none; }
.kpi-ic svg { width: 16px; height: 16px; }
.kpi-ic.ok { background: var(--ok-50); color: var(--ok); }
.kpi-ic.warn { background: var(--warn-50); color: var(--warn); }
.kpi-ic.violet { background: var(--violet-50); color: var(--violet); }
.kpi.accent, :root[data-theme="dark"] .kpi.accent {
  background: var(--grad-primary); border-color: transparent; color: #fff;
  box-shadow: 0 14px 30px -14px rgba(61, 92, 255, .8);
}
.kpi.accent .kpi-ic { background: rgba(255, 255, 255, .18); color: #fff; }
.kpi.accent .label, .kpi.accent .hint { color: rgba(255, 255, 255, .82); }
.kpi.accent::after {
  content: ""; position: absolute; right: -18px; bottom: -26px; width: 120px; height: 120px; opacity: .14;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M3 11.5 12 4l9 7.5M5.5 9.8V20h13V9.8M10 20v-5.5h4V20'/%3E%3C/svg%3E");
}
.trend { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: 99px; font-weight: 700; font-size: 11.5px; background: rgba(255, 255, 255, .2); }

/* ---------- Bandeau d'accueil (tableau de bord) ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 20px; padding: 24px 26px; margin-bottom: 20px; color: #fff;
  background: var(--grad-ink); box-shadow: 0 20px 40px -22px rgba(14, 22, 48, .7);
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(500px 220px at 100% 0%, rgba(106, 69, 255, .45), transparent 70%),
    radial-gradient(400px 200px at 0% 120%, rgba(255, 194, 26, .22), transparent 70%),
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px) 0 0 / 28px 28px;
}
.hero > * { position: relative; }
.hero h1 { color: #fff; font-size: 28px; }
.hero .sub { color: #aeb8d8; margin-top: 4px; text-transform: capitalize; }
.hero .chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.hero .chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .1); color: #dfe5f7; font-size: 12.5px; font-weight: 600; text-decoration: none; transition: background .15s; }
.hero .chip:hover { background: rgba(255, 255, 255, .15); text-decoration: none; }
.hero .chip b { color: var(--amber); }
.hero .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.hero .btn:not(.primary) { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .14); color: #fff; box-shadow: none; }
.hero .btn:not(.primary):hover { background: rgba(255, 255, 255, .16); }
.hero .btn.primary { background: var(--grad-volt); color: #1a1300; box-shadow: 0 8px 20px -8px rgba(255, 171, 0, .8); }
.hero-mark { position: absolute !important; right: 220px; top: -30px; width: 170px; height: 170px; opacity: .06; color: #fff; pointer-events: none; }
@media (max-width: 900px) { .hero-mark { display: none; } .hero h1 { font-size: 23px; } }

/* ---------- Tableaux ---------- */
th { background: transparent; color: var(--muted); font-size: 11px; letter-spacing: .07em; border-bottom: 1px solid var(--border); padding-top: 12px; padding-bottom: 10px; }
td { border-bottom-color: var(--line-soft); }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: var(--row-hover); }
tr.selected td, tr.selected:hover td { background: color-mix(in srgb, var(--primary) 9%, transparent); }
.toolbar { background: linear-gradient(var(--card), var(--soft)); }
.toolbar input, .toolbar select { height: 38px; }

/* ---------- Pastilles & onglets ---------- */
.pill { padding: 3px 10px; font-weight: 650; box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 14%, transparent); }
.tabs { background: var(--soft); padding: 4px; border-radius: 12px; gap: 2px; border: 1px solid var(--border); }
.tab { border-radius: 9px; transition: background .15s, color .15s, box-shadow .15s; }
.tab.active, :root[data-theme="dark"] .tab.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(14, 22, 48, .12), 0 0 0 1px var(--border); }
.subtabs button { transition: color .15s, border-color .15s; }
.subtabs button:hover { color: var(--text); }
.progress { height: 8px; }
.progress > div { background: var(--grad-primary); transition: width .6s var(--ease); }
.progress.ok > div { background: linear-gradient(90deg, #17b27a, #0f8a5f); }

/* ---------- Graphique ---------- */
.chart .bar { fill: url(#gBar); transition: opacity .15s; }
.chart .bar.cur { fill: url(#gBarCur); }
.chart .bar:hover { opacity: .8; }

/* ---------- Modale, toast, alertes ---------- */
.modal { background: rgba(8, 12, 28, .45); backdrop-filter: blur(6px); animation: fade .18s ease; }
.modal-box { border-radius: 20px; padding: 24px 26px; border: 1px solid var(--border); animation: rise .22s var(--ease); }
.toast { border-radius: 12px; background: #111936; box-shadow: 0 18px 40px -12px rgba(14, 22, 48, .6); animation: rise .22s var(--ease); padding: 12px 18px 12px 16px; display: flex; gap: 8px; align-items: center; }
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #2fd38f; box-shadow: 0 0 8px #2fd38f; }
.toast.err { background: #3a1418; } .toast.err::before { background: #ff6b63; box-shadow: 0 0 8px #ff6b63; }
.alert { border-radius: 12px; border: 1px solid color-mix(in srgb, currentColor 14%, transparent); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

/* ---------- Apparition des pages ---------- */
/* « backwards » et non « both » : une fois l'animation finie, plus aucune transformation ne reste sur les blocs. Sinon chaque bloc forme
   sa propre couche et les menus déroulants (Plus, Facturer…) passent derrière les blocs suivants. */
main.enter > * { animation: rise .35s var(--ease) backwards; }
main.enter > *:nth-child(2) { animation-delay: .04s; }
main.enter > *:nth-child(3) { animation-delay: .08s; }
main.enter > *:nth-child(4) { animation-delay: .12s; }
main.enter > *:nth-child(n+5) { animation-delay: .16s; }
main.enter .kpis > * { animation: rise .4s var(--ease) backwards; }
main.enter .kpis > *:nth-child(2) { animation-delay: .05s; } main.enter .kpis > *:nth-child(3) { animation-delay: .1s; }
main.enter .kpis > *:nth-child(4) { animation-delay: .15s; } main.enter .kpis > *:nth-child(5) { animation-delay: .2s; }
.loading { display: grid; gap: 14px; }
.loading .sk { height: 18px; border-radius: 8px; background: linear-gradient(90deg, var(--hover) 25%, var(--soft) 50%, var(--hover) 75%) 0 0 / 200% 100%; animation: shimmer 1.2s linear infinite; }
.loading .sk.big { height: 120px; border-radius: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Page de connexion ---------- */
.auth {
  background:
    radial-gradient(700px 400px at 15% 10%, rgba(61, 92, 255, .45), transparent 65%),
    radial-gradient(600px 400px at 90% 90%, rgba(255, 171, 0, .22), transparent 65%),
    linear-gradient(rgba(255, 255, 255, .04) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(90deg, rgba(255, 255, 255, .04) 1px, transparent 1px) 0 0 / 34px 34px,
    var(--grad-ink);
}
.auth-box { border-radius: 22px; padding: 34px; box-shadow: 0 40px 90px -20px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 255, 255, .06); animation: rise .4s var(--ease); }
.auth-box .brand { font-size: 22px; }
.auth-box .btn.primary { padding: 11px; font-size: 15px; }

/* ---------- Défilement ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
#nav { scrollbar-color: rgba(255, 255, 255, .12) transparent; }

/* Thème sombre : le bandeau d'accueil garde un contour pour se détacher du fond */
:root[data-theme="dark"] .hero { box-shadow: 0 0 0 1px rgba(255, 255, 255, .07), 0 20px 40px -22px rgba(0, 0, 0, .9); }
:root[data-theme="dark"] .toast { background: #1c2540; }

/* Mobile : indicateurs sur deux colonnes, le principal en pleine largeur */
@media (max-width: 600px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis .kpi.accent { grid-column: 1 / -1; }
  .kpi { padding: 12px 14px; }
  .kpi .value { font-size: 21px; }
  .hero { padding: 20px; border-radius: 18px; }
  .hero .actions { margin-left: 0; width: 100%; }
  .hero .actions .btn { flex: 1; }
}

/* Grand écran : contenu centré ; barre du haut : recherche + « Créer » à gauche, cloche et compte collés à droite */
main { margin-left: auto; margin-right: auto; }
.topbar .dropdown:has(#notif-btn) { margin-left: auto; }

/* ---------- Cases à cocher ---------- */
input[type=checkbox] {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 18px; height: 18px; margin: 0; padding: 0; border-radius: 6px; cursor: pointer;
  border: 1.5px solid var(--border-strong); background: var(--card) no-repeat center / 12px 12px;
  display: inline-grid; place-content: center; vertical-align: middle;
  transition: background-color .15s, border-color .15s, box-shadow .15s, transform .1s;
}
input[type=checkbox]:hover { border-color: var(--primary); box-shadow: 0 0 0 4px var(--focus); }
input[type=checkbox]:active { transform: scale(.9); }
input[type=checkbox]:focus-visible { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 4px var(--focus); }
input[type=checkbox]:checked, input[type=checkbox]:indeterminate {
  border-color: transparent; background-color: var(--primary);
  background-image: var(--grad-primary); box-shadow: 0 3px 8px -3px rgba(61, 92, 255, .7);
}
input[type=checkbox]:checked::after, input[type=checkbox]:indeterminate::after {
  content: ""; width: 12px; height: 12px; background: #fff; animation: tick .18s var(--ease);
  -webkit-mask: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
          mask: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}
input[type=checkbox]:indeterminate::after {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
}
input[type=checkbox]:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
:root[data-theme="dark"] input[type=checkbox] { background-color: #0f141f; border-color: #3a4560; }
:root[data-theme="dark"] input[type=checkbox]:checked, :root[data-theme="dark"] input[type=checkbox]:indeterminate { border-color: transparent; }
@keyframes tick { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.check input[type=checkbox] { margin-top: 1px; }
th.sel input, td.sel input { width: 18px; height: 18px; }

/* Menu déroulant ouvert : son bloc passe au premier plan (utile aussi pendant l'animation d'apparition) */
main > *:has(.menu:not(.hidden)), main .doc-layout > *:has(.menu:not(.hidden)), main .grid > *:has(.menu:not(.hidden)) { position: relative; z-index: 7; }
