:root{
  --bg:#070510;
  --panel:#0d0a1d;
  --panel2:#120d28;
  --text:#f4f2ff;
  --muted:#b9b0df;
  --stroke:#2a1b55;
  --violet:#8a4dff;
  --violet2:#b66bff;
  --good:#3ddc97;
  --warn:#ffcc66;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: radial-gradient(1200px 600px at 20% 0%, rgba(138,77,255,.18), transparent 60%),
              radial-gradient(900px 500px at 85% 10%, rgba(182,107,255,.14), transparent 55%),
              var(--bg);
  color:var(--text);
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:16px 18px;
  border-bottom:1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(13,10,29,.92), rgba(7,5,16,.65));
  position: sticky;
  top:0;
  backdrop-filter: blur(10px);
  z-index:10;
}

.brand{display:flex; align-items:center; gap:12px}
.logo{
  width:44px;height:44px;border-radius:14px;
}
.title{font-weight:800; letter-spacing:.3px}
.subtitle{color:var(--muted); font-size:12px; margin-top:2px}

.search{display:flex; gap:10px; align-items:center; width:min(520px, 100%)}
.search input{
  flex:1;
  padding:12px 12px;
  border-radius:12px;
  border:1px solid var(--stroke);
  background: rgba(18,13,40,.65);
  color:var(--text);
  outline:none;
}
.search input:focus{border-color: rgba(138,77,255,.7); box-shadow:0 0 0 3px rgba(138,77,255,.18)}
.search button{
  padding:12px 14px;
  border-radius:12px;
  border:1px solid rgba(138,77,255,.5);
  background: linear-gradient(135deg, rgba(138,77,255,.9), rgba(182,107,255,.85));
  color:#120b23;
  font-weight:800;
  cursor:pointer;
}
.search button:hover{filter:brightness(1.05)}

.container{margin:0 auto; padding:18px}
.grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:14px;
  margin-bottom:14px;
}
@media (max-width: 1000px){
  .grid{grid-template-columns:1fr}
}

.card{
  border:1px solid var(--stroke);
  border-radius:16px;
  background: linear-gradient(180deg, rgba(13,10,29,.86), rgba(18,13,40,.6));
  box-shadow: 0 18px 60px rgba(0,0,0,.35);
  overflow:hidden;
}
.card-h{
  padding:12px 14px;
  font-weight:850;
  border-bottom:1px solid var(--stroke);
  background: rgba(7,5,16,.28);
}
.kpis{display:grid; grid-template-columns:repeat(4,1fr); gap:10px; padding:12px 14px}
.kpi{
  padding:12px 12px;
  border:1px solid rgba(42,27,85,.7);
  border-radius:14px;
  background: rgba(7,5,16,.22);
}
.k{color:var(--muted); font-size:12px}
.v{font-size:20px; font-weight:900; margin-top:6px}

.tablewrap{overflow:auto; max-height:420px}
table{width:100%; border-collapse:collapse; font-size:13px}
th,td{padding:10px 12px; border-bottom:1px solid rgba(42,27,85,.55); vertical-align:top}
th{color:var(--muted); font-weight:800; position:sticky; top:0; background: rgba(13,10,29,.96)}
tr:hover td{background: rgba(138,77,255,.06)}
a{color:var(--violet2); text-decoration:none}
a:hover{text-decoration:underline}
.muted{color:var(--muted); font-size:12px; margin-left: 20px; margin-bottom: 20px;}
.details{padding:12px 14px; line-height:1.45}
.badge{
  display:inline-flex; gap:8px; align-items:center;
  padding:6px 10px; border-radius:999px;
  border:1px solid rgba(42,27,85,.7);
  background: rgba(7,5,16,.22);
  font-size:12px;
}
.footer{
  display:flex; justify-content:center; gap:10px; align-items:center;
  padding:14px 18px; color:var(--muted);
  border-top:1px solid var(--stroke);
}
.dot{opacity:.5}
.code{font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace}

