:root {
  --bg: #0b1220; --bg2: #101a2e; --card: #14203a; --card2: #1a2848; --line: #26365c;
  --text: #e8eefc; --muted: #93a3c4; --accent: #87ceeb; --accent2: #5fb4dc; --on-accent: #08111f;
  --ok: #2ecc71; --warn: #f1c40f; --high: #e67e22; --crit: #e74c3c; --info: #3498db;
  --radius: 14px; --shadow: 0 8px 28px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: radial-gradient(1200px 600px at 80% -10%, rgba(135, 206, 235, .10), transparent 60%), var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.8rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }
.noscript { padding: 2rem; text-align: center; }

/* Barre du haut */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; padding: .7rem 1.2rem; background: rgba(11, 18, 32, .85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.topnav { display: flex; gap: .3rem; margin-left: 1rem; }
.topnav a { padding: .4rem .8rem; border-radius: 8px; color: var(--muted); }
.topnav a.active, .topnav a:hover { color: var(--text); background: var(--card); text-decoration: none; }
.spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: .6rem; padding: .25rem .4rem .25rem .8rem; border: 1px solid var(--line); border-radius: 999px; background: var(--card); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--card2); object-fit: cover; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 0 rgba(46, 204, 113, .6); animation: pulse 2.2s infinite; }
.dot.off { background: var(--crit); }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(46, 204, 113, 0); } 100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); } }

