* {
  box-sizing: border-box;
}

:root {
  --bg: #080808;
  --surface: #111111;
  --surface-2: #171717;
  --surface-3: #1c1c1c;
  --border: #262626;
  --border-strong: #313131;
  --text: #f5f5f5;
  --text-soft: #d8d8d8;
  --muted: #8b8b8b;
  --dim: #636363;
  --primary: #22c55e;
  --danger: #ef4444;
  --warning: #e5a50a;
  --page: 1120px;
  --radius: 18px;
  --radius-md: 14px;
  --radius-sm: 11px;
  --shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 18px 40px rgba(0, 0, 0, 0.18);
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background:
    radial-gradient(900px 520px at 50% -12%, rgba(34, 197, 94, 0.045), transparent 70%),
    var(--bg);
  color: var(--text-soft);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  padding-left: max(1.5rem, calc((100% - var(--page)) / 2 + 1.5rem));
  padding-right: max(1.5rem, calc((100% - var(--page)) / 2 + 1.5rem));
  background: rgba(8, 8, 8, 0.84);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.brand-logo {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  object-fit: cover;
}

.brand-name {
  color: var(--primary);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.66rem;
  white-space: nowrap;
}

.header-note {
  color: var(--dim);
}

.pill {
  padding: 0.18rem 0.5rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
}

.main {
  flex: 1;
  width: min(var(--page), 100%);
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2.5rem;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.15rem;
  margin-bottom: 1rem;
  background: linear-gradient(180deg, #131313 0%, #0e0e0e 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-copy {
  min-width: 0;
}

.state-line {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.state-line h1 {
  margin: 0;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.status-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  background: var(--dim);
  border-radius: 50%;
}

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

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

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

.hero-sub {
  max-width: 58ch;
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.77rem;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(94px, 1fr));
  gap: 0.5rem;
  min-width: 470px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  padding: 0.58rem 0.62rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.summary-label {
  color: var(--dim);
  font-size: 0.56rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.summary-item strong {
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.summary-note {
  min-height: 1em;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.61rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section {
  padding: 1rem 1.1rem 1.1rem;
  margin-bottom: 1rem;
  background: linear-gradient(180deg, #121212 0%, #0f0f0f 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.7rem;
}

.section-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-note {
  color: var(--dim);
  font-size: 0.64rem;
  text-align: right;
}

.nodes-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

.node-card {
  min-width: 0;
  padding: 0.8rem;
  background: linear-gradient(180deg, #161616 0%, #111111 100%);
  border: 1px solid #292929;
  border-radius: var(--radius-md);
}

.node-card.offline {
  border-color: rgba(239, 68, 68, 0.35);
}

.node-card.unknown {
  border-color: rgba(229, 165, 10, 0.35);
}

.node-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.node-title {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  min-width: 0;
}

.node-title h3 {
  overflow: hidden;
  margin: 0;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.63rem;
}

.node-card.offline .status-label {
  color: var(--danger);
}

.node-card.unknown .status-label {
  color: var(--warning);
}

.node-big {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.62rem;
}

.node-big strong {
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
}

.node-big span {
  color: var(--muted);
  font-size: 0.61rem;
  white-space: nowrap;
}

.node-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  padding: 0.48rem 0;
  margin-top: 0.52rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.node-stats div {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  min-width: 0;
}

.node-stats span {
  color: var(--dim);
  font-size: 0.55rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.node-stats b {
  overflow: hidden;
  color: var(--text-soft);
  font-size: 0.71rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-last {
  overflow: hidden;
  margin: 0.48rem 0 0.4rem;
  color: var(--muted);
  font-size: 0.62rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.heat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.heat-row {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
}

.heat-cell {
  height: 7px;
  background: #1a1a1a;
  border-radius: 2px;
}

.heat-cell.up {
  background: var(--primary);
}

.heat-cell.warn {
  background: var(--warning);
}

.heat-cell.down {
  background: var(--danger);
}

.heat-cell.none {
  background: #1a1a1a;
}

.table-wrap {
  overflow-x: auto;
  background: #0d0d0d;
  border: 1px solid #292929;
  border-radius: var(--radius-sm);
}

.service-table {
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
  font-size: 0.73rem;
}

.service-table th {
  padding: 0.55rem 0.7rem;
  color: var(--dim);
  background: #151515;
  border-bottom: 1px solid var(--border);
  font-size: 0.56rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.service-table th:first-child,
.service-table td:first-child {
  padding-left: 0.8rem;
}

.service-table th:last-child,
.service-table td:last-child {
  padding-right: 0.8rem;
}

.service-table td {
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.service-table tbody tr:last-child td {
  border-bottom: 0;
}

.service-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

.service-name {
  display: flex;
  align-items: center;
  gap: 0.36rem;
  color: var(--text);
  font-weight: 500;
}

.type-tag {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 0.06rem 0.28rem;
  color: #9bd6b0;
  background: rgba(34, 197, 94, 0.06);
  border: 1px solid rgba(34, 197, 94, 0.16);
  border-radius: 5px;
  font-size: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.35;
  text-transform: uppercase;
}

.type-tag.vm {
  color: #c4b5fd;
  background: rgba(167, 139, 250, 0.08);
  border-color: rgba(167, 139, 250, 0.22);
}

.service-sub {
  margin-top: 0.08rem;
  color: var(--muted);
  font-size: 0.61rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.14rem 0.42rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.61rem;
  white-space: nowrap;
}

.chip::before {
  content: "";
  display: inline-block;
  flex: 0 0 auto;
  width: 5px;
  height: 5px;
  background: currentColor;
  border-radius: 50%;
}

.chip.running,
.chip.online {
  color: var(--primary);
  background: rgba(34, 197, 94, 0.07);
  border-color: rgba(34, 197, 94, 0.2);
}

.chip.offline {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.07);
  border-color: rgba(239, 68, 68, 0.2);
}

.chip.stopped {
  color: var(--dim);
}

.chip.paused,
.chip.unknown {
  color: var(--warning);
  background: rgba(229, 165, 10, 0.07);
  border-color: rgba(229, 165, 10, 0.2);
}

.cell-muted {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-num {
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.cell-up {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-up small {
  margin-left: 0.22rem;
  color: var(--dim);
  font-size: 0.6rem;
}

.daybar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  width: 58px;
}

.daybar span {
  height: 8px;
  background: #1a1a1a;
  border-radius: 3px;
}

.daybar span.up {
  background: var(--primary);
}

.daybar span.warn {
  background: var(--warning);
}

.daybar span.down {
  background: var(--danger);
}

.daybar span.none {
  background: #1a1a1a;
}

.section-footer {
  margin: 0.55rem 0 0;
  color: var(--dim);
  font-size: 0.62rem;
}

.incident-list {
  overflow: hidden;
  background: #0d0d0d;
  border: 1px solid #292929;
  border-radius: var(--radius-sm);
}

.incident {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.62rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.incident:last-child {
  border-bottom: 0;
}

.incident:hover {
  background: rgba(255, 255, 255, 0.025);
}

.incident-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.incident-main strong {
  overflow: hidden;
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.incident-host {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.63rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kind {
  flex: 0 0 auto;
  min-width: 25px;
  color: var(--dim);
  font-size: 0.54rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.incident-meta {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.8rem;
  color: var(--muted);
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.incident-meta .ongoing {
  color: var(--danger);
}

.empty {
  padding: 0.9rem 0.75rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.5rem;
  padding: 0.2rem 0.15rem 0;
  color: var(--dim);
  font-size: 0.6rem;
}

@media (max-width: 980px) {
  .hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 1rem;
  }

  .summary {
    width: 100%;
    min-width: 0;
  }

  .nodes-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .service-table,
  .service-table tbody {
    display: block;
    min-width: 0;
  }

  .service-table thead {
    display: none;
  }

  .service-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.22rem 0.65rem;
    padding: 0.72rem 0.8rem;
    border-bottom: 1px solid var(--border);
  }

  .service-table tbody tr:last-child {
    border-bottom: 0;
  }

  .service-table td {
    display: block;
    padding: 0;
    border: 0;
  }

  .service-table td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .service-table td:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
  }

  .service-table td:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .service-table td:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
  }

  .service-table td:nth-child(5) {
    grid-column: 1;
    grid-row: 3;
  }

  .service-table td:nth-child(6) {
    grid-column: 2;
    grid-row: 3;
    justify-self: end;
  }

  .service-table td:nth-child(7) {
    grid-column: 1;
    grid-row: 4;
  }

  .service-table td:nth-child(8) {
    grid-column: 2;
    grid-row: 4;
    justify-self: end;
  }

  .service-table td:nth-child(2)::before,
  .service-table td:nth-child(4)::before,
  .service-table td:nth-child(5)::before,
  .service-table td:nth-child(6)::before,
  .service-table td:nth-child(7)::before {
    margin-right: 0.3rem;
    color: var(--dim);
    font-size: 0.53rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .service-table td:nth-child(2)::before {
    content: "Host";
  }

  .service-table td:nth-child(4)::before {
    content: "Uptime";
  }

  .service-table td:nth-child(5)::before {
    content: "Down";
  }

  .service-table td:nth-child(6)::before {
    content: "Incidents";
  }

  .service-table td:nth-child(7)::before {
    content: "Last";
  }
}

@media (max-width: 560px) {
  .header {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .header-note {
    display: none;
  }

  .main {
    padding: 1rem 1rem 2rem;
  }

  .hero {
    padding: 0.95rem;
    margin-bottom: 0.8rem;
  }

  .state-line h1 {
    font-size: 1.2rem;
  }

  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .summary-item {
    padding: 0.5rem 0.55rem;
  }

  .section {
    padding: 0.85rem;
    margin-bottom: 0.8rem;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.2rem;
  }

  .section-note {
    text-align: left;
  }

  .nodes-grid {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    margin-right: -0.15rem;
    margin-left: -0.15rem;
  }

  .incident {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.6rem;
  }

  .incident-meta {
    gap: 0.55rem;
  }

  .footer {
    flex-direction: column;
    gap: 0.2rem;
  }
}

/* homelab not reporting: node and workload data is only the last known state */
.is-stale .nodes-grid,
.is-stale .section:has(#services-title) .table-wrap {
  opacity: 0.55;
}

.service-table td a {
  color: inherit;
  text-decoration: none;
}

.service-table td a:hover {
  text-decoration: underline;
}
