:root {
  --bg: #09090b;
  --surface: #111114;
  --surface-2: #17171b;
  --line: #24242a;
  --line-2: #303038;
  --text: #ececef;
  --muted: #8b8b95;
  --dim: #5d5d66;
  --red: #ff0038;
  --red-soft: rgba(255, 0, 56, 0.12);
  --red-glow: rgba(255, 0, 56, 0.35);
  --green: #2fd27c;
  --green-soft: rgba(47, 210, 124, 0.12);
  --amber: #f5b13d;
  --radius: 10px;
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
body { min-height: 100vh; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }

/* Fond : grille + lueur rouge */
.backdrop {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(255, 0, 56, 0.10), transparent 60%),
    linear-gradient(var(--bg), var(--bg));
}
.backdrop::after {
  content: ''; position: absolute; inset: 0; opacity: 0.35;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 70%);
}
.shell { position: relative; z-index: 1; }

/* Marque */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: 0.14em; font-size: 13px; }
.brand svg { width: 26px; height: 26px; filter: drop-shadow(0 0 10px var(--red-glow)); }
.brand b { color: var(--red); }

/* Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 28px;
  padding: 0 28px; height: 60px; border-bottom: 1px solid var(--line);
  background: rgba(9, 9, 11, 0.82); backdrop-filter: blur(12px);
}
.tabs { display: flex; gap: 4px; height: 100%; }
.tab {
  position: relative; display: flex; align-items: center; padding: 0 14px; border: 0; background: none;
  color: var(--muted); cursor: pointer; font-weight: 600; font-size: 13px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after { content: ''; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px; background: var(--red); box-shadow: 0 0 12px var(--red-glow); }
.topbar .spacer { flex: 1; }

main { max-width: 1240px; margin: 0 auto; padding: 28px; }

/* Cartes stats */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 28px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat.alert .v { color: var(--red); }

/* Panneaux */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 700; }
.panel-body { padding: 18px; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface-2); cursor: pointer; font-weight: 600; font-size: 13px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #45454f; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { box-shadow: 0 0 22px var(--red-glow); }
.btn.danger { color: var(--red); border-color: rgba(255, 0, 56, 0.4); background: var(--red-soft); }
.btn.ghost { background: none; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn svg { width: 15px; height: 15px; }

/* Formulaires */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 600; }
.input, select.input, textarea.input {
  height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg); outline: none; width: 100%;
}
textarea.input { height: 76px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.search { position: relative; flex: 1; max-width: 360px; }
.search svg { position: absolute; left: 11px; top: 11px; width: 15px; height: 15px; color: var(--dim); }
.search .input { padding-left: 34px; height: 36px; }

/* Tableau */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--dim); font-weight: 600; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { cursor: pointer; transition: background 0.12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.who { font-weight: 600; }
.who small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Pastilles */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--green); background: var(--green-soft); }
.pill.bad { color: var(--red); background: var(--red-soft); }
.pill.warn { color: var(--amber); background: rgba(245, 177, 61, 0.12); }

/* Tiroir de detail */
.drawer-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 20; backdrop-filter: blur(2px); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); z-index: 21; overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -30px 0 80px rgba(0, 0, 0, 0.5);
}
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; font-size: 18px; }
.drawer-section { padding: 18px 24px; border-bottom: 1px solid var(--line); }
.drawer-section h4 { margin: 0 0 12px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.copy-row { display: flex; gap: 8px; }
.copy-row .input { font-family: var(--mono); font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.log-list { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.log-list li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.log-list li:last-child { border-bottom: 0; }
.x { margin-left: auto; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line-2); background: none; cursor: pointer; display: grid; place-items: center; }
.x svg { width: 16px; height: 16px; }

/* Detection */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center;
  min-height: 220px; border: 1.5px dashed var(--line-2); border-radius: var(--radius); cursor: pointer; padding: 30px;
  transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.over { border-color: var(--red); background: var(--red-soft); }
.drop svg { width: 34px; height: 34px; color: var(--red); }
.drop strong { font-size: 15px; }
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 16px; }
.progress > div { height: 100%; width: 0; background: var(--red); box-shadow: 0 0 12px var(--red-glow); transition: width 0.2s; }
.verdict { margin-top: 20px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.verdict.hit { border-color: rgba(255, 0, 56, 0.5); box-shadow: 0 0 40px rgba(255, 0, 56, 0.12); }
.verdict-top { display: flex; align-items: center; gap: 16px; padding: 18px 20px; background: var(--surface-2); flex-wrap: wrap; }
.verdict-top .big { font-size: 20px; font-weight: 800; }
.verdict-top .tag { font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--red); font-weight: 800; }
.hits { max-height: 320px; overflow-y: auto; }
.hits .table td { padding: 8px 20px; font-size: 12.5px; }
.hits .table tbody tr { cursor: default; }

/* Produits */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h3 { margin: 0 0 2px; font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { font-size: 11.5px; padding: 3px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.chip b { color: var(--text); }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar h1 { margin: 0; font-size: 20px; font-weight: 800; margin-right: auto; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; z-index: 50;
  background: var(--surface-2); border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 8px; font-weight: 600;
  transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--red); color: var(--red); }

/* Ecran de connexion + page client */
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 30px; }
.login-card .brand { margin-bottom: 24px; }
.login-card .btn { width: 100%; margin-top: 16px; height: 40px; }
.err-msg { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }

.client-card { width: min(520px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.client-hero { padding: 30px 30px 24px; border-bottom: 1px solid var(--line); background: linear-gradient(160deg, rgba(255, 0, 56, 0.10), transparent 55%); }
.client-hero h1 { margin: 18px 0 4px; font-size: 26px; font-weight: 800; line-height: 1.15; }
.client-body { padding: 24px 30px 30px; }
.client-body .btn.primary { width: 100%; height: 48px; font-size: 15px; }
.notice { display: flex; gap: 12px; margin-top: 20px; padding: 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.notice svg { flex: none; width: 18px; height: 18px; color: var(--red); margin-top: 1px; }
.meter { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .topbar { gap: 12px; padding: 0 16px; overflow-x: auto; }
  main { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .table th, .table td { padding: 10px 12px; }
}

.gap-top { margin-top: 14px; }
.spacer { flex: 1; }
.brand, .tab { white-space: nowrap; flex: none; }
@media (max-width: 900px) {
  .toolbar .search { order: 3; flex-basis: 100%; max-width: none; }
  .brand span { display: none; }
}
.dl-list { display: flex; flex-direction: column; gap: 10px; }
.dl-item { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.dl-info { flex: 1; min-width: 0; }
.dl-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-meta { font-size: 12px; color: var(--muted); }
.client-body .dl-item .btn.primary { width: auto; height: 40px; font-size: 13px; }
@media (max-width: 480px) { .dl-item { flex-direction: column; align-items: stretch; } .client-body .dl-item .btn.primary { width: 100%; } }
