/* =====================================================================
   LeivCo — espace administrateur
   Violet #53057F · Vert #055229 · Jaune #D3D510 · Blanc
   ===================================================================== */
:root {
  --violet: #53057F; --violet-d: #33024F; --violet-50: #F3EDF7; --violet-100: #E6D8EE;
  --green: #055229; --green-50: #E7F1EA; --yellow: #D3D510; --yellow-d: #A9AB0A; --yellow-50: #F9FAD9;
  --white: #FFFFFF; --ink: #26033A; --muted: #6D5C78; --line: #ECE4F1; --bg: #F7F3FA; --danger: #B3261E; --danger-50: #FBE9E8;
  --font: 'Bricolage Grotesque', system-ui, sans-serif; --display: 'Bagel Fat One', 'Bricolage Grotesque', sans-serif;
  --shadow: 0 10px 30px rgba(51, 2, 79, .12);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; border-radius: 8px; }
.money { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: 13px; }

/* ------------------------------------------------------------- Boutons & champs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px; border: 0; border-radius: 12px; cursor: pointer; font-weight: 700; font-size: 14.5px; white-space: nowrap; transition: transform .1s, background .15s; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-action { background: var(--yellow); color: var(--violet-d); box-shadow: 0 3px 0 var(--yellow-d); }
.btn-primary { background: var(--violet); color: var(--white); box-shadow: 0 3px 0 var(--violet-d); }
.btn-soft { background: var(--violet-50); color: var(--violet); }
.btn-green { background: var(--green-50); color: var(--green); }
.btn-danger { background: var(--danger-50); color: var(--danger); }
.btn-ghost { background: transparent; color: var(--violet); }
.btn-sm { height: 34px; padding: 0 11px; font-size: 13px; border-radius: 10px; }
.btn-icon { width: 34px; padding: 0; }
.btn-block { width: 100%; }
.spin { width: 16px; height: 16px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 6px 2px; }
.input, .select, textarea.input { width: 100%; height: 44px; padding: 0 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--white); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; min-height: 110px; padding: 10px 14px; resize: vertical; }
.input:focus, .select:focus { border-color: var(--violet); box-shadow: 0 0 0 4px var(--violet-50); }
.select { appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2353057F' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
.search { position: relative; }
.search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--violet); }
.search .input { padding-left: 38px; min-width: 240px; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.check input { position: absolute; opacity: 0; }
.check span { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--violet-100); display: grid; place-items: center; }
.check input:checked + span { background: var(--violet); border-color: var(--violet); }
.check input:checked + span::after { content: ''; width: 6px; height: 10px; border: solid var(--yellow); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px, -1px); }
.check input:focus-visible + span { outline: 3px solid var(--yellow); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* ------------------------------------------------------------- Connexion */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-side { background: var(--violet); color: var(--white); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-side img { width: 170px; }
.login-side h1 { font-family: var(--display); font-weight: 400; font-size: 52px; line-height: 1; margin: 0 0 14px; color: var(--yellow); }
.login-side p { color: #E6D8EE; max-width: 40ch; margin: 0; }
.login-form { display: grid; place-items: center; padding: 30px; }
.login-form form { width: 100%; max-width: 380px; }
.login-form h2 { font-size: 26px; margin: 0 0 6px; }
.demo { margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: var(--yellow-50); border: 1.5px dashed var(--yellow-d); font-size: 13.5px; }

/* ------------------------------------------------------------- Cadre */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--violet-d); color: #E6D8EE; padding: 22px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-logo { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
.side-logo img { height: 30px; }
.side-logo span { font-size: 12px; font-weight: 700; color: var(--yellow); background: rgba(211,213,16,.14); padding: 3px 8px; border-radius: 8px; }
.nav { display: grid; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; font-weight: 600; }
.nav a i { width: 20px; text-align: center; color: #B79AC9; }
.nav a:hover { background: rgba(255,255,255,.06); }
.nav a.on { background: var(--yellow); color: var(--violet-d); }
.nav a.on i { color: var(--violet-d); }
.side-foot { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.1); }
.side-foot b { display: block; color: var(--white); }
.side-foot a { display: inline-flex; gap: 8px; align-items: center; margin-top: 10px; color: #E6D8EE; font-size: 14px; cursor: pointer; }
.side-foot a:hover { color: var(--yellow); }
.main { min-width: 0; }
.topbar { display: none; }
.page { padding: 28px 32px 60px; max-width: 1280px; }
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-family: var(--display); font-weight: 400; font-size: 34px; margin: 0; color: var(--violet); flex: 1; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filters .select { width: auto; min-width: 160px; }
.seg { display: inline-flex; padding: 4px; gap: 3px; border-radius: 12px; background: var(--white); border: 1.5px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; font-weight: 700; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--violet); color: var(--white); }

/* ------------------------------------------------------------- Cartes */
.card { background: var(--white); border-radius: 20px; padding: 20px; box-shadow: 0 1px 0 var(--line); border: 1px solid var(--line); }
.card h3 { margin: 0 0 14px; font-size: 16px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--white); border-radius: 18px; padding: 16px; border: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.kpi .ic { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--violet-50); color: var(--violet); flex: none; font-size: 17px; }
.kpi .ic.g { background: var(--green-50); color: var(--green); }
.kpi .ic.y { background: var(--yellow); color: var(--violet-d); }
.kpi b { display: block; font-size: 22px; font-weight: 800; line-height: 1.1; }
.kpi small { color: var(--muted); font-size: 13px; }
.dash-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-bottom: 16px; }
.bars { display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; align-items: end; height: 170px; padding-top: 10px; }
.bars .b { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 3px; position: relative; }
.bars .b i { display: block; border-radius: 6px 6px 3px 3px; background: var(--violet); min-height: 3px; }
.bars .b i.s { background: var(--yellow); }
.bars .b:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--white); font-size: 12px; padding: 5px 8px; border-radius: 8px; white-space: nowrap; z-index: 2; margin-bottom: 6px; }
.bars-x { display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; font-size: 11px; color: var(--muted); text-align: center; margin-top: 6px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin-top: 10px; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--violet); margin-right: 6px; }
.legend span.s::before { background: var(--yellow); }
.plan-bar { margin-bottom: 12px; }
.plan-bar .row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }
.plan-bar .track { height: 9px; border-radius: 9px; background: var(--violet-50); overflow: hidden; }
.plan-bar .track i { display: block; height: 100%; background: var(--violet); border-radius: 9px; }
.plan-bar.g .track i { background: var(--green); }

