/* =====================================================================
   NeevCloud Monitoring — Design System v3
   Fonts: system fonts only (no Google Fonts dependency)
   ===================================================================== */
:root {
  --bg-0: #090c10;
  --bg-1: #0f1318;
  --bg-2: #151920;
  --bg-3: #1c2130;
  --bg-4: #242a3a;
  --line: #252d3e;
  --line-b: #323c52;

  --t1: #f0f2f5;
  --t2: #b8bfcc;
  --t3: #717a8e;
  --t4: #484f60;

  --green:  #5bffaa;
  --green-s: rgba(91,255,170,.12);
  --orange: #ffb347;
  --red:    #ff4f6b;
  --red-s:  rgba(255,79,107,.12);
  --blue:   #5ba8ff;
  --blue-s: rgba(91,168,255,.10);

  /* System font stack — no external dependency */
  --serif: Georgia, 'Times New Roman', serif;
  --sans:  -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --mono:  ui-monospace, 'Cascadia Code', 'SF Mono', Menlo, Consolas, monospace;

  --r: 8px;
  --r-lg: 12px;
}

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

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--t1);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 900px 400px at 70% -5%, rgba(91,255,170,.06) 0%, transparent 60%),
    radial-gradient(ellipse 500px 300px at 5% 95%, rgba(91,168,255,.04) 0%, transparent 60%);
}

#app { position: relative; z-index: 1; min-height: 100vh; }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }

/* ── Auth ──────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth-hero {
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-hero::before {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(91,255,170,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91,255,170,.03) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at 25% 50%, black 0%, transparent 65%);
}

.auth-logo-wrap {
  position: relative; z-index: 1;
  height: 40px;
  display: flex;
  align-items: center;
}
.auth-logo-wrap img {
  height: 36px;
  width: auto;
  filter: brightness(0) invert(1);
  object-fit: contain;
}

.hero-text {
  position: relative; z-index: 1;
  margin-top: 60px;
}
.hero-text h1 {
  font-family: var(--serif);
  font-size: clamp(36px, 4vw, 56px);
  line-height: 1.1;
  letter-spacing: -.01em;
  font-weight: normal;
}
.hero-text h1 em { font-style: italic; color: var(--green); }
.hero-text p {
  color: var(--t2); font-size: 15px; line-height: 1.65;
  margin-top: 18px; max-width: 380px;
}

.hero-tags {
  position: relative; z-index: 1;
  display: flex; gap: 20px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--t3);
}
.hero-tags span::before { content: "▸ "; color: var(--green); }

.auth-form-side {
  display: flex; align-items: center; justify-content: center;
  padding: 48px;
}
.auth-card { width: 100%; max-width: 360px; }
.auth-card h2 {
  font-family: var(--serif);
  font-size: 36px;
  letter-spacing: -.01em;
  margin-bottom: 6px;
  font-weight: normal;
}
.auth-card .sub { color: var(--t3); margin-bottom: 28px; font-size: 14px; }

.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--t3); margin-bottom: 6px;
}
.field input, .field select {
  width: 100%; padding: 10px 12px;
  background: var(--bg-2); border: 1px solid var(--line);
  color: var(--t1); border-radius: var(--r); font-size: 14px;
  transition: border-color .15s;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--green);
}
.field select option { background: var(--bg-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--r); border: 1px solid transparent;
  font-weight: 600; font-size: 13px; transition: all .12s; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green); color: #090c10; border-color: var(--green); }
.btn-primary:hover { background: #73ffc0; }
.btn-ghost { background: transparent; color: var(--t1); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg-3); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #ff6b82; }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.form-error {
  background: var(--red-s); border: 1px solid var(--red);
  color: var(--red); padding: 10px 12px; border-radius: var(--r);
  margin-bottom: 16px; font-size: 13px;
}
.auth-switch { margin-top: 20px; text-align: center; color: var(--t3); font-size: 13px; }

/* ── Shell ─────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  padding: 0;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow: hidden;
}

.sidebar-logo {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  min-height: 60px;
}
.sidebar-logo img {
  height: 28px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}
.sidebar-logo .logo-fallback {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 700; color: var(--t1);
  letter-spacing: -.01em;
}
.sidebar-logo .logo-fallback .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2.5s infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 6px var(--green); }
  50% { box-shadow: 0 0 14px var(--green); }
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; padding: 10px 10px 0; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  color: var(--t2); padding: 9px 10px; border-radius: var(--r);
  font-size: 13px; font-weight: 500; transition: all .12s;
}
.nav a:hover { background: var(--bg-2); color: var(--t1); text-decoration: none; }
.nav a.active { background: var(--bg-3); color: var(--t1); box-shadow: inset 2px 0 0 var(--green); }
.nav a svg { flex-shrink: 0; opacity: .6; }
.nav a.active svg { opacity: 1; color: var(--green); }

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; margin-top: auto;
}
.sidebar-footer:hover { background: var(--bg-2); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--blue));
  color: #090c10; font-weight: 800; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-info .name { font-size: 13px; font-weight: 600; }
.user-info .email { font-size: 11px; color: var(--t3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }

/* ── Main content ──────────────────────────────────────────────── */
.main { padding: 28px 32px; overflow-y: auto; min-width: 0; }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--line);
  gap: 16px;
}
.page-title {
  font-family: var(--serif);
  font-size: 36px;
  letter-spacing: -.01em;
  line-height: 1.1;
  font-weight: normal;
}
.page-title em { font-style: italic; color: var(--green); }
.page-sub { color: var(--t3); margin-top: 6px; font-size: 13px; }
.page-header-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; padding-top: 4px; }

