:root {
  --bg: #28222f;
  --surface: #302938;
  --surface-hi: #372f40;
  --border: rgba(101, 240, 248, 0.08);
  --cyan-hi: #65f0f8;
  --cyan: #2bcff9;
  --cyan-lo: #01b9f9;
  --text: #eef6fb;
  --muted: #9c93a8;
  --up: #2bcff9;
  --degraded: #ffc857;
  --down: #ff5d7a;
  --none: rgba(255, 255, 255, 0.07);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--bg); }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Fond vivant : deux halos qui dérivent lentement */
.bg-glow {
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(40% 35% at 30% 20%, rgba(43, 207, 249, 0.10), transparent 70%),
    radial-gradient(35% 30% at 75% 70%, rgba(101, 240, 248, 0.06), transparent 70%);
  animation: drift 22s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-4%, -2%, 0) rotate(0deg); }
  to { transform: translate3d(4%, 3%, 0) rotate(8deg); }
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 48px 20px 32px;
}

/* En-tête */
.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 40px;
}

.brand-logo {
  display: block;
  height: 60px;
  width: auto;
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  50% { transform: translateY(-4px); }
}

.brand-name {
  font-weight: 300;
  font-size: 34px;
  letter-spacing: 0.06em;
  line-height: 1;
  color: var(--cyan);
}

.brand-since {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--cyan);
  opacity: 0.85;
}

.brand-side {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

/* Horloge (heure locale du visiteur) */
.clock { text-align: right; font-variant-numeric: tabular-nums; }

.clock-time {
  font-size: 30px;
  font-weight: 300;
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--text);
}

.clock-sec {
  display: inline-block;
  min-width: 2.2ch;
  margin-left: 6px;
  font-size: 16px;
  font-weight: 500;
  color: var(--cyan);
}
.clock-sec.tick { animation: tick 0.45s var(--ease); }

@keyframes tick {
  from { opacity: 0.2; transform: translateY(-5px); }
}

.clock-date {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.clock-date::first-letter { text-transform: uppercase; }

.state {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.4s, background 0.4s;
}

.state-dot, .live-dot {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.state[data-state="online"] { border-color: rgba(43, 207, 249, 0.25); }
.state[data-state="online"] .state-dot { background: var(--up); animation: pulse 2s infinite; }
.state[data-state="degraded"] { border-color: rgba(255, 200, 87, 0.3); }
.state[data-state="degraded"] .state-dot { background: var(--degraded); animation: pulse-warn 2s infinite; }
.state[data-state="offline"] { border-color: rgba(255, 93, 122, 0.3); }
.state[data-state="offline"] .state-dot { background: var(--down); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(43, 207, 249, 0.6); }
  70%, 100% { box-shadow: 0 0 0 9px rgba(43, 207, 249, 0); }
}
@keyframes pulse-warn {
  0% { box-shadow: 0 0 0 0 rgba(255, 200, 87, 0.6); }
  70%, 100% { box-shadow: 0 0 0 9px rgba(255, 200, 87, 0); }
}

/* Encadré de bienvenue */
.welcome {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
  padding: 20px 22px;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(43, 207, 249, 0.10), rgba(43, 207, 249, 0.02) 60%),
    var(--surface);
  animation: rise 0.7s var(--ease) backwards;
  isolation: isolate;
}

/* Bordure dégradée dont la lueur tourne lentement */
.welcome::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  padding: 1px;
  border-radius: inherit;
  background: conic-gradient(from var(--angle, 0deg), rgba(101, 240, 248, 0.55), rgba(101, 240, 248, 0.06) 25%, rgba(101, 240, 248, 0.06) 60%, rgba(1, 185, 249, 0.55));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: orbit 8s linear infinite;
}

@property --angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

@keyframes orbit {
  to { --angle: 360deg; }
}

.welcome-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--cyan-hi);
  background: rgba(43, 207, 249, 0.12);
  border: 1px solid rgba(101, 240, 248, 0.2);
}

.welcome-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.welcome-text {
  margin-top: 6px;
  max-width: 760px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--muted);
}

.welcome-text strong { font-weight: 600; color: var(--cyan); }

/* Sections */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 36px 0 14px;
}
.section-head .section-title { margin: 0; }

.section-title {
  margin: 36px 0 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-sub { font-size: 12px; color: var(--muted); }

.live-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan);
}
.live-dot { width: 7px; height: 7px; background: var(--up); animation: pulse 1.6s infinite; }

