:root {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1c232c;
  --border: #262d38;
  --border-strong: #38414f;
  --text: #e6e9ef;
  --muted: #8b95a5;
  --accent: #00b140;
  --accent-dim: rgba(0, 177, 64, 0.15);
  --up: #00b140;
  --partial: #f59e0b;
  --down: #ef4444;
  --unknown: #4b5563;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(900px 500px at 15% -10%, rgba(0, 177, 64, 0.07), transparent 60%),
    radial-gradient(700px 400px at 95% 0%, rgba(59, 130, 246, 0.05), transparent 55%);
}

a { color: inherit; text-decoration: none; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 22px 80px;
}

/* ---------------------------------------------------------------- en-tête */

header.top {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
}

.spacer { flex: 1; }

.searchbtn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  transition: border-color 0.15s, color 0.15s;
}
.searchbtn:hover { border-color: var(--border-strong); color: var(--text); }
.searchbtn kbd {
  font: 600 11px/1 ui-monospace, monospace;
  padding: 4px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface-2);
}

.ghost {
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  transition: 0.15s;
}
.ghost:hover { border-color: var(--border-strong); color: var(--text); }
.ghost.on {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.who {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.who a { color: var(--muted); border-bottom: 1px solid transparent; }
.who a:hover { color: var(--text); border-color: var(--border-strong); }

/* ----------------------------------------------------------------- grille */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  min-height: 118px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform 0.14s ease, border-color 0.14s, background 0.14s;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.card .ico {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--surface-2);
  padding: 3px;
}

.card .name {
  font-weight: 560;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card .host {
  margin-top: auto;
  font-size: 0.76rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--unknown);
}
.status.up { background: var(--up); box-shadow: 0 0 8px rgba(0, 177, 64, 0.6); }
.status.partial { background: var(--partial); }
.status.down { background: var(--down); box-shadow: 0 0 8px rgba(239, 68, 68, 0.5); }
.status.pending { animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

.remove {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--down);
  color: #fff;
  font-size: 17px;
  line-height: 22px;
  text-align: center;
  border: 2px solid var(--bg);
  display: none;
}
body.editing .remove { display: block; }
body.editing .card { animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge {
  0%, 100% { transform: rotate(-0.25deg); }
  50% { transform: rotate(0.25deg); }
}

.card-add {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 118px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 30px;
  transition: 0.15s;
}
.card-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.empty {
  color: var(--muted);
  padding: 40px 0;
  text-align: center;
}

/* ---------------------------------------------------------------- modales */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 13, 0.72);
  backdrop-filter: blur(3px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 20px 20px;
  z-index: 50;
}
.overlay.open { display: flex; }

.sheet {
  width: 100%;
  max-width: 640px;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.sheet header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.sheet header h2 { margin: 0; font-size: 0.95rem; font-weight: 600; }
.sheet header .close { color: var(--muted); font-size: 20px; padding: 0 4px; }
.sheet header .close:hover { color: var(--text); }

.field {
  width: 100%;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  outline: none;
}
.field:focus { border-color: var(--accent); }
.field::placeholder { color: var(--muted); }

.sheet .body {
  overflow-y: auto;
  padding: 6px 8px 12px;
}

.grouphead {
  padding: 14px 12px 6px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  text-align: left;
  transition: background 0.12s;
}
.row:hover, .row.active { background: var(--surface-2); }
.row img { width: 20px; height: 20px; border-radius: 4px; object-fit: contain; flex: none; }
.row .txt { flex: 1; min-width: 0; }
.row .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .u { font-size: 0.76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .mark {
  flex: none;
  font-size: 0.76rem;
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
}
.row.added .mark { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.custom {
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 8px;
}
.custom button {
  padding: 0 16px;
  border-radius: 10px;
  background: var(--accent);
  color: #07130b;
  font-weight: 600;
}
.custom button:disabled { opacity: 0.4; cursor: not-allowed; }

.hint { padding: 10px 16px; font-size: 0.78rem; color: var(--muted); }

/* --------------------------------------------------------------- connexion */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login .box {
  width: 100%;
  max-width: 380px;
  text-align: center;
  padding: 38px 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
}
.login h1 { margin: 0 0 6px; font-size: 1.3rem; }
.login p { margin: 0 0 26px; color: var(--muted); font-size: 0.9rem; }
.login a.btn {
  display: block;
  padding: 12px;
  background: var(--accent);
  color: #07130b;
  border-radius: 11px;
  font-weight: 600;
}
.login a.btn:hover { filter: brightness(1.08); }

@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
  .custom { grid-template-columns: 1fr; }
  .searchbtn kbd { display: none; }
}
