:root {
  --bg0: #101512;
  --bg1: #171c19;
  --bg2: #1e2621;
  --line: #2c3831;
  --text: #e7f0ea;
  --muted: #8fa297;
  --accent: #5fb38a;
  --accent-dim: #3d7a5c;
  --danger: #d07272;
  --warn: #d2b15a;
  --ok: #5fb38a;
  --degraded: #d2b15a;
  --radius: 12px;
  --font: "Figtree", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 480px at 0% 0%, rgba(63, 120, 90, 0.28), transparent 55%),
    radial-gradient(700px 420px at 100% 10%, rgba(40, 70, 55, 0.35), transparent 50%),
    linear-gradient(180deg, #121816 0%, var(--bg0) 40%);
  background-attachment: fixed;
}

button, input, textarea, select { font: inherit; color: inherit; }
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg2);
  border-radius: 9px;
  padding: 0.55rem 0.95rem;
  transition: background .15s, border-color .15s, transform .12s;
}
button:hover { background: #26312b; border-color: #3d4f44; }
button:active { transform: translateY(1px); }
button.primary {
  background: linear-gradient(180deg, #6fc49a, var(--accent-dim));
  border-color: transparent;
  color: #06140d;
  font-weight: 650;
}
button.primary:hover { filter: brightness(1.05); }
button.danger { border-color: #6e3434; color: #f0c4c4; }
button.ghost { background: transparent; }
button:disabled { opacity: .45; cursor: not-allowed; }

input, textarea, select {
  width: 100%;
  background: #0d1210;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.65rem 0.8rem;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(95, 179, 138, 0.15); }
textarea { min-height: 150px; font-family: var(--mono); font-size: 12px; line-height: 1.45; }
label { display: block; margin-bottom: .35rem; font-size: .82rem; color: var(--muted); font-weight: 500; }
.field { margin-bottom: .9rem; }

.shell { max-width: 1120px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-bottom: 1.5rem;
}
.brand { display: flex; flex-direction: column; gap: .1rem; }
.brand strong {
  font-size: 1.45rem; letter-spacing: -0.03em; font-weight: 700;
  background: linear-gradient(90deg, #e7f0ea, #9fd4b8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand span { color: var(--muted); font-size: .9rem; }
.userbox { display: flex; align-items: center; gap: .65rem; color: var(--muted); font-size: .9rem; }
.userbox code { color: var(--text); font-family: var(--mono); font-size: .8rem; }

.nav {
  display: flex; gap: .35rem; margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--line); padding-bottom: .35rem;
}
.nav button {
  border: none; background: transparent; color: var(--muted);
  padding: .55rem .9rem; border-radius: 8px 8px 0 0; font-weight: 550;
}
.nav button.active {
  color: var(--text);
  background: color-mix(in srgb, var(--bg2) 80%, transparent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  margin-bottom: 1rem; flex-wrap: wrap;
}
.toolbar h2 { margin: 0; font-size: 1.1rem; font-weight: 650; }
.row { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.err { color: #f0a8a8; margin: .5rem 0; }
.ok { color: #9ad4bc; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.stat {
  padding: .9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg1) 85%, transparent);
}
.stat .n { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.03em; }
.stat .l { color: var(--muted); font-size: .8rem; margin-top: .15rem; }

.clist { display: grid; gap: .85rem; }
.cluster {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg1) 90%, transparent);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
  animation: fadeUp .35s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.cluster-head {
  display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start;
  margin-bottom: .85rem;
}
.cluster h3 { margin: 0; font-size: 1.1rem; font-weight: 650; display: flex; gap: .55rem; align-items: center; flex-wrap: wrap; }
.meta { font-size: .8rem; color: var(--muted); margin-top: .25rem; font-family: var(--mono); word-break: break-all; }

.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: .22rem .5rem; border-radius: 999px; border: 1px solid var(--line);
}
.badge.ok { color: #9ad4bc; border-color: #2f5a48; background: rgba(63, 120, 90, 0.2); }
.badge.degraded { color: #e6d09a; border-color: #5a4e28; background: rgba(210, 177, 90, 0.12); }
.badge.error, .badge.unreachable { color: #f0a8a8; border-color: #6e3434; background: rgba(208, 114, 114, 0.12); }
.badge.unknown { color: #c5cbbf; border-color: #3a4540; }

.grid-info {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .65rem;
  margin-bottom: .9rem;
}
.info {
  padding: .65rem .75rem;
  border-radius: 10px;
  background: #121815;
  border: 1px solid #24302a;
}
.info .k { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.info .v { margin-top: .2rem; font-weight: 600; font-size: .95rem; font-family: var(--mono); }

.checks { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .85rem; }
.check {
  font-size: .75rem; padding: .3rem .55rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.check.ok { color: #9ad4bc; border-color: #2f5a48; }
.check.fail { color: #f0a8a8; border-color: #6e3434; }

.login {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
}
.login-card {
  width: min(440px, 100%);
  background: color-mix(in srgb, var(--bg1) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 .35rem; font-size: 1.85rem; letter-spacing: -0.035em; }
.login-card p { margin: 0 0 1.5rem; color: var(--muted); line-height: 1.5; }
.login-card .actions { display: grid; gap: .65rem; }
.login-card .hint { margin-top: 1.25rem; font-size: .78rem; color: var(--muted); font-family: var(--mono); }

.modal-bg {
  position: fixed; inset: 0; background: rgba(5, 10, 8, .72);
  display: grid; place-items: center; padding: 1rem; z-index: 20;
  backdrop-filter: blur(4px);
}
.modal {
  width: min(680px, 100%);
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
  max-height: 90vh; overflow: auto;
}
.modal h3 { margin: 0 0 1rem; font-size: 1.15rem; }

.empty {
  padding: 2rem 1rem; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius);
}

@media (max-width: 860px) {
  .stats, .grid-info { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .stats, .grid-info { grid-template-columns: 1fr; }
  .cluster-head { flex-direction: column; }
  .top { flex-direction: column; align-items: flex-start; }
}
