@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* =====================================================================
   Zelivry — Design system v4 (refonte radicale "premium SaaS")
   Marque : bleu #0066FF · orange #FF6B2B · navy #0A1628
   ===================================================================== */
:root{
  --liv:#0066FF; --liv-600:#0052D6; --liv-700:#003FCC; --liv2:#3D8BFF;
  --accent:#FF6B2B; --accent-600:#E85A1B;
  --ok:#00C781; --ok-600:#00A86B; --warn:#F59E0B; --danger:#EF4444; --info:#0EA5E9;
  --bg:#EEF2FB; --surface:#fff; --surface-2:#F5F8FF;
  --border:#E7ECF5; --border-2:#EEF2F8;
  --text:#0C1A33; --muted:#637089; --muted-2:#9aa6bd;
  --shadow-sm:0 2px 6px rgba(16,40,90,.06);
  --shadow:0 8px 24px rgba(16,40,90,.08);
  --shadow-md:0 14px 36px rgba(16,40,90,.12);
  --shadow-lg:0 26px 60px rgba(16,40,90,.22);
  --glow:0 8px 24px rgba(0,102,255,.35);
  --radius:18px; --radius-sm:12px;
  --bs-primary:#0066FF; --bs-primary-rgb:0,102,255;
  --bs-link-color:#0066FF; --bs-link-hover-color:#0052D6;
}
*{ box-sizing:border-box; }
body{
  margin:0; color:var(--text); font-weight:400;
  background:
    radial-gradient(1100px 520px at 100% -5%, rgba(0,102,255,.07), transparent),
    radial-gradient(900px 500px at -10% 110%, rgba(255,107,43,.06), transparent),
    var(--bg);
  font-family:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;
  font-size:.92rem; line-height:1.55; -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;
}
a{ color:var(--liv); text-decoration:none; }
a:hover{ color:var(--liv-600); }
h1,h2,h3,h4,h5,h6{ color:var(--text); font-weight:600; letter-spacing:-.01em; }
.fw-bold{ font-weight:600!important; }
.fw-semibold{ font-weight:500!important; }

/* ---------- Layout ---------- */
.layout{ display:flex; min-height:100vh; }

