:root{
  --bg: #0a0e16;
  --bg-panel: #10151f;
  --line: #1e2733;
  --text: #e6edf3;
  --muted: #6b7785;
  --muted-2: #45505e;
  --blue: #3b82f6;
  --cyan: #22d3ee;
  --green: #34d399;
  --amber: #f5b544;
  --red: #f2555a;
  --mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;
}
*{ box-sizing:border-box; margin:0; padding:0; }
html,body{ height:100%; }
body{
  background: radial-gradient(ellipse 1200px 800px at 15% -10%, #101c30 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--sans);
  overflow-x:hidden;
  min-height:100vh;
}

/* ---------- top identity bar ---------- */
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(10,14,22,0.6);
  backdrop-filter: blur(6px);
  position: relative; z-index: 5;
}
.brand{ display:flex; align-items:center; gap:10px; }
.brand-mark{
  width:26px; height:26px; border-radius:7px;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  position:relative; flex-shrink:0;
}
.brand-mark::after{
  content:""; position:absolute; inset:6px;
  border:1.5px solid rgba(10,14,22,0.85); border-radius:3px;
}
.brand-name{ font-size:14.5px; font-weight:600; letter-spacing:0.2px; }
.brand-sub{ font-size:11.5px; color:var(--muted); font-family: var(--mono); }
.status-pill{
  display:flex; align-items:center; gap:7px;
  font-size:11.5px; font-family: var(--mono); color: var(--muted);
  padding:6px 12px; border:1px solid var(--line); border-radius:20px;
}
.status-dot{
  width:7px; height:7px; border-radius:50%; background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse{ 0%,100%{ opacity:1; } 50%{ opacity:0.4; } }

/* ---------- dashboard (used on node-control page) ---------- */
.stage{ position: relative; min-height: calc(100vh - 64px); }

.dashboard{ padding: 28px; max-width: 1180px; margin: 0 auto; }
.dashboard.static-preview{
  filter: blur(9px);
  transform: scale(1.01);
  pointer-events: none;
  user-select: none;
}

.grid-metrics{
  display:grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px;
}
.metric-card{
  background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px 18px;
}
.metric-head{ display:flex; justify-content:space-between; align-items:baseline; margin-bottom: 10px; }
.metric-label{ font-size:11.5px; color:var(--muted); text-transform:uppercase; letter-spacing:0.6px; }
.metric-value{ font-family: var(--mono); font-size:20px; font-weight:600; }
.metric-value .unit{ font-size:12px; color:var(--muted); font-weight:400; margin-left:2px; }
canvas.sparkline{ display:block; width:100%; height:44px; }

.grid-lower{ display:grid; grid-template-columns: 1.15fr 1fr; gap: 14px; }
@media (max-width: 900px){
  .grid-metrics{ grid-template-columns: repeat(2,1fr); }
  .grid-lower{ grid-template-columns: 1fr; }
}

.panel{ background: var(--bg-panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.panel-title{
  display:flex; justify-content:space-between; align-items:center;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  font-size: 12.5px; font-weight:600; color: var(--text);
}
.panel-title span.count{ font-family: var(--mono); font-size:11px; color:var(--muted); font-weight:400; }

.node-list{ padding: 6px; }
.node-row{ display:flex; align-items:center; gap:12px; padding: 10px 10px; border-radius: 7px; }
.node-row + .node-row{ border-top: 1px solid var(--line); }
.node-dot{ width:8px; height:8px; border-radius:50%; flex-shrink:0; }
.node-dot.on{ background:var(--green); box-shadow:0 0 6px var(--green); }
.node-dot.warn{ background:var(--amber); box-shadow:0 0 6px var(--amber); }
.node-name{ font-size:13px; font-weight:500; }
.node-meta{ font-size:11px; color:var(--muted); font-family: var(--mono); }
.node-right{ margin-left:auto; text-align:right; }
.node-load{ font-family: var(--mono); font-size:12.5px; }
.node-load-label{ font-size:10.5px; color:var(--muted); }

.log-body{
  height: 280px; overflow: hidden; padding: 10px 14px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.85; color: #a8b3c0;
}
.log-line{ white-space: nowrap; overflow:hidden; text-overflow:ellipsis; opacity:0; animation: fadeIn 0.4s ease forwards; }
@keyframes fadeIn{ from{opacity:0; transform:translateY(2px);} to{opacity:1; transform:translateY(0);} }
.log-ts{ color: var(--muted-2); }
.log-tag{ padding: 1px 5px; border-radius: 4px; font-size:10px; margin: 0 6px; }
.log-tag.ok{ background: rgba(52,211,153,0.12); color:var(--green); }
.log-tag.info{ background: rgba(59,130,246,0.12); color:var(--blue); }
.log-tag.warn{ background: rgba(245,181,68,0.12); color:var(--amber); }

/* ---------- login page ---------- */
.login-overlay{
  position: absolute; inset: 0; display:flex; align-items:center; justify-content:center;
  z-index: 10; padding: 24px;
}
.login-card{
  width: 100%; max-width: 360px;
  background: rgba(16,21,31,0.88);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px; padding: 32px 30px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(59,130,246,0.04);
  backdrop-filter: blur(18px);
}
.login-mark{
  width:42px; height:42px; border-radius:11px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  position:relative;
}
.login-mark::after{ content:""; position:absolute; inset:9px; border:2px solid var(--bg-panel); border-radius:5px; }
.login-title{ text-align:center; font-size:15.5px; font-weight:600; margin-bottom:4px; }
.login-sub{ text-align:center; font-size:12px; color:var(--muted); margin-bottom:24px; font-family: var(--mono); }

.field{ margin-bottom: 14px; }
.field label{ display:block; font-size:11px; color:var(--muted); margin-bottom:6px; letter-spacing:0.3px; }
.field input{
  width:100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 7px; color: var(--text); font-size: 13.5px; font-family: var(--sans);
  outline:none; transition: border-color 0.15s;
}
.field input:focus{ border-color: var(--blue); }

.login-btn{
  width:100%; padding: 11px; margin-top: 6px;
  background: linear-gradient(135deg, var(--blue), #2563eb);
  border:none; border-radius:7px; color:white; font-size:13.5px; font-weight:600;
  cursor:pointer; transition: filter 0.15s, transform 0.1s; font-family: var(--sans);
}
.login-btn:hover{ filter: brightness(1.08); }
.login-btn:active{ transform: scale(0.98); }

.login-err{ font-size:11.5px; color: var(--red); text-align:center; margin-top:12px; height:14px; opacity:0; transition: opacity 0.2s; }
.login-err.show{ opacity:1; }

.login-foot{ text-align:center; margin-top:20px; font-size:10.5px; color: var(--muted-2); font-family: var(--mono); }

/* ---------- topbar sign-out ---------- */
.ghost-btn{
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  font-size: 11.5px; font-family: var(--sans); padding: 6px 12px; border-radius: 8px;
  cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.ghost-btn:hover{ border-color: var(--blue); color: var(--text); }

/* ---------- disk ring (real capacity) ---------- */
.metric-card-disk .metric-head{ margin-bottom: 6px; }
.disk-ring-wrap{ display:flex; align-items:center; justify-content:center; height:44px; }
.disk-ring{ width: 44px; height: 44px; transform: rotate(-90deg); }
.disk-ring-track{ fill:none; stroke: var(--line); stroke-width: 7; }
.disk-ring-fill{
  fill:none; stroke: var(--green); stroke-width: 7; stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}
.disk-ring-text{
  font-family: var(--mono); font-size: 13px; fill: var(--text);
  transform: rotate(90deg); transform-origin: 40px 40px;
}

/* ---------- node status dot: unknown state ---------- */
.node-dot.unknown{ background: var(--muted-2); }

/* ---------- node row controls ---------- */
.node-link{ text-decoration:none; color: var(--text); }
.node-link:hover{ color: var(--blue); text-decoration: underline; }
.node-right{ display:flex; align-items:center; gap:4px; }
.mini-btn{
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  font-size: 10px; width: 22px; height: 22px; border-radius: 5px; cursor:pointer;
  display:flex; align-items:center; justify-content:center; transition: border-color 0.15s, color 0.15s;
}
.mini-btn:hover:not(:disabled){ border-color: var(--blue); color: var(--text); }
.mini-btn:disabled{ opacity: 0.3; cursor: default; }
.mini-btn.danger:hover{ border-color: var(--red); color: var(--red); }

/* ---------- add node form ---------- */
.add-node-form{
  display:grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 12px 14px; border-top: 1px solid var(--line);
}
.add-node-form input{
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  color: var(--text); font-size: 12px; padding: 8px 10px; font-family: var(--sans); outline:none;
}
.add-node-form input:focus{ border-color: var(--blue); }
.add-node-form button{
  grid-column: 1 / -1; background: linear-gradient(135deg, var(--blue), #2563eb);
  border:none; border-radius:6px; color:white; font-size:12.5px; font-weight:600;
  padding: 9px; cursor:pointer;
}

/* ---------- apps placeholder panel ---------- */
.apps-placeholder{ padding: 20px 16px; color: var(--muted); font-size: 12.5px; line-height:1.6; }
.apps-placeholder .muted-small{ font-size: 11px; color: var(--muted-2); margin-top: 6px; }
