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

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #21262d;
  --text: #e6edf3;
  --muted: #7d8590;
  --accent: #58a6ff;
  --online: #3fb950;
  --offline: #f85149;
  --error: #d29922;
  --radius: 10px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}

.header-sub {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.last-refresh {
  font-size: 0.75rem;
  color: var(--muted);
}

.btn-refresh {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 1.1rem;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}

.btn-refresh:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
}

.btn-refresh:disabled { opacity: 0.4; cursor: default; }

/* ── Main grid ── */
main {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.25rem;
}

/* ── Cards ── */
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(88,166,255,0.12), 0 4px 16px rgba(0,0,0,0.25);
  transform: translateY(-2px);
}

.card-self {
  border-style: dashed;
  opacity: 0.7;
}

.card-self:hover { opacity: 1; }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.card-name {
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.3;
}

/* ── Status badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-online  { background: rgba(63,185,80,0.12);  color: var(--online); }
.badge-offline { background: rgba(248,81,73,0.12);  color: var(--offline); }
.badge-error   { background: rgba(210,153,34,0.12); color: var(--error); }

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-online .dot {
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.http-code {
  background: rgba(255,255,255,0.08);
  padding: 0 0.3rem;
  border-radius: 3px;
  font-family: ui-monospace, 'SFMono-Regular', monospace;
}

.card-url {
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-backend {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: ui-monospace, 'SFMono-Regular', monospace;
}

/* ── Placeholder ── */
.placeholder {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 5rem 2rem;
  font-size: 0.9rem;
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 1.5rem 2rem;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--accent); }

/* ── Mobile ── */
@media (max-width: 640px) {
  header { padding: 0.75rem 1rem; }
  main { padding: 1rem; }
  .header-sub { display: none; }
  .grid { grid-template-columns: 1fr; }
}
