/* BURDIGALA Alertes — reprend les jetons de Burdigala UI 1.0.0, avec un mode sombre. */
:root {
  color-scheme: light;
  --primary: #781428;
  --primary-dark: #5b0d1d;
  --primary-deep: #3f0914;
  --primary-soft: #f8f1f2;
  --text: #241b1d;
  --muted: #7d7174;
  --border: #e9e2e3;
  --surface: #ffffff;
  --surface-2: #fbf9f8;
  --bg: #f7f5f4;
  --success: #25745a;
  --success-soft: #e3f4ed;
  --warning: #8a641f;
  --warning-soft: #f5ede0;
  --danger: #a42738;
  --danger-soft: #fae7e9;
  --neutral: #8f8487;
  --shadow: 0 2px 8px rgba(44, 18, 23, .05);
  --shadow-lg: 0 25px 90px rgba(35, 9, 14, .28);
  --radius: .75rem;
  --radius-lg: .875rem;
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
  --display: "Playfair Display", Georgia, serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --primary: #c25a6e;
    --primary-dark: #d97a8c;
    --primary-soft: #2a1a1e;
    --text: #f1eaeb;
    --muted: #a8999c;
    --border: #3a2d30;
    --surface: #1f181a;
    --surface-2: #261d20;
    --bg: #151012;
    --success: #4fbf93;
    --success-soft: #16302a;
    --warning: #d8ad5c;
    --warning-soft: #33291a;
    --danger: #ef6a7c;
    --danger-soft: #3a1a20;
    --neutral: #8a7c80;
    --shadow: 0 2px 8px rgba(0, 0, 0, .3);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: .9375rem; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 2px; }

.app { min-height: 100dvh; display: flex; flex-direction: column; }

/* Barre du haut (bordeaux, comme la colonne des outils Burdigala) */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(.75rem + var(--safe-t)) 1rem .75rem;
  background: #781428; color: #fff;
}
.brand { display: flex; align-items: center; gap: .75rem; }
.brand-logo { display: block; }
.brand-eyebrow { margin: 0; font-size: .625rem; font-weight: 700; letter-spacing: .1rem; text-transform: uppercase; opacity: .75; }
.brand-title { margin: 0; font-family: var(--display); font-weight: 600; font-size: 1.25rem; line-height: 1.1; }
.icon-btn { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .12); color: #fff; cursor: pointer; }
.icon-btn svg { width: 1.25rem; height: 1.25rem; }
.icon-btn:active { background: rgba(255, 255, 255, .22); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.view { flex: 1; width: min(100%, 44rem); margin: 0 auto; padding: 1rem 1rem calc(5.5rem + var(--safe-b)); outline: none; }

/* Navigation du bas */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: .375rem .5rem calc(.375rem + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; gap: .125rem; padding: .375rem; border-radius: .625rem; color: var(--muted); text-decoration: none; font-size: .6875rem; font-weight: 600; }
.tabbar a svg { width: 1.375rem; height: 1.375rem; }
.tabbar a[aria-current="page"] { color: var(--primary); }
.tab-badge { position: absolute; top: .125rem; left: calc(50% + .375rem); min-width: 1.125rem; height: 1.125rem; padding: 0 .3rem; border-radius: 999px; background: var(--danger); color: #fff; font-size: .6875rem; line-height: 1.125rem; text-align: center; }

/* Cartes et titres */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin: 1.5rem .25rem .5rem; }
.section-title h2 { margin: 0; font-size: .6875rem; font-weight: 700; letter-spacing: .1rem; text-transform: uppercase; color: var(--muted); }
.section-title small { color: var(--muted); font-size: .75rem; }
.muted { color: var(--muted); }

/* Bandeau de synthèse */
.hero { display: flex; align-items: center; gap: 1rem; padding: 1.125rem 1.125rem; }
.hero-icon { flex: none; display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 999px; }
.hero-icon svg { width: 1.5rem; height: 1.5rem; }
.hero h2 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 1.3125rem; line-height: 1.2; }
.hero p { margin: .125rem 0 0; font-size: .8125rem; color: var(--muted); }
.hero.ok .hero-icon { background: var(--success-soft); color: var(--success); }
.hero.down { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: linear-gradient(0deg, var(--surface), var(--surface)) padding-box; }
.hero.down .hero-icon { background: var(--danger-soft); color: var(--danger); }
.hero.warn .hero-icon { background: var(--warning-soft); color: var(--warning); }
.banner { margin-top: .75rem; padding: .75rem 1rem; border-radius: var(--radius); font-size: .8125rem; }
.banner.warn { background: var(--warning-soft); color: var(--warning); }
.banner.info { background: var(--primary-soft); color: var(--text); }
.banner.danger { background: var(--danger-soft); color: var(--danger); }
.banner a, .banner button.link { font-weight: 700; color: inherit; }