/* ---------- Sidebar (dégradé bleu vif → navy) ---------- */
.sidebar{
  width:264px; position:fixed; inset:0 auto 0 0; display:flex; flex-direction:column; z-index:1040;
  color:#c5d6f2;
  background:linear-gradient(165deg, var(--liv) 0%, #0a3aa8 42%, #0A1628 100%);
  box-shadow:6px 0 30px rgba(8,24,60,.18);
}
.sidebar .brand{
  font-weight:600; color:#fff; font-size:1.2rem; letter-spacing:.2px;
  padding:20px 22px; display:flex; align-items:center; gap:10px;
  border-bottom:1px solid rgba(255,255,255,.12); min-height:66px;
}
.sidebar .brand img{ border-radius:8px; }
.sidebar .menu{ flex:1; overflow-y:auto; padding:12px 0 16px; }
.sidebar .menu::-webkit-scrollbar{ width:7px; }
.sidebar .menu::-webkit-scrollbar-thumb{ background:rgba(255,255,255,.18); border-radius:10px; }
.sidebar .grp{
  text-transform:uppercase; font-size:.64rem; font-weight:600; letter-spacing:.14em;
  color:rgba(255,255,255,.42); padding:18px 22px 7px;
}
.sidebar .item{
  display:flex; align-items:center; gap:12px; margin:3px 13px; padding:10px 13px;
  color:#cfddf6; text-decoration:none; font-size:.9rem; font-weight:500;
  border-radius:12px; transition:all .16s ease;
}
.sidebar .item .ic{ width:24px; text-align:center; font-size:1.05rem; flex:none; opacity:.92; }
.sidebar .item .lb{ flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sidebar .item:hover{ background:rgba(255,255,255,.12); color:#fff; }
.sidebar .item.active{
  background:rgba(255,255,255,.96); color:var(--liv-700);
  box-shadow:0 8px 20px rgba(4,18,48,.35); font-weight:600;
}
.sidebar .item.active .ic{ opacity:1; }
.sidebar .item .badge{ font-size:.66rem; }
.sidebar .side-foot{ padding:15px 22px; border-top:1px solid rgba(255,255,255,.12); font-size:.78rem; color:rgba(255,255,255,.7); }
.side-foot .t-name{ color:#fff; font-weight:600; }

/* ---------- Contenu / topbar ---------- */
.content{ margin-left:264px; flex:1; display:flex; flex-direction:column; min-width:0; }
.topbar{
  background:rgba(255,255,255,.8); backdrop-filter:saturate(180%) blur(14px);
  border-bottom:1px solid var(--border); padding:0 24px; min-height:64px;
  display:flex; align-items:center; gap:14px; position:sticky; top:0; z-index:1030;
}
.topbar .page-title{ color:var(--text); font-weight:600; font-size:1.22rem; letter-spacing:-.01em; }
.main{ padding:24px; flex:1; }
.foot{ text-align:center; color:var(--muted-2); font-size:.8rem; padding:18px; }

/* ---------- Cartes ---------- */
.card{
  border:1px solid var(--border); background:var(--surface);
  box-shadow:var(--shadow-sm); border-radius:var(--radius);
  transition:box-shadow .2s, transform .2s;
}
.card .card-body{ padding:1.3rem 1.4rem; }
.card-header{ background:transparent; border-bottom:1px solid var(--border); font-weight:600; padding:1rem 1.4rem; }

/* ---------- KPI (gros chiffres + halo coloré) ---------- */
.kpi{ position:relative; overflow:hidden; }
.kpi::after{
  content:""; position:absolute; top:-40px; right:-40px; width:130px; height:130px; border-radius:50%;
  background:radial-gradient(circle at 30% 30%, rgba(0,102,255,.22), transparent 70%); pointer-events:none;
}
.kpi.green::after{ background:radial-gradient(circle at 30% 30%, rgba(0,199,129,.22), transparent 70%); }
.kpi.amber::after{ background:radial-gradient(circle at 30% 30%, rgba(245,158,11,.22), transparent 70%); }
.kpi.red::after{ background:radial-gradient(circle at 30% 30%, rgba(239,68,68,.22), transparent 70%); }
.kpi::before{ content:""; position:absolute; left:0; top:0; bottom:0; width:5px;
  background:linear-gradient(var(--liv),var(--liv-700)); }
.kpi.green::before{ background:linear-gradient(var(--ok),var(--ok-600)); }
.kpi.amber::before{ background:linear-gradient(#fbbf24,var(--warn)); }
.kpi.red::before{ background:linear-gradient(#f87171,var(--danger)); }
.kpi:hover{ box-shadow:var(--shadow-md); transform:translateY(-3px); }
.kpi .lbl{ color:var(--muted); font-size:.7rem; font-weight:500; text-transform:uppercase; letter-spacing:.06em; margin-bottom:.3rem; }
.kpi .val{ font-size:1.4rem; font-weight:600; color:var(--text); letter-spacing:-.01em; font-variant-numeric:tabular-nums; line-height:1.15; }
.kpi.green .val{ color:var(--ok-600); } .kpi.amber .val{ color:#B45309; } .kpi.red .val{ color:var(--danger); }

/* ---------- Tableaux ---------- */
.table{ --bs-table-bg:transparent; margin-bottom:0; }
.table thead th{
  background:var(--surface-2); color:var(--muted); font-weight:500;
  font-size:.7rem; text-transform:uppercase; letter-spacing:.06em;
  white-space:nowrap; border-bottom:1px solid var(--border); padding:.8rem .8rem;
}
.table tbody td{ border-color:var(--border-2); padding:.72rem .8rem; }
.table-sm td,.table-sm th{ vertical-align:middle; }
.table-hover tbody tr{ transition:background .12s; }
.table-hover tbody tr:hover>*{ background:var(--surface-2); }

/* ---------- Boutons ---------- */
.btn{ border-radius:11px; font-weight:500; letter-spacing:.01em; padding:.45rem .95rem;
  transition:all .16s ease; }
.btn:active{ transform:translateY(1px); }
.btn-sm{ border-radius:9px; }
.btn-primary{ background:linear-gradient(135deg,var(--liv2),var(--liv) 55%,var(--liv-700)); border:none; box-shadow:var(--glow); }
.btn-primary:hover,.btn-primary:focus{ filter:brightness(1.07); box-shadow:0 10px 28px rgba(0,102,255,.45); }
.btn-primary:active{ filter:brightness(.95); }
.btn-outline-primary{ color:var(--liv); border:1.5px solid #bcd4ff; background:#fff; }
.btn-outline-primary:hover{ background:var(--liv); border-color:var(--liv); color:#fff; box-shadow:var(--glow); }
.btn-success{ background:linear-gradient(135deg,#1be0a0,var(--ok) 60%,var(--ok-600)); border:none; box-shadow:0 8px 22px rgba(0,199,129,.32); }
.btn-success:hover,.btn-success:focus{ filter:brightness(1.06); color:#fff; }
.btn-outline-success{ color:var(--ok-600); border:1.5px solid #a7e9cf; background:#fff; }
.btn-outline-success:hover{ background:var(--ok); border-color:var(--ok); color:#fff; }
.btn-warning{ background:linear-gradient(135deg,#ff8a4d,var(--accent) 60%,var(--accent-600)); border:none; color:#fff; box-shadow:0 8px 22px rgba(255,107,43,.32); }
.btn-warning:hover,.btn-warning:focus{ filter:brightness(1.05); color:#fff; }
.btn-light{ background:#fff; border:1px solid var(--border); }
.btn-light:hover{ background:var(--surface-2); }

/* ---------- Formulaires ---------- */
.form-control,.form-select{ border:1.5px solid var(--border); border-radius:11px; padding:.5rem .8rem; color:var(--text); }
.form-control::placeholder{ color:var(--muted-2); }
.form-control:focus,.form-select:focus{ border-color:var(--liv); box-shadow:0 0 0 4px rgba(0,102,255,.14); }
.form-label{ font-weight:500; font-size:.83rem; color:#2c3a55; margin-bottom:.35rem; }
.form-text{ color:var(--muted-2); }
.input-group-text{ background:var(--surface-2); border:1.5px solid var(--border); color:var(--muted); border-radius:11px; }
.required:after{ content:" *"; color:var(--danger); }

/* ---------- Badges & divers ---------- */
.badge{ font-weight:500; letter-spacing:.02em; border-radius:8px; padding:.42em .65em; }
.dropdown-menu{ border:1px solid var(--border); border-radius:14px; box-shadow:var(--shadow-md); padding:.45rem; }
.dropdown-item{ border-radius:9px; padding:.5rem .75rem; font-size:.9rem; font-weight:500; }
.dropdown-item:active{ background:var(--liv); }
.alert{ border:1px solid transparent; border-radius:14px; }
.nav-tabs .nav-link.active{ color:var(--liv); border-bottom:2px solid var(--liv); font-weight:600; }
.progress{ border-radius:10px; background:var(--border-2); height:10px; }
.progress-bar{ background:linear-gradient(90deg,var(--liv2),var(--liv)); }
hr{ border-color:var(--border); opacity:1; }
.text-primary{ color:var(--liv)!important; }
.bg-primary{ background-color:var(--liv)!important; }

/* ---------- Auth (login / register / reset) ---------- */
.login-wrap{ max-width:440px; margin:7vh auto; padding:0 16px; }
.login-card{ border:1px solid var(--border); border-radius:22px; box-shadow:var(--shadow-lg); overflow:hidden; }
.login-card .card-body{ padding:2.2rem 2rem; }

/* ---------- Tuiles ---------- */
.tile{
  display:block; padding:20px; border-radius:var(--radius); background:var(--surface);
  border:1px solid var(--border); box-shadow:var(--shadow-sm); text-decoration:none; color:var(--text);
  height:100%; transition:all .2s ease;
}
.tile:hover{ box-shadow:var(--shadow-md); transform:translateY(-3px); border-color:#bcd4ff; color:var(--liv); }
.tile .ic{ font-size:1.8rem; }

/* ---------- Responsive ---------- */
@media (max-width:991.98px){
  .sidebar{ transform:translateX(-100%); transition:transform .24s ease; box-shadow:var(--shadow-lg); }
  .sidebar.show{ transform:translateX(0); }
  .content{ margin-left:0; }
  .main{ padding:16px; }
  .kpi .val{ font-size:1.3rem; }
}

/* ---------- Bouton repli du menu + mode réduit (desktop) ---------- */
.sb-collapse{
  display:flex; align-items:center; gap:11px; margin:6px 13px; padding:9px 13px;
  width:calc(100% - 26px); background:rgba(255,255,255,.08); border:none; border-radius:12px;
  color:#cfddf6; font-size:.85rem; font-weight:500; cursor:pointer; transition:background .15s,color .15s;
}
.sb-collapse:hover{ background:rgba(255,255,255,.18); color:#fff; }
.sb-collapse .chev{ font-size:1.15rem; line-height:1; width:24px; text-align:center; transition:transform .2s; }
@media (min-width:992px){
  html.sb-collapsed .sidebar{ width:78px; }
  html.sb-collapsed .content{ margin-left:78px; }
  html.sb-collapsed .sidebar .brand span,
  html.sb-collapsed .sidebar .lb,
  html.sb-collapsed .sidebar .grp,
  html.sb-collapsed .sidebar .item .badge,
  html.sb-collapsed .side-foot{ display:none; }
  html.sb-collapsed .sidebar .brand{ justify-content:center; padding:20px 0; }
  html.sb-collapsed .sidebar .item{ justify-content:center; padding:11px 0; margin:3px 11px; }
  html.sb-collapsed .sidebar .item .ic{ width:auto; }
  html.sb-collapsed .sb-collapse{ justify-content:center; }
  html.sb-collapsed .sb-collapse .lb{ display:none; }
  html.sb-collapsed .sb-collapse .chev{ transform:rotate(180deg); }
}

/* ---------- En-tête : disposition propre, sans retour à la ligne ---------- */
.topbar{ flex-wrap:nowrap; gap:10px; }
.topbar .page-title{ white-space:nowrap; flex:none; }
.topbar form[role="search"]{ flex:0 1 240px; min-width:0; }
.topbar form[role="search"] input{ width:100%; }
.topbar > .ms-auto{ flex:none; }
.topbar-clock{ color:var(--muted); font-size:.8rem; font-weight:500; font-variant-numeric:tabular-nums;
  white-space:nowrap; align-items:center; text-transform:capitalize; flex:none; }
.topbar-lang, .topbar-lang .small{ white-space:nowrap; }
.topbar .btn{ white-space:nowrap; }
.uava{ display:inline-flex; align-items:center; justify-content:center; width:24px; height:24px; border-radius:50%;
  background:linear-gradient(135deg,var(--liv2),var(--liv)); color:#fff; font-weight:600; font-size:.75rem; flex:none; }
.foot a{ color:var(--muted); text-decoration:none; } .foot a:hover{ color:var(--liv); }

/* ---------- Tables type tableur (séparateurs de colonnes Excel-like) ---------- */
.main .table > :not(caption) > * > *{ border-right:1px solid var(--border-2); }
.main .table > :not(caption) > * > *:last-child{ border-right:0; }

/* ---------- Responsive renforcé (mobile) ---------- */
@media (max-width:575.98px){
  .main{ padding:12px; }
  .card .card-body{ padding:.9rem 1rem; }
  .topbar{ padding:0 14px; min-height:54px; }
  .topbar .page-title{ font-size:1.05rem; }
  .kpi .val{ font-size:1.2rem; }
  .kpi .lbl{ font-size:.66rem; }
  h4{ font-size:1.15rem; } h5{ font-size:1rem; }
  .btn{ padding:.42rem .75rem; }
  .table thead th, .table tbody td{ padding:.55rem .5rem; }
}

/* ---------- Impression ---------- */
.doc{ max-width:800px; margin:20px auto; background:#fff; padding:32px; box-shadow:var(--shadow); border-radius:var(--radius); }
.doc h1{ color:var(--liv); }
@media print{
  .no-print{ display:none !important; }
  .sidebar,.topbar,.foot{ display:none !important; }
  .content{ margin-left:0 !important; }
  .main{ padding:0 !important; }
  body{ background:#fff; }
  .doc{ box-shadow:none; margin:0; max-width:100%; padding:0; border:0; }
  .card{ box-shadow:none; border:1px solid #ddd; }
  .print-block{ page-break-after:always; }
}

/* ---------- Mode sombre ---------- */
html.dark{
  --bg:#0B1220; --surface:#111A2B; --surface-2:#16223A;
  --border:#243049; --border-2:#1E2A42;
  --text:#E6EDF7; --muted:#9DB0C9; --muted-2:#6B7D99;
  --shadow-sm:0 1px 2px rgba(0,0,0,.4); --shadow:0 8px 24px rgba(0,0,0,.45);
  --shadow-md:0 14px 36px rgba(0,0,0,.5); --shadow-lg:0 18px 46px rgba(0,0,0,.6);
  --bs-body-bg:#0B1220; --bs-body-color:#E6EDF7;
}
html.dark body{ background:
  radial-gradient(1100px 520px at 100% -5%, rgba(0,102,255,.10), transparent),
  radial-gradient(900px 500px at -10% 110%, rgba(255,107,43,.06), transparent),
  var(--bg); color:var(--text); }
html.dark .topbar{ background:rgba(17,26,43,.85); border-bottom-color:var(--border); }
html.dark .card, html.dark .dropdown-menu{ background:var(--surface); color:var(--text); }
html.dark .table{ color:var(--text); }
html.dark .table thead th{ background:var(--surface-2); color:var(--muted); border-bottom-color:var(--border); }
html.dark .table tbody td{ border-color:var(--border-2); }
html.dark .table-hover tbody tr:hover>*{ background:var(--surface-2); }
html.dark .main .table > :not(caption) > * > *{ border-right-color:var(--border-2); }
html.dark .form-control, html.dark .form-select{ background:var(--surface-2); color:var(--text); border-color:var(--border); }
html.dark .form-control::placeholder{ color:var(--muted-2); }
html.dark .form-select option{ background:var(--surface); color:var(--text); }
html.dark .input-group-text{ background:var(--surface); border-color:var(--border); color:var(--muted); }
html.dark .btn-light{ background:var(--surface-2); color:var(--text); border-color:var(--border); }
html.dark .btn-light:hover{ background:var(--surface); }
html.dark .dropdown-item{ color:var(--text); }
html.dark .dropdown-item:hover{ background:var(--surface-2); }
html.dark .text-muted{ color:var(--muted)!important; }
html.dark .card-header, html.dark hr{ border-color:var(--border); }
html.dark .table-light, html.dark .table-light>*{ --bs-table-bg:var(--surface-2); --bs-table-color:var(--text); }
html.dark .modal-content{ background:var(--surface); color:var(--text); }
html.dark .kpi .val{ color:var(--text); }
html.dark code{ color:#7ab0ff; }

/* ---------- Icônes Lucide ---------- */
.lucide{ width:18px; height:18px; stroke-width:2; vertical-align:-3px; flex:none; }
.sidebar .item .ic{ display:inline-flex; align-items:center; justify-content:center; }
.sidebar .item .ic .lucide{ width:19px; height:19px; opacity:.95; }
.sidebar .brand .lucide{ width:22px; height:22px; }
.sb-collapse .chev .lucide{ width:18px; height:18px; }
.btn .lucide{ width:16px; height:16px; vertical-align:-3px; }
.topbar .btn .lucide{ width:18px; height:18px; vertical-align:-4px; }

/* ---------- Micro-interactions ---------- */
.card{ animation:zfade .3s ease both; }
@keyframes zfade{ from{ opacity:0; transform:translateY(6px); } to{ opacity:1; transform:none; } }
.btn-primary:hover, .btn-success:hover, .btn-warning:hover{ transform:translateY(-1px); }
.btn:focus-visible, .form-control:focus-visible, .form-select:focus-visible, a:focus-visible, .item:focus-visible{
  outline:2px solid var(--liv); outline-offset:2px; }
.sidebar .item, .tile, .kpi{ will-change:transform; }
.dropdown-menu{ animation:zfade .15s ease both; }

/* ---------- Toasts ---------- */
.toast{ border-radius:12px; box-shadow:var(--shadow-lg); font-weight:500; }
.toast .toast-body{ padding:.85rem 1rem; }

/* ---------- États vides ---------- */
.table td.text-center.text-muted{ padding:2rem 1rem; }
