:root {
  --bg: #eef3f6;
  --card: #fff;
  --ink: #0e2433;
  --muted: #5b7282;
  --deep: #0b2a3c;
  --water: #1677a8;
  --water-soft: #cfe6f2;
  --ok: #1d9a5b;
  --warn: #d98a00;
  --bad: #cf3a33;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(14, 36, 51, .06), 0 6px 24px rgba(14, 36, 51, .06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--deep); color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .02em; }
.brand svg { width: 22px; height: 22px; color: #6cc4ee; }
.lake-select select {
  appearance: none; font: inherit; font-weight: 600; color: #fff;
  background: rgba(255,255,255,.12) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='white' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid rgba(255,255,255,.2); border-radius: 10px;
  padding: 8px 34px 8px 12px; max-width: 60vw;
}
.lake-select option { color: var(--ink); }

main { max-width: 720px; margin: 0 auto; padding: 14px 14px 8px; display: grid; gap: 14px; }
.loading, .error { text-align: center; color: var(--muted); padding: 40px 0; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px; }
.card.small p { margin: 4px 0; font-size: .9rem; }
.muted { color: var(--muted); }

.hero { background: linear-gradient(160deg, #0f3a52, #1677a8); color: #fff; }
.hero-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hero h1 { margin: 0; font-size: 1.05rem; font-weight: 600; opacity: .9; }
.level { margin: 10px 0 2px; display: flex; align-items: baseline; gap: 8px; }
.level .num { font-size: clamp(3rem, 15vw, 4.4rem); font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.level .unit { font-size: 1rem; opacity: .8; }
.range { margin: 4px 0 14px; opacity: .85; font-size: .92rem; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpis div { background: rgba(255,255,255,.12); border-radius: 12px; padding: 10px; text-align: center; }
.kpis span { display: block; font-weight: 700; font-size: clamp(.95rem, 4.4vw, 1.15rem); font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpis small { opacity: .8; font-size: .75rem; }

.badge { font-size: .72rem; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.18); white-space: nowrap; }
.badge.haute { background: #d7f5e5; color: #0f6b3d; }
.badge.moyenne { background: #fff0cc; color: #855400; }
.badge.faible { background: #ffd9d6; color: #8f1f19; }

.alerts:empty { display: none; }
.alert { background: #fff7e6; border: 1px solid #f3d08a; color: #6d4700; border-radius: 12px; padding: 10px 12px; font-size: .88rem; }
.alert + .alert { margin-top: 8px; }

.ramps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ramp { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: #f5f8fa; }
.dot { width: 14px; height: 14px; border-radius: 50%; }
.ramp.ok .dot { background: var(--ok); box-shadow: 0 0 0 4px #d7f5e5; }
.ramp.incertain .dot { background: var(--warn); box-shadow: 0 0 0 4px #fff0cc; }
.ramp.ferme .dot { background: var(--bad); box-shadow: 0 0 0 4px #ffd9d6; }
.ramp .rname { font-weight: 650; }
.ramp .rsub { font-size: .8rem; color: var(--muted); }
.ramp .rstate { font-weight: 700; font-size: .85rem; text-align: right; }
.ramp.ok .rstate { color: var(--ok); }
.ramp.incertain .rstate { color: var(--warn); }
.ramp.ferme .rstate { color: var(--bad); }

.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { font-size: 11px; fill: var(--muted); }
.chart svg { cursor: crosshair; user-select: none; -webkit-user-select: none; }
.xhair-text { font-size: 11.5px; fill: #fff; }
.xhair { pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .75rem; color: var(--muted); margin: 8px 0 0; }
.legend i { display: inline-block; width: 14px; height: 8px; margin-right: 4px; border-radius: 2px; vertical-align: middle; }
.l-line { background: var(--water); }
.l-band { background: var(--water-soft); }
.legend .l-prev { background: repeating-linear-gradient(90deg, var(--water) 0 4px, transparent 4px 7px); height: 3px; }
.legend .l-ramp { background: repeating-linear-gradient(90deg, var(--bad) 0 4px, transparent 4px 7px); height: 2px; }

.legend span { white-space: nowrap; }
.legend .l-sat { width: 9px; height: 9px; border-radius: 50%; border: 1.6px solid var(--deep); background: #fff; }
.legend .l-off { width: 8px; height: 8px; border-radius: 1px; background: var(--warn); transform: rotate(45deg); }
.proj[hidden] { display: none; }
.seg { display: flex; gap: 6px; background: #eef3f6; padding: 4px; border-radius: 12px; margin-bottom: 8px; }
.seg button { flex: 1; font: inherit; font-size: .82rem; font-weight: 650; border: 0; border-radius: 9px; padding: 8px 4px; background: transparent; color: var(--muted); cursor: pointer; }
.seg button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(14,36,51,.12); }
.proj-label { margin: 0 0 6px; font-size: .85rem; color: var(--muted); }
.legend .l-band50 { background: #8cc3e0; }
.days { display: grid; grid-template-columns: repeat(15, 1fr); gap: 2px; margin: 10px 0 4px; }
.days .d { display: flex; flex-direction: column; align-items: center; font-size: .6rem; color: var(--muted); }
.days .bar { width: 70%; background: var(--water); border-radius: 2px 2px 0 0; min-height: 1px; }
.days .barwrap { height: 44px; display: flex; align-items: flex-end; width: 100%; justify-content: center; }
.days-legend { font-size: .72rem; color: var(--muted); margin: 0 0 8px; }
.probs { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.probs li { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; font-size: .9rem; }
.probs .pbar { grid-column: 1 / -1; height: 6px; background: #eef3f6; border-radius: 3px; overflow: hidden; }
.probs .pbar i { display: block; height: 100%; background: var(--ok); }
.probs b { font-variant-numeric: tabular-nums; }
.small-note { font-size: .75rem; margin: 10px 0 0; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.flows { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; font-size: .92rem; }
.flows dt { color: var(--muted); }
.flows dd { margin: 0; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
.meteo { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: .9rem; }
.meteo li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; }
.meteo .rain { color: var(--water); font-weight: 650; min-width: 54px; text-align: right; }

.foot { max-width: 720px; margin: 0 auto; padding: 8px 18px calc(env(safe-area-inset-bottom) + 24px); font-size: .78rem; color: var(--muted); }