/* ------------------------------------------------------------- Tableaux */
.table-wrap { background: var(--white); border-radius: 18px; border: 1px solid var(--line); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 12px 14px; border-bottom: 1.5px solid var(--line); background: #FCFAFD; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #FCFAFD; }
td .who b { display: block; }
td .who small { color: var(--muted); }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 24px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.c-violet { background: var(--violet-50); color: var(--violet); }
.c-green { background: var(--green-50); color: var(--green); }
.c-yellow { background: var(--yellow-50); color: #6E6F00; }
.c-grey { background: #F1EEF3; color: var(--muted); }
.c-red { background: var(--danger-50); color: var(--danger); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty i { font-size: 30px; color: var(--violet-100); display: block; margin-bottom: 10px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; font-size: 13.5px; color: var(--muted); }
.skel { height: 46px; border-radius: 12px; margin: 8px 14px; background: linear-gradient(90deg, #F1ECF4 25%, #F8F5FA 50%, #F1ECF4 75%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Formules */
.plans-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.plan { background: var(--white); border-radius: 20px; border: 2px solid var(--line); padding: 18px; display: flex; flex-direction: column; }
.plan.hl { border-color: var(--violet); }
.plan.g.hl { border-color: var(--green); }
.plan.off { opacity: .55; }
.plan .price { font-family: var(--display); font-size: 30px; color: var(--violet); line-height: 1; margin: 8px 0 2px; }
.plan.g .price { color: var(--green); }
.plan ul { padding: 0; margin: 12px 0 14px; list-style: none; display: grid; gap: 6px; font-size: 14px; flex: 1; }
.plan li::before { content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900; color: var(--green); margin-right: 8px; font-size: 12px; }

/* Réglages */
.set-row { display: grid; grid-template-columns: 1fr 160px; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row b { display: block; font-size: 14.5px; }
.set-row small { color: var(--muted); font-family: monospace; }
.set-row .input { text-align: right; font-weight: 700; }
.prov { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.prov:last-child { border-bottom: 0; }

/* ------------------------------------------------------------- Modales & toasts */
.modal-layer { position: fixed; inset: 0; z-index: 100; background: rgba(38, 3, 58, .5); display: grid; place-items: center; padding: 20px; animation: fade .15s; }
.modal { width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; background: var(--white); border-radius: 22px; padding: 22px; animation: pop .2s cubic-bezier(.2,.9,.3,1.3); }
.modal.small { max-width: 400px; text-align: center; }
.modal h3 { margin: 0 0 6px; font-size: 19px; }
.modal .ic { width: 54px; height: 54px; border-radius: 17px; display: grid; place-items: center; margin: 0 auto 12px; font-size: 22px; background: var(--yellow); color: var(--violet-d); }
.modal .ic.red { background: var(--danger-50); color: var(--danger); }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal.small .modal-foot { justify-content: center; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.toasts { position: fixed; right: 20px; top: 20px; z-index: 200; display: grid; gap: 8px; width: min(380px, calc(100% - 40px)); }
.toast { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--ink); color: var(--white); font-weight: 600; box-shadow: var(--shadow); animation: pop .25s; }
.toast.ok i { color: var(--yellow); }
.toast.err { background: var(--danger); }

/* ------------------------------------------------------------- Mobile */
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } .dash-grid { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; } .login-side { padding: 28px; } .login-side h1 { font-size: 36px; }
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 50; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .25s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(38,3,58,.4); }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--violet-d); position: sticky; top: 0; z-index: 40; }
  .topbar img { height: 26px; }
  .topbar button { width: 40px; height: 40px; border: 0; border-radius: 12px; background: rgba(255,255,255,.12); color: var(--white); font-size: 17px; cursor: pointer; }
  .page { padding: 20px 16px 50px; }
  .page-head h1 { font-size: 28px; }
  .search .input { min-width: 0; width: 100%; } .search { flex: 1 1 100%; }
  .grid2 { grid-template-columns: 1fr; }
}
