:root {
  --bg: #0b1220;
  --bg2: #111b2e;
  --card: #162032;
  --card2: #1c2840;
  --border: #2a3d5c;
  --text: #eef4fc;
  --muted: #8fa3b8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --accent: #3b82f6;
  --accent2: #60a5fa;
  --glow: rgba(59, 130, 246, 0.15);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: radial-gradient(ellipse 120% 80% at 50% -20%, #1a3050 0%, var(--bg) 55%);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--accent2); text-decoration: none; }
.wrap { max-width: 800px; margin: 0 auto; padding: 16px 16px 88px; }

.logo { display: block; flex-shrink: 0; }

.brand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand h1 { font-size: 1.25rem; margin: 0; font-weight: 700; letter-spacing: -0.02em; }
.sub { color: var(--muted); font-size: 0.88rem; margin-top: 4px; }

.btn-ghost {
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.pill {
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
}
.pill.bad { border-color: var(--err); color: #fca5a5; background: rgba(239, 68, 68, 0.08); }
.pill.good { border-color: var(--ok); color: #86efac; background: rgba(34, 197, 94, 0.08); }

.panel {
  margin-bottom: 20px;
}
.panel-primary .panel-title { color: var(--accent2); }
.panel-secondary { opacity: 0.95; }
.panel-accent .trigger-panel {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
}
.panel-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 12px;
  font-weight: 600;
}

/* —— Server health —— */
.server-head {
  background: linear-gradient(135deg, var(--card) 0%, var(--card2) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 12px;
  box-shadow: 0 4px 24px var(--glow);
}
.server-head.ok { border-left: 4px solid var(--ok); }
.server-head.warn { border-left: 4px solid var(--warn); }
.server-head.err { border-left: 4px solid var(--err); }
.server-headline { margin: 0; font-size: 1.05rem; font-weight: 600; }
.server-when { margin: 6px 0 0; font-size: 0.78rem; color: var(--muted); }

.svc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.svc-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
}
.svc-chip.ok { border-color: rgba(34, 197, 94, 0.4); }
.svc-chip.err { border-color: rgba(239, 68, 68, 0.5); color: #fecaca; }
.svc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}
.svc-chip.err .svc-dot { background: var(--err); box-shadow: 0 0 8px var(--err); }

.gauge-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 520px) {
  .gauge-grid { grid-template-columns: 1fr; }
}
.gauge-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 8px 14px;
  text-align: center;
}
.gauge-svg {
  width: 88px;
  height: 88px;
  margin: 0 auto;
  display: block;
  transform: rotate(-90deg);
}
.gauge-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 8;
}
.gauge-fg {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease;
}
.gauge-center {
  position: absolute;
  left: 50%;
  top: 46px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.gauge-val { display: block; font-size: 1.15rem; font-weight: 700; }
.gauge-lbl { display: block; font-size: 0.7rem; color: var(--muted); margin-top: 2px; }

.bar-chart {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.bar-chart-title {
  margin: 0 0 12px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.bar-row {
  display: grid;
  grid-template-columns: 100px 1fr 72px;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.82rem;
}
@media (max-width: 480px) {
  .bar-row { grid-template-columns: 1fr; gap: 4px; }
}
.bar-name { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.bar-fill.ok { background: linear-gradient(90deg, #16a34a, var(--ok)); }
.bar-fill.warn { background: linear-gradient(90deg, #d97706, var(--warn)); }
.bar-fill.err { background: linear-gradient(90deg, #dc2626, var(--err)); }
.bar-val { color: var(--muted); font-size: 0.75rem; text-align: right; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr; }
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.stat-card.ok { border-top: 3px solid var(--ok); }
.stat-card.warn { border-top: 3px solid var(--warn); }
.stat-card.err { border-top: 3px solid var(--err); }
.stat-card.muted { border-top: 3px solid var(--border); }
.stat-card-head {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border);
}
.stat-card-head h3 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
}
.mini-meter {
  height: 4px;
  background: var(--bg);
  border-radius: 999px;
  margin-top: 8px;
  overflow: hidden;
}
.mini-meter-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease;
}
.mini-meter-fill.ok { background: var(--ok); }
.mini-meter-fill.warn { background: var(--warn); }
.mini-meter-fill.err { background: var(--err); }

.stat-dl { margin: 0; padding: 10px 14px 12px; }
.stat-row { margin-bottom: 10px; }
.stat-row:last-child { margin-bottom: 0; }
.stat-dl dt {
  color: var(--muted);
  font-size: 0.72rem;
  margin: 0;
}
.stat-dl dd {
  margin: 3px 0 0;
  font-size: 0.86rem;
  word-break: break-word;
}
.stat-detail {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.attention {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.attention h3 { margin: 0 0 4px; font-size: 0.95rem; color: #fecaca; }
.attention p { margin: 0; font-size: 0.88rem; color: var(--muted); }
.attention .when { font-size: 0.78rem; color: var(--muted); margin-top: 6px; }
.attention.recent-ok {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.35);
}
.attention.recent-ok h3 { color: #86efac; }

.btn {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  box-shadow: 0 4px 16px var(--glow);
}
.btn:disabled { opacity: 0.5; box-shadow: none; }

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-box {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px;
  background: linear-gradient(160deg, var(--card2), var(--card));
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  text-align: center;
}
.login-logo { margin: 0 auto 16px; }
.login-box h1 { margin: 0; font-size: 1.35rem; }
.login-box input {
  width: 100%;
  padding: 14px;
  margin: 16px 0 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
.err-msg { color: var(--err); font-size: 0.88rem; min-height: 1.2em; }

.detail-head { margin-bottom: 20px; }
.detail-head .big { font-size: 1.2rem; font-weight: 600; }
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 6px;
  margin-bottom: 8px;
}
.badge.ok { background: rgba(34,197,94,0.2); color: #86efac; }
.badge.warn { background: rgba(245,158,11,0.2); color: #fcd34d; }
.badge.err { background: rgba(239,68,68,0.2); color: #fca5a5; }
.badge.muted { background: var(--border); color: var(--muted); }

.info-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.info-block h3 { margin: 0 0 8px; font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.info-block p { margin: 0; font-size: 0.95rem; }

.clip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.clip-row:last-child { border-bottom: none; }
.tag-test {
  display: inline-block;
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 6px;
  margin-right: 4px;
}
.clip-meta { flex: 1; min-width: 0; }
.clip-actions { display: flex; flex-shrink: 0; align-items: center; gap: 8px; }
.clip-row a.btn-sm.outline {
  background: transparent;
  color: var(--accent2);
  border: 1px solid var(--accent);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}
.muted-sm { color: var(--muted); font-size: 0.85rem; }
.btn-sm.danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.45);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.refresh-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(22, 32, 50, 0.92);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.back { font-size: 0.9rem; margin-bottom: 12px; display: inline-block; }
.empty { color: var(--muted); text-align: center; padding: 24px; font-size: 0.95rem; }

.trigger-panel { margin: 0; }
.trigger-hint { font-size: 0.85rem; color: var(--muted); margin: 0 0 12px; line-height: 1.5; }
.trigger-status { font-size: 0.88rem; margin: 10px 0 0; min-height: 1.2em; }
.trigger-status.ok { color: #86efac; }
.trigger-status.err { color: #fca5a5; }

.card-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.card-wrap:hover { box-shadow: 0 4px 20px var(--glow); }
.card-wrap.ok { border-left: 4px solid var(--ok); }
.card-wrap.warn { border-left: 4px solid var(--warn); }
.card-wrap.err { border-left: 4px solid var(--err); }
.card-wrap.muted { opacity: 0.85; border-left: 4px solid var(--border); }
.card-wrap .card-body {
  display: block;
  padding: 16px;
  color: inherit;
  text-decoration: none;
}
.card-wrap .card-body h2 { margin: 0 0 6px; font-size: 1.05rem; }
.card-wrap .card-actions { padding: 0 16px 12px; display: flex; gap: 8px; }
.btn-sm {
  flex: 1;
  padding: 10px 12px;
  font-size: 0.88rem;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
.btn-sm:disabled { opacity: 0.45; }
.btn-sm.outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.toast {
  position: fixed;
  top: 12px;
  left: 16px;
  right: 16px;
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 100;
  font-size: 0.9rem;
  display: none;
}
.toast.show { display: block; }
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--err); }