.grid { display: grid; gap: 16px; }
.grid-main,
.grid-ping { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.grid-res { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }

/* Cartes */
.card {
  position: relative;
  padding: 22px 22px 20px;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--surface-hi), var(--surface));
  border: 1px solid var(--border);
  overflow: hidden;
  animation: rise 0.7s var(--ease) backwards;
  animation-delay: var(--delay, 0ms);
  transition: border-color 0.3s, transform 0.3s var(--ease);
}

.card:hover { border-color: rgba(101, 240, 248, 0.2); transform: translateY(-2px); }

.card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan-hi), var(--cyan-lo));
  opacity: 0.55;
  transition: background 0.4s;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.card-label { font-size: 13px; font-weight: 500; color: var(--muted); }

.card-value {
  margin-top: 10px;
  font-size: 38px;
  font-weight: 500;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.num {
  display: inline-block;
  background: linear-gradient(180deg, var(--cyan-hi), var(--cyan-lo));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.num.bump { animation: bump 0.6s var(--ease); }

@keyframes bump {
  30% { transform: translateY(-2px) scale(1.04); filter: brightness(1.45) drop-shadow(0 0 8px rgba(43, 207, 249, 0.45)); }
}

.card-unit { font-size: 16px; font-weight: 400; color: var(--muted); }

.card-hint { margin-top: 8px; font-size: 12px; color: var(--muted); }

.card-note {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
  opacity: 0.75;
}

.meter {
  margin-top: 14px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.meter-fill {
  position: relative;
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan-hi), var(--cyan-lo));
  transition: width 0.8s var(--ease);
  overflow: hidden;
}

/* Reflet qui balaie les jauges */
.meter-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: translateX(-100%);
  animation: shine 2.8s ease-in-out infinite;
}

@keyframes shine {
  60%, 100% { transform: translateX(100%); }
}

/* Mini-graphiques en direct */
.spark {
  height: 46px;
  margin: 14px -22px -20px;
  color: var(--up);
  transition: color 0.4s;
}
.spark svg { display: block; width: 100%; height: 100%; overflow: visible; }
.spark-line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark-area { fill: currentColor; fill-opacity: 0.1; stroke: none; }

.ping-quality { margin-top: 8px; font-size: 12px; font-weight: 500; color: var(--muted); transition: color 0.4s; }
.ping[data-quality="good"] .ping-quality { color: var(--up); }
.ping[data-quality="medium"] .ping-quality,
.ping[data-quality="medium"] .spark { color: var(--degraded); }
.ping[data-quality="bad"] .ping-quality,
.ping[data-quality="bad"] .spark,
.ping[data-quality="down"] .ping-quality,
.ping[data-quality="down"] .spark { color: var(--down); }
.ping[data-quality="medium"]::before { background: var(--degraded); }
.ping[data-quality="bad"]::before,
.ping[data-quality="down"]::before { background: var(--down); }

.page[data-stale="true"] .grid { opacity: 0.55; transition: opacity 0.4s; }

/* Statut général */
.history { padding: 24px; }
.history:hover { transform: none; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 22px; }

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.legend-item::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--state-color);
}

[data-state="up"] { --state-color: var(--up); }
[data-state="degraded"] { --state-color: var(--degraded); }
[data-state="down"] { --state-color: var(--down); }
[data-state="none"] { --state-color: var(--none); }
[data-state="future"] { --state-color: transparent; }

.uptime-row + .uptime-row { margin-top: 20px; }

.uptime-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 14px;
}

.uptime-name { font-weight: 500; }

.uptime-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--state-color);
}
.uptime-live::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.uptime-live[data-state="up"]::before { animation: pulse 2s infinite; }
.uptime-live[data-state="none"] { color: var(--muted); }

.uptime-pct { margin-left: auto; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.bars { display: flex; gap: 3px; height: 36px; }

.bar {
  flex: 1 1 0;
  min-width: 0;
  border: 0;
  border-radius: 3px;
  background: var(--state-color);
  cursor: pointer;
  transform-origin: bottom;
  transition: transform 0.2s var(--ease), filter 0.2s, opacity 0.2s;
}
.bars.intro .bar { animation: grow 0.5s var(--ease) backwards; animation-delay: calc(var(--i) * 5ms); }
.bar:hover, .bar:focus-visible { transform: scaleY(1.12); filter: brightness(1.3); outline: none; }
.bar.selected { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--text); }