/* Boutons et formulaires */
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .55rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card2); color: var(--text); font: inherit; cursor: pointer; transition: transform .12s, background .15s, border-color .15s; }
.btn:hover { background: #22345d; border-color: #35508a; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .toggle input:focus-visible + .slider, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: #a3dbf2; }
.btn.danger { border-color: #7b2d2d; color: #ffb4a8; }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.big { padding: .8rem 1.5rem; font-size: 1.05rem; }
input[type=text], input[type=number], select { width: 100%; padding: .55rem .7rem; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: inherit; }
input[type=number] { max-width: 8rem; }
label.field { display: block; margin-bottom: 1rem; }
label.field > span { display: block; margin-bottom: .3rem; color: var(--muted); font-size: .88rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.row > * { flex: 0 0 auto; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }

/* Mise en page */
.page { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.2rem 4rem; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.layout { display: grid; grid-template-columns: 230px 1fr; gap: 1.5rem; max-width: 1300px; margin: 0 auto; padding: 1.5rem 1.2rem 4rem; }
.sidebar { position: sticky; top: 70px; align-self: start; }
.sidebar .gh { display: flex; align-items: center; gap: .7rem; padding: .6rem; margin-bottom: .8rem; }
.sidebar .gh .gicon { width: 44px; height: 44px; border-radius: 12px; }
.tabs { display: flex; flex-direction: column; gap: .25rem; }
.tabs a { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: 10px; color: var(--muted); }
.tabs a svg, .ico { width: 18px; height: 18px; flex: none; }
.tabs a:hover { background: var(--card); color: var(--text); text-decoration: none; }
.tabs a.active { background: var(--card2); color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.content { min-width: 0; animation: fade .25s ease; }

.card { background: linear-gradient(180deg, var(--card), var(--bg2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow); margin-bottom: 1.2rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; transition: transform .15s, border-color .15s; }
.stat:hover { transform: translateY(-2px); border-color: #35508a; }
.stat .v { font-size: 1.8rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .85rem; display: flex; align-items: center; gap: .4rem; }

/* Accueil */
.hero { text-align: center; padding: 4rem 1rem 2rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
.hero p { max-width: 640px; margin: 0 auto 1.8rem; color: var(--muted); font-size: 1.1rem; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin-top: 2.5rem; }
.feature .ico { width: 28px; height: 28px; color: var(--accent); margin-bottom: .5rem; }
.banner { padding: .8rem 1rem; border-radius: 10px; margin: 1rem auto; max-width: 640px; border: 1px solid #7b2d2d; background: rgba(231, 76, 60, .12); }

/* Serveurs */
.servers { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.server { display: flex; flex-direction: column; gap: .8rem; }
.server .head { display: flex; align-items: center; gap: .8rem; }
.gicon { width: 52px; height: 52px; border-radius: 14px; background: var(--card2); object-fit: cover; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.2rem; color: var(--accent); flex: none; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; border: 1px solid var(--line); color: var(--muted); }
.badge.sev1 { color: #7cc0f5; border-color: #2c5a85; } .badge.sev2 { color: var(--warn); border-color: #7a6a14; }
.badge.sev3 { color: var(--high); border-color: #85501a; } .badge.sev4 { color: #ff8a7d; border-color: #86302a; }
.badge.ok { color: var(--ok); border-color: #1e7a45; }

/* Interrupteurs */
.toggle { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider { position: absolute; inset: 0; background: #2a3a60; border-radius: 26px; transition: background .2s; cursor: pointer; }
.slider::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.toggle input:checked + .slider { background: var(--accent2); }
.toggle input:checked + .slider::before { transform: translateX(20px); }
.toggle input:disabled + .slider { opacity: .5; cursor: not-allowed; }
.module { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--line); }
.module:last-child { border-bottom: 0; }
.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.level { border: 1px solid var(--line); border-radius: 12px; padding: 1rem; cursor: pointer; background: var(--bg2); transition: border-color .15s, background .15s; text-align: left; color: inherit; font: inherit; }
.level:hover { border-color: #35508a; }
.level.sel { border-color: var(--accent); background: var(--card2); box-shadow: 0 0 0 1px var(--accent) inset; }

/* Tableaux */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
tr.fresh td { animation: flash 2.5s ease; }
@keyframes flash { from { background: rgba(135, 206, 235, .25); } to { background: transparent; } }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); }

/* Sécurité */
.secgrid { display: grid; grid-template-columns: 260px 1fr; gap: 1.5rem; align-items: center; }
.gauge { width: 220px; height: 220px; margin: 0 auto; display: block; }
.bar { margin-bottom: .8rem; }
.bar .top { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: .25rem; }
.bar .track { height: 10px; background: #22325a; border-radius: 6px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 6px; transition: width .6s ease; }
details.issue { border: 1px solid var(--line); border-radius: 12px; margin-bottom: .6rem; background: var(--bg2); }
details.issue summary { cursor: pointer; padding: .8rem 1rem; display: flex; align-items: center; gap: .7rem; list-style: none; }
details.issue summary::-webkit-details-marker { display: none; }
details.issue[open] { border-color: #35508a; }
details.issue .body { padding: 0 1rem 1rem; }
details.issue dt { color: var(--muted); font-size: .8rem; text-transform: uppercase; margin-top: .6rem; }
details.issue dd { margin: .15rem 0 0; }
.note { padding: .8rem 1rem; border-left: 3px solid var(--accent); background: rgba(135, 206, 235, .07); border-radius: 0 10px 10px 0; }

/* Graphiques */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #22325a; stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart .area { fill: rgba(135, 206, 235, .12); }
.chart circle.pt { fill: var(--bg); stroke: var(--accent); stroke-width: 2; transition: r .12s; }
.chart circle.pt:hover { r: 6; }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-top: .6rem; font-size: .85rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .4rem; }

/* Notifications */
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .6rem; z-index: 50; max-width: min(380px, calc(100vw - 2rem)); }
.toast { padding: .8rem 1rem; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); box-shadow: var(--shadow); animation: fade .25s ease; }
.toast.sev4 { border-color: var(--crit); } .toast.sev3 { border-color: var(--high); } .toast.ok { border-color: var(--ok); } .toast.err { border-color: var(--crit); }
.toast b { display: block; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: rot .8s linear infinite; vertical-align: -3px; }
@keyframes rot { to { transform: rotate(360deg); } }
.checks { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: .4rem; background: var(--bg2); }
.checks label { display: flex; align-items: center; gap: .6rem; padding: .3rem .4rem; border-radius: 6px; cursor: pointer; }
.checks label:hover { background: var(--card); }
.rdot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .2rem .3rem .2rem .7rem; border: 1px solid var(--line); border-radius: 999px; background: var(--card); }
.chip button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 0 .4rem; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .sidebar, .content, .card { min-width: 0; max-width: 100%; }
  .grid2, .levels, .servers, .features { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  svg, canvas, img { max-width: 100%; }
  .tablewrap { overflow-x: auto; }
  .sidebar { position: static; }
  .tabs { flex-direction: row; overflow-x: auto; padding-bottom: .3rem; }
  .tabs a { white-space: nowrap; }
  .sidebar .gh { display: none; }
  .secgrid { grid-template-columns: 1fr; }
  .topnav { display: none; }
  .userchip .uname { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.sevbox1 { background: #3498db; } .sevbox2 { background: #f1c40f; } .sevbox3 { background: #e67e22; } .sevbox4 { background: #e74c3c; }
