:root {
    --bg: #ffffff;
    --ink: #000000;
    --nodata: #d9d9d9;
    --up: #22c55e;
    --down: #ef4444;
    --degraded: #f59e0b;
    --maintenance: #3b82f6;
    --sans: "Helvetica Neue", Arial, "Liberation Sans", sans-serif;
    --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Courier New", monospace;
}

html[data-theme="dark"] {
    --bg: #000000;
    --ink: #ffffff;
    --nodata: #333333;
}

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

.top-actions { display: flex; align-items: center; gap: 12px; }
.theme-toggle {
    font-family: var(--mono); font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em;
    background: var(--bg); color: var(--ink); border: 2px solid var(--ink);
    padding: 6px 11px; cursor: pointer; border-radius: 0;
}
.theme-toggle:hover { background: var(--ink); color: var(--bg); }

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }

.wrap { max-width: 860px; margin: 0 auto; padding: 44px 20px 80px; }

/* ---------- Header ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 3px solid var(--ink);
    padding-bottom: 20px; margin-bottom: 26px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand .logo {
    width: 46px; height: 46px; flex: none;
    background: var(--ink); color: var(--bg);
    display: grid; place-items: center;
}
.brand .logo svg { width: 28px; height: 28px; display: block; }
.brand h1 {
    font-size: 22px; font-weight: 800; letter-spacing: -0.02em;
    text-transform: uppercase; line-height: 1;
}
.brand .sub {
    font-family: var(--mono); font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.14em; margin-top: 5px;
}
.topbar .link {
    font-family: var(--mono); font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em;
}

/* ---------- Global banner ---------- */
.global-banner {
    display: flex; align-items: center; gap: 16px;
    border: 3px solid var(--ink); background: var(--bg);
    padding: 20px 22px; margin-bottom: 26px;
}
.global-banner.ok { border-color: var(--up); }
.global-banner.warn { border-color: var(--degraded); }
.global-banner.ko { border-color: var(--down); }
.global-banner .dot { width: 16px; height: 16px; flex: none; }
.global-banner .txt strong {
    display: block; font-size: 17px; font-weight: 800;
    text-transform: uppercase; letter-spacing: -0.01em;
}
.global-banner .txt span { font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }

/* ---------- Status marks (noir & blanc, sans couleur) ---------- */
.dot {
    width: 14px; height: 14px; flex: none;
    border: 2px solid var(--ink); background: var(--bg);
}
.dot.up { background: var(--up); border-color: var(--up); }
.dot.degraded { background: var(--degraded); border-color: var(--degraded); }
.dot.maintenance { background: var(--maintenance); border-color: var(--maintenance); }
.dot.down { background: var(--down); border-color: var(--down); }
.dot.pending { border-style: dotted; }

/* ---------- Incidents ---------- */
.incident {
    border: 3px solid var(--ink); background: var(--bg);
    padding: 16px 18px; margin-bottom: 12px;
}
.incident { border-left-width: 8px; }
.incident.major { border-left-color: var(--down); }
.incident.maintenance { border-left-color: var(--maintenance); }
.incident .head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.incident .head .title { font-weight: 800; font-size: 15px; text-transform: uppercase; letter-spacing: -0.01em; }
.incident .msg { font-size: 14px; }
.incident .meta { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 10px; }

/* ---------- Badges ---------- */
.badge {
    font-family: var(--mono); font-size: 10px; font-weight: 700;
    padding: 4px 8px; text-transform: uppercase; letter-spacing: 0.08em;
    border: 2px solid var(--ink); background: var(--bg); color: var(--ink);
    white-space: nowrap;
}
.badge.up { color: var(--up); border-color: var(--up); }
.badge.down { color: var(--down); border-color: var(--down); }
.badge.degraded { color: var(--degraded); border-color: var(--degraded); }
.badge.maintenance { color: var(--maintenance); border-color: var(--maintenance); }
.badge.investigating, .badge.identified { color: var(--degraded); border-color: var(--degraded); }
.badge.monitoring { color: var(--maintenance); border-color: var(--maintenance); }
.badge.resolved { color: var(--up); border-color: var(--up); }

/* ---------- Groups & cards ---------- */
.group { margin-top: 30px; }
.group > h2 {
    font-family: var(--mono); font-size: 12px; text-transform: uppercase;
    letter-spacing: 0.16em; font-weight: 700;
    border-bottom: 2px solid var(--ink); padding-bottom: 6px; margin-bottom: 12px;
}

