:root[data-theme="dark"] {
  --bg: #0b0b0e;
  --bg-2: #16161a;
  --bg-3: #1e1e24;
  --bg-4: #26262e;
  --border: rgba(255, 255, 255, .07);
  --border-2: rgba(255, 255, 255, .13);
  --text: #ececf0;
  --text-2: #8888a0;
  --text-3: #4a4a60;
  --dots: rgba(255, 255, 255, .05);
  --shadow: 0 16px 48px rgba(0, 0, 0, .6);
  --ok: #43d17f;
  --degraded: #f5c518;
  --partial: #f99c00;
  --major: #f87171;
  --unknown: #33333e;
}

:root[data-theme="light"] {
  --bg: #fbfbfd;
  --bg-2: #ffffff;
  --bg-3: #f3f3f7;
  --bg-4: #e7e7ee;
  --border: rgba(20, 20, 40, .09);
  --border-2: rgba(20, 20, 40, .16);
  --text: #1a1a22;
  --text-2: #63637a;
  --text-3: #9a9ab0;
  --dots: rgba(20, 20, 60, .06);
  --shadow: 0 16px 48px rgba(20, 20, 50, .16);
  --ok: #2dbe6c;
  --degraded: #d9a400;
  --partial: #ef8a00;
  --major: #e14b4b;
  --unknown: #dcdce4;
}

:root {
  --accent: #7c6af7;
  --accent-dim: rgba(124, 106, 247, .14);
  --accent-2: #8b78ff;
  --r: 8px;
  --r-lg: 14px;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --top: 57px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

* { scrollbar-width: thin; scrollbar-color: var(--bg-4) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--bg-4);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dots) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--text);
  font-family: Geist, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 13px; font-weight: 500; margin: 0 0 12px; color: var(--text-2); }

/* ---------------------------------------------------------------- barre haute */

header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--top);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 9px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand b { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.mark { width: 19px; height: 19px; fill: var(--accent); display: block; }

.spacer { margin-left: auto; }

.icon {
  background: none;
  border: 1px solid transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 7px 10px;
  border-radius: var(--r);
  cursor: pointer;
}
.icon:hover { color: var(--text); background: var(--bg-3); }

/* ---------------------------------------------------------------- structure */

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 30px 20px 70px;
}

main.wide { max-width: 1200px; }

/* ---------------------------------------------------------------- bandeau global */

.banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 22px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--bg-2);
  margin-bottom: 26px;
}
.banner .pulse {
  position: relative;
  width: 12px;
  height: 12px;
  border-radius: 99px;
  flex: none;
  background: var(--unknown);
}

/* Onde autour de la pastille: rapide quand tout va bien, lente en cas d incident,
   absente en panne majeure pour que l etat critique reste fixe et lisible */
.banner .pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: inherit;
  opacity: 0;
}
.banner.none .pulse::after { animation: pulse-wave 2.1s ease-out infinite; }
.banner.minor .pulse::after { animation: pulse-wave 4.2s ease-out infinite; }
.banner.maintenance .pulse::after { animation: pulse-wave 4.2s ease-out infinite; }
.banner.major .pulse::after { animation: none; }

@keyframes pulse-wave {
  0% { transform: scale(1); opacity: .55; }
  70% { transform: scale(2.6); opacity: 0; }
  100% { transform: scale(2.6); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .banner .pulse::after { animation: none !important; }
}
.banner b { font-size: 19px; font-weight: 600; letter-spacing: -.015em; }
.banner .sub { display: block; color: var(--text-2); font-size: 12.5px; }

.banner.none { border-color: rgba(67, 209, 127, .35); }
.banner.none .pulse { background: var(--ok); box-shadow: 0 0 0 4px rgba(67, 209, 127, .16); }
.banner.minor { border-color: rgba(249, 156, 0, .35); }
.banner.minor .pulse { background: var(--partial); box-shadow: 0 0 0 4px rgba(249, 156, 0, .16); }
.banner.major { border-color: rgba(248, 113, 113, .4); }
.banner.major .pulse { background: var(--major); box-shadow: 0 0 0 4px rgba(248, 113, 113, .16); }
.banner.maintenance { border-color: rgba(124, 106, 247, .4); }
.banner.maintenance .pulse { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-dim); }
.banner.unknown .pulse { background: var(--text-3); }

/* ---------------------------------------------------------------- services */

.group { margin-bottom: 26px; }
.group > h2 {
  font-size: 11px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 10px 2px;
}

.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.card.pad { padding: 4px 20px 14px; }

.service { padding: 16px 20px 14px; border-bottom: 1px solid var(--border); }
.service:last-child { border-bottom: none; }

.service-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.service-head .name { font-weight: 500; color: var(--text); }
a.name:hover { color: var(--accent-2); text-decoration: none; }
.service-head .desc { color: var(--text-3); font-size: 12.5px; }

.state {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  white-space: nowrap;
}
.state .dot { width: 8px; height: 8px; border-radius: 99px; background: var(--unknown); }
.state.operational { color: var(--ok); }
.state.operational .dot { background: var(--ok); }
.state.degraded { color: var(--degraded); }
.state.degraded .dot { background: var(--degraded); }
.state.partial_outage { color: var(--partial); }
.state.partial_outage .dot { background: var(--partial); }
.state.major_outage { color: var(--major); }
.state.major_outage .dot { background: var(--major); }
.state.unknown { color: var(--text-3); }

/* ---------------------------------------------------------------- frise */

