:root {
  color-scheme: light dark;
  --bg: #f7f7f8;
  --panel: #ffffff;
  --text: #1a1a1c;
  --muted: #5f6570;
  --line: #d9dce1;
  --accent: #1d4ed8;
  --ok: #16794a;
  --bad: #b42318;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1b1e24;
    --text: #e8eaed;
    --muted: #a0a6b0;
    --line: #2c313a;
    --accent: #7aa2ff;
    --ok: #4ade80;
    --bad: #f87171;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 1rem;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, sans-serif;
}

h1, h2, h3 {
  margin: 0 0 0.5rem;
  font-weight: 600;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

nav {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1rem;
}

nav a {
  padding: 0.4rem 0.75rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

nav a[aria-current='true'] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

main section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.panel-note {
  margin: 0.5rem 0;
  font-size: 12px;
  color: var(--muted);
}

.panel-note.error {
  color: var(--bad);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th, td {
  text-align: left;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 500;
}

.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.card {
  min-width: 9rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.card strong {
  font-size: 20px;
}

.presence, .filters, .pager, .inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  list-style: none;
  padding: 0;
}

/* The hidden attribute is the only show/hide switch; never let a layout rule win. */
[hidden] {
  display: none !important;
}

.presence > li {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.health {
  display: grid;
  gap: 0.1rem;
  margin: 0.15rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
}

.health > li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.health-label {
  min-width: 4.5rem;
  color: var(--muted);
}

.health-state {
  min-width: 5rem;
  font-weight: 600;
}

.health-state.ok {
  color: var(--ok);
}

.health-state.degraded {
  color: var(--muted);
}

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

.health-state.no_signal {
  color: var(--muted);
  font-style: italic;
}

.health button {
  padding: 0.1rem 0.4rem;
  font-size: 11px;
}

.health button:disabled {
  opacity: 0.6;
  cursor: default;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 0.4rem;
  background: var(--bad);
}

.dot.online {
  background: var(--ok);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.75rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 13px;
}

input, select, textarea, button {
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
}

button {
  cursor: pointer;
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0 0 1rem;
}

textarea {
  min-height: 7rem;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

.hint, .error {
  color: var(--muted);
  font-size: 12px;
}

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

dialog {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  background: var(--panel);
  color: var(--text);
  max-width: 40rem;
}

dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}

.field-error {
  color: var(--bad);
  font-size: 12px;
}

