/* Services Manager — design system léger, sans framework. */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --border: #e3e6ef;
  --text: #1a1d29;
  --muted: #6b7185;
  --primary: #4f46e5;
  --primary-ink: #ffffff;
  --primary-soft: #eef0fe;
  --ok: #0f9d58;
  --ok-soft: #e6f5ec;
  --warn: #b8860b;
  --warn-soft: #fbf3df;
  --danger: #d93025;
  --danger-soft: #fce8e6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 24, 40, 0.06), 0 4px 16px rgba(20, 24, 40, 0.05);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1016;
    --surface: #171a23;
    --surface-2: #1f2330;
    --border: #2a2f3e;
    --text: #e9ecf5;
    --muted: #9aa1b5;
    --primary: #7c83ff;
    --primary-ink: #0e1016;
    --primary-soft: #232744;
    --ok-soft: #14301f;
    --warn-soft: #322a12;
    --danger-soft: #3a1c1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
small { color: var(--muted); }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand .logo { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, var(--primary), #9b5de5); display: grid; place-items: center; color: #fff; font-size: 15px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.topbar .spacer { flex: 1; }
.search-trigger {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; min-width: 200px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--muted); cursor: pointer; font: inherit; font-size: 0.9rem;
}
.search-trigger kbd { margin-left: auto; }
kbd { font: 0.72rem var(--mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; color: var(--muted); }

.lockbar { display: flex; align-items: center; gap: 8px; }
.lock-timer { font: 0.78rem var(--mono); color: var(--muted); }

main { max-width: 1080px; margin: 0 auto; padding: 26px 20px 80px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .spacer { flex: 1; }
.breadcrumb { color: var(--muted); font-size: 0.85rem; margin-bottom: 10px; }
.breadcrumb a { color: var(--muted); }

/* Cards & grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card h2 { margin-top: 0; }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
/* cols-2 = mises en page détail (2 colonnes), repliées sur mobile.
   cols-3 / cols-4 = grilles de cartes : auto-fit pour s'empaqueter sans jamais
   devenir d'énormes blocs pleine largeur sur les largeurs intermédiaires. */
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
@media (max-width: 720px) { .grid.cols-2 { grid-template-columns: 1fr; } .topbar { flex-wrap: wrap; } .search-trigger { min-width: 0; } }

/* Stats */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 1.7rem; font-weight: 700; margin-top: 4px; }
.stat .sub { color: var(--muted); font-size: 0.85rem; }

/* Badges / pills */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 0.76rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.env-prod { background: var(--danger-soft); color: var(--danger); }
.badge.env-staging { background: var(--warn-soft); color: var(--warn); }
.badge.env-dev { background: var(--ok-soft); color: var(--ok); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: 0.9rem; cursor: pointer; transition: background 0.12s, border-color 0.12s; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.07); background: var(--primary); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 4px 10px; font-size: 0.82rem; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Forms */
form .field { margin-bottom: 14px; }
form label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 5px; }
form .hint { color: var(--muted); font-size: 0.8rem; font-weight: 400; margin-top: 3px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; font-size: 0.92rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { resize: vertical; min-height: 64px; font-family: var(--mono); font-size: 0.85rem; }
.field.inline { display: flex; align-items: center; gap: 9px; }
.field.inline input[type=checkbox] { width: auto; }
.field.inline label { margin: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; margin: 0 0 16px; }
legend { font-weight: 700; font-size: 0.85rem; padding: 0 6px; color: var(--muted); }

/* Secret reveal */
.secret { display: inline-flex; align-items: center; gap: 8px; }
.secret code { font-family: var(--mono); font-size: 0.85rem; background: var(--surface-2); padding: 3px 8px; border-radius: 6px; max-width: 380px; overflow: auto; white-space: nowrap; }
.secret .masked { letter-spacing: 2px; color: var(--muted); }

/* Lists / empty / banners */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 2rem; margin-bottom: 8px; }
.banner { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.9rem; border: 1px solid; }
.banner.info { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 30%, transparent); color: var(--text); }
.banner.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.banner.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }

.gap-group { margin-bottom: 14px; }
.gap-group .gap-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-weight: 600; }
.gap-items { display: flex; flex-wrap: wrap; gap: 8px; }
.gap-items a { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: 0.85rem; border: 1px solid var(--border); }
.gap-items a:hover { text-decoration: none; border-color: var(--primary); }
.gap-items a .tag { color: var(--muted); font-size: 0.78rem; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; align-items: baseline; }
.kv dt { color: var(--muted); font-size: 0.85rem; }
.kv dd { margin: 0; word-break: break-word; }
.meta { color: var(--muted); font-size: 0.82rem; }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }

/* Auth screens */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card .brand { justify-content: center; margin-bottom: 18px; font-size: 1.2rem; }
.recovery-key { font-family: var(--mono); font-size: 1rem; line-height: 1.9; letter-spacing: 1px; background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 16px; text-align: center; word-break: break-all; }

/* Cmd+K palette */
.cmdk-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 20, 0.45); display: none; z-index: 100; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.cmdk-backdrop.open { display: flex; }
.cmdk { width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow: hidden; }
.cmdk input { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 15px 18px; font-size: 1rem; }
.cmdk input:focus { outline: 0; }
.cmdk-results { max-height: 50vh; overflow: auto; }
.cmdk-results .res { display: flex; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer; }
.cmdk-results .res.active, .cmdk-results .res:hover { background: var(--primary-soft); }
.cmdk-results .res .t { font-weight: 600; }
.cmdk-results .res .s { color: var(--muted); font-size: 0.82rem; }
.cmdk-results .res .type { margin-left: auto; }
.cmdk-empty { padding: 22px; text-align: center; color: var(--muted); }

/* Utilities (CSP-safe, pas de style inline) */
.mt { margin-top: 14px; }
.mt-lg { margin-top: 22px; }
.mb-0 { margin-bottom: 0; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.flex { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.center { justify-content: center; }
.bar-cell { width: 40%; }
.bar { display: block; height: 8px; border-radius: 4px; background: var(--primary); min-width: 2px; width: 0; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 0.88rem; box-shadow: var(--shadow); opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none; z-index: 200; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