.bars {
  display: flex;
  gap: 2px;
  height: 34px;
  align-items: stretch;
}
.bar {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 2px;
  background: var(--unknown);
  transition: transform .1s, filter .1s;
  cursor: default;
}
.bar:hover { transform: scaleY(1.12); filter: brightness(1.15); }
.bar.operational { background: var(--ok); }
.bar.degraded { background: var(--degraded); }
.bar.partial_outage { background: var(--partial); }
.bar.major_outage { background: var(--major); }

.legend {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--text-3);
}
.legend .line { flex: 1; height: 1px; background: var(--border); }
.legend .uptime { color: var(--text-2); font-family: var(--mono); font-size: 11.5px; }

#tip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  max-width: 260px;
}
#tip b { display: block; font-size: 12px; color: var(--text-2); font-weight: 500; }
#tip .val { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }

/* ---------------------------------------------------------------- incidents */

.section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 34px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.day { margin-bottom: 26px; }
.day > h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.incident { padding: 14px 0; }
.incident + .incident { border-top: 1px solid var(--border); }
.incident .title { font-weight: 500; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  background: var(--bg-4);
  color: var(--text-2);
}
.badge.resolved, .badge.completed { background: rgba(67, 209, 127, .14); color: var(--ok); }
.badge.investigating, .badge.identified { background: rgba(248, 113, 113, .14); color: var(--major); }
.badge.monitoring, .badge.in_progress { background: rgba(249, 156, 0, .14); color: var(--partial); }
.badge.scheduled { background: var(--accent-dim); color: var(--accent-2); }
.badge.auto { background: var(--bg-4); color: var(--text-3); }

.timeline { margin: 10px 0 0; padding: 0 0 0 16px; border-left: 1px solid var(--border-2); }
.timeline li { list-style: none; padding: 0 0 12px; font-size: 14px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline .step { font-weight: 500; margin-right: 6px; }
.timeline .when { display: block; color: var(--text-3); font-size: 11.5px; font-family: var(--mono); }
.timeline .impacted { color: var(--text-3); font-size: 12px; }

.empty { color: var(--text-3); font-size: 13.5px; padding: 8px 0; }
.empty.pad { padding: 18px 20px; }

/* ---------------------------------------------------------------- page d un service */

.back {
  display: inline-block;
  color: var(--text-2);
  font-size: 13px;
  margin-bottom: 16px;
}
.back::before { content: "\2190"; margin-right: 7px; }
.back:hover { color: var(--text); text-decoration: none; }

.lead { color: var(--text-2); font-size: 14px; margin: -12px 0 22px 2px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.stat {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 15px 16px;
  min-width: 0;
}
.stat b {
  display: block;
  font-family: var(--mono);
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -.02em;
}
.stat span { display: block; color: var(--text-2); font-size: 12px; }
.stat .sub {
  color: var(--text-3);
  font-size: 11.5px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat a.sub:hover { color: var(--accent-2); }

.latency {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 92px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.latency-bar {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 2px 2px 0 0;
  background: var(--ok);
}
.latency-bar.degraded { background: var(--degraded); }
.latency-bar.partial_outage { background: var(--partial); }
.latency-bar.major_outage { background: var(--major); }
.latency-bar:hover { filter: brightness(1.2); }

#checks table { font-size: 13.5px; }
#checks td .state { margin-left: 0; }

footer {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px 50px;
  color: var(--text-3);
  font-size: 12px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------- admin */

input, select, textarea {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px 11px;
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; min-height: 80px; }

button {
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--r);
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text);
  transition: background .15s, border-color .15s;
}
button:hover { border-color: var(--border-2); background: var(--bg-4); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
button.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
button.danger { color: var(--major); }
button.small { padding: 5px 10px; font-size: 13px; }

nav.tabs { display: flex; gap: 2px; }
.tab {
  background: none;
  border: none;
  color: var(--text-2);
  padding: 7px 13px;
  border-radius: var(--r);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
}
.tab:hover { color: var(--text); background: var(--bg-3); }
.tab.active { color: var(--text); background: var(--accent-dim); }

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar .spacer { margin-left: auto; }

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 5px;
}
.field .hint { color: var(--text-3); font-size: 11.5px; margin-top: 4px; }

.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 11px 14px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
td.right { text-align: right; white-space: nowrap; }
td .sub { color: var(--text-3); font-size: 12px; }

tr.draggable { cursor: grab; }
tr.dragging { opacity: .4; }
tr.drop-target td { border-top: 2px solid var(--accent); }
.handle { color: var(--text-3); cursor: grab; user-select: none; }

dialog {
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  background: var(--bg-2);
  color: var(--text);
  padding: 0;
  width: min(620px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog .head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
dialog .body { padding: 18px 20px; max-height: 70vh; overflow-y: auto; }
dialog .foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

#toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 70;
  padding: 11px 16px;
  border-radius: var(--r);
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow);
  font-size: 13.5px;
}
#toast.error { border-color: var(--major); color: var(--major); }

.gate {
  max-width: 420px;
  margin: 12vh auto 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
}
.gate h2 { font-size: 16px; color: var(--text); margin-bottom: 6px; }
.gate p { color: var(--text-2); font-size: 13px; margin: 0 0 16px; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 720px) {
  main { padding: 22px 14px 60px; }
  .banner { padding: 16px; }
  .banner b { font-size: 17px; }
  .bar:nth-child(-n+20) { display: none; }
  .service-head { flex-wrap: wrap; }
  .service-head .desc { display: none; }
  .state { margin-left: auto; }
}

@media (max-width: 480px) {
  .bar:nth-child(-n+30) { display: none; }
}
