:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #64708a;
  --line: #e2e7f0;
  --side: #0f1c33;
  --side-ink: #c6d0e3;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --ok: #15803d;
  --ok-bg: #e7f6ec;
  --warn: #b45309;
  --warn-bg: #fdf3e2;
  --bad: #b91c1c;
  --bad-bg: #fdeaea;
  --idle: #64708a;
  --idle-bg: #eef1f6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: "Cascadia Mono", Consolas, ui-monospace, monospace; font-size: 12.5px; }
h1 { font-size: 22px; margin: 0; font-weight: 600; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 600; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { margin-left: auto; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

/* ── Mise en page ── */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 18px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; color: #fff; font-weight: 600; font-size: 15px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; font-weight: 700; }
.side nav a { display: flex; align-items: center; gap: 10px; color: var(--side-ink); padding: 9px 10px; border-radius: 8px; margin-bottom: 2px; }
.side nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.side nav a.active { background: rgba(37, 99, 235, .25); color: #fff; }
.side .section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7d8aa5; padding: 16px 10px 6px; }
.side .me { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .08); padding: 12px 8px 0; font-size: 12.5px; }
.side .me b { color: #fff; display: block; font-weight: 600; }
.main { padding: 26px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }

/* ── Panneaux ── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card.flush { padding: 0; }
.card .card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card .card-head h2, .card .card-head h3 { margin: 0; }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 26px; font-weight: 600; margin-top: 4px; }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ── Tableaux ── */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: #fafbfd; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f7f9fd; }
.table-wrap { overflow-x: auto; }

/* ── Boutons, formulaires ── */
button, .btn {
  font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 13px;
  border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover, .btn:hover { background: #f3f5f9; text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { background: #1d4fd8; }
button.danger { color: var(--bad); border-color: #f1c5c5; }
button.danger:hover { background: var(--bad-bg); }
button.small, .btn.small { padding: 4px 9px; font-size: 12.5px; }
button:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea {
  font: inherit; border: 1px solid #cfd6e3; border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37, 99, 235, .25); border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; }
label.field { display: block; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
label.check { display: flex; gap: 8px; align-items: flex-start; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Pastilles ── */
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 500; background: var(--idle-bg); color: var(--idle); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.plain::before { display: none; }
.tag { display: inline-block; border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; font-size: 12px; color: var(--muted); background: #fafbfd; }

/* ── Jauge ── */
.meter { height: 8px; background: var(--idle-bg); border-radius: 99px; overflow: hidden; }
.meter > div { height: 100%; background: var(--accent); border-radius: 99px; }
.meter.warn > div { background: #d97706; }
.meter.over > div { background: var(--bad); }

/* ── Onglets ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--accent); border-color: var(--accent); font-weight: 500; }

/* ── Environnements ── */
.env-card .env-name { font-size: 16px; font-weight: 600; }
.env-card dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 14px 0; font-size: 13px; }
.env-card dt { color: var(--muted); }
.env-card dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.env-card .actions { display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 12px; }

/* ── Fenêtres ── */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 12px; width: min(620px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal.wide { width: min(980px, 100%); }
.modal header { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal header h2 { margin: 0; }
.modal header .x { margin-left: auto; border: none; font-size: 20px; padding: 2px 8px; }
.modal .body { padding: 18px 20px; }
.modal footer { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); background: #fafbfd; position: sticky; bottom: 0; }
.log { background: #0f172a; color: #d6deeb; border-radius: 8px; padding: 12px 14px; height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0; }
.secret-box { background: #f5f8ff; border: 1px dashed #9db5f5; border-radius: 8px; padding: 12px 14px; font-size: 16px; letter-spacing: .04em; display: flex; align-items: center; gap: 10px; }
.secret-box code { font-size: 16px; flex: 1; overflow-wrap: anywhere; }
.notice { border-radius: 8px; padding: 10px 14px; font-size: 13px; background: var(--idle-bg); }
.notice.warn { background: var(--warn-bg); color: #7a3e06; }
.notice.bad { background: var(--bad-bg); color: #7f1d1d; }
.notice.ok { background: var(--ok-bg); color: #14532d; }
.commit-list { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.commit-list label { display: flex; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: flex-start; }
.commit-list label:last-child { border-bottom: none; }
.commit-list label:hover { background: #f7f9fd; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* ── Connexion ── */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #0f1c33 0%, #1d3a6e 100%); }
.auth .card { width: min(420px, 100%); padding: 28px; }
.auth .brand { color: var(--ink); padding: 0 0 18px; font-size: 17px; }
.auth .qr { display: grid; place-items: center; padding: 8px; }
.auth .qr svg { width: 200px; height: 200px; }

/* ── Notifications ── */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #172033; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 420px; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .side nav { display: flex; flex-wrap: wrap; }
  .side .section, .side .me { display: none; }
  .main { padding: 18px; }
}
