:root {
  --bg: #f5f6f8;
  --panel-bg: #ffffff;
  --border: #e3e5e9;
  --text: #1f2430;
  --text-muted: #6b7280;
  --accent: #2ecc71;
  --danger: #e74c3c;
  --paused: #9aa4b2;
  --sidebar-width: 330px;
  --radius: 10px;
  --radius-pill: 999px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --panel-bg: #161b22;
    --border: #262c36;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --accent: #34c77b;
    --danger: #f0554a;
    --paused: #6b7280;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none; }

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 320px;
  padding: 32px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.login-form .brand { justify-content: center; margin-bottom: 12px; }

.login-form input {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); }
.brand-name { font-weight: 700; font-size: 1.1rem; }

.layout { display: flex; min-height: calc(100vh - 61px); }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

.btn {
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #06280f; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #2b0704; }
.btn-block { width: 100%; }

.add-monitor-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.add-monitor-form input {
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}
.add-monitor-actions { display: flex; gap: 8px; }
.form-error { color: var(--danger); font-size: 0.8rem; margin: 0; }

.search input {
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  margin: 12px 0;
}

.host-list { list-style: none; margin: 0; padding: 0; }

.host-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
}

.host-row:hover { background: var(--bg); }
.host-row.selected { background: var(--bg); outline: 1px solid var(--accent); }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
  color: #06280f;
  min-width: 2.5em;
}

.pill.up { background: var(--accent); }
.pill.down { background: var(--danger); color: #2b0704; }
.pill.paused { background: var(--paused); color: #fff; }
.pill.unknown { background: var(--paused); color: #fff; }

.host-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-heartbeat { display: flex; gap: 2px; }
.mini-heartbeat .bar { width: 4px; height: 16px; border-radius: 2px; background: var(--accent); }
.mini-heartbeat .bar.down { background: var(--danger); }
.mini-heartbeat .bar.paused { background: var(--paused); }

.panel { flex: 1; padding: 24px; overflow-y: auto; }
.empty-state { color: var(--text-muted); }

.card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.host-url { color: var(--accent); text-decoration: none; }
.host-url:hover { text-decoration: underline; }

.detail-actions { display: flex; gap: 8px; margin-top: 10px; }

.detail-header h1 { margin: 0 0 4px; font-size: 1.4rem; }

.heartbeat-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.heartbeat-bar { display: flex; gap: 3px; flex: 1; overflow: hidden; }
.heartbeat-bar .beat { width: 8px; height: 34px; border-radius: 4px; background: var(--accent); flex-shrink: 0; }
.heartbeat-bar .beat.down { background: var(--danger); }
.heartbeat-bar .beat.paused { background: var(--paused); }

.status-badge {
  padding: 6px 20px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  color: #06280f;
  white-space: nowrap;
}
.status-badge.up { background: var(--accent); }
.status-badge.down { background: var(--danger); color: #2b0704; }
.status-badge.paused { background: var(--paused); color: #fff; }
.status-badge.unknown { background: var(--paused); color: #fff; }

.check-caption { color: var(--text-muted); font-size: 0.8rem; margin: 10px 0 0; }

.stat-row { display: flex; flex-wrap: wrap; gap: 24px; }
.stat { flex: 1; min-width: 120px; }
.stat-label { color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value { font-size: 1.2rem; font-weight: 700; margin-top: 4px; }

.chart-container { position: relative; height: 220px; }