/* Liste des sondes */
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: .75rem; width: 100%; padding: .75rem 1rem; border: 0; border-top: 1px solid var(--border); background: none; text-align: left; cursor: pointer; }
.list > li:first-child > .row { border-top: 0; }
.row:active { background: var(--surface-2); }
.row-main { flex: 1; min-width: 0; }
.row-name { display: flex; align-items: center; gap: .375rem; font-weight: 600; font-size: .9375rem; }
.row-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { margin-top: .0625rem; font-size: .75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub.danger { color: var(--danger); }
.row-meta { flex: none; text-align: right; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.row-meta strong { display: block; color: var(--text); font-size: .8125rem; font-weight: 600; }
.mute-ico { width: .875rem; height: .875rem; color: var(--muted); flex: none; }

.dot { flex: none; width: .625rem; height: .625rem; border-radius: 999px; background: var(--neutral); }
.dot.up { background: var(--success); }
.dot.down { background: var(--danger); box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 60%, transparent); animation: pulse 1.6s ease-out infinite; }
.dot.pending { background: var(--warning); }
.dot.maintenance { background: #4b6bb5; }
@keyframes pulse { 70% { box-shadow: 0 0 0 .5rem transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.group-head { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem .25rem; }
.group-head h3 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 1rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .125rem .5rem; border-radius: 999px; font-size: .6875rem; font-weight: 700; }
.chip.ok { background: var(--success-soft); color: var(--success); }
.chip.down { background: var(--danger-soft); color: var(--danger); }
.chip.warn { background: var(--warning-soft); color: var(--warning); }
.chip.neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* Incidents */
.incident { display: grid; grid-template-columns: auto 1fr auto; gap: .25rem .75rem; align-items: start; padding: .875rem 1rem; border-top: 1px solid var(--border); }
.list > li:first-child > .incident { border-top: 0; }
.incident .dot { margin-top: .4rem; }
.incident-name { font-weight: 600; }
.incident-msg { grid-column: 2 / 4; font-size: .75rem; color: var(--muted); overflow-wrap: anywhere; }
.incident-dur { font-size: .8125rem; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.incident-dur.open { color: var(--danger); }
.incident-when { grid-column: 2 / 4; font-size: .75rem; color: var(--muted); }
.day { margin: 1.25rem .25rem .5rem; font-size: .6875rem; font-weight: 700; letter-spacing: .1rem; text-transform: uppercase; color: var(--muted); }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 2.75rem; padding: .625rem 1.125rem; border: 1px solid transparent; border-radius: var(--radius); font-weight: 700; font-size: .875rem; text-decoration: none; cursor: pointer; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:active { background: var(--surface-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.btn-row .btn { flex: 1 1 auto; }
.link { padding: 0; border: 0; background: none; color: var(--primary); font-weight: 700; cursor: pointer; }

.panel { padding: 1rem; }
.panel + .panel { border-top: 1px solid var(--border); }
.panel h3 { margin: 0 0 .25rem; font-size: 1rem; font-weight: 700; }
.panel p { margin: 0 0 .75rem; font-size: .8125rem; color: var(--muted); }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-top: 1px solid var(--border); font-size: .875rem; }
.kv:first-child { border-top: 0; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { text-align: right; overflow-wrap: anywhere; }
.device { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem 0; border-top: 1px solid var(--border); font-size: .8125rem; }
.device:first-child { border-top: 0; }
.device small { display: block; color: var(--muted); }

/* Utilitaires */
.flush { margin: 0 !important; }
.banner.flush { margin: 0 0 .75rem !important; }
.gap-top { margin-top: 1rem; }
.login-error { margin: -.5rem 0 1rem !important; }
.mute-ico.inline { display: inline; vertical-align: -2px; }

/* Écran de connexion */
.login { display: grid; place-items: center; min-height: 70dvh; text-align: center; }
.login .card { width: min(100%, 24rem); padding: 2rem 1.5rem; }
.login-mark { display: block; width: 4rem; height: 4rem; margin: 0 auto 1rem; border-radius: 1rem; }
.login h2 { margin: 0 0 .5rem; font-family: var(--display); font-weight: 600; font-size: 1.5rem; }
.login p { margin: 0 0 1.5rem; color: var(--muted); font-size: .875rem; }

/* Feuille de détail */
.sheet { width: min(100%, 32rem); max-height: 85dvh; margin: auto auto 0; padding: 0; border: 0; border-radius: 1.25rem 1.25rem 0 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.sheet::backdrop { background: rgba(20, 8, 11, .45); }
.sheet[open] { animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(30%); opacity: .4; } }
@media (min-width: 40rem) { .sheet { margin: auto; border-radius: 1.25rem; } }
.sheet-body { padding: 1.25rem 1.25rem calc(1.25rem + var(--safe-b)); }
.sheet-grip { width: 2.5rem; height: .3rem; margin: -.5rem auto 1rem; border-radius: 999px; background: var(--border); }
.sheet h2 { display: flex; align-items: center; gap: .5rem; margin: 0 0 .25rem; font-family: var(--display); font-weight: 600; font-size: 1.25rem; }
.sheet .target { margin: 0 0 1rem; font-size: .75rem; color: var(--muted); overflow-wrap: anywhere; }
.sheet .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: 1rem; }
.sheet .stat { padding: .625rem; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); text-align: center; }
.sheet .stat b { display: block; font-size: 1rem; font-variant-numeric: tabular-nums; }
.sheet .stat span { font-size: .6875rem; color: var(--muted); }
.sheet .msg { margin: 0 0 1rem; padding: .625rem .75rem; border-radius: var(--radius); background: var(--surface-2); font-size: .8125rem; overflow-wrap: anywhere; }
.sheet h3 { margin: 1rem 0 .5rem; font-size: .6875rem; font-weight: 700; letter-spacing: .1rem; text-transform: uppercase; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: calc(5.25rem + var(--safe-b)); z-index: 30; transform: translateX(-50%); max-width: calc(100% - 2rem); padding: .625rem 1rem; border-radius: 999px; background: var(--text); color: var(--bg); font-size: .8125rem; font-weight: 600; box-shadow: var(--shadow-lg); }

.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); font-size: .875rem; }
.skeleton { height: 4.5rem; border-radius: var(--radius-lg); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border: 1px solid var(--border); margin-bottom: .75rem; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
