/* serverstats — matrix-green terminal theme */

:root {
  --bg:         #0a0e0a;
  --bg-panel:   #0f1410;
  --bg-panel-2: #121812;
  --border:     #1f2a1f;
  --border-hi:  #2d4030;
  --fg:         #c8ffc8;
  --fg-dim:     #6f8f6f;
  --fg-strong:  #e8ffe8;
  --accent:     #39ff7a;
  --accent-dim: #2ac05d;
  --accent-cyan:#5fffdf;
  --warn:       #ffcc33;
  --crit:       #ff4d5e;
  --font-mono:  'JetBrains Mono','Fira Code','Cascadia Code','Menlo','Consolas',monospace;
  --radius:     4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg,
    rgba(57, 255, 122, 0.03) 0 1px,
    transparent 1px 3px
  );
  z-index: 1;
  mix-blend-mode: screen;
}

@media (prefers-reduced-motion: reduce) {
  body::before { display: none; }
  * { transition: none !important; animation: none !important; }
}

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

button {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  padding: 0.4em 0.9em;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
button:hover {
  background: rgba(57, 255, 122, 0.08);
  box-shadow: 0 0 12px rgba(57, 255, 122, 0.15);
}

input[type="text"], input[type="password"] {
  background: var(--bg-panel-2);
  color: var(--fg-strong);
  border: 1px solid var(--border-hi);
  padding: 0.5em 0.7em;
  font-family: inherit;
  font-size: inherit;
  border-radius: var(--radius);
  width: 100%;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim), 0 0 12px rgba(57, 255, 122, 0.2);
}

/* Layout shell */
.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 48px 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  min-height: 100vh;
  position: relative;
  z-index: 2;
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  gap: 1rem;
}
.topbar .host {
  color: var(--accent);
  text-shadow: 0 0 8px rgba(57, 255, 122, 0.4);
  font-weight: 700;
}
.topbar .conn-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--fg-dim);
  box-shadow: 0 0 6px rgba(200, 255, 200, 0.3);
}
.topbar .conn-dot.ok   { background: var(--accent); box-shadow: 0 0 8px rgba(57,255,122,0.6); }
.topbar .conn-dot.warn { background: var(--warn);   box-shadow: 0 0 8px rgba(255,204,51,0.5); }
.topbar .conn-dot.err  { background: var(--crit);   box-shadow: 0 0 8px rgba(255,77,94,0.6); }
.topbar .spacer { flex: 1; }

.sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 1rem 0;
}
.sidebar nav a {
  display: block;
  padding: 0.5rem 1.25rem;
  color: var(--fg-dim);
  border-left: 2px solid transparent;
}
.sidebar nav a:hover { color: var(--fg); }
.sidebar nav a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(57, 255, 122, 0.05);
  text-shadow: 0 0 6px rgba(57,255,122,0.3);
}

main {
  grid-area: main;
  padding: 1.25rem;
}

/* Hamburger toggle — shown only on mobile */
.nav-toggle {
  display: none;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  padding: 0.3em 0.6em;
  font-family: inherit;
  font-size: 18px;
  line-height: 1;
  border-radius: var(--radius);
  cursor: pointer;
}

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "sidebar"
      "main";
    grid-template-rows: 48px auto 1fr;
  }
  .nav-toggle { display: inline-block; }
  .topbar .host { font-size: 12px; }
  .sidebar {
    display: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0;
  }
  .sidebar.open { display: block; }
  .sidebar nav a {
    padding: 0.75rem 1.25rem;
    border-left: none;
    border-bottom: 1px solid transparent;
  }
  .sidebar nav a.active {
    border-left: none;
    border-bottom-color: var(--accent);
  }
  main { padding: 0.75rem; }
  .grid { gap: 0.75rem; }
  .panel { padding: 0.75rem 0.9rem; }
  .hero { padding: 0.9rem; }
  .hero .host { font-size: 16px; }
  table { font-size: 12px; }
  th, td { padding: 0.35rem 0.4rem; }
  /* Force horizontal scroll on wide tables rather than reflow */
  .panel table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* Panels */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: 0 0 0 1px rgba(57,255,122,0.04), 0 0 24px rgba(57,255,122,0.025);
  margin-bottom: 1rem;
}
.panel-title {
  margin: 0 0 0.75rem 0;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-dim);
}
.panel-title::before { content: "▸ "; color: var(--accent); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

/* Health banner */
.health-banner {
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid var(--border-hi);
  font-weight: 600;
}
.health-banner.ok   { color: var(--accent); border-color: rgba(57,255,122,0.4); text-shadow: 0 0 6px rgba(57,255,122,0.3); }
.health-banner.warn { color: var(--warn);   border-color: rgba(255,204,51,0.4); }
.health-banner.crit { color: var(--crit);   border-color: rgba(255,77,94,0.5); }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.15em 0.5em;
  border-radius: 2px;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid var(--border-hi);
}
.badge-ok   { color: var(--accent); border-color: rgba(57,255,122,0.4); text-shadow: 0 0 6px rgba(57,255,122,0.6); }
.badge-warn { color: var(--warn);   border-color: rgba(255,204,51,0.4); text-shadow: 0 0 6px rgba(255,204,51,0.5); }
.badge-crit { color: var(--crit);   border-color: rgba(255,77,94,0.5); text-shadow: 0 0 6px rgba(255,77,94,0.6); }
.badge-dim  { color: var(--fg-dim); }

