*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --text: #e2e4ed;
  --muted: #6b7280;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  font-size: 14px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  min-height: 100vh;
}

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

/* NAV */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 48px;
}

nav .brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: 0.05em;
}

nav a {
  color: var(--muted);
  font-size: 0.875rem;
  padding: 0 0.25rem;
  height: 48px;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
}

nav a:hover, nav a.active {
  color: var(--text);
  text-decoration: none;
  border-bottom-color: var(--accent);
}

nav .spacer { flex: 1; }

nav .logout {
  font-size: 0.8rem;
  color: var(--muted);
}

/* MAIN */
main {
  padding: 2rem 1.5rem;
  max-width: 1100px;
}

h1 { font-size: 1.25rem; font-weight: 600; margin: 0 0 1.5rem; }
h2 { font-size: 1rem; font-weight: 600; margin: 0 0 1rem; }

/* CARDS */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.stat .label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.4rem; }
.stat .value { font-size: 1.5rem; font-weight: 700; }

/* TABLE */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge.online { background: rgba(34,197,94,0.15); color: var(--green); }
.badge.offline { background: rgba(239,68,68,0.1); color: var(--red); }

.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* KV TABLE */
.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.kv td:first-child { color: var(--muted); width: 180px; font-size: 0.8rem; }
.kv td:last-child { font-family: 'JetBrains Mono', monospace; word-break: break-all; }
.kv tr:last-child td { border-bottom: none; }

/* LOGIN */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2.5rem 2rem;
  width: 340px;
}

.login-box h1 { text-align: center; margin-bottom: 1.75rem; font-size: 1.1rem; }

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.4rem; }
.field input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}
.field input:focus { border-color: var(--accent); }

.btn {
  width: 100%;
  padding: 0.65rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
}
.btn:hover { background: var(--accent-hover); }

.error-msg {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--red);
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  margin-bottom: 1rem;
}

/* HTMX indicator */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; font-size: 0.75rem; color: var(--muted); }
.htmx-request .htmx-indicator { opacity: 1; }
