/* Liberty Jail — base commune (tokens + composants).
   Design : système Apple (typo, arrondis, espacements, effets) en sombre + rouge par défaut, clair + rouge en option.
   Thème : <html data-theme="dark|light">. Ne pas mettre de couleur en dur dans les pages : utiliser les variables. */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap");

:root, :root[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-elev: #111111;
  --surface: #141414;
  --surface-2: #1a1a1a;
  --surface-3: #222224;
  --hover: #1d1d1f;
  --border: #262626;
  --border-strong: #333336;
  --text: #f5f5f7;
  --text-2: #d2d2d7;
  --muted: #9a9a9a;
  --faint: #6e6e73;
  --red: #c8102e;
  --red-hover: #a90d27;
  --red-text: #ff4d63;
  --red-soft: rgba(200, 16, 46, 0.14);
  --red-line: rgba(200, 16, 46, 0.55);
  --green: #30d158;
  --green-soft: rgba(48, 209, 88, 0.12);
  --amber: #ffb340;
  --amber-soft: rgba(255, 179, 64, 0.12);
  --blue: #2997ff;
  --overlay: rgba(0, 0, 0, 0.66);
  --shadow: 0 2px 4px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.35);
  --glass: rgba(10, 10, 10, 0.72);
  --grid-dot: rgba(255,255,255,0.05);
  --logo-name: #ffffff;
  --logo-ai: #9a9a9a;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #fafafc;
  --surface: #f5f5f7;
  --surface-2: #ffffff;
  --surface-3: #e8e8ed;
  --hover: #ececf0;
  --border: #d2d2d7;
  --border-strong: #b8b8bf;
  --text: #1d1d1f;
  --text-2: #333336;
  --muted: #6e6e73;
  --faint: #86868b;
  --red: #c8102e;
  --red-hover: #a90d27;
  --red-text: #c8102e;
  --red-soft: rgba(200, 16, 46, 0.08);
  --red-line: rgba(200, 16, 46, 0.45);
  --green: #1a8f3c;
  --green-soft: rgba(26, 143, 60, 0.10);
  --amber: #b25000;
  --amber-soft: rgba(178, 80, 0, 0.10);
  --blue: #0066cc;
  --overlay: rgba(0, 0, 0, 0.4);
  --shadow: 0 2px 4px rgba(0,0,0,.06), 0 12px 32px rgba(0,0,0,.10);
  --glass: rgba(255, 255, 255, 0.78);
  --grid-dot: rgba(0,0,0,0.06);
  --logo-name: #1d1d1f;
  --logo-ai: #86868b;
  color-scheme: light;
}

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", Inter, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r-sm: 8px; --r-md: 11px; --r-lg: 18px; --r-xl: 28px; --r-pill: 9999px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 28px; --s7: 32px; --s8: 48px;
  --ease: cubic-bezier(0, 0, 0.5, 1);
  --sidebar-w: 228px;
  --banner-h: 46px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.47;
  letter-spacing: -0.2px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
