:root {
  --bg: #0a0d14;
  --bg-card: #10141d;
  --bg-input: #0d1119;
  --border: #1e2430;
  --border-hover: #2a3140;
  --text: #e7eaf0;
  --text-muted: #8b93a3;
  --text-faint: #5b6472;
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.14);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.14);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: inherit;
}

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
}

nav .brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

nav .links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

nav a, nav button {
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
}

nav a:hover, nav button:hover {
  color: var(--text);
}

main {
  padding: 2rem;
  max-width: 1280px;
  margin: 0 auto;
}

.error {
  color: var(--red);
}

.success {
  color: var(--green);
}

/* dashboard header */
.page-header h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
}

.page-header p {
  color: var(--text-muted);
  margin: 0 0 1.75rem;
}

/* toolbar */
.toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.75rem;
}

.toolbar input[type="search"] {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
}

.toolbar select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.9rem;
}

.toolbar input:focus, .toolbar select:focus, a:focus-visible, button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 1px;
}

.toolbar label {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

/* card grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.1rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: var(--border-hover);
}

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

.card-title {
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  color: var(--text);
}

.card-title:hover {
  text-decoration: underline;
}

.card-meta {
  color: var(--text-faint);
  font-size: 0.82rem;
  margin-top: 0.3rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta .category {
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-up {
  background: var(--green-bg);
  color: var(--green);
}

.badge-down {
  background: var(--red-bg);
  color: var(--red);
}

.badge-unknown {
  background: rgba(139, 147, 163, 0.14);
  color: var(--text-muted);
}

.card-response {
  text-align: right;
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 0.9rem;
}

.history {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 34px;
  margin-top: 0.4rem;
}

.history .bar {
  position: relative;
  flex: 1;
  min-width: 2px;
  height: 100%;
  border-radius: 1px;
  background: var(--border);
  cursor: default;
}

.history .bar[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.35rem 0.6rem;
  background: #171c28;
  border: 1px solid var(--border-hover);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
}

.history .bar[data-tooltip]:hover::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--border-hover);
  z-index: 20;
}

.history .bar.up {
  background: var(--green);
}

.history .bar.down {
  background: var(--red);
}

.history-range {
  display: flex;
  justify-content: space-between;
  color: var(--text-faint);
  font-size: 0.75rem;
  margin-top: 0.5rem;
}

.empty-state {
  color: var(--text-muted);
  padding: 2rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* plain tables used on the other, lighter-touch pages */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

th, td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
}

.status-up {
  color: var(--green);
  font-weight: 600;
}

.status-down {
  color: var(--red);
  font-weight: 600;
}

form.inline {
  display: inline;
}

form.inline button[type="submit"] {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
}

form.inline button[type="submit"]:hover {
  color: var(--text);
  border-color: var(--border-hover);
  filter: none;
}

/* forms (login, settings) */
form:not(.inline) {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-width: 420px;
}

form:not(.inline) label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

input, select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.9rem;
}

button[type="submit"] {
  background: var(--green);
  color: #06210f;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  width: fit-content;
}

button[type="submit"]:hover {
  filter: brightness(1.08);
}

@media (max-width: 640px) {
  main { padding: 1.25rem; }
  nav { padding: 1rem 1.25rem; }
  .toolbar { flex-wrap: wrap; }
}
