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

:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --gray: #94a3b8;
  --nav-bg: #0f172a;
  --radius: 8px;
}

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Nav */
.topnav {
  background: var(--nav-bg);
  color: #fff;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topnav-inner {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { color: #fff; font-weight: 700; font-size: 16px; }
.brand:hover { text-decoration: none; opacity: 0.9; }
.nav-link { color: #94a3b8; font-size: 13px; }
.nav-link:hover { color: #fff; text-decoration: none; }

/* Main */
main { max-width: 1400px; margin: 0 auto; padding: 24px; }
main.with-nav { /* already has padding */ }

/* Summary cards */
.summary-cards {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  flex: 1;
  min-width: 140px;
  text-align: center;
  border-top: 3px solid var(--border);
}
.card .count { display: block; font-size: 28px; font-weight: 700; line-height: 1.2; }
.card .label { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.card-total { border-top-color: var(--primary); }
.card-total .count { color: var(--primary); }
.card-up { border-top-color: var(--green); }
.card-up .count { color: var(--green); }
.card-down { border-top-color: var(--red); }
.card-down .count { color: var(--red); }
.card-nodns { border-top-color: var(--gray); }
.card-nodns .count { color: var(--gray); }
.card-unchecked { border-top-color: var(--yellow); }
.card-unchecked .count { color: var(--yellow); }

/* Controls */
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.filters select, .search-input {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--card);
  color: var(--text);
}
.filters select:focus, .search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,.15);
}
.search-input { width: 200px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn.primary:hover { background: var(--primary-hover); }

/* Status dots */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 4px;
}
.dot.sm { width: 6px; height: 6px; }
.dot.lg { width: 10px; height: 10px; }
.dot.green { background: var(--green); }
.dot.red { background: var(--red); }
.dot.yellow { background: var(--yellow); }
.dot.gray { background: var(--gray); }

/* Table */
.table-count { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
thead { background: #f8fafc; }
th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
  user-select: none;
}
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--text); }
th.sort-asc::after { content: ' \2191'; }
th.sort-desc::after { content: ' \2193'; }
td {
  padding: 9px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

.text-red { color: var(--red); font-weight: 600; }
.text-yellow { color: var(--yellow); font-weight: 600; }
.error-cell { font-size: 11px; color: var(--red); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Health check progress */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.check-done { color: var(--green); font-size: 13px; font-weight: 500; margin-left: 8px; }

/* Site detail */
.site-detail { max-width: 1000px; }
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.site-header h1 { font-size: 22px; }
.site-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}
.meta-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  min-width: 120px;
}
.meta-label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 4px; }
.site-detail h2 { font-size: 16px; margin-bottom: 12px; }
.muted { color: var(--muted); }
.history-table { margin-bottom: 24px; }

/* Login */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 4px 24px rgba(0,0,0,.06);
}
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-sub { color: var(--muted); margin-bottom: 32px; }
.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #3c4043;
  cursor: pointer;
  transition: box-shadow .2s;
}
.google-btn:hover { box-shadow: 0 1px 6px rgba(0,0,0,.1); text-decoration: none; }
.alert {
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 13px;
}
.alert.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* Responsive */
@media (max-width: 768px) {
  main { padding: 16px; }
  .summary-cards { gap: 8px; }
  .card { padding: 12px; min-width: 80px; }
  .card .count { font-size: 20px; }
  .controls { flex-direction: column; align-items: stretch; }
  .search-input { width: 100%; }
  table { font-size: 12px; display: block; overflow-x: auto; }
  .site-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}
