:root{
  --bg:#f6f7fb;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e2e8f0;

  --blue:#2563eb;
  --blue-100:#dbeafe;

  --purple:#7c3aed;
  --purple-100:#ede9fe;

  --green:#16a34a;
  --green-100:#dcfce7;

  --slate:#475569;
  --slate-100:#f1f5f9;

  --shadow: 0 8px 24px rgba(15,23,42,.06);
  --radius: 14px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background:var(--bg);
  color:var(--text);
}

.wrap{
  width:min(1200px, calc(100% - 32px));
  margin:0 auto;
}

.site-header{
  background:#fff;
  border-bottom:1px solid var(--border);
}
.header-row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  padding:18px 0;
}
.title h1{
  margin:0;
  font-size:22px;
  letter-spacing:-.02em;
}
.sub{ color:var(--muted); margin-top:6px; font-size:13px; }

.actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}

.notice{
  margin:14px 0 0;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  font-weight:700;
}
.notice.ok{ background:#ecfdf5; border-color:#bbf7d0; color:#065f46; }
.notice.err{ background:#fef2f2; border-color:#fecaca; color:#991b1b; }

.grid{ display:grid; gap:16px; }
.kpis{ margin-top:16px; grid-template-columns: repeat(4, 1fr); }

.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow: var(--shadow);
  padding:16px;
  min-width:0;
}

.kpi{ padding:14px 16px; }
.kpi-head{
  display:flex;
  align-items:center;
  gap:10px;
  margin-bottom:10px;
}
.kpi-title{
  margin:0;
  color:var(--muted);
  font-weight:800;
  font-size:13px;
  letter-spacing:.01em;
}
.kpi-value{
  margin:0;
  font-size:26px;
  font-weight:900;
  letter-spacing:-.02em;
}

.muted{ color:var(--muted); font-size:12px; }
.right{ text-align:right; }
.strong{ font-weight:900; }

.kpi-icon{
  width:34px; height:34px;
  border-radius:999px;
  display:grid;
  place-items:center;
  flex:0 0 auto;
}
.kpi-icon svg{
  width:18px; height:18px;
  fill:none; stroke: currentColor;
  stroke-width:2;
  stroke-linecap:round; stroke-linejoin:round;
}
.kpi-icon.blue{ background:var(--blue-100); color:var(--blue); }
.kpi-icon.purple{ background:var(--purple-100); color:var(--purple); }
.kpi-icon.green{ background:var(--green-100); color:var(--green); }
.kpi-icon.slate{ background:var(--slate-100); color:var(--slate); }

.h3{
  margin:0 0 12px;
  font-size:15px;
  font-weight:900;
  letter-spacing:-.01em;
}
.with-ico{
  display:flex;
  align-items:center;
  gap:10px;
}

.ico{
  width:30px; height:30px;
  border-radius:10px;
  display:grid;
  place-items:center;
  background:#f1f5f9;
  color:#334155;
  flex:0 0 auto;
}
.ico svg{
  width:18px; height:18px;
  fill:none; stroke: currentColor;
  stroke-width:2;
  stroke-linecap:round; stroke-linejoin:round;
}

.card-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}

.row-2col{
  display:grid;
  grid-template-columns: 60% 40%;
  gap:16px;
  align-items:start;
  margin-top:16px;
}
.mt-18{ margin-top:18px; }
.w60,.w40{ min-width:0; }

.row{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
  margin-bottom:12px;
}
.inline{ display:flex; gap:10px; }
.actions.form-actions{ margin-top:14px; display:flex; gap:10px; justify-content:flex-end; }

