:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6eb;
  --text: #1a1d23;
  --muted: #6b7280;
  --accent: #2f5bea;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --idle: #9ca3af;
  --ok-bg: #dcfce7;
  --warn-bg: #fef3c7;
  --bad-bg: #fee2e2;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --border: #2a2e37;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --accent: #7c9cff;
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --idle: #6b7280;
    --ok-bg: #14301f;
    --warn-bg: #3a2c0f;
    --bad-bg: #3b1616;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main, .top { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.top { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; padding-top: 24px; padding-bottom: 8px; }
main { padding-bottom: 48px; }

h1 { margin: 0; font-size: 22px; }
h2 { margin: 32px 0 4px; font-size: 18px; }
h3 { margin: 16px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; font-weight: 400; }
p { margin: 0; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.toggle { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; cursor: pointer; }

button {
  font: inherit;
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: .6; cursor: wait; }
button.link { border: none; background: none; color: var(--accent); padding: 0; font-size: 13px; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; }
.stat .value { font-size: 26px; font-weight: 600; line-height: 1.2; }
.stat .label { font-size: 13px; color: var(--muted); }

.notify { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; font-size: 13px; color: var(--muted); }
.notify .item { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.notify .err { color: var(--bad); }
.notify button { font-size: 13px; padding: 4px 10px; }

#alerts:not(:empty) { margin-top: 16px; display: grid; gap: 8px; }
.alert { padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.grid:empty::after { content: "Aucun élément"; color: var(--muted); font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.name { font-weight: 600; }
.url { font-size: 13px; color: var(--muted); word-break: break-all; }
.url a { color: inherit; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.idle { background: var(--border); color: var(--muted); }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.metric .v { font-weight: 600; font-size: 15px; }
.metric .l { font-size: 12px; color: var(--muted); }
.v.ok { color: var(--ok); }
.v.warn { color: var(--warn); }
.v.bad { color: var(--bad); }

.spark { width: 100%; height: 32px; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; }
.spark circle { fill: var(--bad); }

details.marketing { border-top: 1px solid var(--border); padding-top: 10px; }
details.marketing summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.mk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.mk-note { font-size: 13px; color: var(--muted); margin-top: 8px; }
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.tag { font-size: 11px; font-weight: 600; background: var(--warn-bg); color: var(--warn); border-radius: 6px; padding: 1px 6px; margin-left: 6px; }

[hidden] { display: none !important; }

dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 24px; width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { margin: 0 0 16px; font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
.field input, .field select { font: inherit; font-weight: 400; padding: 9px 12px; min-height: 42px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
.form-error { color: var(--bad); font-size: 13px; min-height: 20px; margin: 0; }
.dialog-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.spacer { flex: 1; }
button.danger { color: var(--bad); }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 32px; }
.login-card h1 { margin-bottom: 4px; }
.login-card form { margin-top: 20px; }
.login-card button.primary { width: 100%; min-height: 44px; font-weight: 600; }

@media (max-width: 480px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
}
