/* Fresh Keys, true-black-flat. Ground froid, une seule teinte de donnees (bleu),
   elevation par pas de clarte, aucun degrade, aucun halo. */
:root {
  --ground: #0c0d0f;
  --surface: #14161b;
  --raised: #1e2129;
  --rule: #1c1f27;
  --hairline: #23262f;
  --control: #3a3e48;
  --text: #ffffff;
  --muted: #b4b4b4;
  --faint: #949494;
  --data: #4cb3f0;
  --data-dim: rgba(76, 179, 240, .14);
  --positive-bg: #1b2b1a; --positive-ink: #7fd67f;
  --warning-bg: #2b2414; --warning-ink: #e5a93b;
  --negative-bg: #2c1a20; --negative-ink: #e5566f;
  --negative-fill: #e5484d;
  --radius-card: 20px;
  --radius-control: 999px;
  --gap: 14px;
  --control-height: 36px;
}
* { box-sizing: border-box; }
html { scrollbar-color: #3a3e48 var(--ground); }
body {
  margin: 0; background: var(--ground); color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px; line-height: 1.5; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { font-weight: 600; letter-spacing: -.01em; margin: 0; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hidden { display: none !important; }
.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- boutons ---------- */
.btn-primary {
  height: var(--control-height); padding: 0 20px; border: none; border-radius: var(--radius-control);
  background: #fff; color: #0c0d0f; font: 600 14px "Inter", system-ui, sans-serif; cursor: pointer;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--data); }
.btn-primary:active { transform: translateY(1px); }
.btn-quiet {
  height: var(--control-height); padding: 0 16px; border: 1px solid var(--hairline); border-radius: var(--radius-control);
  background: transparent; color: var(--muted); font: 500 14px "Inter", system-ui, sans-serif; cursor: pointer;
  white-space: nowrap;
}
.btn-quiet:hover { color: var(--text); border-color: var(--control); }
.btn-quiet.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-danger {
  height: var(--control-height); padding: 0 20px; border: none; border-radius: var(--radius-control);
  background: var(--negative-fill); color: #fff; font: 600 14px "Inter", system-ui, sans-serif; cursor: pointer;
  white-space: nowrap;
}
.btn-danger:hover { filter: brightness(1.12); }
.btn-danger:active { transform: translateY(1px); }
:focus-visible { outline: 2px solid var(--data); outline-offset: 2px; }

/* ---------- connexion ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 360px; background: var(--surface); border-radius: var(--radius-card); padding: 32px 30px; }
.login-card h1 { font-size: 20px; margin: 18px 0 4px; }
.login-card .sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.login-card .btn-primary { width: 100%; margin-top: 6px; }
.wordmark { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 600; }
.wordmark.small { font-size: 15px; }
.mark { width: 11px; height: 20px; background: var(--data); transform: skewX(-16deg); border-radius: 2px; display: inline-block; }

/* ---------- shell ---------- */
.topbar {
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 29px; border-bottom: 1px solid var(--rule);
}
.top-right { display: flex; align-items: center; gap: 10px; }
.admin-mail { color: var(--faint); font-size: 13px; margin-right: 4px; }
.canvas { max-width: 1204px; margin: 0 auto; padding: 36px 29px 64px; }

/* ---------- titre ---------- */
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.title-row h1 { font-size: 24px; }
.finding { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.title-actions { display: flex; gap: 10px; }

/* ---------- bandeau KPI : un conteneur, filets 1px ---------- */
.kpi-strip {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-radius: var(--radius-card); margin-bottom: var(--gap);
}
.kpi { padding: 18px 22px; }
.kpi + .kpi { border-left: 1px solid var(--rule); }
.kpi-label { display: block; color: var(--muted); font-size: 14px; }
.kpi-value { display: block; font-size: 24px; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* ---------- panneaux graphiques ---------- */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--gap); margin-bottom: 48px; }
/* 2 x 568 + 14 = 1150, gouttières 29 x 2 : 1150 + 58 = 1208 ≈ 1204 */
.panel { background: var(--surface); border-radius: var(--radius-card); padding: 22px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { font-size: 16px; font-weight: 500; }
.period { color: var(--faint); font-size: 12px; }
#chart-bars { width: 100%; height: 195px; display: block; }
.panel-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.panel-foot b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.ring-wrap { position: relative; width: 180px; margin: 6px auto 0; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.ring-center div { font-size: 24px; font-variant-numeric: tabular-nums; }
.ring-center span { font-size: 12px; color: var(--faint); }
.ring-legend { display: flex; flex-direction: column; margin-top: 16px; }
.ring-legend div { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); padding: 7px 0; border-top: 1px solid var(--rule); }
.ring-legend b { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.sw { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sw.is-active { background: var(--data); }
.sw.is-expired { background: var(--warning-ink); }
.sw.is-revoked { background: var(--negative-ink); }

/* ---------- onglets + barre d'outils ---------- */
.list-head { border-bottom: 1px solid var(--rule); }
.tabs { display: flex; gap: 22px; overflow-x: auto; }
.tab {
  background: none; border: none; padding: 10px 2px; cursor: pointer;
  color: var(--faint); font: 500 14px "Inter", system-ui, sans-serif;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--data); }
.toolbar { display: flex; align-items: center; gap: 12px; margin: 22px 0 8px; }
.search {
  display: flex; align-items: center; gap: 9px; color: var(--faint);
  background: var(--surface); border-radius: var(--radius-control);
  padding: 0 16px; height: var(--control-height); width: 316px;
}
.search input[type="text"] { flex: 1; min-width: 0; height: 100%; margin: 0; padding: 0; background: none; border: none; outline: none; color: var(--text); font: 400 14px "Inter", system-ui, sans-serif; }
.search input[type="text"]::placeholder { color: var(--faint); }
.count { margin-left: auto; color: var(--faint); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---------- table : filets, pas de carte ---------- */
.table-wrap { overflow: auto; max-height: 560px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 900px; }
thead th {
  text-align: left; font-size: 12px; font-weight: 400; color: var(--faint);
  padding: 12px 12px; background: var(--ground);
  position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
tbody td { padding: 0 12px; height: 52px; border-top: 1px solid var(--rule); vertical-align: middle; }
tbody tr:hover td { background: rgba(255, 255, 255, .018); }
tbody tr:first-child td { border-top: none; }
td.key-cell { max-width: 250px; }
.key-id { display: inline-flex; align-items: center; gap: 8px; color: var(--text); }
.key-id code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.copy-btn {
  background: none; border: none; color: var(--faint); cursor: pointer; padding: 4px;
  display: inline-flex; border-radius: 6px; flex-shrink: 0;
}
.copy-btn:hover { color: var(--data); }
.note-cell { color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.num, th.num { text-align: right; }
.dim { color: var(--muted); font-variant-numeric: tabular-nums; }
.dash { color: var(--faint); }
.pill { display: inline-block; padding: 4px 12px; border-radius: var(--radius-control); font-size: 13px; font-weight: 500; white-space: nowrap; }
.pill.is-active { background: var(--data-dim); color: var(--data); }
.pill.is-expired { background: var(--warning-bg); color: var(--warning-ink); }
.pill.is-revoked { background: var(--negative-bg); color: var(--negative-ink); }
.subline { display: block; font-size: 12px; color: var(--faint); margin-top: 2px; }
.empty { text-align: center; color: var(--faint); padding: 40px 12px !important; height: auto; }

/* ---------- menu contextuel (fixe, jamais rogne par le scroll) ---------- */
.kebab {
  background: none; border: none; color: var(--faint); cursor: pointer;
  font-size: 16px; padding: 6px 10px; border-radius: 8px; line-height: 1;
}
.kebab:hover { color: var(--text); background: var(--raised); }
.menu {
  position: fixed; z-index: 40; min-width: 190px; margin: 0;
  background: var(--raised); border-radius: 12px; padding: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .55);
}
.menu button {
  display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  color: var(--text); font: 400 13px "Inter", system-ui, sans-serif;
  padding: 9px 12px; border-radius: 8px; white-space: nowrap;
}
.menu button:hover { background: rgba(255, 255, 255, .06); }
.menu button.danger { color: var(--negative-ink); }
.menu button.danger:hover { background: var(--negative-bg); }
.menu hr { border: none; border-top: 1px solid var(--hairline); margin: 5px 8px; }

/* ---------- endpoint ---------- */
.endpoint {
  display: flex; align-items: center; gap: 12px; margin-top: 32px;
  font-size: 13px; color: var(--faint);
}
.endpoint code {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted); font-size: 12px;
}

/* ---------- popups ---------- */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .66); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
.card {
  background: var(--surface); border-radius: var(--radius-card);
  padding: 28px; width: 420px; max-width: 100%;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .6);
}
.modal-card { position: relative; }
.modal-card h2 { font-size: 16px; margin-bottom: 16px; }
.modal-x {
  position: absolute; top: 14px; right: 14px; width: 30px; height: 30px;
  border-radius: 8px; border: none; background: transparent;
  color: var(--faint); cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-x:hover { color: var(--text); background: var(--raised); }
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 14px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select {
  width: 100%; margin-top: 6px; padding: 0 14px; height: 40px; border-radius: 12px;
  background: var(--ground); border: 1px solid var(--hairline); color: var(--text);
  font: 400 14px "Inter", system-ui, sans-serif; outline: none;
}
select { appearance: none; }
input:focus, select:focus { border-color: var(--data); }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn-primary, .modal-actions .btn-quiet, .modal-actions .btn-danger { flex: 1; }
.key-label { font-size: 13px; color: var(--data); word-break: break-all; margin: -8px 0 8px; }
.pc-line { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.pc-line b { color: var(--text); font-weight: 600; }
.hint { color: var(--faint); font-size: 13px; margin: 0 0 4px; }
.error { background: var(--negative-bg); color: var(--negative-ink); padding: 10px 14px; border-radius: 12px; font-size: 13px; margin-bottom: 12px; }
.result-label { color: var(--muted); font-size: 13px; margin: 16px 0 6px; }
.new-key { display: flex; gap: 8px; align-items: center; background: var(--ground); border: 1px solid var(--hairline); padding: 10px 10px 10px 14px; border-radius: 12px; }
.new-key code { flex: 1; color: var(--data); font-size: 13px; word-break: break-all; }
/* popup suppression */
.del-key { font-size: 14px; color: var(--text); word-break: break-all; margin: 0 0 6px; }
.del-note { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.del-warn { background: var(--negative-bg); color: var(--negative-ink); font-size: 13px; border-radius: 12px; padding: 10px 14px; margin: 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--raised); color: var(--text); font-size: 14px;
  padding: 12px 20px; border-radius: var(--radius-control); z-index: 50;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5); white-space: nowrap;
}

/* ---------- formulaires ---------- */
::placeholder { color: var(--faint); }

/* ---------- téléphone ---------- */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .kpi-strip { grid-template-columns: 1fr 1fr; }
  .kpi:nth-child(3) { border-left: none; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .title-row { flex-direction: column; align-items: flex-start; }
  .canvas { padding: 24px 16px 48px; }
  .topbar { padding: 0 16px; }
  .admin-mail { display: none; }
  .search { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
