:root {
  color-scheme: light dark;
  --bg: #f4f4f1;
  --surface: #ffffff;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --border: #e2e2dc;
  --accent: #2f5bd3;
  --accent-text: #ffffff;
  --ok: #2b8a3e;
  --bad: #d6336c;
  --warn: #e8590c;
  --unknown: #a0a09a;
  --chart: #2f5bd3;
  --chart-area: rgb(47 91 211 / 0.12);
  --radius: 12px;
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1e1e1c;
    --text: #ececea;
    --muted: #a3a39d;
    --border: #33332f;
    --accent: #7c9cf5;
    --accent-text: #10131c;
    --ok: #69db7c;
    --bad: #f783ac;
    --warn: #ffa94d;
    --unknown: #6f6f69;
    --chart: #7c9cf5;
    --chart-area: rgb(124 156 245 / 0.15);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--accent);
}

h1 {
  font-size: 1.6rem;
  margin: 0 0 1rem;
}

h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
}

pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

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

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-wrap: wrap;
  flex: 1;
}

.tabs .project-name {
  font-weight: 600;
  margin-right: 0.75rem;
}

.tabs a {
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
}

.tabs a[aria-current='page'] {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
}

.logout {
  margin-left: auto;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.page-head h1,
.page-head h2 {
  margin: 0;
}

.muted,
.empty {
  color: var(--muted);
}

.empty {
  margin: 0.5rem 0;
}

.notice {
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  background: var(--surface);
}

.notice.ok {
  border-color: color-mix(in srgb, var(--ok) 50%, var(--border));
}

.notice.error {
  border-color: color-mix(in srgb, var(--bad) 60%, var(--border));
}

.notice.warn {
  border-color: color-mix(in srgb, var(--warn) 60%, var(--border));
}

/* Forms */

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 500;
}

label small {
  font-weight: 400;
  color: var(--muted);
}

label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
}

input,
select,
textarea {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  min-width: 0;
}

textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}

input[type='checkbox'] {
  width: 1.1rem;
  height: 1.1rem;
}

button,
.button {
  font: inherit;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.5rem 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button.secondary,
.button.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

button.danger {
  background: var(--bad);
  color: #fff;
}

button.link,
a.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}

button.link.danger {
  color: var(--bad);
}

.stack {
  display: grid;
  gap: 0.9rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.9rem 1rem;
  align-items: end;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.inline {
  display: flex;
  gap: 0.75rem;
  align-items: end;
  flex-wrap: wrap;
}

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

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  display: grid;
  gap: 0.4rem;
}

legend {
  padding: 0 0.3rem;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

details {
  margin-top: 0.75rem;
}

details summary {
  cursor: pointer;
  color: var(--muted);
}

details form {
  margin-top: 0.6rem;
}

.auth {
  max-width: 420px;
  margin: 3rem auto;
}

.qr svg {
  width: 200px;
  height: 200px;
  background: #fff;
  border-radius: 8px;
}

/* Tables */

table {
  width: 100%;
  border-collapse: collapse;
}

table.list th,
table.list td {
  text-align: left;
  padding: 0.55rem 0.5rem;
  border-top: 1px solid var(--border);
  vertical-align: top;
}

table.list thead th {
  border-top: none;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85rem;
}

table.values th,
table.values td {
  padding: 0.3rem 0;
  border-top: 1px solid var(--border);
  font-weight: 400;
  text-align: left;
}

table.values td {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-left: 1rem;
}

table.values tr:first-child th,
table.values tr:first-child td {
  border-top: none;
}

.row-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Status */

.dot {
  display: inline-block;
  line-height: 1;
}

.dot.ok {
  color: var(--ok);
}

.dot.bad {
  color: var(--bad);
}

.dot.warn {
  color: var(--warn);
}

.dot.unknown {
  color: var(--unknown);
}

.status-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.status-list li {
  display: flex;
  gap: 0.45rem;
  align-items: baseline;
}

.events {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.events time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Dashboard */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  grid-auto-flow: dense;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.tile {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.tile.size-2 {
  grid-column: span 2;
}

@media (max-width: 640px) {
  .tile.size-2 {
    grid-column: auto;
  }
}

.tile header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}

.tile h2 {
  margin: 0;
  font-size: 0.95rem;
}

.tile footer {
  margin-top: auto;
  font-size: 0.8rem;
}

.updated {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.updated.stale {
  color: var(--warn);
}

.number strong {
  display: block;
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.change {
  font-size: 0.85rem;
  color: var(--muted);
}

.change.up {
  color: var(--ok);
}

.change.down {
  color: var(--bad);
}

.number .muted {
  display: block;
  font-size: 0.8rem;
}

.chart {
  margin: 0;
}

.chart svg {
  width: 100%;
  height: 130px;
  display: block;
}

.chart .line {
  fill: none;
  stroke: var(--chart);
  stroke-width: 2;
}

.chart .point {
  fill: var(--chart);
}

.chart .area {
  fill: var(--chart-area);
}

.chart .axis,
.chart .grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart .grid {
  stroke-dasharray: 3 4;
}

.chart figcaption {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
  gap: 0.5rem;
}

.grid.editing .tile {
  outline: 2px dashed var(--border);
  outline-offset: 2px;
  cursor: grab;
}

.tile.dragging {
  opacity: 0.4;
}

.tile-tools {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
  font-size: 0.85rem;
}

.tile-tools form {
  display: flex;
  gap: 0.5rem;
}

.drag-hint {
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
}

/* Catalog */

.catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.catalog-item {
  color: inherit;
  text-decoration: none;
  margin: 0;
}

.catalog-item:hover,
.catalog-item:focus-visible {
  border-color: var(--accent);
}

.catalog-item p {
  margin: 0.25rem 0 0;
}

.tag {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.55rem;
  margin-bottom: 0.4rem;
}

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