:root {
  --page-bg: #f6f6f8;
  --surface: #ffffff;
  --border: #e4e7ec;
  --text: #171923;
  --text-dim: #6b7280;
  --text-faint: #9aa1af;

  --orange: #f6821f;
  --orange-dark: #c2570a;
  --orange-tint: #fef1e6;
  --blue: #1568c8;

  --ok-bg: #e6f7ee;
  --ok-fg: #0f9d58;
  --down-bg: #fde8e7;
  --down-fg: #d92d20;
  --idle-bg: #f2f3f5;
  --idle-fg: #6b7280;

  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }

:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}

.topbar__mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
}

.topbar__search {
  flex: 1;
  max-width: 340px;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--page-bg);
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
}

.topbar__search:hover { border-color: var(--text-faint); }
.topbar__search .kbd {
  float: right;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
  background: var(--surface);
}

.topbar__spacer { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 6px;
  padding: 0.5rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { border-color: var(--text-faint); }

.btn--primary {
  background: var(--orange);
  border-color: var(--orange);
  color: white;
}

.btn--primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

/* ---------- Page header + KPIs ---------- */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

.page__title {
  margin: 0 0 1.1rem;
  font-size: 1.4rem;
  font-weight: 700;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}

.kpi__label {
  margin: 0 0 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.kpi__value {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.kpi__value--ok { color: var(--ok-fg); }
.kpi__value--down { color: var(--down-fg); }

/* ---------- Warnings ---------- */

.warnings {
  margin: 0 0 1rem;
  padding: 0.65rem 0.9rem;
  border: 1px solid #fde68a;
  background: #fffbeb;
  border-radius: 6px;
  color: #92400e;
  font-size: 0.85rem;
}

/* ---------- Table ---------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }

thead th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #fafafb; }

td { padding: 0.8rem 1rem; vertical-align: middle; }

.cell-project { display: flex; align-items: center; gap: 0.7rem; min-width: 220px; }

.cell-avatar {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.cell-project__name { font-weight: 600; color: var(--text); text-decoration: none; }
.cell-project__name:hover { color: var(--blue); text-decoration: underline; }
.cell-project__desc { color: var(--text-dim); font-size: 0.78rem; margin-top: 0.1rem; }

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

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

.pill--up { background: var(--ok-bg); color: var(--ok-fg); }
.pill--down { background: var(--down-bg); color: var(--down-fg); }
.pill--unknown { background: var(--idle-bg); color: var(--idle-fg); }

.commit { max-width: 260px; }
.commit__msg {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.commit__time { color: var(--text-faint); font-size: 0.74rem; }
.commit__none { color: var(--text-faint); }

.sparkline { display: flex; align-items: flex-end; gap: 2px; height: 24px; margin-bottom: 0.25rem; }
.sparkline__bar { width: 3px; border-radius: 1px; background: var(--idle-fg); }
.sparkline__bar--up { background: var(--ok-fg); }
.sparkline__bar--down { background: var(--down-fg); height: 100% !important; }

.uptime__pct { font-weight: 600; font-variant-numeric: tabular-nums; }

.metric { font-variant-numeric: tabular-nums; font-weight: 600; }
.metric--empty { color: var(--text-faint); font-weight: 400; }

.actions { display: flex; gap: 0.4rem; white-space: nowrap; }
.actions a {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.55rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text);
}
.actions a:hover { border-color: var(--text-faint); background: var(--page-bg); }

details.stack, details.readme { margin-top: 0.3rem; }
details.stack summary, details.readme summary {
  cursor: pointer;
  font-size: 0.72rem;
  color: var(--blue);
  list-style: none;
}
details.stack summary::-webkit-details-marker,
details.readme summary::-webkit-details-marker { display: none; }
details pre {
  white-space: pre-wrap;
  font-size: 0.78rem;
  color: var(--text-dim);
  max-width: 320px;
  margin: 0.4rem 0 0;
}
details p { font-size: 0.78rem; color: var(--text-dim); margin: 0.3rem 0 0; }

/* ---------- Command palette ---------- */

.palette {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(23, 25, 35, 0.35);
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}

.palette.is-open { display: flex; }

.palette__panel {
  width: min(560px, 92vw);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(16, 24, 40, 0.25);
  overflow: hidden;
}

.palette__inputrow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.palette__prompt { color: var(--orange); font-weight: 700; }

#command-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  color: var(--text);
}
#command-input:focus { outline: none; }

#command-list { list-style: none; margin: 0; padding: 0.4rem; max-height: 50vh; overflow-y: auto; }
#command-list li { padding: 0.55rem 0.7rem; border-radius: 6px; cursor: pointer; font-size: 0.85rem; }
#command-list li:hover { background: var(--page-bg); }

@media (max-width: 720px) {
  .cell-project { min-width: 160px; }
  .commit { max-width: 160px; }
}