.card {
    border: 2px solid var(--ink); background: var(--bg);
    padding: 15px 18px; margin-bottom: 12px;
}
.card .row1 { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card .name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.card .name .n { font-weight: 800; font-size: 16px; text-transform: uppercase; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .name .host { font-family: var(--mono); font-size: 12px; }
.card .right { display: flex; align-items: center; gap: 14px; flex: none; }
.card .latency { font-family: var(--mono); font-size: 13px; font-weight: 700; }

/* ---------- History bars ---------- */
.history { display: flex; gap: 2px; margin-top: 15px; align-items: stretch; }
.history .seg {
    flex: 1; height: 28px; min-width: 2px;
    background: var(--nodata);
    cursor: pointer;
    transition: transform 0.08s linear, opacity 0.08s linear;
}
.history .seg.full { background: var(--up); }
.history .seg.part { background: var(--degraded); }
.history .seg.down { background: var(--down); }
.history .seg.none { background: var(--nodata); }
.history:hover .seg { opacity: 0.55; }
.history .seg.hover { opacity: 1; transform: scaleY(1.18); }

/* ---------- Tooltip journée ---------- */
.daytip {
    position: fixed; z-index: 50; left: 0; top: 0;
    width: 320px; max-width: calc(100vw - 16px);
    background: var(--bg); color: var(--ink);
    border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--ink);
    padding: 12px 13px 11px;
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity 0.1s linear;
}
.daytip.on { opacity: 1; visibility: visible; }
.daytip .tip-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.daytip .tip-svc {
    font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: -0.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.daytip .tip-pct {
    font-family: var(--mono); font-size: 12px; font-weight: 800; flex: none;
    padding: 2px 6px; border: 2px solid var(--ink);
}
.daytip .tip-pct.full { color: var(--up); border-color: var(--up); }
.daytip .tip-pct.part { color: var(--degraded); border-color: var(--degraded); }
.daytip .tip-pct.down { color: var(--down); border-color: var(--down); }
.daytip .tip-date {
    font-family: var(--mono); font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.1em; margin-top: 3px; opacity: 0.75;
}

.daytip .tip-hours {
    display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px;
    height: 44px; margin-top: 11px;
    border-bottom: 2px solid var(--ink);
    padding-bottom: 3px;
}
.daytip .hcell { display: flex; height: 100%; }
.daytip .hbar { width: 100%; height: 100%; background: var(--nodata); }
.daytip .hcell.full .hbar { background: var(--up); }
.daytip .hcell.part .hbar { background: var(--degraded); }
.daytip .hcell.down .hbar { background: var(--down); }
.daytip .hcell.none .hbar { background: var(--nodata); }
.daytip .hcell.load .hbar { background: var(--nodata); animation: tipload 1s ease-in-out infinite alternate; }
@keyframes tipload { from { opacity: 0.35; } to { opacity: 0.9; } }

.daytip .tip-scale {
    display: flex; justify-content: space-between;
    font-family: var(--mono); font-size: 9px; letter-spacing: 0.06em;
    margin-top: 5px; opacity: 0.7;
}
.daytip .tip-foot {
    margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--ink);
    font-family: var(--mono); font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.06em; line-height: 1.6;
}
.daytip .tip-foot .dim { opacity: 0.6; }

@media (prefers-reduced-motion: reduce) {
    .history .seg, .daytip { transition: none; }
    .daytip .hcell.load .hbar { animation: none; }
}

.card .foot {
    display: flex; justify-content: space-between; gap: 10px;
    font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
    margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--ink);
}
.card .foot .uptimes b { font-weight: 800; }

.footer {
    margin-top: 44px; padding-top: 18px; border-top: 3px solid var(--ink);
    text-align: center; font-family: var(--mono); font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.1em;
}

/* ---------- Admin ---------- */
.login-box {
    max-width: 380px; margin: 10vh auto 0;
    border: 3px solid var(--ink); background: var(--bg); padding: 30px;
}
.login-box h1 { font-size: 22px; font-weight: 800; text-transform: uppercase; letter-spacing: -0.02em; margin-bottom: 4px; }
.login-box p { font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 22px; }

label {
    display: block; font-family: var(--mono); font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.1em; font-weight: 700; margin: 14px 0 6px;
}
input, select, textarea {
    width: 100%; background: var(--bg); border: 2px solid var(--ink); color: var(--ink);
    padding: 10px 12px; font-size: 14px; font-family: var(--sans); border-radius: 0;
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--ink); outline-offset: 2px; }
textarea { resize: vertical; min-height: 72px; }

.btn {
    display: inline-flex; align-items: center; gap: 7px; justify-content: center;
    background: var(--ink); color: var(--bg); border: 2px solid var(--ink);
    padding: 10px 16px; font-family: var(--mono); font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em; cursor: pointer; border-radius: 0;
}
.btn:hover { background: var(--bg); color: var(--ink); }
.btn.full { width: 100%; }
.btn.ghost { background: var(--bg); color: var(--ink); }
.btn.ghost:hover { background: var(--ink); color: var(--bg); }
.btn.danger { background: var(--bg); color: var(--ink); border-style: dashed; }
.btn.danger:hover { background: var(--ink); color: var(--bg); }
.btn.sm { padding: 6px 10px; font-size: 11px; }

.err { font-family: var(--mono); font-size: 12px; margin-top: 10px; min-height: 18px; text-transform: uppercase; letter-spacing: 0.06em; }

.admin-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 3px solid var(--ink); padding-bottom: 18px; margin-bottom: 24px; }
.tabs { display: flex; gap: 0; margin-bottom: 22px; }
.tab {
    padding: 9px 16px; border: 2px solid var(--ink); background: var(--bg); color: var(--ink);
    cursor: pointer; font-family: var(--mono); font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em; margin-left: -2px;
}
.tab:first-child { margin-left: 0; }
.tab.active { background: var(--ink); color: var(--bg); }

.panel { border: 2px solid var(--ink); background: var(--bg); padding: 20px; margin-bottom: 16px; }
.panel h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.02em; margin-bottom: 14px; font-weight: 800; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 14px; border: 2px solid var(--ink); margin-bottom: -2px; background: var(--bg);
}
.item .info { min-width: 0; }
.item .info .t { font-weight: 800; font-size: 14px; text-transform: uppercase; letter-spacing: -0.01em; }
.item .info .s { font-family: var(--mono); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .actions { display: flex; gap: 6px; flex: none; align-items: center; }
.item select.sm { width: auto; padding: 6px 8px; font-family: var(--mono); font-size: 11px; }

@media (max-width: 560px) {
    .card .name .host { display: none; }
    .grid2 { grid-template-columns: 1fr; }
    .card .foot { flex-direction: column; gap: 4px; }
    .brand h1 { font-size: 18px; }
}
