:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #6b7785;
  --line: #e3e7ec;
  --accent: #2f6f4e;
  --warn: #9a4b1b;
  --alert: #a32c2c;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d;
    --surface: #1d232a;
    --text: #e8ecf1;
    --muted: #9aa5b1;
    --line: #2b333c;
    --accent: #6fbf8f;
    --warn: #d99a5b;
    --alert: #e08585;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding-bottom: 5rem;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 1rem 1rem 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-main { display: flex; align-items: center; gap: 0.6rem; }
.topbar h1 { margin: 0; font-size: 1.15rem; }
.topbar p { margin: 0.25rem 0 0; font-size: 0.85rem; }

main { padding: 1rem; max-width: 40rem; margin: 0 auto; }
h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-top: 1.5rem; }

.list { display: flex; flex-direction: column; gap: 0.5rem; }

.card, .row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.card { margin-bottom: 0.75rem; }
.card p { margin: 0.25rem 0; }
.metric { font-size: 1.05rem; }
.metric strong { font-size: 1.5rem; }

.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.row-main { flex: 1 1 55%; min-width: 0; }
.row-main + * { flex: 0 0 auto; }
.row-title { font-weight: 600; }
.row-sub { font-size: 0.82rem; color: var(--muted); }

.muted { color: var(--muted); font-size: 0.85rem; }

.pill {
  font-size: 0.72rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.pill-nominal { color: var(--accent); border-color: currentColor; }
.pill-degraded { color: var(--warn); border-color: currentColor; }
.pill-lost { color: var(--alert); border-color: currentColor; }
.pill-allow { color: var(--accent); border-color: currentColor; }
.pill-suspend { color: var(--warn); border-color: currentColor; }
.pill-hide { color: var(--muted); }

button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 0.45rem 0.8rem;
  cursor: pointer;
}
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--alert); border-color: currentColor; }
button.ghost { margin-left: auto; padding: 0.25rem 0.6rem; font-size: 0.85rem; }

#login-form { display: flex; flex-direction: column; gap: 0.75rem; }
#login-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
#login-form input {
  font: inherit; padding: 0.5rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
#login-error { color: var(--alert); }

/* Avant connexion, rien de l'application ne doit apparaitre. */
body.login-mode .topbar,
body.login-mode .tabbar { display: none; }
body.login-mode { padding-bottom: 1rem; }
button:disabled { opacity: 0.45; cursor: default; }

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }

.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1;
  border: 0;
  border-radius: 0;
  padding: 0.85rem 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  position: relative;
}
.tabbar button.active { color: var(--accent); font-weight: 600; }

.badge {
  display: inline-block;
  min-width: 1.1rem;
  margin-left: 0.25rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--alert);
  color: #fff;
  font-size: 0.7rem;
}

.toast {
  position: fixed;
  left: 50%; bottom: 5.5rem;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 10;
}

.empty { color: var(--muted); font-size: 0.9rem; padding: 1rem; text-align: center; }

input[type="text"], select {
  font: inherit;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
}

/* Bandeau d'etat : porte par l'en-tete, visible sur les quatre ecrans. */
.banner {
  margin-top: 0.75rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid currentColor;
  border-radius: var(--radius);
}
.banner p { margin: 0.2rem 0; color: var(--text); }
.banner-lost { color: var(--alert); }
.banner .actions { margin-top: 0.5rem; }

/* Aide contextuelle : repliee par defaut, au point d'usage. */
.help { margin-top: 0.6rem; }
.help summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.2rem 0;
}
.help summary:hover { color: var(--text); }
.help p { margin: 0.4rem 0; }

.linky {
  border: 0;
  background: none;
  padding: 0;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: underline;
}
.linky:hover { color: var(--text); }

/* Actions destructrices ou rares : presentes, jamais mises en avant. */
button.ghost-inline { font-size: 0.85rem; color: var(--muted); }
button.ghost-inline.danger { color: var(--alert); }

dialog {
  width: min(26rem, calc(100vw - 2rem));
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog h3 { margin: 0 0 0.5rem; font-size: 1rem; text-transform: none; letter-spacing: 0; color: var(--text); }
dialog p { margin: 0.4rem 0; font-size: 0.9rem; }
dialog ul { margin: 0.4rem 0; padding-left: 1.1rem; font-size: 0.9rem; color: var(--muted); }
dialog li { margin: 0.2rem 0; }
dialog label { display: block; margin-top: 0.75rem; font-size: 0.85rem; color: var(--muted); }
dialog label input { margin-top: 0.3rem; }
dialog code { font-family: ui-monospace, monospace; color: var(--text); }
dialog .actions { justify-content: flex-end; }