/* ── Stat cards ─────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px 20px;
}
.stat-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--t3); }
.stat-val {
  font-size: 32px; line-height: 1.1; font-weight: 700;
  margin-top: 8px; font-family: var(--mono);
  color: var(--t1);
}
.stat-val.ok   { color: var(--green); }
.stat-val.warn { color: var(--orange); }
.stat-val.crit { color: var(--red); }
.stat-val .u { font-size: 14px; color: var(--t3); margin-left: 3px; font-weight: 400; }
.stat-foot { color: var(--t3); font-size: 12px; margin-top: 6px; }

/* ── Tables ─────────────────────────────────────────────────────── */
.host-table {
  width: 100%; background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden; border-collapse: collapse;
}
.host-table th {
  text-align: left; padding: 11px 16px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--t3);
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.host-table td { padding: 13px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.host-table tr:last-child td { border-bottom: none; }
.host-table tbody tr { cursor: pointer; transition: background .1s; }
.host-table tbody tr:hover { background: var(--bg-2); }
.hn { font-weight: 600; font-size: 14px; }
.hm { color: var(--t3); font-size: 11px; font-family: var(--mono); margin-top: 2px; }

/* ── Status pills ───────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 100px; font-size: 11px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.pill-ok   { background: var(--green-s); color: var(--green); }
.pill-ok .dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.pill-warn { background: rgba(255,179,71,.12); color: var(--orange); }
.pill-warn .dot { background: var(--orange); }
.pill-err  { background: var(--red-s); color: var(--red); }
.pill-err .dot { background: var(--red); }

/* ── Empty state ────────────────────────────────────────────────── */
.empty {
  background: var(--bg-1); border: 1.5px dashed var(--line-b);
  border-radius: var(--r-lg); padding: 60px 32px; text-align: center;
}
.empty h3 { font-family: var(--serif); font-size: 30px; margin-bottom: 8px; font-weight: normal; }
.empty p { color: var(--t3); margin-bottom: 24px; max-width: 400px; margin-inline: auto; line-height: 1.6; }

/* ── Panel ──────────────────────────────────────────────────────── */
.panel {
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 20px;
}
.panel h4 { font-size: 15px; font-weight: 700; margin-bottom: 14px; color: var(--t1); }

.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }

.metric-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
  gap: 12px;
}
.metric-row:last-child { border-bottom: none; }
.metric-k { color: var(--t2); font-size: 13px; min-width: 0; flex: 1; }
.metric-sub { color: var(--t4); font-family: var(--mono); font-size: 10px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.metric-v { font-family: var(--mono); font-weight: 600; color: var(--green); font-size: 12px; white-space: nowrap; }
.chart-wrap { height: 260px; position: relative; }

/* ── Sys info bar ───────────────────────────────────────────────── */
.sys-info-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 10px 14px;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r);
}
.sys-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 100px; font-size: 11px; color: var(--t2); font-family: var(--mono);
  white-space: nowrap;
}

