:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #dfe4ea;
  --text: #17202a;
  --muted: #667085;
  --ok: #087443;
  --ok-bg: #dcfce7;
  --bad: #b42318;
  --bad-bg: #fee4e2;
  --unknown: #6941c6;
  --unknown-bg: #ede9fe;
  --accent: #0f766e;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 32px auto;
}

.shell.narrow {
  width: min(460px, calc(100vw - 32px));
}

.topbar, .section-head, .actions, .top-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1, h2, p { margin: 0; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 18px; }
p, small, label, .count { color: var(--muted); }
small { display: block; margin-top: 4px; overflow-wrap: anywhere; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 18px;
  padding: 18px;
}

.grid-form {
  display: grid;
  grid-template-columns: 1.1fr 1.8fr 0.8fr 0.8fr 0.8fr auto;
  align-items: end;
  gap: 12px;
  margin-top: 14px;
}

.grid-form.compact {
  grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
}

.stack-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.error {
  color: var(--bad);
  margin-top: 12px;
}

.form-note {
  margin-top: 14px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  padding: 10px 11px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}

.button.ghost {
  background: white;
  color: var(--accent);
}

.button.danger {
  background: #b42318;
  border-color: #b42318;
}

.button.small {
  min-height: 32px;
  padding: 0 10px;
}

.table {
  display: grid;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.row {
  display: grid;
  grid-template-columns: 120px 1fr 100px 130px 1.2fr 110px 130px 80px;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.checks .row {
  grid-template-columns: 110px 100px 1.2fr 120px 180px 1fr;
}

.users .row {
  grid-template-columns: 1fr 140px 140px 140px 80px;
}

.user-sites .row {
  grid-template-columns: 110px 1fr 100px 130px 120px 90px;
}

.row:first-child { border-top: 0; }
.row.head {
  min-height: 42px;
  background: #f9fafb;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.site-link, .back {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.back {
  color: var(--accent);
  display: inline-block;
  margin-bottom: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-width: 72px;
  justify-content: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 24px;
  padding: 0 10px;
  text-transform: uppercase;
}

.badge.ok, .badge.up { background: var(--ok-bg); color: var(--ok); }
.badge.bad, .badge.down { background: var(--bad-bg); color: var(--bad); }
.badge.unknown { background: var(--unknown-bg); color: var(--unknown); }
.badge.muted { background: #eef2f6; color: #475467; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.status-dot {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  display: inline-block;
  position: relative;
}

.status-dot.ok,
.status-dot.up {
  background: var(--ok);
}

.status-dot.bad,
.status-dot.down {
  background: var(--bad);
}

.status-dot.unknown {
  background: var(--unknown);
}

.status-dot.muted {
  background: #98a2b3;
}

.status-dot.ok::after,
.status-dot.up::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 4px;
  width: 7px;
  height: 4px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg);
}

.status-dot.bad::before,
.status-dot.bad::after,
.status-dot.down::before,
.status-dot.down::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 6px;
  width: 7px;
  height: 2px;
  background: #fff;
}

.status-dot.bad::before,
.status-dot.down::before {
  transform: rotate(45deg);
}

.status-dot.bad::after,
.status-dot.down::after {
  transform: rotate(-45deg);
}

.empty {
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.metrics div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metrics strong {
  display: block;
  font-size: 24px;
}

.metrics span {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.problem {
  border-color: #fda29b;
}

.actions {
  justify-content: flex-start;
}

.spaced {
  margin-top: 14px;
}

@media (max-width: 780px) {
  .shell { width: min(100vw - 20px, 1120px); margin: 18px auto; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .grid-form, .metrics { grid-template-columns: 1fr; }
  .row, .checks .row {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .row.head { display: none; }
}
