@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #12151a;
  --surface: #1a1f27;
  --surface-2: #20262f;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #eceef1;
  --text-dim: #8b93a1;
  --text-faint: #5a6170;
  --accent: #4f8cff;
  --accent-dim: rgba(79, 140, 255, 0.14);
  --ok: #34d399;
  --bad: #f87171;
  --warn: #fbbf24;
  --radius: 10px;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --display: 'Space Grotesk', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  background-image:
    radial-gradient(680px circle at 12% -10%, rgba(79, 140, 255, 0.10), transparent 60%),
    radial-gradient(520px circle at 100% 0%, rgba(52, 211, 153, 0.06), transparent 55%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--display);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- status dot ---- */

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot--ok {
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
  animation: pulse 2.4s ease-out infinite;
}

.dot--bad {
  background: var(--bad);
}

.dot--warn {
  background: var(--warn);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(52, 211, 153, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dot--ok {
    animation: none;
  }
}

/* ---- login page ---- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  animation: rise 0.5s ease both;
}

.login-panel {
  background: linear-gradient(165deg, var(--surface), var(--surface) 60%, var(--surface-2));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  animation: rise 0.5s 0.05s ease both;
}

.login-panel h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px;
}

.login-panel .sub {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 20px;
}

label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-family: var(--mono);
}

input[type='email'],
input[type='password'],
input[type='text'] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  margin-bottom: 14px;
}

input:disabled {
  opacity: 0.6;
}

button {
  font-family: var(--display);
  font-weight: 600;
  font-size: 13px;
  border: none;
  border-radius: 7px;
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(165deg, #6ea2ff, var(--accent));
  color: #0b0e12;
  padding: 11px;
  margin-top: 4px;
  box-shadow: 0 8px 20px -8px rgba(79, 140, 255, 0.55);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px -8px rgba(79, 140, 255, 0.65);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: default;
}

.field-msg {
  font-size: 12px;
  color: var(--bad);
  margin: -6px 0 14px;
  min-height: 1em;
}

.hint {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 16px;
}

/* ---- dashboard ---- */

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.topbar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 140px;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-left h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.01em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: var(--mono);
  color: var(--text-dim);
  font-size: 12px;
}

.logout-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: var(--mono);
}

.logout-btn:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  background: linear-gradient(165deg, var(--surface), var(--surface) 70%, var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: 0 16px 40px -28px rgba(0, 0, 0, 0.6);
  animation: rise 0.45s ease both;
}

.stat-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.stat-card-head svg {
  width: 15px;
  height: 15px;
  color: var(--accent);
  opacity: 0.85;
}

.stat-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.stat-value {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

.stat-value .unit {
  font-size: 13px;
  color: var(--text-dim);
}

.gauge {
  display: flex;
  gap: 3px;
  margin-bottom: 9px;
}

.gauge-seg {
  flex: 1;
  height: 12px;
  border-radius: 3px;
  background: var(--surface-2);
  transition: background 0.3s ease;
}

.gauge-seg.filled {
  background: var(--accent);
  box-shadow: 0 0 10px -1px rgba(79, 140, 255, 0.55);
}

.gauge-seg.filled.warn {
  background: var(--warn);
  box-shadow: 0 0 10px -1px rgba(251, 191, 36, 0.5);
}

.gauge-seg.filled.crit {
  background: var(--bad);
  box-shadow: 0 0 10px -1px rgba(248, 113, 113, 0.5);
}

.gauge-pct {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

.section-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.proc-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 16px 40px -28px rgba(0, 0, 0, 0.6);
  animation: rise 0.45s 0.05s ease both;
}

.proc-table th,
.proc-table td {
  text-align: left;
  padding: 13px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.proc-table th {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 500;
  background: rgba(255, 255, 255, 0.015);
}

.proc-table tbody tr {
  transition: background 0.15s ease;
}

.proc-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

.proc-table tr:last-child td {
  border-bottom: none;
}

.proc-name {
  font-weight: 600;
}

.proc-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
}

.proc-status.online {
  color: var(--ok);
}

.proc-status.stopped,
.proc-status.errored {
  color: var(--bad);
}

.mono-dim {
  font-family: var(--mono);
  color: var(--text-dim);
  font-size: 12px;
}

.restart-btn {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
}

.restart-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.restart-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 13px;
}

.certs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
  margin-bottom: 28px;
}

.cert-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

.cert-chip .dot {
  width: 7px;
  height: 7px;
}

.cert-chip .cert-domain {
  color: var(--text);
  font-weight: 500;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}
