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

:root {
  --bg: #0d1117;
  --card: #161b22;
  --border: #30363d;
  --text: #c9d1d9;
  --muted: #8b949e;
  --green: #3cddc7;
  --red: #f85149;
  --yellow: #d2991d;
  --accent: #3cddc7;
  --accent-hover: #5ee4d5;
  --radius: 8px;
}

html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

/* ---- Main ---- */
main {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 16px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.header-row h2 { font-size: 1.4rem; }
h2 { font-size: 1.3rem; margin-bottom: 16px; }
h3 { font-size: 1.05rem; margin: 24px 0 12px; }
.subtitle { color: var(--muted); margin-bottom: 16px; }
.muted { color: var(--muted); }

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: #1c2533; }
.btn-primary { background: #0d9488; border-color: #14a89d; color: #fff; }
.btn-primary:hover { background: #14a89d; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: transparent; }
.btn-full { display: block; width: 100%; text-align: center; padding: 10px 16px; font-size: 1rem; }
.link-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 1rem; padding: 2px 4px;
}
.link-btn:hover { color: var(--red); }
.inline-form { display: inline; }

/* ---- Forms ---- */
.monitor-form { max-width: 500px; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 4px; font-size: 0.85rem; color: var(--muted); }
.field input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
}
.field input:focus { outline: none; border-color: var(--accent); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.hint { display: block; margin-top: 2px; font-size: 0.78rem; color: var(--muted); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; }

/* ---- Alerts ---- */
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.9rem; }
.alert-error { background: #490202; border: 1px solid var(--red); color: var(--red); }

/* ---- Login ---- */
.login-container {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; padding: 20px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
}
.login-card h1 { font-size: 1.3rem; margin-bottom: 4px; }
.login-card .subtitle { font-size: 0.9rem; }

/* ---- Empty ---- */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state p { color: var(--muted); margin-bottom: 16px; }

/* ---- Monitor Grid ---- */
.monitor-grid { display: flex; flex-direction: column; gap: 10px; }

.monitor-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card-top {
  display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
}
.status-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.card-favicon { width: 16px; height: 16px; flex-shrink: 0; border-radius: 2px; }
.status-up { background: var(--green); box-shadow: 0 0 6px rgba(60,221,199,0.5); }
.status-down { background: var(--red); box-shadow: 0 0 6px rgba(248,81,73,0.5); animation: pulse 1.5s infinite; }
.status-unknown { background: var(--muted); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.monitor-name { font-weight: 600; flex: 1; }
.card-actions { display: flex; gap: 8px; }
.card-actions a { color: var(--muted); text-decoration: none; font-size: 1rem; }
.card-actions a:hover { color: var(--accent); }

.card-url { font-size: 0.82rem; color: var(--accent); word-break: break-all; margin-bottom: 4px; }
.card-meta { font-size: 0.78rem; color: var(--muted); margin-bottom: 6px; }

.card-stats { display: flex; gap: 16px; font-size: 0.82rem; }
.uptime { font-weight: 600; }
.uptime-good { color: var(--green); }
.uptime-warn { color: var(--yellow); }
.uptime-bad { color: var(--red); }
.checks-count { color: var(--muted); }
.next-check { color: var(--muted); font-size: 0.78rem; margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---- Stats bar ---- */
.stats-bar {
  display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px;
}
.stat {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; text-align: center; min-width: 80px;
}
.stat-label { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 2px; }
.stat-value { font-size: 1.2rem; font-weight: 700; }
.text-green { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-red { color: var(--red); }

/* ---- History Table ---- */
.history-table-wrapper { overflow-x: auto; }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.history-table th {
  text-align: left; padding: 8px 10px; font-weight: 600;
  color: var(--muted); border-bottom: 1px solid var(--border); font-size: 0.78rem;
}
.history-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.history-table tr:hover { background: rgba(255,255,255,0.02); }
.row-up { border-left: 3px solid var(--green); }
.row-down { border-left: 3px solid var(--red); }
.status-dot-small { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; }
.dot-up { background: var(--green); }
.dot-down { background: var(--red); }

/* Mobile table */
@media (max-width: 500px) {
  .history-table thead { display: none; }
  .history-table tr { display: block; margin-bottom: 8px; }
  .history-table td {
    display: flex; justify-content: space-between; padding: 6px 10px;
  }
  .history-table td::before { content: attr(data-label); font-weight: 600; color: var(--muted); }
}