/* ── Load bar ───────────────────────────────────────────────────── */
.load-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 9px 14px;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r);
  font-size: 13px;
}
.load-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--t3);
}
.load-chip { color: var(--t2); font-family: var(--mono); }
.load-chip b { color: var(--green); font-weight: 700; }

/* ── Chart controls ─────────────────────────────────────────────── */
.chart-controls {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; flex-wrap: wrap; gap: 8px;
}
.chart-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--t3); }
.btn-group { display: flex; gap: 4px; flex-wrap: wrap; }
.tz-badge {
  font-size: 10px; font-family: var(--mono); color: var(--t3);
  background: var(--bg-2); border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 100px; white-space: nowrap;
}

/* ── Install command box ────────────────────────────────────────── */
.cmd-wrap { position: relative; margin-top: 8px; }
.cmd-box {
  background: #04060a; border: 1px solid var(--line-b); border-radius: var(--r);
  padding: 14px 16px; font-family: var(--mono); font-size: 12px;
  color: var(--green); word-break: break-all; line-height: 1.6;
  padding-right: 70px;
}
.cmd-box::before { content: "$ "; color: var(--t4); }
.copy-btn {
  position: absolute; top: 10px; right: 10px;
  background: var(--bg-3); border: 1px solid var(--line-b);
  color: var(--t1); padding: 4px 10px; border-radius: 4px;
  font-size: 11px; font-family: var(--sans); font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; cursor: pointer;
  transition: background .12s;
}
.copy-btn:hover { background: var(--bg-4); }
.copy-btn.copied { background: var(--green); color: #090c10; }

.callout {
  border-left: 3px solid var(--blue); background: var(--blue-s);
  padding: 10px 14px; border-radius: 4px; font-size: 13px; line-height: 1.55;
  color: var(--t2); margin-top: 12px;
}
.callout.warn { border-color: var(--orange); background: rgba(255,179,71,.08); }
.callout strong { color: var(--t1); }

/* ── Modal ──────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(5,8,12,.8); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--r-lg); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
}
.modal-hd {
  padding: 18px 22px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-hd h3 { font-size: 18px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--t3);
  width: 28px; height: 28px; border-radius: 4px; font-size: 20px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.modal-close:hover { background: var(--bg-3); color: var(--t1); }
.modal-body { padding: 22px; }

/* ── Alert cards ────────────────────────────────────────────────── */
.alert-card {
  background: var(--bg-1); border: 1px solid var(--line);
  border-left: 3px solid var(--red); border-radius: var(--r);
  padding: 14px 16px; margin-bottom: 8px;
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px;
}
.alert-name { font-weight: 600; font-size: 13px; }
.alert-meta { color: var(--t3); font-size: 11px; font-family: var(--mono); margin-top: 2px; }

/* ── Toast ──────────────────────────────────────────────────────── */
#toast-container { position: fixed; top: 16px; right: 16px; z-index: 999; display: flex; flex-direction: column; gap: 6px; }
.toast {
  background: var(--bg-3); border: 1px solid var(--line-b); border-left: 3px solid var(--green);
  color: var(--t1); padding: 10px 14px; border-radius: var(--r);
  font-size: 13px; min-width: 220px; max-width: 340px;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
  animation: tin .2s ease;
}
.toast.err { border-left-color: var(--red); }
@keyframes tin { from { transform: translateX(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Loader ─────────────────────────────────────────────────────── */
.spin { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: rot .7s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }
.c-loader { display: flex; justify-content: center; padding: 60px; }

/* ── Metric categories ──────────────────────────────────────────── */
.metric-category { margin-bottom: 12px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.metric-cat-header {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.metric-cat-icon { font-size: 14px; }
.metric-cat-title { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--t1); }
.metric-cat-count { margin-left: auto; font-size: 10px; color: var(--t3); background: var(--bg-3); padding: 1px 7px; border-radius: 100px; }
.metric-cat-body { padding: 2px 14px; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; height: auto; position: relative; border-right: none; border-bottom: 1px solid var(--line); padding: 0; overflow-x: auto; }
  .sidebar-logo { padding: 10px 12px; border-bottom: none; border-right: 1px solid var(--line); min-height: unset; }
  .nav { flex-direction: row; padding: 8px; }
  .sidebar-footer { margin-left: auto; }
  .main { padding: 16px; }
  .page-title { font-size: 26px; }
  .detail-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
