/* Appli Jarvis — interface mobile d'abord, claire et sombre. */
:root {
  --bg: #f2f4f1; --card: #ffffff; --text: #18201c; --muted: #5e6a64; --line: #dde3df;
  --accent: #1f6f5c; --accent-soft: #e3f0eb; --accent-text: #ffffff;
  --ok: #1f9d55; --warn: #c27a06; --bad: #d23b3b; --info: #2f5fb3; --purple: #6a4fc4;
  --radius: 16px; --shadow: 0 1px 2px rgba(0,0,0,.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513; --card: #1a201d; --text: #edf1ee; --muted: #9aa6a0; --line: #2b332f;
    --accent: #5cc4a6; --accent-soft: #1d332c; --accent-text: #0d1a15;
    --ok: #4cc785; --warn: #f0a83a; --bad: #ff6b6b; --info: #7fa6ef; --purple: #a99cf2;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font: 16px/1.5 var(--font);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -0.01em; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-weight: 900;
}
.mac-status { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); white-space: nowrap; }
.mac-status.off { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }

main { max-width: 860px; margin: 0 auto; padding: 16px; }
h1 { font-size: 26px; line-height: 1.15; margin: 4px 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 28px 0 10px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.loading { color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 28px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); min-width: 0;
}
.card h3 { margin: 0 0 4px; font-size: 17px; overflow-wrap: anywhere; }
.card p { margin: 4px 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.card .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.s-ONLINE { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.s-WARNING, .s-DEGRADED { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.s-OFFLINE, .s-CRITICAL { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.s-MAINTENANCE, .s-INFO { background: color-mix(in srgb, var(--info) 18%, transparent); color: var(--info); }
.s-IMPORTANT { background: color-mix(in srgb, var(--purple) 18%, transparent); color: var(--purple); }
.mode-sim { background: var(--accent-soft); color: var(--accent); }
.mode-real { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); }

.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 9px 14px;
  font-weight: 600; cursor: pointer; min-height: 42px;
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.banner { border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; font-size: 15px; }
.banner.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); }
.banner.info { background: var(--accent-soft); }

.list { display: grid; gap: 8px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.item .meta { color: var(--muted); font-size: 12px; }
.reply { white-space: pre-wrap; background: var(--bg); border-left: 3px solid var(--accent); padding: 8px 10px;
  border-radius: 8px; margin-top: 8px; font-size: 14px; color: var(--text); }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; margin-top: 6px; }

form.stack { display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-weight: 600; font-size: 14px; }
label small { font-weight: 400; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
}
input:focus-visible, select:focus-visible, .btn:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.radio { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.radio input { width: auto; }

.login { max-width: 380px; margin: 12vh auto 0; }
.login .logo { width: 56px; height: 56px; font-size: 28px; border-radius: 16px; margin-bottom: 12px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav button {
  border: 0; background: none; display: grid; justify-items: center; gap: 2px; font-size: 11px; color: var(--muted);
  padding: 6px 2px; cursor: pointer; border-radius: 10px; min-height: 48px;
}
.nav button .ico { font-size: 20px; line-height: 1; }
.nav button[aria-current="page"] { color: var(--accent); font-weight: 700; background: var(--accent-soft); }

.modal { border: 0; border-radius: var(--radius); padding: 18px; max-width: min(92vw, 460px); background: var(--card); color: var(--text); }
.modal::backdrop { background: rgba(0,0,0,.45); }
.modal h3 { margin-top: 0; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 9;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; max-width: 90vw; font-size: 14px;
}
.empty { color: var(--muted); font-style: italic; }
@media (min-width: 900px) {
  .nav { left: 50%; right: auto; transform: translateX(-50%); width: 560px; border: 1px solid var(--line);
    border-bottom: 0; border-radius: 16px 16px 0 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