a.link { color: var(--red-text); }
a.link:hover { text-decoration: underline; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
::selection { background: var(--red); color: #fff; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: -0.5px; }
h1 { font-size: 30px; line-height: 1.1; }
h2 { font-size: 21px; line-height: 1.19; }
h3 { font-size: 17px; line-height: 1.24; }
p { margin: 0; }
.mono { font-family: var(--mono); font-size: 0.86em; letter-spacing: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.red { color: var(--red-text); }
.green { color: var(--green); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.strike { text-decoration: line-through; color: var(--faint); }
.right { text-align: right; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: var(--s3); }
.spacer { flex: 1; }

/* ---------- Bandeau promo (haut de page, rouge) ---------- */
.banner {
  height: var(--banner-h);
  background: var(--red);
  color: #fff;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 14px; font-weight: 600; letter-spacing: -0.2px;
  position: relative; z-index: 50;
}
.banner a { display: flex; align-items: center; gap: 10px; }
.banner .pill-new {
  border: 1.5px solid #fff; border-radius: var(--r-pill);
  padding: 1px 9px; font-size: 11px; font-weight: 700; letter-spacing: 1px;
}

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 500; font-size: 15.5px; letter-spacing: -0.4px; white-space: nowrap; }
.logo svg { width: 22px; height: 22px; flex: none; }
.logo .name { color: var(--logo-name); }
.logo .ai { color: var(--logo-ai); }

/* ---------- Boutons (pilules Apple, rouge) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 14.5px; font-weight: 600; letter-spacing: -0.2px;
  cursor: pointer; white-space: nowrap;
  transition: background .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease), transform .1s;
  background: var(--surface-2); color: var(--text); border-color: var(--border);
}
.btn:hover { background: var(--hover); border-color: var(--border-strong); }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--red); color: #fff; border-color: var(--red); }
.btn-primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-outline-red { background: transparent; color: var(--text); border-color: var(--red-line); }
.btn-outline-red:hover { background: var(--red-soft); border-color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--hover); }
.btn-pill { border-radius: var(--r-pill); }
.btn-lg { height: 48px; padding: 0 24px; font-size: 16px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.icon-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Cartes ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.card-pad { padding: 20px 22px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 15.5px; }
.card-lift { transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease); }
.card-lift:hover { transform: scale(1.01); box-shadow: var(--shadow); border-color: var(--border-strong); }

/* ---------- Champs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.hint { font-size: 12.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-md);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--red-line); box-shadow: 0 0 0 3px var(--red-soft); }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.input-prefix > .input { padding-left: 26px; }
.search {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 12px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md); color: var(--muted);
}
.search input { flex: 1; background: transparent; border: 0; outline: none; color: var(--text); font-size: 14px; min-width: 0; }
.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--border-strong); border-radius: 6px; padding: 1px 6px; color: var(--muted); }

/* ---------- Badges / états ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { color: var(--green); background: var(--green-soft); }
.badge-red { color: var(--red-text); background: var(--red-soft); }
.badge-amber { color: var(--amber); background: var(--amber-soft); }
.badge-gray { color: var(--muted); background: var(--surface-3); }
.dot-status { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.dot-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.dot-status.off::before { background: var(--faint); }
.dot-status.bad::before { background: var(--red); }
.tag-preview { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 10.5px; letter-spacing: 1px; color: var(--muted); }
.tag-preview::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-2); font-size: 11px; font-weight: 600; }

/* ---------- Puces de filtre (All 5, Z.ai 2...) ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: transparent; color: var(--text-2); cursor: pointer; font-size: 13.5px;
}
.chip .n { color: var(--muted); font-size: 12px; }
.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); font-weight: 600; }

/* ---------- Onglets soulignés (Active 2 / Revoked 0 / All 2) ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 10px 11px; color: var(--muted); font-weight: 500; cursor: pointer; border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); font-weight: 600; border-bottom-color: var(--text); }

/* ---------- Segment (Spend | Requests, 1h 3h ... 90d) ---------- */
.segment { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md); }
.segment button { height: 30px; padding: 0 10px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; }
.segment button:hover { color: var(--text); }
.segment button.active { background: var(--surface-3); color: var(--text); font-weight: 600; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--hover); }
.table .sub { display: block; font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 2px; letter-spacing: 0; }
.table .r { text-align: right; }
.table-foot { display: flex; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }

/* ---------- Modale ---------- */
.modal-back { position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px; animation: fade .15s; }
.modal { width: 100%; max-width: 500px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-xl); box-shadow: var(--shadow); max-height: calc(100vh - 32px); overflow: auto; animation: pop .18s var(--ease); }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 22px 24px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 19px; }
.modal-head p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }
.close-x { margin-left: auto; width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--border-strong); background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.close-x:hover { color: var(--text); background: var(--hover); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } }

/* ---------- Bloc de code avec onglets ---------- */
.code { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.code-tabs { display: flex; align-items: center; gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid var(--border); }
.code-tabs button { padding: 8px 10px 10px; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 13.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.code-tabs button.active { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
.code pre { margin: 0; padding: 18px 20px; overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.6; color: var(--text-2); letter-spacing: 0; }
.code .k { color: var(--red-text); } .code .s { color: #f5a97f; } .code .c { color: var(--faint); }
:root[data-theme="light"] .code .s { color: #b25000; }
.copy-btn { color: var(--muted); }

/* ---------- Toast ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 300; }
.toast { background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 10px 14px; box-shadow: var(--shadow); font-size: 14px; animation: pop .2s var(--ease); max-width: 360px; }
.toast.err { border-color: var(--red-line); }

/* ---------- Divers ---------- */
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; color: transparent !important; }
@keyframes shimmer { to { background-position: -200% 0; } }
.toggle { position: relative; width: 44px; height: 26px; border-radius: var(--r-pill); background: var(--surface-3); border: 1px solid var(--border-strong); cursor: pointer; transition: background .2s; flex: none; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.toggle.on { background: var(--red); border-color: var(--red); }
.toggle.on::after { transform: translateX(18px); }
.range { width: 100%; accent-color: var(--red); }
.vendor-logo { width: 34px; height: 34px; flex: none; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--bg); color: var(--text); }
.vendor-logo svg { width: 18px; height: 18px; }
.modality { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border-strong); border-radius: 5px; color: var(--muted); }
.modality svg { width: 13px; height: 13px; }
.grid-bg { background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px); background-size: 22px 22px; }

@media (max-width: 734px) {
  body { font-size: 14.5px; }
  h1 { font-size: 26px; }
  .banner { font-size: 12.5px; padding: 0 12px; text-align: center; }
}