.footlink{
  color: var(--violet2);
  text-decoration:none;
  cursor:pointer;
}
.footlink:hover{ text-decoration:underline; }


/* =========================
   Responsive patch (mobile)
   ========================= */

/* Header: passe en colonne sur mobile */
@media (max-width: 900px){
  .topbar{
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .brand{
    justify-content: flex-start;
  }
  .search{
    width: 100%;
  }
  .search input{
    width: 100%;
  }
}

/* Grilles: déjà OK, on améliore le spacing */
@media (max-width: 1000px){
  .container{ padding: 14px; }
  .grid{ gap: 12px; margin-bottom: 12px; }
}

/* KPI: 3 colonnes -> 2 -> 1 */
@media (max-width: 900px){
  .kpis{
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 520px){
  .kpis{
    grid-template-columns: 1fr;
  }
  .v{ font-size: 18px; }
}

/* Tables: scroll horizontal propre + tailles plus petites */
.tablewrap{
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
table{
  min-width: 640px; /* évite que tout se casse, scroll horizontal si besoin */
}
@media (max-width: 900px){
  th, td{ padding: 9px 10px; }
  table{ font-size: 12.5px; }
}
@media (max-width: 520px){
  th, td{ padding: 8px 9px; }
  table{ font-size: 12px; }
}

/* Footer: wrap sur mobile */
@media (max-width: 520px){
  .footer{
    flex-wrap: wrap;
    row-gap: 6px;
  }
}

/* Bonus: logo + titres un peu plus compacts sur mobile */
@media (max-width: 520px){
  .logo{ width: 40px; height: 40px; border-radius: 13px; }
  .title{ font-size: 16px; }
  .subtitle{ font-size: 11px; }
}

/* ===== Full width card in grid ===== */
.grid-2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:14px;
  margin-bottom:14px;
}
@media (max-width:1000px){
  .grid-2{ grid-template-columns: 1fr; }
}
.card.full{
  grid-column: 1 / -1; /* ✅ prend toute la largeur */
}

/* ===== Modal ===== */
.modal.hidden{ display:none; }

.modal{
  position:fixed;
  inset:0;
  z-index:9999;
}

.modal-backdrop{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
}

.modal-dialog{
  position:relative;
  margin: 7vh auto;
  width: min(920px, calc(100% - 28px));
  max-height: 86vh;
  overflow: hidden;

  border:1px solid var(--stroke);
  border-radius:18px;
  background: linear-gradient(180deg, rgba(13,10,29,.96), rgba(18,13,40,.85));
  box-shadow: 0 30px 120px rgba(0,0,0,.65);
}

.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 14px;
  border-bottom:1px solid rgba(42,27,85,.55);
  background: rgba(7,5,16,.25);
}

.modal-title{
  font-weight:900;
  letter-spacing:.3px;
}

.modal-x{
  border:1px solid rgba(138,77,255,.45);
  background: rgba(18,13,40,.5);
  color: var(--text);
  border-radius:12px;
  padding: 8px 10px;
  cursor:pointer;
}
.modal-x:hover{ filter:brightness(1.08); }

.modal-body{
  padding: 14px;
  overflow:auto;
  max-height: calc(86vh - 54px);
}

/* Petit confort mobile */
@media (max-width:520px){
  .modal-dialog{ margin: 4vh auto; }
  .modal-body{ padding: 12px; }
}

/* ✅ Fix boutons badge (ex: Copy link) */
.badge-btn{
  appearance: none;
  -webkit-appearance: none;
  background: rgba(7,5,16,.22);
  border:1px solid rgba(42,27,85,.7);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.badge-btn:hover{ filter: brightness(1.08); }
.badge-btn:active{ transform: translateY(1px); }
.badge-btn:focus{ outline: 2px solid rgba(138,77,255,.55); outline-offset: 2px; }

button.badge[disabled]{
  opacity: .85;
  cursor: default;
}