/* Usage bars */
.bar {
  height: 6px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}
.bar > div {
  height: 100%;
  background: var(--accent);
  transition: width 0.4s ease;
  box-shadow: 0 0 6px rgba(57,255,122,0.35);
}
.bar > div.warn { background: var(--warn); box-shadow: 0 0 6px rgba(255,204,51,0.4); }
.bar > div.crit { background: var(--crit); box-shadow: 0 0 6px rgba(255,77,94,0.5); }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
th { color: var(--fg-dim); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
tr:hover td { background: rgba(57,255,122,0.03); }

/* Login page */
.login-container {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 2rem;
  position: relative;
  z-index: 2;
}
.login-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 0 0 1px rgba(57,255,122,0.06), 0 0 48px rgba(57,255,122,0.08);
}
.login-card h1 {
  margin: 0 0 1.25rem 0;
  font-size: 14px;
  color: var(--fg-dim);
}
.login-card label { display: block; margin-bottom: 0.9rem; }
.login-card label span { display: block; font-size: 11px; color: var(--fg-dim); margin-bottom: 0.25rem; }
.login-card button { width: 100%; margin-top: 0.75rem; padding: 0.65em; }
.login-error { color: var(--crit); font-size: 12px; margin: 0.5rem 0 0 0; }

/* Flash messages */
.flash-messages { position: fixed; top: 1rem; right: 1rem; z-index: 10; }
.flash { padding: 0.5rem 1rem; margin-bottom: 0.5rem; border: 1px solid var(--border-hi); border-radius: var(--radius); background: var(--bg-panel); }
.flash-success { color: var(--accent); border-color: rgba(57,255,122,0.4); }
.flash-error   { color: var(--crit);   border-color: rgba(255,77,94,0.5); }

/* Toasts */
.toast-container { position: fixed; bottom: 1rem; right: 1rem; z-index: 100; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { padding: 0.6rem 1rem; background: var(--bg-panel); border: 1px solid var(--border-hi); border-radius: var(--radius); font-size: 13px; animation: toastIn 0.2s ease; }
.toast.warn { color: var(--warn); border-color: rgba(255,204,51,0.4); }
.toast.error { color: var(--crit); border-color: rgba(255,77,94,0.5); }
.toast.info { color: var(--accent); border-color: rgba(57,255,122,0.4); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* Sparkline wrapper — Chart.js needs a fixed-height, position:relative parent
   to avoid a responsive resize feedback loop. Do NOT set height on the canvas. */
.spark-wrap {
  position: relative;
  height: 60px;
  margin-top: 0.75rem;
  width: 100%;
}
.spark-wrap > canvas { display: block; }

/* Hero block */
.hero {
  padding: 1.25rem;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.hero .host {
  font-size: 20px;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(57,255,122,0.35);
}
.hero .meta { color: var(--fg-dim); font-size: 12px; margin-top: 4px; }

/* Mono numbers */
.num { color: var(--fg-strong); font-feature-settings: "tnum"; }
.num.dim { color: var(--fg-dim); }

/* Utility */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 0.5rem; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.mt { margin-top: 0.75rem; }