label{ display:block; font-size:12px; font-weight:800; color:#334155; margin-bottom:6px; }
input, select{
  width:100%;
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px 12px;
  background:#fff;
  outline:none;
}
input:focus, select:focus{ border-color:#93c5fd; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }

.btn, .btn2, .btn-ghost{
  border-radius:12px;
  padding:10px 12px;
  border:1px solid var(--border);
  cursor:pointer;
  font-weight:900;
  background:#fff;min-width: 80px;margin: 2px;
}
.btn{ background:var(--blue); border-color:var(--blue); color:#fff; }
.btn:hover{ filter:brightness(.98); }
.btn2:hover, .btn-ghost:hover{ background:#f8fafc; }
.btn-ghost{ background:#fff; }

.icon-btn{
  display:inline-flex;
  align-items:center;
  gap:10px;
}
.icon-btn .ico{
  width:28px; height:28px;
  border-radius:10px;
  background:#f1f5f9;
}
.icon-btn svg{
  width:18px; height:18px;
  fill:none; stroke: currentColor;
  stroke-width:2;
  stroke-linecap:round; stroke-linejoin:round;
}

/* Filters row */
.filters{
  grid-template-columns: 1.5fr repeat(5, 1fr);
  align-items:end;
  margin-bottom:12px;
}
.search{ min-width:200px; }

/* TABLE */
.table-wrap{ overflow:auto; border-radius:12px; border:1px solid var(--border); }
table{ width:100%; border-collapse:separate; border-spacing:0; font-size:13px; }
thead th{
  position:sticky;
  top:0;
  background:#f8fafc;
  z-index:2;
}
tfoot td{
  position:sticky;
  bottom:0;
  background:#f8fafc;
  z-index:1;
}
th,td{
  padding:10px 12px;
  border-bottom:1px solid var(--border);
  vertical-align:top;
}
tbody tr:hover td{ background:#fafafa; }
.tfoot{ border-bottom:none; }

.pill{
  display:inline-block;
  font-size:12px;
  font-weight:900;
  color:#1d4ed8;
  background:#dbeafe;
  padding:4px 8px;
  border-radius:999px;
}

/* Scrollable table without breaking layout */
.table-card-scroll{
  display:flex;
  flex-direction:column;
  min-height: 520px;
}
.table-scroll{
  max-height: 360px;   /* scroll inside */
  overflow:auto;
}

/* CHART: stable height */
.card-chart .chart-box{
  height:340px; /* ✅ stable height */
  position:relative;
}
#chartEmpty{ padding-top:10px; }

/* MODAL */
.modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,.45);
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
}
.modal-backdrop.open{ display:flex; }
.modal{
  width:min(760px, 100%);
  background:#fff;
  border-radius:18px;
  border:1px solid var(--border);
  box-shadow: var(--shadow);
  overflow:hidden;
}
.modal-head, .modal-foot{
  padding:14px 16px;
  background:#f8fafc;
  border-bottom:1px solid var(--border);
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
}
.modal-foot{
  border-bottom:none;
  border-top:1px solid var(--border);
  justify-content:flex-end;
}
.modal-title{ font-weight:900; }
.icon-btn{
  border:1px solid var(--border);
  background:#fff;
  border-radius:12px;
  padding:8px 10px;
}
.modal-body{ padding:16px; max-height: 65vh; overflow:auto; }
.budget-grid{
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap:12px;
}
.budget-item{
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px;
  background:#fff;
}
.b-label{ font-weight:900; font-size:12px; color:#475569; margin-bottom:8px; }
.b-row{ display:flex; align-items:center; gap:10px; }
.mad{ color:var(--muted); font-weight:800; font-size:12px; }

/* Responsive */
@media (max-width: 1100px){
  .filters{ grid-template-columns: 1fr 1fr; }
}
@media (max-width: 980px){
  .row-2col{ grid-template-columns: 1fr; }
  .kpis{ grid-template-columns: 1fr 1fr; }
  .row{ grid-template-columns: 1fr; }
  .btn-text{ display:none; } /* garde juste les icônes si tu veux */
}
@media (max-width: 560px){
  .kpis{ grid-template-columns: 1fr; }
}
.btn-danger{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;min-width: 80px;margin: 2px;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid #fecaca;      /* red-200 */
  background:#fff;
  color:#b91c1c;                  /* red-700 */
  font-weight:900;
  cursor:pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .05s ease;
}

.btn-danger:hover{
  background:#fef2f2;             /* red-50 */
  border-color:#fca5a5;           /* red-300 */
  color:#991b1b;                  /* red-800 */
}

.btn-danger:active{
  transform: translateY(1px);
}

.btn-danger:focus{
  outline:none;
  box-shadow: 0 0 0 3px rgba(239,68,68,.18);
}

/* état désactivé */
.btn-danger:disabled{
  opacity:.45;
  cursor:not-allowed;
}

/* si tu as un bouton icône "danger" */
.btn-danger.icon{
  padding:8px;
  width:38px;
  height:38px;
}

.btn-danger svg{
  width:16px;
  height:16px;
  fill:none;
  stroke:currentColor;
  stroke-width:2;
  stroke-linecap:round;
  stroke-linejoin:round;
}
/* ===== FILTERS GRID ===== */
.filters-grid{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:14px 16px;
  margin-bottom:14px;
}

.filter-item{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.filter-item label{
  font-size:12px;
  font-weight:700;
  color:#475569;
}

/* Input avec icône */
.input-icon{
  position:relative;
  display:flex;
  align-items:center;
  gap:8px;
  background:#fff;
  border:1px solid #e2e8f0;
  border-radius:12px;
  padding:8px 10px;
  transition:border-color .15s ease, box-shadow .15s ease;
}

.input-icon:hover{
  border-color:#cbd5f5;
}

.input-icon:focus-within{
  border-color:#6366f1;
  box-shadow:0 0 0 3px rgba(99,102,241,.15);
}

/* emoji picto */
.input-icon::before{
  content: attr(data-icon);
}

/* champ */
.input-icon input,
.input-icon select{
  border:none;
  outline:none;
  width:100%;
  background:transparent;
  font-size:13px;
  color:#0f172a;
}

/* recherche plus large */
.filter-item.search{
  grid-column: span 2;
}

/* responsive */
@media (max-width: 900px){
  .filters-grid{
    grid-template-columns: 1fr 1fr;
  }
  .filter-item.search{
    grid-column: span 2;
  }
}

@media (max-width: 520px){
  .filters-grid{
    grid-template-columns: 1fr;
  }
  .filter-item.search{
    grid-column: span 1;
  }
}
/* label + bouton + */
.label-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.mini-plus{
  width:26px;
  height:26px;
  border-radius:10px;
  border:1px solid #c7d2fe;
  background:#eef2ff;
  color:#3730a3;
  font-weight:900;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  line-height:1;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}

.mini-plus:hover{
  background:#e0e7ff;
  border-color:#a5b4fc;
}

.mini-plus:active{
  transform: translateY(1px);
}

/* label + bouton + */
.label-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.mini-plus{
  width:26px;
  height:26px;
  border-radius:5px;
  border:1px solid #c7d2fe;
  background:#eef2ff;
  color:#3730a3;
  font-weight:900;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  line-height:1;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}

.mini-plus:hover{
  background:#e0e7ff;
  border-color:#a5b4fc;
}

.mini-plus:active{
  transform: translateY(1px);
}