@keyframes grow {
  from { transform: scaleY(0); opacity: 0; }
  to { transform: scaleY(1); opacity: 1; }
}

.history-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}
.axis-60, .axis-30 { display: none; }

.history-note {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(43, 207, 249, 0.06);
  font-size: 12px;
  color: var(--muted);
}

.day-detail {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  scroll-margin-top: 20px;
}

.day-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.day-navs { display: flex; gap: 6px; flex-shrink: 0; }

.day-title { font-size: 15px; font-weight: 500; }
.day-title::first-letter { text-transform: uppercase; }

.day-nav, .day-picker {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.2s, background 0.2s;
}
.day-nav { width: 32px; height: 32px; font-size: 18px; line-height: 1; cursor: pointer; }
.day-nav:hover:not(:disabled), .day-picker:hover { border-color: rgba(101, 240, 248, 0.35); }
.day-nav:disabled { opacity: 0.3; cursor: default; }
.day-picker { margin-left: auto; height: 32px; padding: 0 10px; font-size: 12px; color-scheme: dark; }

.hour-row + .hour-row { margin-top: 14px; }

.hour-row-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}
.hour-row-head span:last-child { color: var(--muted); font-size: 12px; }

.hour-cells { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 3px; }

.hour-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 4px 0;
  border-radius: 6px;
  background: color-mix(in srgb, var(--state-color) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--state-color) 35%, transparent);
  font-variant-numeric: tabular-nums;
  cursor: default;
  animation: rise 0.4s var(--ease) backwards;
  animation-delay: calc(var(--i) * 12ms);
  transition: transform 0.2s var(--ease), background 0.2s;
}
.hour-cell:hover { transform: translateY(-2px); background: color-mix(in srgb, var(--state-color) 28%, transparent); }
.hour-cell[data-state="none"] { background: rgba(255, 255, 255, 0.03); border-color: rgba(255, 255, 255, 0.06); }
.hour-cell[data-state="future"] { background: transparent; border: 1px dashed rgba(255, 255, 255, 0.06); }
.hour-cell .h { font-size: 9px; color: var(--muted); }
.hour-cell .v { font-size: 11px; font-weight: 600; color: var(--state-color); }
.hour-cell[data-state="none"] .v,
.hour-cell[data-state="future"] .v { color: var(--muted); font-weight: 400; }

/* Infobulle */
.tooltip {
  position: fixed;
  z-index: 30;
  max-width: 240px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(24, 20, 29, 0.96);
  border: 1px solid rgba(101, 240, 248, 0.18);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  font-size: 12px;
  line-height: 1.55;
  pointer-events: none;
  animation: pop 0.15s var(--ease);
}
.tooltip strong { display: block; margin-bottom: 2px; font-weight: 600; }
.tooltip .t-state { color: var(--state-color); font-weight: 500; }
.tooltip .t-muted,
.tooltip .t-state[data-state="none"],
.tooltip .t-state[data-state="future"] { color: var(--muted); }

@keyframes pop {
  from { opacity: 0; transform: translateY(4px); }
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Responsive */
@media (max-width: 900px) {
  .bars .bar:nth-child(-n+30) { display: none; }
  .axis-90 { display: none; }
  .axis-60 { display: inline; }
  .hour-cells { grid-template-columns: repeat(12, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .page { padding: 32px 16px 24px; }
  .brand { flex-wrap: wrap; gap: 14px; margin-bottom: 28px; }
  .brand-logo { height: 48px; }
  .brand-name { font-size: 28px; }
  .brand-side { margin-left: 0; width: 100%; align-items: stretch; }
  .clock { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; text-align: left; }
  .clock-time { font-size: 26px; }
  .clock-date { margin-top: 0; }
  .state { justify-content: center; white-space: normal; text-align: center; }
  .card-value { font-size: 32px; }
  .welcome { flex-direction: column; gap: 12px; padding: 18px 16px; margin-bottom: 22px; }
  .welcome-icon { width: 38px; height: 38px; }
  .history { padding: 18px 16px; }
  .bars { gap: 2px; height: 32px; }
  .bars .bar:nth-child(-n+60) { display: none; }
  .axis-60 { display: none; }
  .axis-30 { display: inline; }
  .day-head { flex-wrap: wrap; }
  .day-title { order: -1; width: 100%; }
  .day-picker { margin-left: auto; }
  .hour-cells { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .hour-row-head { flex-direction: column; gap: 2px; }
  .hour-cell { min-height: 42px; }
  .section-head { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
